Table of Contents

Class TextEdit

Namespace
Godot
Assembly
GodotSharp.dll

A multiline text editor. It also has limited facilities for editing code, such as syntax highlighting support. For more advanced facilities for editing code, see CodeEdit.

Note: Most viewport, caret and edit methods contain a caret_index argument for CaretMultiple support. The argument should be one of the following: -1 for all carets, 0 for the main caret, or greater than 0 for secondary carets.

Note: When holding down Alt, the vertical scroll wheel will scroll 5 times as fast as it would normally do. This also works in the Godot script editor.

public class TextEdit : Control, IDisposable
Inheritance
TextEdit
Implements
Derived
Inherited Members

Constructors

TextEdit()

public TextEdit()

Properties

AutowrapMode

If WrapMode is set to Boundary, sets text wrapping mode. To see how each mode behaves, see TextServer.AutowrapMode.

public TextServer.AutowrapMode AutowrapMode { get; set; }

Property Value

TextServer.AutowrapMode

If true, makes the caret blink.

public bool CaretBlink { get; set; }

Property Value

bool

CaretBlinkInterval

The interval at which the caret blinks (in seconds).

public float CaretBlinkInterval { get; set; }

Property Value

float

CaretDrawWhenEditableDisabled

If true, caret will be visible when Editable is disabled.

public bool CaretDrawWhenEditableDisabled { get; set; }

Property Value

bool

CaretMidGrapheme

Allow moving caret, selecting and removing the individual composite character components.

Note: Backspace is always removing individual composite character components.

public bool CaretMidGrapheme { get; set; }

Property Value

bool

CaretMoveOnRightClick

If true, a right-click moves the caret at the mouse position before displaying the context menu.

If false, the context menu ignores mouse location.

public bool CaretMoveOnRightClick { get; set; }

Property Value

bool

CaretMultiple

Sets if multiple carets are allowed.

public bool CaretMultiple { get; set; }

Property Value

bool

CaretType

Set the type of caret to draw.

public TextEdit.CaretTypeEnum CaretType { get; set; }

Property Value

TextEdit.CaretTypeEnum

ContextMenuEnabled

If true, a right-click displays the context menu.

public bool ContextMenuEnabled { get; set; }

Property Value

bool

DeselectOnFocusLossEnabled

If true, the selected text will be deselected when focus is lost.

public bool DeselectOnFocusLossEnabled { get; set; }

Property Value

bool

DragAndDropSelectionEnabled

If true, allow drag and drop of selected text.

public bool DragAndDropSelectionEnabled { get; set; }

Property Value

bool

DrawControlChars

If true, control characters are displayed.

public bool DrawControlChars { get; set; }

Property Value

bool

DrawSpaces

If true, the "space" character will have a visible representation.

public bool DrawSpaces { get; set; }

Property Value

bool

DrawTabs

If true, the "tab" character will have a visible representation.

public bool DrawTabs { get; set; }

Property Value

bool

Editable

If false, existing text cannot be modified and new text cannot be added.

public bool Editable { get; set; }

Property Value

bool

HighlightAllOccurrences

If true, all occurrences of the selected text will be highlighted.

public bool HighlightAllOccurrences { get; set; }

Property Value

bool

HighlightCurrentLine

If true, the line containing the cursor is highlighted.

public bool HighlightCurrentLine { get; set; }

Property Value

bool

Language

Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.

public string Language { get; set; }

Property Value

string

MiddleMousePasteEnabled

If false, using middle mouse button to paste clipboard will be disabled.

Note: This method is only implemented on Linux.

public bool MiddleMousePasteEnabled { get; set; }

Property Value

bool

MinimapDraw

If true, a minimap is shown, providing an outline of your source code.

public bool MinimapDraw { get; set; }

Property Value

bool

MinimapWidth

The width, in pixels, of the minimap.

public int MinimapWidth { get; set; }

Property Value

int

PlaceholderText

Text shown when the TextEdit is empty. It is not the TextEdit's default value (see Text).

public string PlaceholderText { get; set; }

Property Value

string

ScrollFitContentHeight

If true, TextEdit will disable vertical scroll and fit minimum height to the number of visible lines.

public bool ScrollFitContentHeight { get; set; }

Property Value

bool

