Class TextEdit
- Namespace
- Forma
- Assembly
- Forma.dll
Edits multiline text with wrapping, multiple carets, gutters, syntax highlighting, and undo history.
public class TextEdit : LineEdit, IAddChild<Control>, IAddChild, INotifyPropertyChanged, IDisposable
- Inheritance
-
TextEdit
- Implements
- Derived
- Inherited Members
Constructors
TextEdit()
public TextEdit()
Properties
CaretColumnInLine
public int CaretColumnInLine { get; }
Property Value
CaretCount
public int CaretCount { get; }
Property Value
CaretLine
public int CaretLine { get; set; }
Property Value
ClipboardTextProvider
Optional per-control override used by Paste(int) before Clipboard.
public Func<TextEdit, string> ClipboardTextProvider { get; set; }
Property Value
CurrentAction
public TextEditEditAction CurrentAction { get; }
Property Value
EmptySelectionClipboardEnabled
Allows copying/cutting whole caret line ranges when no caret has a selection, matching Godot's empty_selection_clipboard_enabled.
public bool EmptySelectionClipboardEnabled { get; set; }
Property Value
FirstVisibleLine
First visible source line, corresponding to Godot's get_first_visible_line().
public int FirstVisibleLine { get; }
Property Value
FirstVisibleLineWrapIndex
Visual wrap-row offset within FirstVisibleLine.
public int FirstVisibleLineWrapIndex { get; }
Property Value
GutterCount
public int GutterCount { get; }
Property Value
HasRedo
public bool HasRedo { get; }
Property Value
HasUndo
public bool HasUndo { get; }
Property Value
LineCount
public int LineCount { get; }
Property Value
LineWrappingMode
public TextEditLineWrappingMode LineWrappingMode { get; set; }
Property Value
MultipleCaretsEnabled
Enables Godot-style secondary caret creation and multi-caret text input.
public bool MultipleCaretsEnabled { get; set; }
Property Value
SearchFlags
public TextSearchFlags SearchFlags { get; }
Property Value
SearchText
public string SearchText { get; }
Property Value
ShortcutKeysEnabled
Enables Control/Command copy, cut, paste, and select-all dispatch, matching Godot's shortcut_keys_enabled.
public bool ShortcutKeysEnabled { get; set; }
Property Value
TextContentLeftInset
Extra horizontal space reserved by specialized text editors before their editable content.
protected virtual float TextContentLeftInset { get; }
Property Value
UndoEnabled
public bool UndoEnabled { get; set; }
Property Value
UndoStackMaxSize
public int UndoStackMaxSize { get; set; }
Property Value
WrapAtColumn
Optional deterministic wrap width in source columns; zero derives a width from the editor viewport.
public int WrapAtColumn { get; set; }
Property Value
WrapMode
Compatibility alias for enabling or disabling LineWrappingMode.
public bool WrapMode { get; set; }
Property Value
Methods
AddCaret(int, int)
Adds a non-overlapping secondary caret and returns its Godot-compatible index, or -1 when unavailable.
public int AddCaret(int line, int column)
Parameters
Returns
AddCaretAtCarets(bool)
Adds one caret above or below every existing caret where the adjacent visible source line exists.
public void AddCaretAtCarets(bool below)
Parameters
belowbool
AddGutter(int)
public void AddGutter(int at = -1)
Parameters
atint
AddSelectionForNextOccurrence()
Adds a selected secondary caret at the next case-sensitive occurrence of the final caret's selected word.
public void AddSelectionForNextOccurrence()
AdjustViewportToCaret()
Moves the text viewport only when the caret would otherwise be outside it.
public void AdjustViewportToCaret()
CenterViewportToCaret()
Centers the active caret line in the text viewport where possible.
public void CenterViewportToCaret()
Clear()
Clears the retained document and secondary carets, matching Godot's clear.
public void Clear()
ClearLineBackgroundColor(int)
public void ClearLineBackgroundColor(int line)
Parameters
lineint
ClearUndoHistory()
public void ClearUndoHistory()
Copy(int)
Requests a host clipboard write using Godot's selection-or-whole-line copy policy.
public void Copy(int caret = -1)
Parameters
caretint
Cut(int)
Copies text using Copy(int) then removes selections or whole caret line ranges when editable.
public void Cut(int caret = -1)
Parameters
caretint
DeleteAllSelections()
public void DeleteAllSelections()
DeleteSelection(int)
Deletes selections at one caret, or every selected caret when caret is -1.
public void DeleteSelection(int caret)
Parameters
caretint
Deselect(int)
Clears selection state at one caret, or all carets when caret is -1.
public void Deselect(int caret)
Parameters
caretint
DeselectAll()
public void DeselectAll()
EndAction()
Finishes the active action and commits its grouped undo/version entry.
public void EndAction()
FindVisibleLineAtOrAfter(int)
protected int FindVisibleLineAtOrAfter(int line)
Parameters
lineint
Returns
FindVisibleLineAtOrBefore(int, int)
protected int FindVisibleLineAtOrBefore(int line, int fallback)
Parameters
Returns
GetCaretColumn(int)
public int GetCaretColumn(int caret = 0)
Parameters
caretint
Returns
GetCaretColumnAtPosition(Point)
protected override int GetCaretColumnAtPosition(Point position)
Parameters
positionPoint
Returns
GetCaretCount()
public int GetCaretCount()
Returns
GetCaretLine(int)
public int GetCaretLine(int caret = 0)
Parameters
caretint
Returns
GetCarets()
public IReadOnlyList<TextEditCaret> GetCarets()
Returns
GetCurrentAction()
public TextEditEditAction GetCurrentAction()
Returns
GetFirstNonWhitespaceColumn(int)
Returns the first non-whitespace source column, or the line length when a line is blank.
public int GetFirstNonWhitespaceColumn(int line)
Parameters
lineint
Returns
GetFirstVisibleLine()
public int GetFirstVisibleLine()
Returns
GetGutterName(int)
public string GetGutterName(int gutter)
Parameters
gutterint
Returns
GetGutterType(int)
public TextEditGutterType GetGutterType(int gutter)
Parameters
gutterint
Returns
GetGutterWidth(int)
public int GetGutterWidth(int gutter)
Parameters
gutterint
Returns
GetIndentLevel(int)
Returns leading indentation measured with Godot-compatible tab width of four columns.
public int GetIndentLevel(int line)
Parameters
lineint
Returns
GetLastFullVisibleLine()
public int GetLastFullVisibleLine()
Returns
GetLastFullVisibleLineWrapIndex()
public int GetLastFullVisibleLineWrapIndex()
Returns
GetLine(int)
public string GetLine(int line)
Parameters
lineint
Returns
GetLineAtVisibleRow(int)
protected int GetLineAtVisibleRow(int row)
Parameters
rowint
Returns
GetLineBackgroundColor(int)
public Color? GetLineBackgroundColor(int line)
Parameters
lineint
Returns
- Color?
GetLineGutterIcon(int, int)
public Texture2D GetLineGutterIcon(int line, int gutter)
Parameters
Returns
- Texture2D
GetLineGutterItemColor(int, int)
public Color GetLineGutterItemColor(int line, int gutter)
Parameters
Returns
- Color
GetLineGutterMetadata(int, int)
public object GetLineGutterMetadata(int line, int gutter)
Parameters
Returns
GetLineGutterText(int, int)
public string GetLineGutterText(int line, int gutter)
Parameters
Returns
GetLineSyntaxHighlighting(int)
Gets the retained highlighter output for a line. Empty when no provider is assigned.
public IReadOnlyList<SyntaxHighlightSpan> GetLineSyntaxHighlighting(int line)
Parameters
lineint
Returns
GetLineWidth(int, int)
Returns the width of a source line or one of its visual wrap rows.
public float GetLineWidth(int line, int wrapIndex = -1)
Parameters
Returns
GetLineWrapCount(int)
Returns the number of continuation rows after the first visual row for a source line.
public int GetLineWrapCount(int line)
Parameters
lineint
Returns
GetLineWrapIndexAtColumn(int, int)
public int GetLineWrapIndexAtColumn(int line, int column)
Parameters
Returns
GetLineWrapIndexAtVisibleRow(int)
Returns the source-line wrap row represented by a viewport-relative visual row.
protected int GetLineWrapIndexAtVisibleRow(int row)
Parameters
rowint
Returns
GetLineWrapLength(int, int)
protected int GetLineWrapLength(int line, int wrapIndex)
Parameters
Returns
GetLineWrapStartColumn(int, int)
protected int GetLineWrapStartColumn(int line, int wrapIndex)
Parameters
Returns
GetLineWrappedText(int)
public IReadOnlyList<string> GetLineWrappedText(int line)
Parameters
lineint
Returns
GetLineWrappingMode()
public TextEditLineWrappingMode GetLineWrappingMode()
Returns
GetMenu()
Returns the retained context popup, equivalent to Godot's get_menu().
public override PopupMenu GetMenu()
Returns
GetSavedVersion()
public uint GetSavedVersion()
Returns
GetScrollPosForLine(int, int)
Returns the visual-row scroll position for a source line and wrap row.
public int GetScrollPosForLine(int line, int wrapIndex = 0)
Parameters
Returns
GetSelectedText(int)
Returns Godot-style selected text, or newline-joined selected fragments from all carets when caret is -1.
public string GetSelectedText(int caret = -1)
Parameters
caretint
Returns
GetSelectionFrom(int)
public int GetSelectionFrom(int caret)
Parameters
caretint
Returns
GetSelectionOriginColumn(int)
public int GetSelectionOriginColumn(int caret = 0)
Parameters
caretint
Returns
GetSelectionOriginLine(int)
public int GetSelectionOriginLine(int caret = 0)
Parameters
caretint
Returns
GetSelectionRectangles(int)
Returns screen-space visual-row rectangles for a caret selection, including wrapped source rows.
public IReadOnlyList<Rectangle> GetSelectionRectangles(int caret = 0)
Parameters
caretint
Returns
- IReadOnlyList<Rectangle>
GetSelectionTo(int)
public int GetSelectionTo(int caret)
Parameters
caretint
Returns
GetSyntaxHighlighter()
public SyntaxHighlighter GetSyntaxHighlighter()
Returns
GetTotalGutterWidth()
public int GetTotalGutterWidth()
Returns
GetTotalVisibleLineCount()
public int GetTotalVisibleLineCount()
Returns
GetVersion()
public uint GetVersion()
Returns
GetVisibleLineCount()
Returns the visible line capacity of the current text viewport.
public int GetVisibleLineCount()
Returns
GetVisibleLineCountInRange(int, int)
public int GetVisibleLineCountInRange(int fromLine, int toLine)
Parameters
Returns
GetVisibleRow(int, int)
protected int GetVisibleRow(int line, int wrapIndex = 0)
Parameters
Returns
HasCaretSelection(int)
Returns selection state for a specific caret without shadowing LineEdit's primary HasSelection property.
public bool HasCaretSelection(int caret)
Parameters
caretint
Returns
InsertLineAt(int, string)
public void InsertLineAt(int line, string text)
Parameters
InsertNewline()
public void InsertNewline()
InsertText(string)
public override void InsertText(string text)
Parameters
textstring
InsertText(string, int, int, bool, bool)
Inserts text at a source line and column, retaining all caret and selection positions relative to the inserted range.
public void InsertText(string text, int line, int column, bool beforeSelectionBegin = true, bool beforeSelectionEnd = false)
Parameters
InsertTextAtCaret(string, int)
Inserts text at one caret, or all carets when caret is -1, matching Godot's insert_text_at_caret.
public void InsertTextAtCaret(string text, int caret = -1)
Parameters
IsEmptySelectionClipboardEnabled()
public bool IsEmptySelectionClipboardEnabled()
Returns
IsGutterClickable(int)
public bool IsGutterClickable(int gutter)
Parameters
gutterint
Returns
IsGutterDrawn(int)
public bool IsGutterDrawn(int gutter)
Parameters
gutterint
Returns
IsGutterOverwritable(int)
public bool IsGutterOverwritable(int gutter)
Parameters
gutterint
Returns
IsLineGutterClickable(int, int)
public bool IsLineGutterClickable(int line, int gutter)
Parameters
Returns
IsLineHiddenForDisplay(int)
Allows specialized editors to hide document lines without mutating the underlying text.
protected virtual bool IsLineHiddenForDisplay(int line)
Parameters
lineint
Returns
IsLineInViewport(int)
public bool IsLineInViewport(int line)
Parameters
lineint
Returns
IsLineWrapped(int)
public bool IsLineWrapped(int line)
Parameters
lineint
Returns
IsMenuVisible()
public override bool IsMenuVisible()
Returns
IsMultipleCaretsEnabled()
public bool IsMultipleCaretsEnabled()
Returns
IsShortcutKeysEnabled()
public bool IsShortcutKeysEnabled()
Returns
MenuOption(TextEditMenuOption)
Executes one retained context-menu command.
public void MenuOption(TextEditMenuOption option)
Parameters
optionTextEditMenuOption
MergeOverlappingCarets()
Merges caret points or selections that overlap, following Godot's inclusive overlap rule.
public void MergeOverlappingCarets()
Paste(int)
Obtains host clipboard content and applies Godot's multi-caret paste distribution policy.
public void Paste(int caret = -1)
Parameters
caretint
Paste(string, int)
Pastes supplied clipboard content at one caret or all carets. A line per caret is used when the counts match.
public void Paste(string clipboard, int caret = -1)
Parameters
Redo()
public void Redo()
RemoveCaret(int)
public void RemoveCaret(int caret)
Parameters
caretint
RemoveGutter(int)
public void RemoveGutter(int gutter)
Parameters
gutterint
RemoveLineAt(int)
public void RemoveLineAt(int line)
Parameters
lineint
RemoveSecondaryCarets()
public void RemoveSecondaryCarets()
RemoveText(int, int, int, int)
Removes a source range, retaining all carets and selections at the collapsed range start where necessary.
public void RemoveText(int fromLine, int fromColumn, int toLine, int toColumn)
Parameters
Search(string, TextSearchFlags, int, int)
Returns a Godot-compatible (column, line) point, or (-1, -1) when not found.
public Point Search(string key, TextSearchFlags flags, int fromLine = 0, int fromColumn = 0)
Parameters
keystringflagsTextSearchFlagsfromLineintfromColumnint
Returns
- Point
Select(int, int, int, int, int)
public void Select(int fromLine, int fromColumn, int toLine, int toColumn, int caret = 0)
Parameters
SelectAll()
Selects the entire document with the primary caret, matching Godot's select_all.
public void SelectAll()
SelectWordUnderCaret(int)
Selects the word at one caret, or toggles the existing selection off, matching Godot's select_word_under_caret.
public void SelectWordUnderCaret(int caret = -1)
Parameters
caretint
SetCaret(int, int)
public void SetCaret(int line, int column)
Parameters
SetCaret(int, int, int)
public void SetCaret(int line, int column, int caret)
Parameters
SetCaretColumn(int, int)
public void SetCaretColumn(int column, int caret = 0)
Parameters
SetCaretLine(int, int)
public void SetCaretLine(int line, int caret = 0)
Parameters
SetEmptySelectionClipboardEnabled(bool)
public void SetEmptySelectionClipboardEnabled(bool enabled)
Parameters
enabledbool
SetGutterClickable(int, bool)
public void SetGutterClickable(int gutter, bool clickable)
Parameters
SetGutterCustomDraw(int, Action<UIRenderContext, TextEdit, int, Rectangle>)
public void SetGutterCustomDraw(int gutter, Action<UIRenderContext, TextEdit, int, Rectangle> draw)
Parameters
gutterintdrawAction<UIRenderContext, TextEdit, int, Rectangle>
SetGutterDraw(int, bool)
public void SetGutterDraw(int gutter, bool draw)
Parameters
SetGutterName(int, string)
public void SetGutterName(int gutter, string name)
Parameters
SetGutterOverwritable(int, bool)
public void SetGutterOverwritable(int gutter, bool overwritable)
Parameters
SetGutterType(int, TextEditGutterType)
public void SetGutterType(int gutter, TextEditGutterType type)
Parameters
gutterinttypeTextEditGutterType
SetGutterWidth(int, int)
public void SetGutterWidth(int gutter, int width)
Parameters
SetLine(int, string)
public void SetLine(int line, string text)
Parameters
SetLineAsCenterVisible(int, int)
public void SetLineAsCenterVisible(int line, int wrapIndex = 0)
Parameters
SetLineAsFirstVisible(int, int)
public void SetLineAsFirstVisible(int line, int wrapIndex = 0)
Parameters
SetLineAsLastVisible(int, int)
public void SetLineAsLastVisible(int line, int wrapIndex = 0)
Parameters
SetLineBackgroundColor(int, Color)
public void SetLineBackgroundColor(int line, Color color)
Parameters
lineintcolorColor
SetLineGutterClickable(int, int, bool)
public void SetLineGutterClickable(int line, int gutter, bool clickable)
Parameters
SetLineGutterIcon(int, int, Texture2D)
public void SetLineGutterIcon(int line, int gutter, Texture2D icon)
Parameters
SetLineGutterItemColor(int, int, Color)
public void SetLineGutterItemColor(int line, int gutter, Color color)
Parameters
SetLineGutterMetadata(int, int, object)
public void SetLineGutterMetadata(int line, int gutter, object metadata)
Parameters
SetLineGutterText(int, int, string)
public void SetLineGutterText(int line, int gutter, string text)
Parameters
SetLineWrappingMode(TextEditLineWrappingMode)
public void SetLineWrappingMode(TextEditLineWrappingMode mode)
Parameters
SetMultipleCaretsEnabled(bool)
public void SetMultipleCaretsEnabled(bool enabled)
Parameters
enabledbool
SetSearchFlags(TextSearchFlags)
public void SetSearchFlags(TextSearchFlags flags)
Parameters
flagsTextSearchFlags
SetSearchText(string)
public void SetSearchText(string text)
Parameters
textstring
SetShortcutKeysEnabled(bool)
public void SetShortcutKeysEnabled(bool enabled)
Parameters
enabledbool
SetSyntaxHighlighter(SyntaxHighlighter)
Sets the document-bound syntax provider, analogous to Godot's set_syntax_highlighter().
public void SetSyntaxHighlighter(SyntaxHighlighter highlighter)
Parameters
highlighterSyntaxHighlighter
SkipSelectionForNextOccurrence()
Moves the final occurrence selection to its next match, matching Godot's skip_selection_for_next_occurrence.
public void SkipSelectionForNextOccurrence()
StartAction(TextEditEditAction)
Begins a Godot-style edit action; all edits until EndAction() become one undo step.
public void StartAction(TextEditEditAction action)
Parameters
actionTextEditEditAction
SwapLines(int, int)
Swaps two source lines while retaining carets, selections, line backgrounds, and gutter items with their original line content.
public void SwapLines(int fromLine, int toLine)
Parameters
TagSavedVersion()
public void TagSavedVersion()
Undo()
public void Undo()
Events
CopyRequested
Raised after Copy or Cut submits text to Clipboard.
public event Action<TextEdit, string> CopyRequested
Event Type
GutterClicked
public event Action<TextEdit, int, int> GutterClicked