Table of Contents

Class TextView

Namespace
Terminal.Gui
Assembly
Terminal.Gui.dll

Multi-line text editing View.

public class TextView : View, IDisposable, ISupportInitializeNotification, ISupportInitialize
Inheritance
TextView
Implements
Inherited Members

Remarks

TextView provides a multi-line text editor. Users interact with it with the standard Windows, Mac, and Linux (Emacs) commands.

ShortcutAction performed
Left cursor, Control-bMoves the editing point left.
Right cursor, Control-fMoves the editing point right.
Alt-bMoves one word back.
Alt-fMoves one word forward.
Up cursor, Control-pMoves the editing point one line up.
Down cursor, Control-nMoves the editing point one line down
Home key, Control-aMoves the cursor to the beginning of the line.
End key, Control-eMoves the cursor to the end of the line.
Control-HomeScrolls to the first line and moves the cursor there.
Control-EndScrolls to the last line and moves the cursor there.
Delete, Control-dDeletes the character in front of the cursor.
BackspaceDeletes the character behind the cursor.
Control-k Deletes the text until the end of the line and replaces the kill buffer with the deleted text. You can paste this text in a different place by using Control-y.
Control-yPastes the content of the kill ring into the current position.
Alt-d Deletes the word above the cursor and adds it to the kill ring. You can paste the contents of the kill ring with Control-y.
Control-q Quotes the next input character, to prevent the normal processing of key handling to take place.

Constructors

TextView()

Initializes a TextView on the specified area, with dimensions controlled with the X, Y, Width and Height properties.

Properties

AllowsReturn

Gets or sets a value indicating whether pressing ENTER in a TextView creates a new line of text in the view or activates the default button for the Toplevel.

AllowsTab

Gets or sets whether the TextView inserts a tab character into the text or ignores tab input. If set to false and the user presses the tab key (or shift-tab) the focus will move to the next view (or previous with shift-tab). The default is true; if the user presses the tab key, a tab character will be inserted into the text.

Autocomplete

Provides autocomplete context menu based on suggestions at the current cursor position. Configure SuggestionGenerator to enable this feature

BottomOffset

The bottom offset needed to use a horizontal scrollbar or for another reason. This is only needed with the keyboard navigation.

ContextMenu

Get the ContextMenu for this view.

CurrentColumn

Gets the cursor column.

CurrentRow

Gets the current cursor row.

CursorPosition

Sets or gets the current cursor position.

HasHistoryChanges

Indicates whatever the text has history changes or not. true if the text has history changes false otherwise.

InheritsPreviousColorScheme

If true and the current ColorScheme is null will inherit from the previous, otherwise if false (default) do nothing. If the text is load with Load(List<RuneCell>) this property is automatically sets to true.

IsDirty

Indicates whatever the text was changed or not. true if the text was changed false otherwise.

LeftColumn

Gets or sets the left column.

Lines

Gets the number of lines.

Maxlength

Gets the maximum visible length line.

Multiline

Gets or sets a value indicating whether this TextView is a multiline text view.

ReadOnly

Gets or sets whether the TextView is in read-only mode or not

RightOffset

The right offset needed to use a vertical scrollbar or for another reason. This is only needed with the keyboard navigation.

SelectedLength

Length of the selected text.

SelectedText

The selected text.

Selecting

Get or sets whether the user is currently selecting text.

SelectionStartColumn

Start column position of the selected text.

SelectionStartRow

Start row position of the selected text.

TabWidth

Gets or sets a value indicating the number of whitespace when pressing the TAB key.

Text

Sets or gets the text in the TextView.

TopRow

Gets or sets the top row.

Used

Tracks whether the text view should be considered "used", that is, that the user has moved in the entry, so new input should be appended at the cursor position, rather than clearing the entry

WordWrap

Allows word wrap the to fit the available container width.

Methods

ClearHistoryChanges()

Allows clearing the HistoryText.HistoryTextItem items updating the original text.

CloseFile()

Closes the contents of the stream into the TextView.

Copy()

Copy the selected text to the clipboard contents.

Cut()

Cut the selected text to the clipboard contents.

DeleteAll()

Deletes all text.

DeleteCharLeft()

Deletes all the selected or a single character at left from the position of the cursor.

