TextBlock
ConsoleMonster.Widgets
Literal text or explicit Spectre-compatible markup ([bold], [pass], [#ff8800]), wrapped or truncated to its width and aligned left, centre or right.
Inheritance
- object
- TextBlock
Usage
Explore 30 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by 16
- Method Ui.Markup
- Method Ui.Text
- Extension method TextBlock.Alignment
- Extension method TextBlock.Content
- Extension method TextBlock.Markup
- Extension method TextBlock.Overflow
- Extension method TextBlock.Role
- Extension method TextBlock.WrapSeparator
- Method TextBlock.FromMarkup
- Method TextBlock.Plain
- Method TextBlockFluent.Alignment
- Method TextBlockFluent.Content
- Method TextBlockFluent.Markup
- Method TextBlockFluent.Overflow
- Method TextBlockFluent.Role
- Method TextBlockFluent.WrapSeparator
Accepted by parameters 14
- Method ContentBuilder.Text
- Method ContentBuilder.Text
- Extension method TextBlock.Alignment
- Extension method TextBlock.Content
- Extension method TextBlock.Markup
- Extension method TextBlock.Overflow
- Extension method TextBlock.Role
- Extension method TextBlock.WrapSeparator
- Method TextBlockFluent.Alignment
- Method TextBlockFluent.Content
- Method TextBlockFluent.Markup
- Method TextBlockFluent.Overflow
- Method TextBlockFluent.Role
- Method TextBlockFluent.WrapSeparator
Constructors
public TextBlock(string text) #Creates a text block from literal text; brackets are displayed unchanged.
Parameters
- text string
- The literal text.
Methods
public static TextBlock FromMarkup(string markup) #Creates text from explicit Spectre-compatible markup.
Parameters
- markup string
- The markup source.
public Size Measure(Constraints constraints, RenderContext context) #Returns the size the widget wants within the constraints.
Parameters
- constraints ConsoleMonster.Layout.Constraints
- The space offered.
- context ConsoleMonster.Canvas.RenderContext
- Profile, theme and glyphs.
public static TextBlock Plain(string text, ThemeToken? role = null) #Creates a text block from plain text (brackets are shown literally).
Parameters
- text string
- The text.
- role ConsoleMonster.Styling.ThemeToken? = null
- An optional theme role.
public void Render(Region region, RenderContext context) #Renders into a region. The region may be smaller or larger than the measured size.
Parameters
- region ConsoleMonster.Canvas.Region
- The target region.
- context ConsoleMonster.Canvas.RenderContext
- Profile, theme and glyphs.
Inherited Methods
Properties
public string Content { get; set; } #Literal text, interpreted as markup only when TextBlock.IsMarkup is true.
public bool IsMarkup { get; set; } #Whether TextBlock.Content is markup (default false).
public string? WrapSeparator { get; set; } #When set, wrap at this literal separator before breaking within an oversized entry.
Extension Methods
public static TextBlock Alignment(TextBlock textBlock, HorizontalAlignment value) #Sets TextBlock.Alignment: Alignment (default left).
Parameters
- textBlock ConsoleMonster.Widgets.TextBlock
- The instance.
- value ConsoleMonster.Layout.HorizontalAlignment
- The value.
Examples
// C# initializer or property // C# fluent
textBlock.Alignment = value; Ui.Text().Alignment(value);public static TextBlock Content(TextBlock textBlock, string value) #Sets TextBlock.Content: Literal text, interpreted as markup only when TextBlock.IsMarkup is true.
Parameters
- textBlock ConsoleMonster.Widgets.TextBlock
- The instance.
- value string
- The value.
Examples
// C# initializer or property // C# fluent
textBlock.Content = value; Ui.Text().Content(value);public static TextBlock Markup(TextBlock textBlock, bool value = true) #Sets TextBlock.IsMarkup: Whether TextBlock.Content is markup (default false).
Parameters
- textBlock ConsoleMonster.Widgets.TextBlock
- The instance.
- value bool = true
- The value; true when omitted.
Examples
// C# initializer or property // C# fluent
textBlock.IsMarkup = value; Ui.Text().Markup(value);public static TextBlock Overflow(TextBlock textBlock, TextOverflow value) #Sets TextBlock.Overflow: Overflow handling (default wrap).
Parameters
- textBlock ConsoleMonster.Widgets.TextBlock
- The instance.
- value ConsoleMonster.Widgets.TextOverflow
- The value.
Examples
// C# initializer or property // C# fluent
textBlock.Overflow = value; Ui.Text().Overflow(value);public static TextBlock Role(TextBlock textBlock, ThemeToken? value) #Sets TextBlock.Role: A theme role layered under the text, or null.
Parameters
- textBlock ConsoleMonster.Widgets.TextBlock
- The instance.
- value ConsoleMonster.Styling.ThemeToken?
- The value.
Examples
// C# initializer or property // C# fluent
textBlock.Role = value; Ui.Text().Role(value);public static TextBlock WrapSeparator(TextBlock textBlock, string? value) #Sets TextBlock.WrapSeparator: When set, wrap at this literal separator before breaking within an oversized entry.
Parameters
- textBlock ConsoleMonster.Widgets.TextBlock
- The instance.
- value string?
- The value.
Examples
// C# initializer or property // C# fluent
textBlock.WrapSeparator = value; Ui.Text().WrapSeparator(value);