Class TextFormatter | Terminal.Gui v2 (original) (raw)
Namespace
Assembly
Terminal.Gui.dll
Provides text formatting. Supports HotKeys, horizontal and vertical alignment, text direction, multiple lines, and word-based line wrap.
public class TextFormatter
Inheritance
TextFormatter
Inherited Members
Properties
Get or sets the horizontal text alignment.
Gets or sets the height Text will be constrained to when formatted.
Gets or sets the width and height Text will be constrained to when formatted.
Gets or sets the width Text will be constrained to when formatted.
Gets the cursor position of the HotKey. If the HotKey is defined, the cursor will be positioned over it.
Gets or sets the text-direction.
Determines if the viewport width will be used or only the text width will be used, If true all the viewport area will be filled with whitespaces and the same background color showing a perfect rectangle.
Gets or sets the hot key. Fires the HotKeyChanged event.
The position in the text of the hot key. The hot key will be rendered using the hot color.
The specifier character for the hot key (e.g. '_'). Set to '\xffff' to disable hot key support for this View instance. The default is '\xffff'.
Gets or sets a value indicating whether multi line is allowed.
Gets or sets whether the TextFormatter needs to format the text.
Gets or sets whether trailing spaces at the end of word-wrapped lines are preserved or not whenWordWrap is enabled. If true trailing spaces at the end of wrapped lines will be removed when Text is formatted for display. The default is false.
Gets or sets the number of columns used for a tab.
The text to be formatted. This string is never modified.
Gets or sets the vertical text-alignment.
Gets or sets whether word wrap will be used to fit Text to ConstrainToSize.
Methods
ClipAndJustify(string, int, bool, TextDirection, int, TextFormatter?)
Justifies text within a specified width.
ClipAndJustify(string, int, Alignment, TextDirection, int, TextFormatter?)
Justifies text within a specified width.
Adds trailing whitespace or truncates text
so that it fits exactly width
columns. Note that some unicode characters take 2+ columns
Draw(Rectangle, Attribute, Attribute, Rectangle, IConsoleDriver?)
Draws the text held by TextFormatter to IConsoleDriver using the colors specified.
FindHotKey(string, Rune, out int, out Key, bool)
Finds the HotKey and its location in text.
Returns the formatted text, constrained to ConstrainToSize.
Format(string, int, bool, bool, bool, int, TextDirection, bool, TextFormatter?)
Formats text into lines, applying text alignment and optionally wrapping text to new lines on word boundaries.
Format(string, int, Alignment, bool, bool, int, TextDirection, bool, TextFormatter?)
Formats text into lines, applying text alignment and optionally wrapping text to new lines on word boundaries.
Gets the size required to hold the formatted text, given the constraints placed by ConstrainToSize.
GetColumnsRequiredForVerticalText(List, int, int, int)
Returns the number of columns required to render lines
oriented vertically.
GetDrawRegion(Rectangle, Rectangle)
Calculates and returns a Region describing the areas where text would be output, based on the formatting rules of TextFormatter.
GetHotKeySpecifierLength(bool)
Gets the width or height of the HotKeySpecifier characters in the Text property.
GetLengthThatFits(List, int, int, TextDirection)
Gets the number of the Runes in a list of Runes that will fit in width
.
GetLengthThatFits(string, int, int, TextDirection)
Gets the number of the Runes in the text that will fit in width
.
Gets a list of formatted lines, constrained to ConstrainToSize.
GetMaxColsForWidth(List, int, int)
Gets the index position from the list based on the width
.
GetSumMaxCharWidth(string, int, int, int)
Gets the maximum number of columns from the text based on the startIndex
and thelength
.
GetWidestLineLength(string, int)
Returns the number of columns in the widest line in the text, without word wrap, accounting for wide-glyphs (uses GetColumns(string)). text
if it contains newlines.
IsHorizontalDirection(TextDirection)
Check if it is a horizontal direction
Check if it is Left to Right direction
Check if it is Top to Bottom direction
IsVerticalDirection(TextDirection)
Check if it is a vertical direction
Justify(string, int, char, TextDirection, int)
Justifies the text to fill the width provided. Space will be added between words to make the text just fitwidth
. Spaces will not be added to the start or end.
RemoveHotKeySpecifier(string, int, Rune)
Removes the hotkey specifier from text.
ReplaceHotKeyWithTag(string, int)
Replaces the Rune at the index specified by the hotPos
parameter with a tag identifying it as the hotkey.
Splits all newlines in the text
into a list and supports both CRLF and LF, preserving the ending newline.
WordWrapText(string, int, bool, int, TextDirection, TextFormatter?)
Formats the provided text to fit within the width provided using word wrapping.
Events
Event invoked when the HotKey is changed.