DeleteCharRight()

Deletes all the selected or a single character at right from the position of the cursor.

FindNextText(string, out bool, bool, bool, string?, bool)

Find the next text based on the match case with the option to replace it.

FindPreviousText(string, out bool, bool, bool, string?, bool)

Find the previous text based on the match case with the option to replace it.

FindTextChanged()

Reset the flag to stop continuous find.

GetAllLines()

Gets all lines of characters.

GetCurrentLine()

Returns the characters on the current line (where the cursor is positioned). Use CurrentColumn to determine the position of the cursor within that line

GetLine(int)

Returns the characters on the line.

GetNormalColor()

Determines the current ColorScheme based on the Enabled value.

InsertText(string)

Inserts the given toAdd text at the current cursor position exactly as if the user had just typed it

Load(List<List<RuneCell>>)

Loads the contents of the list of RuneCell list into the TextView.

Load(List<RuneCell>)

Loads the contents of the RuneCell list into the TextView.

Load(Stream)

Loads the contents of the stream into the TextView.

Load(string)

Loads the contents of the file into the TextView.

MoveEnd()

Will scroll the TextView to the last line and position the cursor there.

MoveHome()

Will scroll the TextView to the first line and position the cursor there.

OnContentsChanged()

Called when the contents of the TextView change. E.g. when the user types text or deletes text. Raises the ContentsChanged event.

OnDrawContent(Rectangle)

Draws the view's content, including Subviews.

OnDrawNormalColor(List<RuneCell>, int, int)

Sets the Driver to an appropriate color for rendering the given idxCol of the current line. Override to provide custom coloring by calling SetAttribute(Attribute) Defaults to Normal.

OnDrawReadOnlyColor(List<RuneCell>, int, int)

Sets the Driver to an appropriate color for rendering the given idxCol of the current line. Override to provide custom coloring by calling SetAttribute(Attribute) Defaults to Focus.

OnDrawSelectionColor(List<RuneCell>, int, int)

Sets the Driver to an appropriate color for rendering the given idxCol of the current line. Override to provide custom coloring by calling SetAttribute(Attribute) Defaults to Focus.

OnDrawUsedColor(List<RuneCell>, int, int)

Sets the Driver to an appropriate color for rendering the given idxCol of the current line. Override to provide custom coloring by calling SetAttribute(Attribute) Defaults to HotFocus.

OnInvokingKeyBindings(Key)

Low-level API called when a user presses a key; invokes any key bindings set on the view. This is called during NewKeyDownEvent(Key) after OnKeyDown(Key) has returned.

OnKeyUp(Key)

Method invoked when a key is released. This method is called from NewKeyUpEvent(Key).

OnLeave(View)

Method invoked when a view loses focus.

OnMouseEvent(MouseEvent)

Called when a mouse event occurs within the view's Viewport.

OnProcessKeyDown(Key)

Low-level API called when the user presses a key, allowing views do things during key down events. This is called from NewKeyDownEvent(Key) after OnInvokingKeyBindings(Key).

OnUnwrappedCursorPosition(int?, int?)

Invoke the UnwrappedCursorPosition event with the unwrapped CursorPosition.

Paste()

Paste the clipboard contents into the current selected position.

PositionCursor()

Positions the cursor on the current row and column

Redo()

Redoes the latest changes.

ReplaceAllText(string, bool, bool, string?)

Replaces all the text based on the match case.

ScrollTo(int, bool)

Will scroll the TextView to display the specified row at the top if isRow is true or will scroll the TextView to display the specified column at the left if isRow is false.

SelectAll()

Select all text.

SetNormalColor()

Sets the driver to the default color for the control where no text is being rendered. Defaults to Normal.

Undo()

Undoes the latest changes.

Events

ContentsChanged

Raised when the contents of the TextView are changed.

DrawNormalColor

Invoked when the normal color is drawn.

DrawReadOnlyColor

Invoked when the ready only color is drawn.

DrawSelectionColor

Invoked when the selection color is drawn.

DrawUsedColor

Invoked when the used color is drawn. The Used Color is used to indicate if the InsertChar was pressed and enabled.

UnwrappedCursorPosition

Invoked with the unwrapped CursorPosition.