ConsoleTextLayout
ConsoleMonster.Text
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.
Returned or exposed by 26
- Extension method ConsoleTextLayout.Alignment
- Extension method ConsoleTextLayout.Indent
- Extension method ConsoleTextLayout.LinesAfter
- Extension method ConsoleTextLayout.LinesBefore
- Extension method ConsoleTextLayout.PadCenter
- Extension method ConsoleTextLayout.PadCharacter
- Extension method ConsoleTextLayout.PadLeft
- Extension method ConsoleTextLayout.PadRight
- Extension method ConsoleTextLayout.SplitLines
- Extension method ConsoleTextLayout.StartTab
- Extension method ConsoleTextLayout.Time
- Extension method ConsoleTextLayout.TimestampFormat
- Extension method ConsoleTextLayout.Wrap
- Method ConsoleTextLayoutFluent.Alignment
- Method ConsoleTextLayoutFluent.Indent
- Method ConsoleTextLayoutFluent.LinesAfter
- Method ConsoleTextLayoutFluent.LinesBefore
- Method ConsoleTextLayoutFluent.PadCenter
- Method ConsoleTextLayoutFluent.PadCharacter
- Method ConsoleTextLayoutFluent.PadLeft
- Method ConsoleTextLayoutFluent.PadRight
- Method ConsoleTextLayoutFluent.SplitLines
- Method ConsoleTextLayoutFluent.StartTab
- Method ConsoleTextLayoutFluent.Time
- Method ConsoleTextLayoutFluent.TimestampFormat
- Method ConsoleTextLayoutFluent.Wrap
Accepted by parameters 26
- Extension method ConsoleTextLayout.Alignment
- Extension method ConsoleTextLayout.Indent
- Extension method ConsoleTextLayout.LinesAfter
- Extension method ConsoleTextLayout.LinesBefore
- Extension method ConsoleTextLayout.PadCenter
- Extension method ConsoleTextLayout.PadCharacter
- Extension method ConsoleTextLayout.PadLeft
- Extension method ConsoleTextLayout.PadRight
- Extension method ConsoleTextLayout.SplitLines
- Extension method ConsoleTextLayout.StartTab
- Extension method ConsoleTextLayout.Time
- Extension method ConsoleTextLayout.TimestampFormat
- Extension method ConsoleTextLayout.Wrap
- Method ConsoleTextLayoutFluent.Alignment
- Method ConsoleTextLayoutFluent.Indent
- Method ConsoleTextLayoutFluent.LinesAfter
- Method ConsoleTextLayoutFluent.LinesBefore
- Method ConsoleTextLayoutFluent.PadCenter
- Method ConsoleTextLayoutFluent.PadCharacter
- Method ConsoleTextLayoutFluent.PadLeft
- Method ConsoleTextLayoutFluent.PadRight
- Method ConsoleTextLayoutFluent.SplitLines
- Method ConsoleTextLayoutFluent.StartTab
- Method ConsoleTextLayoutFluent.Time
- Method ConsoleTextLayoutFluent.TimestampFormat
- Method ConsoleTextLayoutFluent.Wrap
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
- The text.
- context ConsoleMonster.Canvas.RenderContext
- The render context.
- width int
- The width for wrapping and centring.
public IReadOnlyList<RichText> Parts(RichText text) #The parts of a text after ConsoleTextLayout.SplitLines.
Parameters
- text ConsoleMonster.Text.RichText
- The text.
Inherited Methods
Properties
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
- The instance.
- value ConsoleMonster.Layout.HorizontalAlignment
- The value.
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
- The instance.
- value int
- The value.
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
- The instance.
- value int
- The value.
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
- The instance.
- value int
- The value.
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
- The instance.
- value int
- The value.
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
- The instance.
- value char
- The value.
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
- The instance.
- value int
- The value.
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
- The instance.
- value int
- The value.
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
- The instance.
- value string?
- The value.
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
- The instance.
- value int
- The value.
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
- The instance.
- value System.DateTime?
- The value.
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
- The instance.
- value string
- The value.
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
- The instance.
- value bool = true
- The value; true when omitted.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Text.ConsoleTextLayout { Wrap = value }; consoleTextLayout.Wrap(value);