Table of Contents

Method Format

Namespace
Terminal.Gui
Assembly
Terminal.Gui.dll

Format(ustring, int, TextAlignment, bool, bool, int, TextDirection)

Reformats text into lines, applying text alignment and optionally wrapping text to new lines on word boundaries.

public static List<ustring> Format(ustring text, int width, TextAlignment talign, bool wordWrap, bool preserveTrailingSpaces = false, int tabWidth = 0, TextDirection textDirection = TextDirection.LeftRight_TopBottom)

Parameters

text ustring
width int

The width to bound the text to for word wrapping and clipping.

talign TextAlignment

Specifies how the text will be aligned horizontally.

wordWrap bool

If true, the text will be wrapped to new lines as need. 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 and 'wordWrap' also true, the wrapped text will keep the trailing spaces. If false, the trailing spaces will be trimmed.

tabWidth int

The tab width.

textDirection TextDirection

The text direction.

Returns

List<ustring>

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(ustring, int, bool, bool, bool, int, TextDirection)

Reformats text into lines, applying text alignment and optionally wrapping text to new lines on word boundaries.

public static List<ustring> Format(ustring text, int width, bool justify, bool wordWrap, bool preserveTrailingSpaces = false, int tabWidth = 0, TextDirection textDirection = TextDirection.LeftRight_TopBottom)

Parameters

text ustring
width int

The width to bound 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 as need. 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 and 'wordWrap' also true, the wrapped text will keep the trailing spaces. If false, the trailing spaces will be trimmed.

tabWidth int

The tab width.

textDirection TextDirection

The text direction.

Returns

List<ustring>

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.