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

int

CaretCount

public int CaretCount { get; }

Property Value

int

CaretLine

public int CaretLine { get; set; }

Property Value

int

ClipboardTextProvider

Optional per-control override used by Paste(int) before Clipboard.

public Func<TextEdit, string> ClipboardTextProvider { get; set; }

Property Value

Func<TextEdit, string>

CurrentAction

public TextEditEditAction CurrentAction { get; }

Property Value

TextEditEditAction

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

bool

FirstVisibleLine

First visible source line, corresponding to Godot's get_first_visible_line().

public int FirstVisibleLine { get; }

Property Value

int

FirstVisibleLineWrapIndex

Visual wrap-row offset within FirstVisibleLine.

public int FirstVisibleLineWrapIndex { get; }

Property Value

int

GutterCount

public int GutterCount { get; }

Property Value

int

HasRedo

public bool HasRedo { get; }

Property Value

bool

HasUndo

public bool HasUndo { get; }

Property Value

bool

LineCount

public int LineCount { get; }

Property Value

int

LineWrappingMode

public TextEditLineWrappingMode LineWrappingMode { get; set; }

Property Value

TextEditLineWrappingMode

MultipleCaretsEnabled

Enables Godot-style secondary caret creation and multi-caret text input.

public bool MultipleCaretsEnabled { get; set; }

Property Value

bool

SearchFlags

public TextSearchFlags SearchFlags { get; }

Property Value

TextSearchFlags

SearchText

public string SearchText { get; }

Property Value

string

ShortcutKeysEnabled

Enables Control/Command copy, cut, paste, and select-all dispatch, matching Godot's shortcut_keys_enabled.

public bool ShortcutKeysEnabled { get; set; }

Property Value

bool

TextContentLeftInset

Extra horizontal space reserved by specialized text editors before their editable content.

protected virtual float TextContentLeftInset { get; }

Property Value

float

UndoEnabled

public bool UndoEnabled { get; set; }

Property Value

bool

UndoStackMaxSize

public int UndoStackMaxSize { get; set; }

Property Value

int

WrapAtColumn

Optional deterministic wrap width in source columns; zero derives a width from the editor viewport.

public int WrapAtColumn { get; set; }

Property Value

int

WrapMode

Compatibility alias for enabling or disabling LineWrappingMode.

public bool WrapMode { get; set; }

Property Value

bool

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

line int
column int

Returns

int

AddCaretAtCarets(bool)

Adds one caret above or below every existing caret where the adjacent visible source line exists.

public void AddCaretAtCarets(bool below)

Parameters

below bool

AddGutter(int)

public void AddGutter(int at = -1)

Parameters

at int

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

line int

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

caret int

Cut(int)

Copies text using Copy(int) then removes selections or whole caret line ranges when editable.

public void Cut(int caret = -1)

Parameters

caret int

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

caret int

Deselect(int)

Clears selection state at one caret, or all carets when caret is -1.

public void Deselect(int caret)

Parameters

caret int

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

line int

Returns

int

FindVisibleLineAtOrBefore(int, int)

protected int FindVisibleLineAtOrBefore(int line, int fallback)

Parameters

line int
fallback int

Returns

int

GetCaretColumn(int)

public int GetCaretColumn(int caret = 0)

Parameters

caret int

Returns

int

GetCaretColumnAtPosition(Point)

protected override int GetCaretColumnAtPosition(Point position)

Parameters

position Point

Returns

int

GetCaretCount()

public int GetCaretCount()

Returns

int

GetCaretLine(int)

public int GetCaretLine(int caret = 0)

Parameters

caret int

Returns

int

GetCarets()

public IReadOnlyList<TextEditCaret> GetCarets()

Returns

IReadOnlyList<TextEditCaret>

GetCurrentAction()

public TextEditEditAction GetCurrentAction()

Returns

TextEditEditAction

GetFirstNonWhitespaceColumn(int)

Returns the first non-whitespace source column, or the line length when a line is blank.

public int GetFirstNonWhitespaceColumn(int line)

Parameters

line int

Returns

int

GetFirstVisibleLine()

public int GetFirstVisibleLine()