ScrollHorizontal

If there is a horizontal scrollbar, this determines the current horizontal scroll value in pixels.

public int ScrollHorizontal { get; set; }

Property Value

int

ScrollPastEndOfFile

Allow scrolling past the last line into "virtual" space.

public bool ScrollPastEndOfFile { get; set; }

Property Value

bool

ScrollSmooth

Scroll smoothly over the text rather than jumping to the next location.

public bool ScrollSmooth { get; set; }

Property Value

bool

ScrollVScrollSpeed

Sets the scroll speed with the minimap or when ScrollSmooth is enabled.

public float ScrollVScrollSpeed { get; set; }

Property Value

float

ScrollVertical

If there is a vertical scrollbar, this determines the current vertical scroll value in line numbers, starting at 0 for the top line.

public double ScrollVertical { get; set; }

Property Value

double

SelectingEnabled

If true, text can be selected.

If false, text can not be selected by the user or by the Select(int, int, int, int, int) or SelectAll() methods.

public bool SelectingEnabled { get; set; }

Property Value

bool

ShortcutKeysEnabled

If true, shortcut keys for context menu items are enabled, even if the context menu is disabled.

public bool ShortcutKeysEnabled { get; set; }

Property Value

bool

StructuredTextBidiOverride

Set BiDi algorithm override for the structured text.

public TextServer.StructuredTextParser StructuredTextBidiOverride { get; set; }

Property Value

TextServer.StructuredTextParser

StructuredTextBidiOverrideOptions

Set additional options for BiDi override.

public Array StructuredTextBidiOverrideOptions { get; set; }

Property Value

Array

SyntaxHighlighter

Sets the SyntaxHighlighter to use.

public SyntaxHighlighter SyntaxHighlighter { get; set; }

Property Value

SyntaxHighlighter

Text

String value of the TextEdit.

public string Text { get; set; }

Property Value

string

TextDirection

Base text writing direction.

public Control.TextDirection TextDirection { get; set; }

Property Value

Control.TextDirection

VirtualKeyboardEnabled

If true, the native virtual keyboard is shown when focused on platforms that support it.

public bool VirtualKeyboardEnabled { get; set; }

Property Value

bool

WrapMode

Sets the line wrapping mode to use.

public TextEdit.LineWrappingMode WrapMode { get; set; }

Property Value

TextEdit.LineWrappingMode

Methods

AddCaret(int, int)

Adds a new caret at the given location. Returns the index of the new caret, or -1 if the location is invalid.

public int AddCaret(int line, int col)

Parameters

line int
col int

Returns

int

AddCaretAtCarets(bool)

Adds an additional caret above or below every caret. If below is true the new caret will be added below and above otherwise.

public void AddCaretAtCarets(bool below)

Parameters

below bool

AddGutter(int)

Register a new gutter to this TextEdit. Use at to have a specific gutter order. A value of -1 appends the gutter to the right.

public void AddGutter(int at = -1)

Parameters

at int

AddSelectionForNextOccurrence()

Adds a selection and a caret for the next occurrence of the current selection. If there is no active selection, selects word under caret.

public void AddSelectionForNextOccurrence()

AdjustCaretsAfterEdit(int, int, int, int, int)

Reposition the carets affected by the edit. This assumes edits are applied in edit order, see GetCaretIndexEditOrder().

public void AdjustCaretsAfterEdit(int caret, int fromLine, int fromCol, int toLine, int toCol)

Parameters

caret int
fromLine int
fromCol int
toLine int
toCol int

AdjustViewportToCaret(int)

Adjust the viewport so the caret is visible.

public void AdjustViewportToCaret(int caretIndex = 0)

Parameters

caretIndex int

Backspace(int)

Called when the user presses the backspace key. Can be overridden with _Backspace(int).

public void Backspace(int caretIndex = -1)

Parameters

caretIndex int

BeginComplexOperation()

Starts a multipart edit. All edits will be treated as one action until EndComplexOperation() is called.

public void BeginComplexOperation()

CenterViewportToCaret(int)

Centers the viewport on the line the editing caret is at. This also resets the ScrollHorizontal value to 0.

public void CenterViewportToCaret(int caretIndex = 0)

Parameters

caretIndex int

Clear()

