Skip to content
ConsoleMonster

API Reference

Class

TextBlock

Namespace ConsoleMonster.Widgets
Assembly ConsoleMonster
Implements
Modifiers sealed

Text with Spectre-compatible markup ([bold], [pass], [#ff8800]), wrapped or truncated to its width and aligned left, centre or right.

Inheritance

  • Object
  • TextBlock

Usage

Explore 22 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 10

Constructors

public TextBlock(String markup) #

Creates a text block from markup.

Parameters

markup System.String requiredposition: 0
The markup.

Methods

public Size Measure(Constraints constraints, RenderContext context) #
Returns: Size

Returns the size the widget wants within the constraints.

Parameters

constraints ConsoleMonster.Layout.Constraints requiredposition: 0
The space offered.
context ConsoleMonster.Canvas.RenderContext requiredposition: 1
Profile, theme and glyphs.

Returns

The desired size, never larger than the constraints.

public static TextBlock Plain(String text, ThemeToken? token = null) #
Returns: TextBlock

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

Parameters

text System.String requiredposition: 0
The text.
token ConsoleMonster.Styling.ThemeToken? = null optionalposition: 1
An optional theme token.

Returns

The text block.

public Void Render(Region region, RenderContext context) #
Returns: Void

Renders into a region. The region may be smaller or larger than the measured size.

Parameters

region ConsoleMonster.Canvas.Region requiredposition: 0
The target region.
context ConsoleMonster.Canvas.RenderContext requiredposition: 1
Profile, theme and glyphs.

Properties

public String Content { get; set; } #

The content (markup unless TextBlock.IsMarkup is false).

public Boolean IsMarkup { get; set; } #

Whether TextBlock.Content is markup (default true).

public ThemeToken? Token { get; set; } #

A theme token layered under the text, or null.

public HorizontalAlignment Alignment { get; set; } #

Alignment (default left).

public TextOverflow Overflow { get; set; } #

Overflow handling (default wrap).

Extension Methods

public static TextBlock WithAlignment(TextBlock textBlock, HorizontalAlignment value) #
Returns: TextBlock

Sets TextBlock.Alignment: Alignment (default left).

Parameters

textBlock ConsoleMonster.Widgets.TextBlock requiredposition: 0
The instance.
value ConsoleMonster.Layout.HorizontalAlignment requiredposition: 1
The value.

Returns

The same instance.

public static TextBlock WithContent(TextBlock textBlock, String value) #
Returns: TextBlock

Sets TextBlock.Content: The content (markup unless TextBlock.IsMarkup is false).

Parameters

textBlock ConsoleMonster.Widgets.TextBlock requiredposition: 0
The instance.
value System.String requiredposition: 1
The value.

Returns

The same instance.

public static TextBlock WithIsMarkup(TextBlock textBlock, Boolean value = true) #
Returns: TextBlock

Sets TextBlock.IsMarkup: Whether TextBlock.Content is markup (default true).

Parameters

textBlock ConsoleMonster.Widgets.TextBlock requiredposition: 0
The instance.
value System.Boolean = true optionalposition: 1
The value (default true).

Returns

The same instance.

public static TextBlock WithOverflow(TextBlock textBlock, TextOverflow value) #
Returns: TextBlock

Sets TextBlock.Overflow: Overflow handling (default wrap).

Parameters

textBlock ConsoleMonster.Widgets.TextBlock requiredposition: 0
The instance.
value ConsoleMonster.Widgets.TextOverflow requiredposition: 1
The value.

Returns

The same instance.

public static TextBlock WithToken(TextBlock textBlock, ThemeToken? value) #
Returns: TextBlock

Sets TextBlock.Token: A theme token layered under the text, or null.

Parameters

textBlock ConsoleMonster.Widgets.TextBlock requiredposition: 0
The instance.
value ConsoleMonster.Styling.ThemeToken? requiredposition: 1
The value.

Returns

The same instance.