Returns

int

GetGutterName(int)

public string GetGutterName(int gutter)

Parameters

gutter int

Returns

string

GetGutterType(int)

public TextEditGutterType GetGutterType(int gutter)

Parameters

gutter int

Returns

TextEditGutterType

GetGutterWidth(int)

public int GetGutterWidth(int gutter)

Parameters

gutter int

Returns

int

GetIndentLevel(int)

Returns leading indentation measured with Godot-compatible tab width of four columns.

public int GetIndentLevel(int line)

Parameters

line int

Returns

int

GetLastFullVisibleLine()

public int GetLastFullVisibleLine()

Returns

int

GetLastFullVisibleLineWrapIndex()

public int GetLastFullVisibleLineWrapIndex()

Returns

int

GetLine(int)

public string GetLine(int line)

Parameters

line int

Returns

string

GetLineAtVisibleRow(int)

protected int GetLineAtVisibleRow(int row)

Parameters

row int

Returns

int

GetLineBackgroundColor(int)

public Color? GetLineBackgroundColor(int line)

Parameters

line int

Returns

Color?

GetLineGutterIcon(int, int)

public Texture2D GetLineGutterIcon(int line, int gutter)

Parameters

line int
gutter int

Returns

Texture2D

GetLineGutterItemColor(int, int)

public Color GetLineGutterItemColor(int line, int gutter)

Parameters

line int
gutter int

Returns

Color

GetLineGutterMetadata(int, int)

public object GetLineGutterMetadata(int line, int gutter)

Parameters

line int
gutter int

Returns

object

GetLineGutterText(int, int)

public string GetLineGutterText(int line, int gutter)

Parameters

line int
gutter int

Returns

string

GetLineSyntaxHighlighting(int)

Gets the retained highlighter output for a line. Empty when no provider is assigned.

public IReadOnlyList<SyntaxHighlightSpan> GetLineSyntaxHighlighting(int line)

Parameters

line int

Returns

IReadOnlyList<SyntaxHighlightSpan>

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

line int
wrapIndex int

Returns

float

GetLineWrapCount(int)

Returns the number of continuation rows after the first visual row for a source line.

public int GetLineWrapCount(int line)

Parameters

line int

Returns

int

GetLineWrapIndexAtColumn(int, int)

public int GetLineWrapIndexAtColumn(int line, int column)

Parameters

line int
column int

Returns

int

GetLineWrapIndexAtVisibleRow(int)

Returns the source-line wrap row represented by a viewport-relative visual row.

protected int GetLineWrapIndexAtVisibleRow(int row)

Parameters

row int

Returns

int

GetLineWrapLength(int, int)

protected int GetLineWrapLength(int line, int wrapIndex)

Parameters

line int
wrapIndex int

Returns

int

GetLineWrapStartColumn(int, int)

protected int GetLineWrapStartColumn(int line, int wrapIndex)

Parameters

line int
wrapIndex int

Returns

int

GetLineWrappedText(int)

public IReadOnlyList<string> GetLineWrappedText(int line)

Parameters

line int

Returns

IReadOnlyList<string>

GetLineWrappingMode()

public TextEditLineWrappingMode GetLineWrappingMode()

Returns

TextEditLineWrappingMode

GetMenu()

Returns the retained context popup, equivalent to Godot's get_menu().

public override PopupMenu GetMenu()

Returns

PopupMenu

GetSavedVersion()

public uint GetSavedVersion()

Returns

uint

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

line int
wrapIndex int

Returns

int

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

caret int

Returns

string

GetSelectionFrom(int)

public int GetSelectionFrom(int caret)

Parameters

caret int

Returns

int

GetSelectionOriginColumn(int)

public int GetSelectionOriginColumn(int caret = 0)

Parameters

caret int

Returns

int

GetSelectionOriginLine(int)

public int GetSelectionOriginLine(int caret = 0)

Parameters

caret int

Returns

int

GetSelectionRectangles(int)

Returns screen-space visual-row rectangles for a caret selection, including wrapped source rows.

public IReadOnlyList<Rectangle> GetSelectionRectangles(int caret = 0)