Performs a full reset of TextEdit, including undo history.

public void Clear()

ClearUndoHistory()

Clears the undo history.

public void ClearUndoHistory()

Copy(int)

Copies the current text selection. Can be overridden with _Copy(int).

public void Copy(int caretIndex = -1)

Parameters

caretIndex int

Cut(int)

Cut's the current selection. Can be overridden with _Cut(int).

public void Cut(int caretIndex = -1)

Parameters

caretIndex int

DeleteSelection(int)

Deletes the selected text.

public void DeleteSelection(int caretIndex = -1)

Parameters

caretIndex int

Deselect(int)

Deselects the current selection.

public void Deselect(int caretIndex = -1)

Parameters

caretIndex int

EndAction()

Marks the end of steps in the current action started with StartAction(EditAction).

public void EndAction()

EndComplexOperation()

Ends a multipart edit, started with BeginComplexOperation(). If called outside a complex operation, the current operation is pushed onto the undo/redo stack.

public void EndComplexOperation()

GetCaretColumn(int)

Returns the column the editing caret is at.

public int GetCaretColumn(int caretIndex = 0)

Parameters

caretIndex int

Returns

int

GetCaretCount()

Returns the number of carets in this TextEdit.

public int GetCaretCount()

Returns

int

GetCaretDrawPos(int)

Returns the caret pixel draw position.

public Vector2 GetCaretDrawPos(int caretIndex = 0)

Parameters

caretIndex int

Returns

Vector2

GetCaretIndexEditOrder()

Returns a list of caret indexes in their edit order, this done from bottom to top. Edit order refers to the way actions such as InsertTextAtCaret(string, int) are applied.

public int[] GetCaretIndexEditOrder()

Returns

int[]

GetCaretLine(int)

Returns the line the editing caret is on.

public int GetCaretLine(int caretIndex = 0)

Parameters

caretIndex int

Returns

int

GetCaretWrapIndex(int)

Returns the wrap index the editing caret is on.

public int GetCaretWrapIndex(int caretIndex = 0)

Parameters

caretIndex int

Returns

int

GetFirstNonWhiteSpaceColumn(int)

Returns the first column containing a non-whitespace character.

public int GetFirstNonWhiteSpaceColumn(int line)

Parameters

line int

Returns

int

GetFirstVisibleLine()

Returns the first visible line.

public int GetFirstVisibleLine()

Returns

int

GetGutterCount()

Returns the number of gutters registered.

public int GetGutterCount()

Returns

int

GetGutterName(int)

Returns the name of the gutter at the given index.

public string GetGutterName(int gutter)

Parameters

gutter int

Returns

string

GetGutterType(int)

Returns the type of the gutter at the given index.

public TextEdit.GutterType GetGutterType(int gutter)

Parameters

gutter int

Returns

TextEdit.GutterType

GetGutterWidth(int)

Returns the width of the gutter at the given index.

public int GetGutterWidth(int gutter)

Parameters

gutter int

Returns

int

GetHScrollBar()

Returns the HScrollBar used by TextEdit.

public HScrollBar GetHScrollBar()

Returns

HScrollBar

GetIndentLevel(int)

Returns the number of spaces and tab * tab_size before the first char.

public int GetIndentLevel(int line)

Parameters

line int

Returns

int

GetLastFullVisibleLine()

Returns the last visible line. Use GetLastFullVisibleLineWrapIndex() for the wrap index.

public int GetLastFullVisibleLine()

Returns

int

GetLastFullVisibleLineWrapIndex()

Returns the last visible wrap index of the last visible line.

public int GetLastFullVisibleLineWrapIndex()

Returns

int

GetLastUnhiddenLine()

Returns the last unhidden line in the entire TextEdit.

public int GetLastUnhiddenLine()

Returns

int

GetLine(int)

Returns the text of a specific line.

public string GetLine(int line)

Parameters

line int

Returns

string

GetLineBackgroundColor(int)

Returns the current background color of the line. Color(0, 0, 0, 0) is returned if no color is set.

public Color GetLineBackgroundColor(int line)

Parameters

line int

Returns

Color

GetLineColumnAtPos(Vector2I, bool)

Returns the line and column at the given position. In the returned vector, x is the column, y is the line. If allowOutOfBounds is false and the position is not over the text, both vector values will be set to -1.

