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
CaretBlink
If true
, makes the caret blink.
public bool CaretBlink { get; set; }
Property Value
CaretBlinkInterval
The interval at which the caret blinks (in seconds).
public float CaretBlinkInterval { get; set; }
Property Value
CaretDrawWhenEditableDisabled
If true
, caret will be visible when Editable is disabled.
public bool CaretDrawWhenEditableDisabled { get; set; }
Property Value
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
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
CaretMultiple
Sets if multiple carets are allowed.
public bool CaretMultiple { get; set; }
Property Value
CaretType
Set the type of caret to draw.
public TextEdit.CaretTypeEnum CaretType { get; set; }
Property Value
ContextMenuEnabled
If true
, a right-click displays the context menu.
public bool ContextMenuEnabled { get; set; }
Property Value
DeselectOnFocusLossEnabled
If true
, the selected text will be deselected when focus is lost.
public bool DeselectOnFocusLossEnabled { get; set; }
Property Value
DragAndDropSelectionEnabled
If true
, allow drag and drop of selected text.
public bool DragAndDropSelectionEnabled { get; set; }
Property Value
DrawControlChars
If true
, control characters are displayed.
public bool DrawControlChars { get; set; }
Property Value
DrawSpaces
If true
, the "space" character will have a visible representation.
public bool DrawSpaces { get; set; }
Property Value
DrawTabs
If true
, the "tab" character will have a visible representation.
public bool DrawTabs { get; set; }
Property Value
Editable
If false
, existing text cannot be modified and new text cannot be added.
public bool Editable { get; set; }
Property Value
HighlightAllOccurrences
If true
, all occurrences of the selected text will be highlighted.
public bool HighlightAllOccurrences { get; set; }
Property Value
HighlightCurrentLine
If true
, the line containing the cursor is highlighted.
public bool HighlightCurrentLine { get; set; }
Property Value
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
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
MinimapDraw
If true
, a minimap is shown, providing an outline of your source code.
public bool MinimapDraw { get; set; }
Property Value
MinimapWidth
The width, in pixels, of the minimap.
public int MinimapWidth { get; set; }
Property Value
PlaceholderText
public string PlaceholderText { get; set; }
Property Value
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
ScrollHorizontal
If there is a horizontal scrollbar, this determines the current horizontal scroll value in pixels.
public int ScrollHorizontal { get; set; }
Property Value
ScrollPastEndOfFile
Allow scrolling past the last line into "virtual" space.
public bool ScrollPastEndOfFile { get; set; }
Property Value
ScrollSmooth
Scroll smoothly over the text rather than jumping to the next location.
public bool ScrollSmooth { get; set; }
Property Value
ScrollVScrollSpeed
Sets the scroll speed with the minimap or when ScrollSmooth is enabled.
public float ScrollVScrollSpeed { get; set; }
Property Value
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
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
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
StructuredTextBidiOverride
Set BiDi algorithm override for the structured text.
public TextServer.StructuredTextParser StructuredTextBidiOverride { get; set; }
Property Value
StructuredTextBidiOverrideOptions
Set additional options for BiDi override.
public Array StructuredTextBidiOverrideOptions { get; set; }
Property Value
SyntaxHighlighter
Sets the SyntaxHighlighter to use.
public SyntaxHighlighter SyntaxHighlighter { get; set; }
Property Value
Text
String value of the TextEdit.
public string Text { get; set; }
Property Value
TextDirection
Base text writing direction.
public Control.TextDirection TextDirection { get; set; }
Property Value
VirtualKeyboardEnabled
If true
, the native virtual keyboard is shown when focused on platforms that support it.
public bool VirtualKeyboardEnabled { get; set; }
Property Value
WrapMode
Sets the line wrapping mode to use.
public TextEdit.LineWrappingMode WrapMode { get; set; }
Property Value
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
Returns
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
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
GetCaretCount()
Returns the number of carets in this TextEdit.
public int GetCaretCount()
Returns
GetCaretDrawPos(int)
Returns the caret pixel draw position.
public Vector2 GetCaretDrawPos(int caretIndex = 0)
Parameters
caretIndex
int
Returns
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
GetCaretWrapIndex(int)
Returns the wrap index the editing caret is on.
public int GetCaretWrapIndex(int caretIndex = 0)
Parameters
caretIndex
int
Returns
GetFirstNonWhiteSpaceColumn(int)
Returns the first column containing a non-whitespace character.
public int GetFirstNonWhiteSpaceColumn(int line)
Parameters
line
int
Returns
GetFirstVisibleLine()
Returns the first visible line.
public int GetFirstVisibleLine()
Returns
GetGutterCount()
Returns the number of gutters registered.
public int GetGutterCount()
Returns
GetGutterName(int)
Returns the name of the gutter at the given index.
public string GetGutterName(int gutter)
Parameters
gutter
int
Returns
GetGutterType(int)
Returns the type of the gutter at the given index.
public TextEdit.GutterType GetGutterType(int gutter)
Parameters
gutter
int
Returns
GetGutterWidth(int)
Returns the width of the gutter at the given index.
public int GetGutterWidth(int gutter)
Parameters
gutter
int
Returns
GetHScrollBar()
Returns the HScrollBar used by TextEdit.
public HScrollBar GetHScrollBar()
Returns
GetIndentLevel(int)
Returns the number of spaces and tab * tab_size
before the first char.
public int GetIndentLevel(int line)
Parameters
line
int
Returns
GetLastFullVisibleLine()
Returns the last visible line. Use GetLastFullVisibleLineWrapIndex() for the wrap index.
public int GetLastFullVisibleLine()
Returns
GetLastFullVisibleLineWrapIndex()
Returns the last visible wrap index of the last visible line.
public int GetLastFullVisibleLineWrapIndex()
Returns
GetLastUnhiddenLine()
Returns the last unhidden line in the entire TextEdit.
public int GetLastUnhiddenLine()
Returns
GetLine(int)
Returns the text of a specific line.
public string GetLine(int line)
Parameters
line
int
Returns
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
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
Returns
GetLineCount()
Returns the number of lines in the text.
public int GetLineCount()
Returns
GetLineGutterIcon(int, int)
Returns the icon currently in gutter
at line
.
public Texture2D GetLineGutterIcon(int line, int gutter)
Parameters
Returns
GetLineGutterItemColor(int, int)
Returns the color currently in gutter
at line
.
public Color GetLineGutterItemColor(int line, int gutter)
Parameters
Returns
GetLineGutterMetadata(int, int)
Returns the metadata currently in gutter
at line
.
public Variant GetLineGutterMetadata(int line, int gutter)
Parameters
Returns
GetLineGutterText(int, int)
Returns the text currently in gutter
at line
.
public string GetLineGutterText(int line, int gutter)
Parameters
Returns
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
GetLineWidth(int, int)
Returns the width in pixels of the wrapIndex
on line
.
public int GetLineWidth(int line, int wrapIndex = -1)
Parameters
Returns
GetLineWrapCount(int)
Returns the number of times the given line is wrapped.
public int GetLineWrapCount(int line)
Parameters
line
int
Returns
GetLineWrapIndexAtColumn(int, int)
Returns the wrap index of the given line column.
public int GetLineWrapIndexAtColumn(int line, int column)
Parameters
Returns
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
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
GetMinimapLineAtPos(Vector2I)
Returns the equivalent minimap line at position
.
public int GetMinimapLineAtPos(Vector2I position)
Parameters
position
Vector2I
Returns
GetMinimapVisibleLines()
Returns the number of lines that may be drawn on the minimap.
public int GetMinimapVisibleLines()
Returns
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
Returns
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
Returns
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
Returns
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
Returns
GetSavedVersion()
Returns the last tagged saved version from TagSavedVersion().
public uint GetSavedVersion()
Returns
GetScrollPosForLine(int, int)
Returns the scroll position for wrapIndex
of line
.
public double GetScrollPosForLine(int line, int wrapIndex = 0)
Parameters
Returns
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
GetSelectionColumn(int)
Returns the original start column of the selection.
public int GetSelectionColumn(int caretIndex = 0)
Parameters
caretIndex
int
Returns
GetSelectionFromColumn(int)
Returns the selection begin column.
public int GetSelectionFromColumn(int caretIndex = 0)
Parameters
caretIndex
int
Returns
GetSelectionFromLine(int)
Returns the selection begin line.
public int GetSelectionFromLine(int caretIndex = 0)
Parameters
caretIndex
int
Returns
GetSelectionLine(int)
Returns the original start line of the selection.
public int GetSelectionLine(int caretIndex = 0)
Parameters
caretIndex
int
Returns
GetSelectionMode()
Returns the current selection mode.
public TextEdit.SelectionMode GetSelectionMode()
Returns
GetSelectionToColumn(int)
Returns the selection end column.
public int GetSelectionToColumn(int caretIndex = 0)
Parameters
caretIndex
int
Returns
GetSelectionToLine(int)
Returns the selection end line.
public int GetSelectionToLine(int caretIndex = 0)
Parameters
caretIndex
int
Returns
GetTabSize()
Returns the TextEdit's' tab size.
public int GetTabSize()
Returns
GetTotalGutterWidth()
Returns the total width of all gutters and internal padding.
public int GetTotalGutterWidth()
Returns
GetTotalVisibleLineCount()
Returns the number of lines that may be drawn.
public int GetTotalVisibleLineCount()
Returns
GetVScrollBar()
Returns the VScrollBar of the TextEdit.
public VScrollBar GetVScrollBar()
Returns
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
GetVisibleLineCount()
Returns the number of visible lines, including wrapped text.
public int GetVisibleLineCount()
Returns
GetVisibleLineCountInRange(int, int)
Returns the total number of visible + wrapped lines between the two lines.
public int GetVisibleLineCountInRange(int fromLine, int toLine)
Parameters
Returns
GetWordAtPos(Vector2)
Returns the word at position
.
public string GetWordAtPos(Vector2 position)
Parameters
position
Vector2
Returns
GetWordUnderCaret(int)
Returns a string text with the word under the caret's location.
public string GetWordUnderCaret(int caretIndex = -1)
Parameters
caretIndex
int
Returns
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_nameName of the method to check for.
Returns
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_nameName of the signal to check for.
Returns
HasImeText()
Returns if the user has IME text.
public bool HasImeText()
Returns
HasRedo()
Returns true
if a "redo" action is available.
public bool HasRedo()
Returns
HasSelection(int)
Returns true
if the user has selected text.
public bool HasSelection(int caretIndex = -1)
Parameters
caretIndex
int
Returns
HasUndo()
Returns true
if an "undo" action is available.
public bool HasUndo()
Returns
InsertLineAt(int, string)
Inserts a new line with text
at line
.
public void InsertLineAt(int line, string text)
Parameters
InsertTextAtCaret(string, int)
Insert the specified text at the caret position.
public void InsertTextAtCaret(string text, int caretIndex = -1)
Parameters
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_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
IsCaretVisible(int)
Returns true
if the caret is visible on the screen.
public bool IsCaretVisible(int caretIndex = 0)
Parameters
caretIndex
int
Returns
IsDraggingCursor()
Returns true
if the user is dragging their mouse for scrolling or selecting.
public bool IsDraggingCursor()
Returns
IsGutterClickable(int)
Returns whether the gutter is clickable.
public bool IsGutterClickable(int gutter)
Parameters
gutter
int
Returns
IsGutterDrawn(int)
Returns whether the gutter is currently drawn.
public bool IsGutterDrawn(int gutter)
Parameters
gutter
int
Returns
IsGutterOverwritable(int)
Returns whether the gutter is overwritable.
public bool IsGutterOverwritable(int gutter)
Parameters
gutter
int
Returns
IsLineGutterClickable(int, int)
Returns whether the gutter on the given line is clickable.
public bool IsLineGutterClickable(int line, int gutter)
Parameters
Returns
IsLineWrapped(int)
Returns if the given line is wrapped.
public bool IsLineWrapped(int line)
Parameters
line
int
Returns
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
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
Returns
IsOvertypeModeEnabled()
Returns whether the user is in overtype mode.
public bool IsOvertypeModeEnabled()
Returns
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
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
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
Returns
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
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
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
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
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
SetGutterDraw(int, bool)
Sets whether the gutter should be drawn.
public void SetGutterDraw(int gutter, bool draw)
Parameters
SetGutterName(int, string)
Sets the name of the gutter.
public void SetGutterName(int gutter, string name)
Parameters
SetGutterOverwritable(int, bool)
Sets the gutter to overwritable. See MergeGutters(int, int).
public void SetGutterOverwritable(int gutter, bool overwritable)
Parameters
SetGutterType(int, GutterType)
Sets the type of gutter.
public void SetGutterType(int gutter, TextEdit.GutterType type)
Parameters
gutter
inttype
TextEdit.GutterType
SetGutterWidth(int, int)
Set the width of the gutter.
public void SetGutterWidth(int gutter, int width)
Parameters
SetLine(int, string)
Sets the text for a specific line.
public void SetLine(int line, string newText)
Parameters
SetLineAsCenterVisible(int, int)
Positions the wrapIndex
of line
at the center of the viewport.
public void SetLineAsCenterVisible(int line, int wrapIndex = 0)
Parameters
SetLineAsFirstVisible(int, int)
Positions the wrapIndex
of line
at the top of the viewport.
public void SetLineAsFirstVisible(int line, int wrapIndex = 0)
Parameters
SetLineAsLastVisible(int, int)
Positions the wrapIndex
of line
at the bottom of the viewport.
public void SetLineAsLastVisible(int line, int wrapIndex = 0)
Parameters
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
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
SetLineGutterIcon(int, int, Texture2D)
Sets the icon for gutter
on line
to icon
.
public void SetLineGutterIcon(int line, int gutter, Texture2D icon)
Parameters
SetLineGutterItemColor(int, int, Color)
Sets the color for gutter
on line
to color
.
public void SetLineGutterItemColor(int line, int gutter, Color color)
Parameters
SetLineGutterMetadata(int, int, Variant)
Sets the metadata for gutter
on line
to metadata
.
public void SetLineGutterMetadata(int line, int gutter, Variant metadata)
Parameters
SetLineGutterText(int, int, string)
Sets the text for gutter
on line
to text
.
public void SetLineGutterText(int line, int gutter, string text)
Parameters
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.SelectionModeline
intcolumn
intcaretIndex
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
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
_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
GutterAdded
Emitted when a gutter is added.
public event Action GutterAdded
Event Type
GutterClicked
Emitted when a gutter is clicked.
public event TextEdit.GutterClickedEventHandler GutterClicked
Event Type
GutterRemoved
Emitted when a gutter is removed.
public event Action GutterRemoved
Event Type
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
TextChanged
Emitted when the text changes.
public event Action TextChanged
Event Type
TextSet
public event Action TextSet