Class TextView
Multi-line text editing
View.
Assembly: Terminal.Gui.dll
Syntax
public class TextView : View, IDisposable, ISupportInitializeNotification, ISupportInitialize
Constructors
|
Edit this page
View Source
TextView()
Initializes a
TextView on the specified area,
with dimensions controlled with the X, Y, Width and Height properties.
Declaration
|
Edit this page
View Source
TextView(Rect)
Initializes a
TextView on the specified area, with absolute position and size.
Declaration
public TextView(Rect frame)
Parameters
| Type |
Name |
Description |
| Rect |
frame |
|
Properties
|
Edit this page
View Source
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.
Declaration
public bool AllowsReturn { get; set; }
Property Value
|
Edit this page
View Source
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.
Declaration
public bool AllowsTab { get; set; }
Property Value
|
Edit this page
View Source
Autocomplete
Provides autocomplete context menu based on suggestions at the current cursor
position. Populate
AllSuggestions to enable this feature
Declaration
public IAutocomplete Autocomplete { get; protected set; }
Property Value
|
Edit this page
View Source
BottomOffset
The bottom offset needed to use a horizontal scrollbar or for another reason.
This is only needed with the keyboard navigation.
Declaration
public int BottomOffset { get; set; }
Property Value
|
Edit this page
View Source
CanFocus
Gets or sets a value indicating whether this
Responder can focus.
Declaration
public override bool CanFocus { get; set; }
Property Value
| Type |
Description |
| bool |
true if can focus; otherwise, false. |
Overrides
|
Edit this page
View Source
Declaration
public ContextMenu ContextMenu { get; }
Property Value
|
Edit this page
View Source
CurrentColumn
Gets the cursor column.
Declaration
public int CurrentColumn { get; }
Property Value
| Type |
Description |
| int |
The cursor column. |
|
Edit this page
View Source
CurrentRow
Gets the current cursor row.
Declaration
public int CurrentRow { get; }
Property Value
|
Edit this page
View Source
CursorPosition
Sets or gets the current cursor position.
Declaration
public Point CursorPosition { get; set; }
Property Value
|
Edit this page
View Source
DesiredCursorVisibility
Get / Set the wished cursor when the field is focused
Declaration
public CursorVisibility DesiredCursorVisibility { get; set; }
Property Value
|
Edit this page
View Source
Frame
Gets or sets the frame for the view. The frame is relative to the view's container (
SuperView).
Declaration
public override Rect Frame { get; set; }
Property Value
| Type |
Description |
| Rect |
The frame. |
Overrides
|
Edit this page
View Source
HasHistoryChanges
Indicates whatever the text has history changes or not.
true if the text has history changes
false otherwise.
Declaration
public bool HasHistoryChanges { get; }
Property Value
|
Edit this page
View Source
IsDirty
Indicates whatever the text was changed or not.
true if the text was changed
false otherwise.
Declaration
public bool IsDirty { get; }
Property Value
|
Edit this page
View Source
LeftColumn
Gets or sets the left column.
Declaration
public int LeftColumn { get; set; }
Property Value
|
Edit this page
View Source
Lines
Gets the number of lines.
Declaration
public int Lines { get; }
Property Value
|
Edit this page
View Source
Maxlength
Gets the maximum visible length line.
Declaration
public int Maxlength { get; }
Property Value
|
Edit this page
View Source
Multiline
Gets or sets a value indicating whether this
TextView is a multiline text view.
Declaration
public bool Multiline { get; set; }
Property Value
|
Edit this page
View Source
ReadOnly
Gets or sets whether the
TextView is in read-only mode or not
Declaration
public bool ReadOnly { get; set; }
Property Value
| Type |
Description |
| bool |
Boolean value(Default false) |
|
Edit this page
View Source
RightOffset
The right offset needed to use a vertical scrollbar or for another reason.
This is only needed with the keyboard navigation.
Declaration
public int RightOffset { get; set; }
Property Value
|
Edit this page
View Source
SelectedLength
Length of the selected text.
Declaration
public int SelectedLength { get; }
Property Value
|
Edit this page
View Source
SelectedText
The selected text.
Declaration
public ustring SelectedText { get; }
Property Value
|
Edit this page
View Source
Selecting
Get or sets the selecting.
Declaration
public bool Selecting { get; set; }
Property Value
|
Edit this page
View Source
SelectionStartColumn
Start column position of the selected text.
Declaration
public int SelectionStartColumn { get; set; }
Property Value
|
Edit this page
View Source
SelectionStartRow
Start row position of the selected text.
Declaration
public int SelectionStartRow { get; set; }
Property Value
|
Edit this page
View Source
TabWidth
Gets or sets a value indicating the number of whitespace when pressing the TAB key.
Declaration
public int TabWidth { get; set; }
Property Value
|
Edit this page
View Source
Text
Declaration
public override ustring Text { get; set; }
Property Value
Overrides
|
Edit this page
View Source
TopRow
Gets or sets the top row.
Declaration
public int TopRow { get; set; }
Property Value
|
Edit this page
View Source
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
Declaration
public bool Used { get; set; }
Property Value
|
Edit this page
View Source
WordWrap
Allows word wrap the to fit the available container width.
Declaration
public bool WordWrap { get; set; }
Property Value
Methods
|
Edit this page
View Source
ClearHistoryChanges()
Declaration
public void ClearHistoryChanges()
|
Edit this page
View Source
CloseFile()
Closes the contents of the stream into the
TextView.
Declaration
Returns
| Type |
Description |
| bool |
true, if stream was closed, false otherwise. |
|
Edit this page
View Source
Copy()
Copy the selected text to the clipboard contents.
Declaration
|
Edit this page
View Source
Cut()
Cut the selected text to the clipboard contents.
Declaration
|
Edit this page
View Source
DeleteAll()
Deletes all text.
Declaration
|
Edit this page
View Source
DeleteCharLeft()
Deletes all the selected or a single character at left from the position of the cursor.
Declaration
public void DeleteCharLeft()
|
Edit this page
View Source
DeleteCharRight()
Deletes all the selected or a single character at right from the position of the cursor.
Declaration
public void DeleteCharRight()
|
Edit this page
View Source
FindNextText(ustring, out bool, bool, bool, ustring, bool)
Find the next text based on the match case with the option to replace it.
Declaration
public bool FindNextText(ustring textToFind, out bool gaveFullTurn, bool matchCase = false, bool matchWholeWord = false, ustring textToReplace = null, bool replace = false)
Parameters
| Type |
Name |
Description |
| ustring |
textToFind |
The text to find. |
| bool |
gaveFullTurn |
trueIf all the text was forward searched.falseotherwise. |
| bool |
matchCase |
The match case setting. |
| bool |
matchWholeWord |
The match whole word setting. |
| ustring |
textToReplace |
The text to replace. |
| bool |
replace |
trueIf is replacing.falseotherwise. |
Returns
| Type |
Description |
| bool |
trueIf the text was found.falseotherwise. |
|
Edit this page
View Source
FindPreviousText(ustring, out bool, bool, bool, ustring, bool)
Find the previous text based on the match case with the option to replace it.
Declaration
public bool FindPreviousText(ustring textToFind, out bool gaveFullTurn, bool matchCase = false, bool matchWholeWord = false, ustring textToReplace = null, bool replace = false)
Parameters
| Type |
Name |
Description |
| ustring |
textToFind |
The text to find. |
| bool |
gaveFullTurn |
trueIf all the text was backward searched.falseotherwise. |
| bool |
matchCase |
The match case setting. |
| bool |
matchWholeWord |
The match whole word setting. |
| ustring |
textToReplace |
The text to replace. |
| bool |
replace |
trueIf the text was found.falseotherwise. |
Returns
| Type |
Description |
| bool |
trueIf the text was found.falseotherwise. |
|
Edit this page
View Source
FindTextChanged()
Reset the flag to stop continuous find.
Declaration
public void FindTextChanged()
|
Edit this page
View Source
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
Declaration
public List<Rune> GetCurrentLine()
Returns
| Type |
Description |
| List<Rune> |
|
|
Edit this page
View Source
GetNormalColor()
Declaration
public override Attribute GetNormalColor()
Returns
Overrides
|
Edit this page
View Source
InsertText(string)
Inserts the given toAdd text at the current cursor position
exactly as if the user had just typed it
Declaration
public void InsertText(string toAdd)
Parameters
| Type |
Name |
Description |
| string |
toAdd |
Text to add |
|
Edit this page
View Source
LoadFile(string)
Loads the contents of the file into the
TextView.
Declaration
public bool LoadFile(string path)
Parameters
| Type |
Name |
Description |
| string |
path |
Path to the file to load. |
Returns
| Type |
Description |
| bool |
true, if file was loaded, false otherwise. |
|
Edit this page
View Source
LoadStream(Stream)
Loads the contents of the stream into the
TextView.
Declaration
public void LoadStream(Stream stream)
Parameters
| Type |
Name |
Description |
| Stream |
stream |
Stream to load the contents from. |
|
Edit this page
View Source
MouseEvent(MouseEvent)
Method invoked when a mouse event is generated
Declaration
public override bool MouseEvent(MouseEvent ev)
Parameters
Returns
| Type |
Description |
| bool |
true, if the event was handled, false otherwise. |
Overrides
|
Edit this page
View Source
MoveEnd()
Will scroll the
TextView to the last line and position the cursor there.
Declaration
|
Edit this page
View Source
MoveHome()
Will scroll the
TextView to the first line and position the cursor there.
Declaration
|
Edit this page
View Source
OnContentsChanged()
Called when the contents of the TextView change. E.g. when the user types text or deletes text. Raises
the
ContentsChanged event.
Declaration
public virtual void OnContentsChanged()
|
Edit this page
View Source
OnEnter(View)
Method invoked when a view gets focus.
Declaration
public override bool OnEnter(View view)
Parameters
| Type |
Name |
Description |
| View |
view |
The view that is losing focus. |
Returns
| Type |
Description |
| bool |
true, if the event was handled, false otherwise. |
Overrides
|
Edit this page
View Source
OnKeyUp(KeyEvent)
Method invoked when a key is released.
Declaration
public override bool OnKeyUp(KeyEvent kb)
Parameters
Returns
| Type |
Description |
| bool |
true if the event was handled |
Overrides
|
Edit this page
View Source
OnLeave(View)
Method invoked when a view loses focus.
Declaration
public override bool OnLeave(View view)
Parameters
| Type |
Name |
Description |
| View |
view |
The view that is getting focus. |
Returns
| Type |
Description |
| bool |
true, if the event was handled, false otherwise. |
Overrides
|
Edit this page
View Source
OnUnwrappedCursorPosition(int?, int?)
Declaration
public virtual void OnUnwrappedCursorPosition(int? cRow = null, int? cCol = null)
Parameters
| Type |
Name |
Description |
| int? |
cRow |
|
| int? |
cCol |
|
|
Edit this page
View Source
Paste()
Paste the clipboard contents into the current selected position.
Declaration
|
Edit this page
View Source
PositionCursor()
Positions the cursor on the current row and column
Declaration
public override void PositionCursor()
Overrides
|
Edit this page
View Source
ProcessKey(KeyEvent)
If the view is focused, gives the view a
chance to process the keystroke.
Declaration
public override bool ProcessKey(KeyEvent kb)
Parameters
Returns
Overrides
|
Edit this page
View Source
Redraw(Rect)
Redraws this view and its subviews; only redraws the views that have been flagged for a re-display.
Declaration
public override void Redraw(Rect bounds)
Parameters
| Type |
Name |
Description |
| Rect |
bounds |
The bounds (view-relative region) to redraw. |
Overrides
|
Edit this page
View Source
ReplaceAllText(ustring, bool, bool, ustring)
Replaces all the text based on the match case.
Declaration
public bool ReplaceAllText(ustring textToFind, bool matchCase = false, bool matchWholeWord = false, ustring textToReplace = null)
Parameters
| Type |
Name |
Description |
| ustring |
textToFind |
The text to find. |
| bool |
matchCase |
The match case setting. |
| bool |
matchWholeWord |
The match whole word setting. |
| ustring |
textToReplace |
The text to replace. |
Returns
| Type |
Description |
| bool |
trueIf the text was found.falseotherwise. |
|
Edit this page
View Source
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.
Declaration
public void ScrollTo(int idx, bool isRow = true)
Parameters
| Type |
Name |
Description |
| int |
idx |
Row that should be displayed at the top or Column that should be displayed at the left,
if the value is negative it will be reset to zero |
| bool |
isRow |
If true (default) the idx is a row, column otherwise. |
|
Edit this page
View Source
SelectAll()
Select all text.
Declaration
|
Edit this page
View Source
SetNormalColor()
Sets the driver to the default color for the control where no text is being rendered. Defaults to
Normal.
Declaration
protected virtual void SetNormalColor()
|
Edit this page
View Source
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.
Declaration
protected virtual void SetNormalColor(List<Rune> line, int idx)
Parameters
| Type |
Name |
Description |
| List<Rune> |
line |
|
| int |
idx |
|
|
Edit this page
View Source
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.
Declaration
protected virtual void SetReadOnlyColor(List<Rune> line, int idx)
Parameters
| Type |
Name |
Description |
| List<Rune> |
line |
|
| int |
idx |
|
|
Edit this page
View Source
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.
Declaration
protected virtual void SetSelectionColor(List<Rune> line, int idx)
Parameters
| Type |
Name |
Description |
| List<Rune> |
line |
|
| int |
idx |
|
|
Edit this page
View Source
SetUsedColor(List<Rune>, int)
Declaration
protected virtual void SetUsedColor(List<Rune> line, int idx)
Parameters
| Type |
Name |
Description |
| List<Rune> |
line |
|
| int |
idx |
|
Events
|
Edit this page
View Source
ContentsChanged
Raised when the contents of the
TextView are changed.
Declaration
public event Action<TextView.ContentsChangedEventArgs> ContentsChanged
Event Type
|
Edit this page
View Source
TextChanged
Declaration
public event Action TextChanged
Event Type
|
Edit this page
View Source
UnwrappedCursorPosition
Declaration
public event Action<Point> UnwrappedCursorPosition
Event Type
Implements