public Vector2I GetLineColumnAtPos(Vector2I position, bool allowOutOfBounds = true)

Parameters

position Vector2I
allowOutOfBounds bool

Returns

Vector2I

GetLineCount()

Returns the number of lines in the text.

public int GetLineCount()

Returns

int

GetLineGutterIcon(int, int)

Returns the icon currently in gutter at line.

public Texture2D GetLineGutterIcon(int line, int gutter)

Parameters

line int
gutter int

Returns

Texture2D

GetLineGutterItemColor(int, int)

Returns the color currently in gutter at line.

public Color GetLineGutterItemColor(int line, int gutter)

Parameters

line int
gutter int

Returns

Color

GetLineGutterMetadata(int, int)

Returns the metadata currently in gutter at line.

public Variant GetLineGutterMetadata(int line, int gutter)

Parameters

line int
gutter int

Returns

Variant

GetLineGutterText(int, int)

Returns the text currently in gutter at line.

public string GetLineGutterText(int line, int gutter)

Parameters

line int
gutter int

Returns

string

GetLineHeight()

Returns the maximum value of the line height among all lines.

Note: The return value is influenced by line_spacing and font_size. And it will not be less than 1.

public int GetLineHeight()

Returns

int

GetLineWidth(int, int)

Returns the width in pixels of the wrapIndex on line.

public int GetLineWidth(int line, int wrapIndex = -1)

Parameters

line int
wrapIndex int

Returns

int

GetLineWrapCount(int)

Returns the number of times the given line is wrapped.

public int GetLineWrapCount(int line)

Parameters

line int

Returns

int

GetLineWrapIndexAtColumn(int, int)

Returns the wrap index of the given line column.

public int GetLineWrapIndexAtColumn(int line, int column)

Parameters

line int
column int

Returns

int

GetLineWrappedText(int)

Returns an array of strings representing each wrapped index.

public string[] GetLineWrappedText(int line)

Parameters

line int

Returns

string[]

GetLocalMousePos()

Returns the local mouse position adjusted for the text direction.

public Vector2 GetLocalMousePos()

Returns

Vector2

GetMenu()

Returns the PopupMenu of this TextEdit. By default, this menu is displayed when right-clicking on the TextEdit.

You can add custom menu items or remove standard ones. Make sure your IDs don't conflict with the standard ones (see TextEdit.MenuItems). For example:

public override void _Ready()
  {
      var menu = GetMenu();
      // Remove all items after "Redo".
      menu.ItemCount = menu.GetItemIndex(TextEdit.MenuItems.Redo) + 1;
      // Add custom items.
      menu.AddSeparator();
      menu.AddItem("Insert Date", TextEdit.MenuItems.Max + 1);
      // Add event handler.
      menu.IdPressed += OnItemPressed;
  }

public void OnItemPressed(int id) { if (id == TextEdit.MenuItems.Max + 1) { InsertTextAtCaret(Time.GetDateStringFromSystem()); } }

Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their Visible property.

public PopupMenu GetMenu()

Returns

PopupMenu

GetMinimapLineAtPos(Vector2I)

Returns the equivalent minimap line at position.

public int GetMinimapLineAtPos(Vector2I position)

Parameters

position Vector2I

Returns

int

GetMinimapVisibleLines()

Returns the number of lines that may be drawn on the minimap.

public int GetMinimapVisibleLines()

Returns

int

GetNextVisibleLineIndexOffsetFrom(int, int, int)

Similar to GetNextVisibleLineOffsetFrom(int, int), but takes into account the line wrap indexes. In the returned vector, x is the line, y is the wrap index.

public Vector2I GetNextVisibleLineIndexOffsetFrom(int line, int wrapIndex, int visibleAmount)

Parameters

line int
wrapIndex int
visibleAmount int

Returns

Vector2I

GetNextVisibleLineOffsetFrom(int, int)

Returns the count to the next visible line from line to line + visible_amount. Can also count backwards. For example if a TextEdit has 5 lines with lines 2 and 3 hidden, calling this with line = 1, visible_amount = 1 would return 3.

public int GetNextVisibleLineOffsetFrom(int line, int visibleAmount)

Parameters