Parameters

caret int

Returns

IReadOnlyList<Rectangle>

GetSelectionTo(int)

public int GetSelectionTo(int caret)

Parameters

caret int

Returns

int

GetSyntaxHighlighter()

public SyntaxHighlighter GetSyntaxHighlighter()

Returns

SyntaxHighlighter

GetTotalGutterWidth()

public int GetTotalGutterWidth()

Returns

int

GetTotalVisibleLineCount()

public int GetTotalVisibleLineCount()

Returns

int

GetVersion()

public uint GetVersion()

Returns

uint

GetVisibleLineCount()

Returns the visible line capacity of the current text viewport.

public int GetVisibleLineCount()

Returns

int

GetVisibleLineCountInRange(int, int)

public int GetVisibleLineCountInRange(int fromLine, int toLine)

Parameters

fromLine int
toLine int

Returns

int

GetVisibleRow(int, int)

protected int GetVisibleRow(int line, int wrapIndex = 0)

Parameters

line int
wrapIndex int

Returns

int

HasCaretSelection(int)

Returns selection state for a specific caret without shadowing LineEdit's primary HasSelection property.

public bool HasCaretSelection(int caret)

Parameters

caret int

Returns

bool

InsertLineAt(int, string)

public void InsertLineAt(int line, string text)

Parameters

line int
text string

InsertNewline()

public void InsertNewline()

InsertText(string)

public override void InsertText(string text)

Parameters

text string

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

text string
line int
column int
beforeSelectionBegin bool
beforeSelectionEnd bool

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

text string
caret int

IsEmptySelectionClipboardEnabled()

public bool IsEmptySelectionClipboardEnabled()

Returns

bool

IsGutterClickable(int)

public bool IsGutterClickable(int gutter)

Parameters

gutter int

Returns

bool

IsGutterDrawn(int)

public bool IsGutterDrawn(int gutter)

Parameters

gutter int

Returns

bool

IsGutterOverwritable(int)

public bool IsGutterOverwritable(int gutter)

Parameters

gutter int

Returns

bool

IsLineGutterClickable(int, int)

public bool IsLineGutterClickable(int line, int gutter)

Parameters

line int
gutter int

Returns

bool

IsLineHiddenForDisplay(int)

Allows specialized editors to hide document lines without mutating the underlying text.

protected virtual bool IsLineHiddenForDisplay(int line)

Parameters

line int

Returns

bool

IsLineInViewport(int)

public bool IsLineInViewport(int line)

Parameters

line int

Returns

bool

IsLineWrapped(int)

public bool IsLineWrapped(int line)

Parameters

line int

Returns

bool

IsMenuVisible()

public override bool IsMenuVisible()

Returns

bool

IsMultipleCaretsEnabled()

public bool IsMultipleCaretsEnabled()

Returns

bool

IsShortcutKeysEnabled()

public bool IsShortcutKeysEnabled()

Returns

bool

MenuOption(TextEditMenuOption)

Executes one retained context-menu command.

public void MenuOption(TextEditMenuOption option)

Parameters

option TextEditMenuOption

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

caret int

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

clipboard string
caret int

Redo()

public void Redo()

RemoveCaret(int)

public void RemoveCaret(int caret)

Parameters

caret int

RemoveGutter(int)

public void RemoveGutter(int gutter)

Parameters

gutter int

RemoveLineAt(int)

public void RemoveLineAt(int line)

Parameters

line int

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

fromLine int
fromColumn int
toLine int
toColumn int

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

key string
flags TextSearchFlags
fromLine int
fromColumn int

Returns

Point

Select(int, int, int, int, int)

public void Select(int fromLine, int fromColumn, int toLine, int toColumn, int caret = 0)

Parameters

fromLine int
fromColumn int
toLine int
toColumn int
caret int

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

caret int

SetCaret(int, int)

public void SetCaret(int line, int column)

Parameters

line int
column int

SetCaret(int, int, int)

public void SetCaret(int line, int column, int caret)

Parameters

line int
column int
caret int

SetCaretColumn(int, int)

public void SetCaretColumn(int column, int caret = 0)

