Table of Contents

Method Format

Namespace
Terminal.Gui
Assembly
Terminal.Gui.dll

Format()

Returns the formatted text, constrained to ConstrainToSize.

public string Format()

Returns

string

The formatted text.

Remarks

If NeedsFormat is true, causes a format, resetting NeedsFormat to false.

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.

public static List<string> Format(string text, int width, Alignment textAlignment, bool wordWrap, bool preserveTrailingSpaces = false, int tabWidth = 0, TextDirection textDirection = TextDirection.LeftRight_TopBottom, bool multiLine = false, TextFormatter? textFormatter = null)

Parameters

text string
width int

The number of columns to constrain the text to for word wrapping and clipping.

textAlignment Alignment

Specifies how the text will be aligned horizontally.

wordWrap bool

If true, the text will be wrapped to new lines no longer than width. If false, forces text to fit a single line. Line breaks are converted to spaces. The text will be clipped to width.

preserveTrailingSpaces bool

If true trailing spaces at the end of wrapped lines will be preserved. If false , trailing spaces at the end of wrapped lines will be trimmed.

tabWidth int

The number of columns used for a tab.

textDirection TextDirection

The text direction.

multiLine bool

If true new lines are allowed.

textFormatter TextFormatter

TextFormatter instance to access any of his objects.

Returns

List<string>

A list of word wrapped lines.

Remarks

An empty text string will result in one empty line.

If width is 0, a single, empty line will be returned.

If width is int.MaxValue, the text will be formatted to the maximum width possible.

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.

public static List<string> Format(string text, int width, bool justify, bool wordWrap, bool preserveTrailingSpaces = false, int tabWidth = 0, TextDirection textDirection = TextDirection.LeftRight_TopBottom, bool multiLine = false, TextFormatter? textFormatter = null)

Parameters

text string
width int

The number of columns to constrain the text to for word wrapping and clipping.

justify bool

Specifies whether the text should be justified.

wordWrap bool

If true, the text will be wrapped to new lines no longer than width. If false, forces text to fit a single line. Line breaks are converted to spaces. The text will be clipped to width.

preserveTrailingSpaces bool

If true trailing spaces at the end of wrapped lines will be preserved. If false , trailing spaces at the end of wrapped lines will be trimmed.

tabWidth int

The number of columns used for a tab.

textDirection TextDirection

The text direction.

multiLine bool

If true new lines are allowed.

textFormatter TextFormatter

TextFormatter instance to access any of his objects.

Returns

List<string>

A list of word wrapped lines.

Remarks

An empty text string will result in one empty line.

If width is 0, a single, empty line will be returned.

If width is int.MaxValue, the text will be formatted to the maximum width possible.