Skip to content
ConsoleMonster
Class

TextBlock

ConsoleMonster.Widgets

Namespace
ConsoleMonster.Widgets
Assembly
ConsoleMonster
Implements
IWidget ILineFlow
Modifiers
sealed

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.

Accepted by parameters 14

Constructors

public TextBlock(string text) #

Creates a text block from literal text; brackets are displayed unchanged.

Parameters

text string required
The literal text.

Methods

public static TextBlock FromMarkup(string markup) #

Creates text from explicit Spectre-compatible markup.

Parameters

markup string required
The markup source.

Returns

TextBlock A text block that interprets markup tags.
public Size Measure(Constraints constraints, RenderContext context) #

Returns the size the widget wants within the constraints.

Parameters

constraints ConsoleMonster.Layout.Constraints required
The space offered.
context ConsoleMonster.Canvas.RenderContext required
Profile, theme and glyphs.

Returns

Size The desired size, never larger than the constraints.
public static TextBlock Plain(string text, ThemeToken? role = null) #

Creates a text block from plain text (brackets are shown literally).

Parameters

text string required
The text.
role ConsoleMonster.Styling.ThemeToken? = null optional
An optional theme role.

Returns

TextBlock The text block.
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 required
The target region.
context ConsoleMonster.Canvas.RenderContext required
Profile, theme and glyphs.

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 ThemeToken? Role { get; set; } #

A theme role layered under the text, or null.

public HorizontalAlignment Alignment { get; set; } #

Alignment (default left).

public TextOverflow Overflow { get; set; } #

Overflow handling (default wrap).

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 required
The instance.
value ConsoleMonster.Layout.HorizontalAlignment required
The value.

Returns

TextBlock The same instance.

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 required
The instance.
value string required
The value.

Returns

TextBlock The same instance.

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 required
The instance.
value bool = true optional
The value; true when omitted.

Returns

TextBlock The same instance.

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 required
The instance.
value ConsoleMonster.Widgets.TextOverflow required
The value.

Returns

TextBlock The same instance.

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 required
The instance.
value ConsoleMonster.Styling.ThemeToken? required
The value.

Returns

TextBlock The same instance.

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 required
The instance.
value string? required
The value.

Returns

TextBlock The same instance.

Examples

// C# initializer or property       // C# fluent
textBlock.WrapSeparator = value;    Ui.Text().WrapSeparator(value);