line int
visibleAmount int

Returns

int

GetPosAtLineColumn(int, int)

Returns the local position for the given line and column. If x or y of the returned vector equal -1, the position is outside of the viewable area of the control.

Note: The Y position corresponds to the bottom side of the line. Use GetRectAtLineColumn(int, int) to get the top side position.

public Vector2I GetPosAtLineColumn(int line, int column)

Parameters

line int
column int

Returns

Vector2I

GetRectAtLineColumn(int, int)

Returns the local position and size for the grapheme at the given line and column. If x or y position of the returned rect equal -1, the position is outside of the viewable area of the control.

Note: The Y position of the returned rect corresponds to the top side of the line, unlike GetPosAtLineColumn(int, int) which returns the bottom side.

public Rect2I GetRectAtLineColumn(int line, int column)

Parameters

line int
column int

Returns

Rect2I

GetSavedVersion()

Returns the last tagged saved version from TagSavedVersion().

public uint GetSavedVersion()

Returns

uint

GetScrollPosForLine(int, int)

Returns the scroll position for wrapIndex of line.

public double GetScrollPosForLine(int line, int wrapIndex = 0)

Parameters

line int
wrapIndex int

Returns

double

GetSelectedText(int)

Returns the text inside the selection of a caret, or all the carets if caretIndex is its default value -1.

public string GetSelectedText(int caretIndex = -1)

Parameters

caretIndex int

Returns

string

GetSelectionColumn(int)

Returns the original start column of the selection.

public int GetSelectionColumn(int caretIndex = 0)

Parameters

caretIndex int

Returns

int

GetSelectionFromColumn(int)

Returns the selection begin column.

public int GetSelectionFromColumn(int caretIndex = 0)

Parameters

caretIndex int

Returns

int

GetSelectionFromLine(int)

Returns the selection begin line.

public int GetSelectionFromLine(int caretIndex = 0)

Parameters

caretIndex int

Returns

int

GetSelectionLine(int)

Returns the original start line of the selection.

public int GetSelectionLine(int caretIndex = 0)

Parameters

caretIndex int

Returns

int

GetSelectionMode()

Returns the current selection mode.

public TextEdit.SelectionMode GetSelectionMode()

Returns

TextEdit.SelectionMode

GetSelectionToColumn(int)

Returns the selection end column.

public int GetSelectionToColumn(int caretIndex = 0)

Parameters

caretIndex int

Returns

int

GetSelectionToLine(int)

Returns the selection end line.

public int GetSelectionToLine(int caretIndex = 0)

Parameters

caretIndex int

Returns

int

GetTabSize()

Returns the TextEdit's' tab size.

public int GetTabSize()

Returns

int

GetTotalGutterWidth()

Returns the total width of all gutters and internal padding.

public int GetTotalGutterWidth()

Returns

int

GetTotalVisibleLineCount()

Returns the number of lines that may be drawn.

public int GetTotalVisibleLineCount()

Returns

int

GetVScrollBar()

Returns the VScrollBar of the TextEdit.

public VScrollBar GetVScrollBar()

Returns

VScrollBar

GetVersion()

Returns the current version of the TextEdit. The version is a count of recorded operations by the undo/redo history.

public uint GetVersion()

Returns

uint

GetVisibleLineCount()

Returns the number of visible lines, including wrapped text.

public int GetVisibleLineCount()

Returns

int

GetVisibleLineCountInRange(int, int)

Returns the total number of visible + wrapped lines between the two lines.

public int GetVisibleLineCountInRange(int fromLine, int toLine)

Parameters

fromLine int
toLine int

Returns

int

GetWordAtPos(Vector2)

Returns the word at position.

public string GetWordAtPos(Vector2 position)

Parameters

position Vector2

Returns

string

GetWordUnderCaret(int)

Returns a string text with the word under the caret's location.

public string GetWordUnderCaret(int caretIndex = -1)

Parameters

caretIndex int

Returns

string

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

HasImeText()

Returns if the user has IME text.

public bool HasImeText()

Returns

bool

HasRedo()

Returns true if a "redo" action is available.

public bool HasRedo()

Returns

bool

HasSelection(int)

Returns true if the user has selected text.

public bool HasSelection(int caretIndex = -1)

