Skip to content
ConsoleMonster
Class

ConsoleTextLayout

ConsoleMonster.Text

Namespace
ConsoleMonster.Text
Assembly
ConsoleMonster
Modifiers
sealed
Attributes
Fluent

Lays out console text the way Write-Color does, for Write-ConsoleText and C# hosts alike: empty lines before and after, a prefix of tabs, spaces and an optional time stamp on the first line, text split at a separator with the following parts aligned under the text, wrapping that continues under the text, padding (left, right or centred, measured in terminal cells) and centring in the window.

Inheritance

  • object
  • ConsoleTextLayout

Usage

Explore 52 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 26

Constructors

public ConsoleTextLayout() #

Methods

public IReadOnlyList<StyledLine> Lines(RichText text, RenderContext context, int width) #

The lines of a text at a width.

Parameters

text ConsoleMonster.Text.RichText required
The text.
context ConsoleMonster.Canvas.RenderContext required
The render context.
width int required
The width for wrapping and centring.

Returns

IReadOnlyList<StyledLine> The lines.
public IReadOnlyList<RichText> Parts(RichText text) #

The parts of a text after ConsoleTextLayout.SplitLines.

Parameters

text ConsoleMonster.Text.RichText required
The text.

Returns

IReadOnlyList<RichText> The parts (one when there is no separator).

Properties

public int StartTab { get; set; } #

Tabs before the text (eight cells each).

public int Indent { get; set; } #

Spaces before the text.

public int LinesBefore { get; set; } #

Empty lines before the text.

public int LinesAfter { get; set; } #

Empty lines after the text.

public DateTime? Time { get; set; } #

The time shown in brackets at the start, or null for none.

public string TimestampFormat { get; set; } #

The time format (default yyyy-MM-dd HH:mm:ss).

public string? SplitLines { get; set; } #

A separator the text is split at; the following parts are aligned under the first, after the prefix.

public bool Wrap { get; set; } #

Wraps long text at the width, continuing under the text after the prefix.

public HorizontalAlignment Alignment { get; set; } #

Aligns each completed line within the available width, including indentation and timestamps.

public int PadLeft { get; set; } #

Pads each line on the left to this many cells (right-aligned).

public int PadRight { get; set; } #

Pads each line on the right to this many cells.

public int PadCenter { get; set; } #

Centres each line within this many cells.

public char PadCharacter { get; set; } #

The padding character (default a space).

Extension Methods

public static ConsoleTextLayout Alignment(ConsoleTextLayout consoleTextLayout, HorizontalAlignment value) #

Sets ConsoleTextLayout.Alignment: Aligns each completed line within the available width, including indentation and timestamps.

Parameters

consoleTextLayout ConsoleMonster.Text.ConsoleTextLayout required
The instance.
value ConsoleMonster.Layout.HorizontalAlignment required
The value.

Returns

ConsoleTextLayout The same instance.

Examples

// C# initializer or property                                               // C# fluent
new global::ConsoleMonster.Text.ConsoleTextLayout { Alignment = value };    consoleTextLayout.Alignment(value);
public static ConsoleTextLayout Indent(ConsoleTextLayout consoleTextLayout, int value) #

Sets ConsoleTextLayout.Indent: Spaces before the text.

Parameters

consoleTextLayout ConsoleMonster.Text.ConsoleTextLayout required
The instance.
value int required
The value.

Returns

ConsoleTextLayout The same instance.

Examples

// C# initializer or property                                            // C# fluent
new global::ConsoleMonster.Text.ConsoleTextLayout { Indent = value };    consoleTextLayout.Indent(value);
public static ConsoleTextLayout LinesAfter(ConsoleTextLayout consoleTextLayout, int value) #

Sets ConsoleTextLayout.LinesAfter: Empty lines after the text.

Parameters

consoleTextLayout ConsoleMonster.Text.ConsoleTextLayout required
The instance.
value int required
The value.

Returns

ConsoleTextLayout The same instance.

Examples

// C# initializer or property                                                // C# fluent
new global::ConsoleMonster.Text.ConsoleTextLayout { LinesAfter = value };    consoleTextLayout.LinesAfter(value);
public static ConsoleTextLayout LinesBefore(ConsoleTextLayout consoleTextLayout, int value) #

Sets ConsoleTextLayout.LinesBefore: Empty lines before the text.

Parameters

consoleTextLayout ConsoleMonster.Text.ConsoleTextLayout required
The instance.
value int required
The value.

Returns

ConsoleTextLayout The same instance.

Examples

// C# initializer or property                                                 // C# fluent
new global::ConsoleMonster.Text.ConsoleTextLayout { LinesBefore = value };    consoleTextLayout.LinesBefore(value);
public static ConsoleTextLayout PadCenter(ConsoleTextLayout consoleTextLayout, int value) #

Sets ConsoleTextLayout.PadCenter: Centres each line within this many cells.

Parameters

