Class LineDisplayState
- Namespace
- InteractiveReadLine.Formatting
- Assembly
- InteractiveReadLine.dll
Holds all of the information to present to the user through the view. The LineDisplayState is typically the output of a formatter, and is intended to be written directly to an IReadLineProvider
public class LineDisplayState
- Inheritance
-
LineDisplayState
- Inherited Members
Remarks
The LineDisplayState is the output of a formatter, which is a function which receives either a LineState or a TokenizedLine object and returns a LineDisplayState.
A LineDisplayState consists of three pieces of formatted text in addition to a cursor position. The actual presentation of the LineDisplayState is the responsibility of the IReadLineProvider, but it is typically intended that the prefix be written first (like a prompt), the line body in the middle, and the suffix at the end. The cursor should be located as an offset of the first character of the line body in order to visually align with how the ReadLineHandler will perform character inserts.
Text and word wrapping is left up to the provider.
Constructors
LineDisplayState(FormattedText, FormattedText, FormattedText, int)
Creates a display state from the line body, its surrounding text, and the cursor position within the body.
public LineDisplayState(FormattedText prefix, FormattedText lineBody, FormattedText suffix, int cursor)
Parameters
prefixFormattedTextText displayed before the line, such as a prompt.
lineBodyFormattedTextThe displayed form of the line being edited.
suffixFormattedTextText displayed after the line, such as a hint.
cursorintThe cursor position, measured from the start of the body.
Properties
Cursor
Gets the position of the cursor as an integer offset from the beginning of the LineBody
public int Cursor { get; }
Property Value
LineBody
Gets the line's body text, which is typically the text entered by the user or some representation of what they've entered
public FormattedText LineBody { get; }
Property Value
Prefix
Gets the prefix, which is displayed before the line body
public FormattedText Prefix { get; }
Property Value
Suffix
Gets the suffix, which is displayed after the line body
public FormattedText Suffix { get; }