Parameters

caretIndex int

Returns

bool

HasUndo()

Returns true if an "undo" action is available.

public bool HasUndo()

Returns

bool

InsertLineAt(int, string)

Inserts a new line with text at line.

public void InsertLineAt(int line, string text)

Parameters

line int
text string

InsertTextAtCaret(string, int)

Insert the specified text at the caret position.

public void InsertTextAtCaret(string text, int caretIndex = -1)

Parameters

text string
caretIndex int

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

IsCaretVisible(int)

Returns true if the caret is visible on the screen.

public bool IsCaretVisible(int caretIndex = 0)

Parameters

caretIndex int

Returns

bool

IsDraggingCursor()

Returns true if the user is dragging their mouse for scrolling or selecting.

public bool IsDraggingCursor()

Returns

bool

IsGutterClickable(int)

Returns whether the gutter is clickable.

public bool IsGutterClickable(int gutter)

Parameters

gutter int

Returns

bool

IsGutterDrawn(int)

Returns whether the gutter is currently drawn.

public bool IsGutterDrawn(int gutter)

Parameters

gutter int

Returns

bool

IsGutterOverwritable(int)

Returns whether the gutter is overwritable.

public bool IsGutterOverwritable(int gutter)

Parameters

gutter int

Returns

bool

IsLineGutterClickable(int, int)

Returns whether the gutter on the given line is clickable.

public bool IsLineGutterClickable(int line, int gutter)

Parameters

line int
gutter int

Returns

bool

IsLineWrapped(int)

Returns if the given line is wrapped.

public bool IsLineWrapped(int line)

Parameters

line int

Returns

bool

IsMenuVisible()

Returns whether the menu is visible. Use this instead of get_menu().visible to improve performance (so the creation of the menu is avoided).

public bool IsMenuVisible()

Returns

bool

IsMouseOverSelection(bool, int)

Returns whether the mouse is over selection. If edges is true, the edges are considered part of the selection.

public bool IsMouseOverSelection(bool edges, int caretIndex = -1)

Parameters

edges bool
caretIndex int

Returns

bool

IsOvertypeModeEnabled()

Returns whether the user is in overtype mode.

public bool IsOvertypeModeEnabled()

Returns

bool

MenuOption(int)

Executes a given action as defined in the TextEdit.MenuItems enum.

public void MenuOption(int option)

Parameters

option int

MergeGutters(int, int)

Merge the gutters from fromLine into toLine. Only overwritable gutters will be copied.

public void MergeGutters(int fromLine, int toLine)

Parameters

fromLine int
toLine int

MergeOverlappingCarets()

Merges any overlapping carets. Will favor the newest caret, or the caret with a selection.

Note: This is not called when a caret changes position but after certain actions, so it is possible to get into a state where carets overlap.

public void MergeOverlappingCarets()

Paste(int)

Paste at the current location. Can be overridden with _Paste(int).

public void Paste(int caretIndex = -1)

Parameters

caretIndex int

PastePrimaryClipboard(int)

Pastes the primary clipboard.

public void PastePrimaryClipboard(int caretIndex = -1)

Parameters

caretIndex int

Redo()

Perform redo operation.

public void Redo()

RemoveCaret(int)

Removes the given caret index.

Note: This can result in adjustment of all other caret indices.

public void RemoveCaret(int caret)

Parameters

caret int

RemoveGutter(int)

Removes the gutter from this TextEdit.

public void RemoveGutter(int gutter)

Parameters

gutter int

RemoveSecondaryCarets()

Removes all additional carets.

public void RemoveSecondaryCarets()

RemoveText(int, int, int, int)

Removes text between the given positions.

Note: This does not adjust the caret or selection, which as a result it can end up in an invalid position.

public void RemoveText(int fromLine, int fromColumn, int toLine, int toColumn)

Parameters

fromLine int
fromColumn int
toLine int
toColumn int

Search(string, uint, int, int)

Perform a search inside the text. Search flags can be specified in the TextEdit.SearchFlags enum.

In the returned vector, x is the column, y is the line. If no results are found, both are equal to -1.

Vector2I result = Search("print", (uint)TextEdit.SearchFlags.WholeWords, 0, 0);
  if (result.X != -1)
  {
      // Result found.
      int lineNumber = result.Y;
      int columnNumber = result.X;
  }