consoleTextLayout ConsoleMonster.Text.ConsoleTextLayout required
The instance.
value int required
The value.

Returns

ConsoleTextLayout The same instance.

Examples

// C# initializer or property                                               // C# fluent
new global::ConsoleMonster.Text.ConsoleTextLayout { PadCenter = value };    consoleTextLayout.PadCenter(value);
public static ConsoleTextLayout PadCharacter(ConsoleTextLayout consoleTextLayout, char value) #

Sets ConsoleTextLayout.PadCharacter: The padding character (default a space).

Parameters

consoleTextLayout ConsoleMonster.Text.ConsoleTextLayout required
The instance.
value char required
The value.

Returns

ConsoleTextLayout The same instance.

Examples

// C# initializer or property                                                  // C# fluent
new global::ConsoleMonster.Text.ConsoleTextLayout { PadCharacter = value };    consoleTextLayout.PadCharacter(value);
public static ConsoleTextLayout PadLeft(ConsoleTextLayout consoleTextLayout, int value) #

Sets ConsoleTextLayout.PadLeft: Pads each line on the left to this many cells (right-aligned).

Parameters

consoleTextLayout ConsoleMonster.Text.ConsoleTextLayout required
The instance.
value int required
The value.

Returns

ConsoleTextLayout The same instance.

Examples

// C# initializer or property                                             // C# fluent
new global::ConsoleMonster.Text.ConsoleTextLayout { PadLeft = value };    consoleTextLayout.PadLeft(value);
public static ConsoleTextLayout PadRight(ConsoleTextLayout consoleTextLayout, int value) #

Sets ConsoleTextLayout.PadRight: Pads each line on the right to this many cells.

Parameters

consoleTextLayout ConsoleMonster.Text.ConsoleTextLayout required
The instance.
value int required
The value.

Returns

ConsoleTextLayout The same instance.

Examples

// C# initializer or property                                              // C# fluent
new global::ConsoleMonster.Text.ConsoleTextLayout { PadRight = value };    consoleTextLayout.PadRight(value);
public static ConsoleTextLayout SplitLines(ConsoleTextLayout consoleTextLayout, string? value) #

Sets ConsoleTextLayout.SplitLines: A separator the text is split at; the following parts are aligned under the first, after the prefix.

Parameters

consoleTextLayout ConsoleMonster.Text.ConsoleTextLayout required
The instance.
value string? required
The value.

Returns

ConsoleTextLayout The same instance.

Examples

// C# initializer or property                                                // C# fluent
new global::ConsoleMonster.Text.ConsoleTextLayout { SplitLines = value };    consoleTextLayout.SplitLines(value);
public static ConsoleTextLayout StartTab(ConsoleTextLayout consoleTextLayout, int value) #

Sets ConsoleTextLayout.StartTab: Tabs before the text (eight cells each).

Parameters

consoleTextLayout ConsoleMonster.Text.ConsoleTextLayout required
The instance.
value int required
The value.

Returns

ConsoleTextLayout The same instance.

Examples

// C# initializer or property                                              // C# fluent
new global::ConsoleMonster.Text.ConsoleTextLayout { StartTab = value };    consoleTextLayout.StartTab(value);
public static ConsoleTextLayout Time(ConsoleTextLayout consoleTextLayout, DateTime? value) #

Sets ConsoleTextLayout.Time: The time shown in brackets at the start, or null for none.

Parameters

consoleTextLayout ConsoleMonster.Text.ConsoleTextLayout required
The instance.
value System.DateTime? required
The value.

Returns

ConsoleTextLayout The same instance.

Examples

// C# initializer or property                                          // C# fluent
new global::ConsoleMonster.Text.ConsoleTextLayout { Time = value };    consoleTextLayout.Time(value);
public static ConsoleTextLayout TimestampFormat(ConsoleTextLayout consoleTextLayout, string value) #

Sets ConsoleTextLayout.TimestampFormat: The time format (default yyyy-MM-dd HH:mm:ss).

Parameters

consoleTextLayout ConsoleMonster.Text.ConsoleTextLayout required
The instance.
value string required
The value.

Returns

ConsoleTextLayout The same instance.

Examples

// C# initializer or property                                                     // C# fluent
new global::ConsoleMonster.Text.ConsoleTextLayout { TimestampFormat = value };    consoleTextLayout.TimestampFormat(value);
public static ConsoleTextLayout Wrap(ConsoleTextLayout consoleTextLayout, bool value = true) #

Sets ConsoleTextLayout.Wrap: Wraps long text at the width, continuing under the text after the prefix.

Parameters

consoleTextLayout ConsoleMonster.Text.ConsoleTextLayout required
The instance.
value bool = true optional
The value; true when omitted.

Returns

ConsoleTextLayout The same instance.

Examples

// C# initializer or property                                          // C# fluent
new global::ConsoleMonster.Text.ConsoleTextLayout { Wrap = value };    consoleTextLayout.Wrap(value);