This document captures the design and implementation of the Placeholder control.
new Placeholder(), optional text)Placeholder : Visual (sealed)new Placeholder()new Placeholder(string text)new Placeholder(Func<string?> text)new Placeholder(Binding<string?> text)These match the current constructor patterns used by controls such as TextBlock.
Text : string?Wrap : bool (default: true)TextAlignment : TextAlignment (default: Center)VerticalTextAlignment : Align (default: Center)Trimming : TextTrimming (default: Clip)Use a dedicated PlaceholderStyle (environment style):
Foreground : Color?Background : Color?ForegroundBrush : Brush?BackgroundBrush : Brush?TextStyle : TextStyleFillBackground : bool (default: true)Padding : Thickness (default: 0)ForegroundBrush overrides Foreground for text cells.BackgroundBrush overrides Background for filled background cells.Text is null/empty:
1x1 so the control remains visible when explicitly sized by container.TextBlock-like width/height computation (Unicode width aware).TextBlock semantics.PlaceholderStyle + theme.FillBackground is true and either background color or background brush is set:
Text is not null/empty:
ForegroundBrush using text rendering coordinates.TextBlock per-line restart behavior by default.The control must support:
new Placeholder()
.Style(PlaceholderStyle.Default with
{
Background = Colors.SlateBlue
});
Or with gradients:
new Placeholder()
.Style(PlaceholderStyle.Default with
{
BackgroundBrush = Brush.LinearGradient(
new GradientPoint(0f, 0f),
new GradientPoint(1f, 0f),
[
new GradientStop(0f, Colors.MidnightBlue),
new GradientStop(1f, Colors.SlateBlue),
])
});
CellBuffer brush helpers (FillRectWithBrush, WriteTextWithBrush).RenderOverride:
src/XenoAtom.Terminal.UI/Controls/Placeholder.cssrc/XenoAtom.Terminal.UI/Styling/PlaceholderStyle.cssrc/XenoAtom.Terminal.UI.Tests/PlaceholderTests.cssamples/ControlsDemo/Demos/PlaceholderDemo.cssite/docs/controls/placeholder.mdCenter and End).FillBackground = false keeps non-text cells unchanged.VerticalTextAlignment is part of v1 and normalizes Align.Stretch to Align.Center.FillBackground defaults to true.