public Vector2I Search(string text, uint flags, int fromLine, int fromColum)

Parameters

text string
flags uint
fromLine int
fromColum int

Returns

Vector2I

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

Perform selection, from line/column to line/column.

If SelectingEnabled is false, no selection will occur.

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

Parameters

fromLine int
fromColumn int
toLine int
toColumn int
caretIndex int

SelectAll()

Select all the text.

If SelectingEnabled is false, no selection will occur.

public void SelectAll()

SelectWordUnderCaret(int)

Selects the word under the caret.

public void SelectWordUnderCaret(int caretIndex = -1)

Parameters

caretIndex int

SetCaretColumn(int, bool, int)

Moves the caret to the specified column index.

If adjustViewport is true, the viewport will center at the caret position after the move occurs.

Note: If supporting multiple carets this will not check for any overlap. See MergeOverlappingCarets().

public void SetCaretColumn(int column, bool adjustViewport = true, int caretIndex = 0)

Parameters

column int
adjustViewport bool
caretIndex int

SetCaretLine(int, bool, bool, int, int)

Moves the caret to the specified line index.

If adjustViewport is true, the viewport will center at the caret position after the move occurs.

If canBeHidden is true, the specified line can be hidden.

Note: If supporting multiple carets this will not check for any overlap. See MergeOverlappingCarets().

public void SetCaretLine(int line, bool adjustViewport = true, bool canBeHidden = true, int wrapIndex = 0, int caretIndex = 0)

Parameters

line int
adjustViewport bool
canBeHidden bool
wrapIndex int
caretIndex int

SetGutterClickable(int, bool)

Sets the gutter as clickable. This will change the mouse cursor to a pointing hand when hovering over the gutter.

public void SetGutterClickable(int gutter, bool clickable)

Parameters

gutter int
clickable bool

SetGutterCustomDraw(int, Callable)

Set a custom draw method for the gutter. The callback method must take the following args: line: int, gutter: int, Area: Rect2.

public void SetGutterCustomDraw(int column, Callable drawCallback)

Parameters

column int
drawCallback Callable

SetGutterDraw(int, bool)

Sets whether the gutter should be drawn.

public void SetGutterDraw(int gutter, bool draw)

Parameters

gutter int
draw bool

SetGutterName(int, string)

Sets the name of the gutter.

public void SetGutterName(int gutter, string name)

Parameters

gutter int
name string

SetGutterOverwritable(int, bool)

Sets the gutter to overwritable. See MergeGutters(int, int).

public void SetGutterOverwritable(int gutter, bool overwritable)

Parameters

gutter int
overwritable bool

SetGutterType(int, GutterType)

Sets the type of gutter.

public void SetGutterType(int gutter, TextEdit.GutterType type)

Parameters

gutter int
type TextEdit.GutterType

SetGutterWidth(int, int)

Set the width of the gutter.

public void SetGutterWidth(int gutter, int width)

Parameters

gutter int
width int

SetLine(int, string)

Sets the text for a specific line.

public void SetLine(int line, string newText)

Parameters

line int
newText string

SetLineAsCenterVisible(int, int)

Positions the wrapIndex of line at the center of the viewport.

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

Parameters

line int
wrapIndex int

SetLineAsFirstVisible(int, int)

Positions the wrapIndex of line at the top of the viewport.

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

Parameters

line int
wrapIndex int

SetLineAsLastVisible(int, int)

Positions the wrapIndex of line at the bottom of the viewport.

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

Parameters

line int
wrapIndex int

SetLineBackgroundColor(int, Color)

Sets the current background color of the line. Set to Color(0, 0, 0, 0) for no color.

public void SetLineBackgroundColor(int line, Color color)

Parameters

line int
color Color

SetLineGutterClickable(int, int, bool)

If clickable is true, makes the gutter on line clickable. See GutterClicked.

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

Parameters

line int
gutter int
clickable bool

SetLineGutterIcon(int, int, Texture2D)

Sets the icon for gutter on line to icon.

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

Parameters

line int
gutter int
icon Texture2D

SetLineGutterItemColor(int, int, Color)

Sets the color for gutter on line to color.

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

