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
| Member | Summary |
|---|---|
TextAreaModal() |
Properties
| Member | Summary |
|---|---|
Anchor | Where the selection was started from, on the caret while nothing is selected. |
Caret | Where the caret sits, counted from the start of the whole text. |
Column | Where the caret sits inside its row, as an index into that line. |
FirstVisible | First visible row, kept in step with the caret while drawing. |
Lines | The lines as they stand, top to bottom. |
Message | Why the last attempt to submit was refused, drawn under the text. |
OnSubmit | Called with the accepted text. |
Row | Row the caret is on. |
Rows | Where the text area was drawn last frame, for turning a click into a caret position. |
Text | The whole text, lines joined with a newline. Assigning it puts the caret at the end. |
Typing | The line being typed into, which here is the whole text with its newlines in it. |
Validate | Checked when the text is submitted; return a message to keep the dialog open, or null to accept. |
VisibleRows | How many rows of text the dialog shows before it starts scrolling. |
Methods
| Member | Summary |
|---|---|
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()
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
| Name | Type | Description |
|---|---|---|
frame | ModalFrame |
Handle(ModalFrame, KeyPress)
public override void Handle(ModalFrame frame, KeyPress key);
Parameters
| Name | Type | Description |
|---|---|---|
frame | ModalFrame | |
key | KeyPress |
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
| Name | Type | Description |
|---|---|---|
frame | ModalFrame | The keys to obey, and how to close. |
text | string | What was pasted. |
InsertText(string)
public void InsertText(string text);
Inserts text where the caret is, over whatever was selected.
Parameters
| Name | Type | Description |
|---|---|---|
text | string | What 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
| Name | Type | Description |
|---|---|---|
row | int | Row to move to. |
column | int | Index 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
| Name | Type | Description |
|---|---|---|
rows | int | How 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
| Name | Type | Description |
|---|---|---|
rows | int | How 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
| Name | Type | Description |
|---|---|---|
row | int | The row, clamped to the rows there are. |
Returns int — The index of the first character on it.