Skip to main content

TextAreaModal class

Namespace: Arlecchino.Modals.Asking · Assembly: Arlecchino

Several lines of text, edited in place, where Enter starts a new line and the Submit binding confirms. The text is one line with newlines in it, so every edit is the one a field of one line has.

public sealed class TextAreaModal : Modal, ITextEntry

Inherits from Modal
Implements ITextEntry

Constructors

MemberSummary
TextAreaModal()

Properties

MemberSummary
AnchorWhere the selection was started from, on the caret while nothing is selected.
CaretWhere the caret sits, counted from the start of the whole text.
ColumnWhere the caret sits inside its row, as an index into that line.
FirstVisibleFirst visible row, kept in step with the caret while drawing.
LinesThe lines as they stand, top to bottom.
MessageWhy the last attempt to submit was refused, drawn under the text.
OnSubmitCalled with the accepted text.
RowRow the caret is on.
RowsWhere the text area was drawn last frame, for turning a click into a caret position.
TextThe whole text, lines joined with a newline. Assigning it puts the caret at the end.
TypingThe line being typed into, which here is the whole text with its newlines in it.
ValidateChecked when the text is submitted; return a message to keep the dialog open, or null to accept.
VisibleRowsHow many rows of text the dialog shows before it starts scrolling.

Methods

MemberSummary
Draw(ModalFrame)
Handle(ModalFrame, KeyPress)
HandlePaste(ModalFrame, string)Takes pasted text whole, line breaks included, since this is the one dialog that holds more than one row of it.
InsertText(string)Inserts text where the caret is, over whatever was selected.
MoveCaret(int, int)Puts the caret at a row and a position inside it, clamped to what exists.
MoveRows(int)Moves the caret a number of rows, keeping as much of the column as the new row has.
MoveToLineEnd()Puts the caret at the end of its line.
MoveToLineStart()Puts the caret at the start of its line.
SelectRows(int)Takes the selection a number of rows, dragging it along behind the caret.
SelectToLineEnd()Takes the selection on to the end of the line.
SelectToLineStart()Takes the selection back to the start of the line.
StartOf(int)Where in the whole text a row begins.

Constructors in detail

TextAreaModal()

Obsolete

Constructors of types with required members are not supported in this version of your compiler.

public TextAreaModal();

Properties in detail

Anchor

public int Anchor { get; set; }

Where the selection was started from, on the caret while nothing is selected.

Type int

Caret

public int Caret { get; set; }

Where the caret sits, counted from the start of the whole text.

Type int

Column

public int Column { get; }

Where the caret sits inside its row, as an index into that line.

Type int

FirstVisible

public int FirstVisible { get; set; }

First visible row, kept in step with the caret while drawing.

Type int

Lines

public IReadOnlyList<string> Lines { get; }

The lines as they stand, top to bottom.

Type IReadOnlyList<T><string>

Message

public string Message { get; set; }

Why the last attempt to submit was refused, drawn under the text.

Type string

OnSubmit

public Action<string> OnSubmit { get; init; }

Called with the accepted text.

Type Action<T><string>

Row

public int Row { get; }

Row the caret is on.

Type int

Rows

public SurfaceRegion Rows { get; set; }

Where the text area was drawn last frame, for turning a click into a caret position.

Type SurfaceRegion

Text

public string Text { get; set; }

The whole text, lines joined with a newline. Assigning it puts the caret at the end.

Type string

Typing

public override ITextEntry Typing { get; }

The line being typed into, which here is the whole text with its newlines in it.

Type ITextEntry

Validate

public Func<string, string?>? Validate { get; init; }

Checked when the text is submitted; return a message to keep the dialog open, or null to accept.

Type Func<T, TResult><string, string>

VisibleRows

public int VisibleRows { get; init; }

How many rows of text the dialog shows before it starts scrolling.

Type int

Methods in detail

Draw(ModalFrame)

public override void Draw(ModalFrame frame);

Parameters

NameTypeDescription
frameModalFrame

Handle(ModalFrame, KeyPress)

public override void Handle(ModalFrame frame, KeyPress key);

Parameters

NameTypeDescription
frameModalFrame
keyKeyPress

HandlePaste(ModalFrame, string)

public override void HandlePaste(ModalFrame frame, string text);

Takes pasted text whole, line breaks included, since this is the one dialog that holds more than one row of it.

Parameters

NameTypeDescription
frameModalFrameThe keys to obey, and how to close.
textstringWhat was pasted.

InsertText(string)

public void InsertText(string text);

Inserts text where the caret is, over whatever was selected.

Parameters

NameTypeDescription
textstringWhat to insert; a newline in it starts a new line.

MoveCaret(int, int)

public void MoveCaret(int row, int column);

Puts the caret at a row and a position inside it, clamped to what exists.

Parameters

NameTypeDescription
rowintRow to move to.
columnintIndex inside that row.

MoveRows(int)

public void MoveRows(int rows);

Moves the caret a number of rows, keeping as much of the column as the new row has.

Parameters

NameTypeDescription
rowsintHow far to move; negative goes up.

MoveToLineEnd()

public void MoveToLineEnd();

Puts the caret at the end of its line.

MoveToLineStart()

public void MoveToLineStart();

Puts the caret at the start of its line.

SelectRows(int)

public void SelectRows(int rows);

Takes the selection a number of rows, dragging it along behind the caret.

Parameters

NameTypeDescription
rowsintHow far to take it; negative goes up.

SelectToLineEnd()

public void SelectToLineEnd();

Takes the selection on to the end of the line.

SelectToLineStart()

public void SelectToLineStart();

Takes the selection back to the start of the line.

StartOf(int)

public int StartOf(int row);

Where in the whole text a row begins.

Parameters

NameTypeDescription
rowintThe row, clamped to the rows there are.

Returns int — The index of the first character on it.