Parameters

line int
gutter int
color Color

SetLineGutterMetadata(int, int, Variant)

Sets the metadata for gutter on line to metadata.

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

Parameters

line int
gutter int
metadata Variant

SetLineGutterText(int, int, string)

Sets the text for gutter on line to text.

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

Parameters

line int
gutter int
text string

SetOvertypeModeEnabled(bool)

If true, sets the user into overtype mode. When the user types in this mode, it will override existing text.

public void SetOvertypeModeEnabled(bool enabled)

Parameters

enabled bool

SetSearchFlags(uint)

Sets the search flags. This is used with SetSearchText(string) to highlight occurrences of the searched text. Search flags can be specified from the TextEdit.SearchFlags enum.

public void SetSearchFlags(uint flags)

Parameters

flags uint

SetSearchText(string)

Sets the search text. See SetSearchFlags(uint).

public void SetSearchText(string searchText)

Parameters

searchText string

SetSelectionMode(SelectionMode, int, int, int)

Sets the current selection mode.

public void SetSelectionMode(TextEdit.SelectionMode mode, int line = -1, int column = -1, int caretIndex = 0)

Parameters

mode TextEdit.SelectionMode
line int
column int
caretIndex int

SetTabSize(int)

Sets the tab size for the TextEdit to use.

public void SetTabSize(int size)

Parameters

size int

SetTooltipRequestFunc(Callable)

Provide custom tooltip text. The callback method must take the following args: hovered_word: String.

public void SetTooltipRequestFunc(Callable callback)

Parameters

callback Callable

StartAction(EditAction)

Starts an action, will end the current action if action is different.

An action will also end after a call to EndAction(), after ProjectSettings.gui/timers/text_edit_idle_detect_sec is triggered or a new undoable step outside the StartAction(EditAction) and EndAction() calls.

public void StartAction(TextEdit.EditAction action)

Parameters

action TextEdit.EditAction

SwapLines(int, int)

Swaps the two lines.

public void SwapLines(int fromLine, int toLine)

Parameters

fromLine int
toLine int

TagSavedVersion()

Tag the current version as saved.

public void TagSavedVersion()

Undo()

Perform undo operation.

public void Undo()

_Backspace(int)

Override this method to define what happens when the user presses the backspace key.

public virtual void _Backspace(int caretIndex)

Parameters

caretIndex int

_Copy(int)

Override this method to define what happens when the user performs a copy operation.

public virtual void _Copy(int caretIndex)

Parameters

caretIndex int

_Cut(int)

Override this method to define what happens when the user performs a cut operation.

public virtual void _Cut(int caretIndex)

Parameters

caretIndex int

_HandleUnicodeInput(int, int)

Override this method to define what happens when the user types in the provided key unicodeChar.

public virtual void _HandleUnicodeInput(int unicodeChar, int caretIndex)

Parameters

unicodeChar int
caretIndex int

_Paste(int)

Override this method to define what happens when the user performs a paste operation.

public virtual void _Paste(int caretIndex)

Parameters

caretIndex int

_PastePrimaryClipboard(int)

Override this method to define what happens when the user performs a paste operation with middle mouse button.

Note: This method is only implemented on Linux.

public virtual void _PastePrimaryClipboard(int caretIndex)

Parameters

caretIndex int

Events

CaretChanged

Emitted when the caret changes position.

public event Action CaretChanged

Event Type

Action

GutterAdded

Emitted when a gutter is added.

public event Action GutterAdded

Event Type

Action

GutterClicked

Emitted when a gutter is clicked.

public event TextEdit.GutterClickedEventHandler GutterClicked

Event Type

TextEdit.GutterClickedEventHandler

GutterRemoved

Emitted when a gutter is removed.

public event Action GutterRemoved

Event Type

Action

LinesEditedFrom

Emitted immediately when the text changes.

When text is added fromLine will be less than toLine. On a remove toLine will be less than fromLine.

public event TextEdit.LinesEditedFromEventHandler LinesEditedFrom

Event Type

TextEdit.LinesEditedFromEventHandler

TextChanged

Emitted when the text changes.

public event Action TextChanged

Event Type

Action

TextSet

Emitted when Clear() is called or Text is set.

public event Action TextSet

Event Type

Action