API Reference
TextBlock
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.
Returned or exposed by 12
- Method Ui.Text
- Extension method TextBlock.WithAlignment
- Extension method TextBlock.WithContent
- Extension method TextBlock.WithIsMarkup
- Extension method TextBlock.WithOverflow
- Extension method TextBlock.WithToken
- Method TextBlock.Plain
- Method TextBlockFluent.WithAlignment
- Method TextBlockFluent.WithContent
- Method TextBlockFluent.WithIsMarkup
- Method TextBlockFluent.WithOverflow
- Method TextBlockFluent.WithToken
Accepted by parameters 10
- Extension method TextBlock.WithAlignment
- Extension method TextBlock.WithContent
- Extension method TextBlock.WithIsMarkup
- Extension method TextBlock.WithOverflow
- Extension method TextBlock.WithToken
- Method TextBlockFluent.WithAlignment
- Method TextBlockFluent.WithContent
- Method TextBlockFluent.WithIsMarkup
- Method TextBlockFluent.WithOverflow
- Method TextBlockFluent.WithToken
Constructors
public TextBlock(String markup) #Creates a text block from markup.
Parameters
- markup System.String
- The markup.
Methods
public Size Measure(Constraints constraints, RenderContext context) #SizeReturns the size the widget wants within the constraints.
Parameters
- constraints ConsoleMonster.Layout.Constraints
- The space offered.
- context ConsoleMonster.Canvas.RenderContext
- Profile, theme and glyphs.
Returns
The desired size, never larger than the constraints.
public static TextBlock Plain(String text, ThemeToken? token = null) #TextBlockCreates a text block from plain text (brackets are shown literally).
Parameters
- text System.String
- The text.
- token ConsoleMonster.Styling.ThemeToken? = null
- An optional theme token.
Returns
The text block.
public Void Render(Region region, RenderContext context) #VoidRenders 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
public virtual Boolean Equals(Object? obj) #BooleanParameters
- obj Object?
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.
Extension Methods
public static TextBlock WithAlignment(TextBlock textBlock, HorizontalAlignment value) #TextBlockSets TextBlock.Alignment: Alignment (default left).
Parameters
- textBlock ConsoleMonster.Widgets.TextBlock
- The instance.
- value ConsoleMonster.Layout.HorizontalAlignment
- The value.
Returns
The same instance.
public static TextBlock WithContent(TextBlock textBlock, String value) #TextBlockSets TextBlock.Content: The content (markup unless TextBlock.IsMarkup is false).
Parameters
- textBlock ConsoleMonster.Widgets.TextBlock
- The instance.
- value System.String
- The value.
Returns
The same instance.
public static TextBlock WithIsMarkup(TextBlock textBlock, Boolean value = true) #TextBlockSets TextBlock.IsMarkup: Whether TextBlock.Content is markup (default true).
Parameters
- textBlock ConsoleMonster.Widgets.TextBlock
- The instance.
- value System.Boolean = true
- The value (default true).
Returns
The same instance.
public static TextBlock WithOverflow(TextBlock textBlock, TextOverflow value) #TextBlockSets TextBlock.Overflow: Overflow handling (default wrap).
Parameters
- textBlock ConsoleMonster.Widgets.TextBlock
- The instance.
- value ConsoleMonster.Widgets.TextOverflow
- The value.
Returns
The same instance.
public static TextBlock WithToken(TextBlock textBlock, ThemeToken? value) #TextBlockSets TextBlock.Token: A theme token layered under the text, or null.
Parameters
- textBlock ConsoleMonster.Widgets.TextBlock
- The instance.
- value ConsoleMonster.Styling.ThemeToken?
- The value.
Returns
The same instance.