Parameters

column int
caret int

SetCaretLine(int, int)

public void SetCaretLine(int line, int caret = 0)

Parameters

line int
caret int

SetEmptySelectionClipboardEnabled(bool)

public void SetEmptySelectionClipboardEnabled(bool enabled)

Parameters

enabled bool

SetGutterClickable(int, bool)

public void SetGutterClickable(int gutter, bool clickable)

Parameters

gutter int
clickable bool

SetGutterCustomDraw(int, Action<UIRenderContext, TextEdit, int, Rectangle>)

public void SetGutterCustomDraw(int gutter, Action<UIRenderContext, TextEdit, int, Rectangle> draw)

Parameters

gutter int
draw Action<UIRenderContext, TextEdit, int, Rectangle>

SetGutterDraw(int, bool)

public void SetGutterDraw(int gutter, bool draw)

Parameters

gutter int
draw bool

SetGutterName(int, string)

public void SetGutterName(int gutter, string name)

Parameters

gutter int
name string

SetGutterOverwritable(int, bool)

public void SetGutterOverwritable(int gutter, bool overwritable)

Parameters

gutter int
overwritable bool

SetGutterType(int, TextEditGutterType)

public void SetGutterType(int gutter, TextEditGutterType type)

Parameters

gutter int
type TextEditGutterType

SetGutterWidth(int, int)

public void SetGutterWidth(int gutter, int width)

Parameters

gutter int
width int

SetLine(int, string)

public void SetLine(int line, string text)

Parameters

line int
text string

SetLineAsCenterVisible(int, int)

public void SetLineAsCenterVisible(int line, int wrapIndex = 0)

Parameters

line int
wrapIndex int

SetLineAsFirstVisible(int, int)

public void SetLineAsFirstVisible(int line, int wrapIndex = 0)

Parameters

line int
wrapIndex int

SetLineAsLastVisible(int, int)

public void SetLineAsLastVisible(int line, int wrapIndex = 0)

Parameters

line int
wrapIndex int

SetLineBackgroundColor(int, Color)

public void SetLineBackgroundColor(int line, Color color)

Parameters

line int
color Color

SetLineGutterClickable(int, int, bool)

public void SetLineGutterClickable(int line, int gutter, bool clickable)

Parameters

line int
gutter int
clickable bool

SetLineGutterIcon(int, int, Texture2D)

public void SetLineGutterIcon(int line, int gutter, Texture2D icon)

Parameters

line int
gutter int
icon Texture2D

SetLineGutterItemColor(int, int, Color)

public void SetLineGutterItemColor(int line, int gutter, Color color)

Parameters

line int
gutter int
color Color

SetLineGutterMetadata(int, int, object)

public void SetLineGutterMetadata(int line, int gutter, object metadata)

Parameters

line int
gutter int
metadata object

SetLineGutterText(int, int, string)

public void SetLineGutterText(int line, int gutter, string text)

Parameters

line int
gutter int
text string

SetLineWrappingMode(TextEditLineWrappingMode)

public void SetLineWrappingMode(TextEditLineWrappingMode mode)

Parameters

mode TextEditLineWrappingMode

SetMultipleCaretsEnabled(bool)

public void SetMultipleCaretsEnabled(bool enabled)

Parameters

enabled bool

SetSearchFlags(TextSearchFlags)

public void SetSearchFlags(TextSearchFlags flags)

Parameters

flags TextSearchFlags

SetSearchText(string)

public void SetSearchText(string text)

Parameters

text string

SetShortcutKeysEnabled(bool)

public void SetShortcutKeysEnabled(bool enabled)

Parameters

enabled bool

SetSyntaxHighlighter(SyntaxHighlighter)

Sets the document-bound syntax provider, analogous to Godot's set_syntax_highlighter().

public void SetSyntaxHighlighter(SyntaxHighlighter highlighter)

Parameters

highlighter SyntaxHighlighter

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

action TextEditEditAction

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

fromLine int
toLine int

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

Action<TextEdit, string>

GutterClicked

public event Action<TextEdit, int, int> GutterClicked

Event Type

Action<TextEdit, int, int>