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-b Moves the editing point left.
Right cursor, Control-f Moves the editing point right.
Alt-b Moves one word back.
Alt-f Moves one word forward.
Up cursor, Control-p Moves the editing point one line up.
Down cursor, Control-n Moves the editing point one line down
Home key, Control-a Moves the cursor to the beginning of the line.
End key, Control-e Moves the cursor to the end of the line.
Control-Home Scrolls to the first line and moves the cursor there.
Control-End Scrolls to the last line and moves the cursor there.
Delete, Control-d Deletes the character in front of the cursor.
Backspace Deletes 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-y Pastes 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.

TextView(Rect)

Initializes a TextView on the specified area, with absolute position and size.

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. Populate AllSuggestions 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.

CanFocus

Gets or sets a value indicating whether this Responder can focus.

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.

DesiredCursorVisibility

Get / Set the wished cursor when the field is focused

Frame

Gets or sets the frame for the view. The frame is relative to the view's container (SuperView).

HasHistoryChanges

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

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 the selecting.

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

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

FindPreviousText(ustring, out bool, bool, bool, ustring, bool)

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

FindTextChanged()

Reset the flag to stop continuous find.

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

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

LoadFile(string)

Loads the contents of the file into the TextView.

LoadStream(Stream)

Loads the contents of the stream into the TextView.

MouseEvent(MouseEvent)

Method invoked when a mouse event is generated

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.

OnEnter(View)

Method invoked when a view gets focus.

OnKeyUp(KeyEvent)

Method invoked when a key is released.

OnLeave(View)

Method invoked when a view loses focus.

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

ProcessKey(KeyEvent)

If the view is focused, gives the view a chance to process the keystroke.

Redraw(Rect)

Redraws this view and its subviews; only redraws the views that have been flagged for a re-display.

ReplaceAllText(ustring, bool, bool, ustring)

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.

SetNormalColor(List<Rune>, int)

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

SetReadOnlyColor(List<Rune>, int)

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

SetSelectionColor(List<Rune>, int)

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

SetUsedColor(List<Rune>, int)

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

Events

ContentsChanged

Raised when the contents of the TextView are changed.

TextChanged

Raised when the Text property of the TextView changes.

UnwrappedCursorPosition

Invoked with the unwrapped CursorPosition.