Multiline text editing control.
TextEdit is meant for editing large, multiline text. It also has facilities for editing code, such as syntax highlighting support and multiple levels of undo/redo.
[b]Note:[/b] When holding down [kbd]Alt[/kbd], the vertical scroll wheel will scroll 5 times as fast as it would normally do. This also works in the Godot script editor.
Override this method to define what happens when the user presses the backspace key.
Override this method to define what happens when the user performs a copy operation.
Override this method to define what happens when the user performs a cut operation.
Override this method to define what happens when the types in the provided key [code]unicode[/code].
Override this method to define what happens when the user performs a paste operation.
Register a new gutter to this [TextEdit]. Use [code]at[/code] to have a specific gutter order. A value of [code]-1[/code] appends the gutter to the right.
Adjust the viewport so the caret is visible.
Called when the user presses the backspace key. Can be overridden with [method _backspace].
Starts a multipart edit. All edits will be treated as one action until [method end_complex_operation] is called.
Centers the viewport on the line the editing caret is at. This also resets the [member scroll_horizontal] value to [code]0[/code].
Performs a full reset of [TextEdit], including undo history.
Removes all OpenType features.
Clears the undo history.
Copies the current text selection. Can be overridden with [method _copy].
Cut's the current selection. Can be overridden with [method _cut].
Deletes the selected text.
Deselects the current selection.
Ends a multipart edit, started with [method begin_complex_operation]. If called outside a complex operation, the current operation is pushed onto the undo/redo stack.
Returns the column the editing caret is at.
Returns the caret pixel draw position.
Returns the line the editing caret is on.
Returns the wrap index the editing caret is on.
Returns the first column containing a non-whitespace character.
Returns the first visible line.
Returns the total amount of gutters registered.
Returns the name of the gutter at the given index.
Returns the type of the gutter at the given index.
Returns the width of the gutter at the given index.
Returns the amount of spaces and [code]tab * tab_size[/code] before the first char.
Return the last visible line. Use [method get_last_full_visible_line_wrap_index] for the wrap index.
Returns the last visible wrap index of the last visible line.
Returns the last unhidden line in the entire [TextEdit].
Returns the text of a specific line.
Returns the current background color of the line. [code]Color(0, 0, 0, 0)[/code] is returned if no color is set.
Returns the line and column at the given position. In the returned vector, [code]x[/code] is the column, [code]y[/code] is the line.
Returns the amount of total lines in the text.
Returns the icon currently in [code]gutter[/code] at [code]line[/code].
Returns the color currently in [code]gutter[/code] at [code]line[/code].
Returns the metadata currently in [code]gutter[/code] at [code]line[/code].
Returns the text currently in [code]gutter[/code] at [code]line[/code].
Returns the height of a largest line.
Returns the width in pixels of the [code]wrap_index[/code] on [code]line[/code].
Returns the number of times the given line is wrapped.
Returns the wrap index of the given line column.
Returns an array of [String]s representing each wrapped index.
Returns the local mouse position adjusted for the text direction.
Returns the [PopupMenu] of this [TextEdit]. By default, this menu is displayed when right-clicking on the [TextEdit].
Returns the equivalent minimap line at [code]position[/code]
Returns the total amount of lines that can be draw on the minimap.
Similar to [method get_next_visible_line_offset_from], but takes into account the line wrap indexes. In the returned vector, [code]x[/code] is the line, [code]y[/code] is the wrap index.
Returns the count to the next visible line from [code]line[/code] to [code]line + visible_amount[/code]. Can also count backwards. For example if a [TextEdit] has 5 lines with lines 2 and 3 hidden, calling this with [code]line = 1, visible_amount = 1[/code] would return 3.
Returns OpenType feature [code]tag[/code].
Returns the last tagged saved version from [method tag_saved_version]
Returns the scroll position for [code]wrap_index[/code] of [code]line[/code].
Returns the text inside the selection.
Returns the original start column of the selection.
Returns the selection begin column.
Returns the selection begin line.
Returns the original start line of the selection.
Returns the current selection mode.
Returns the selection end column.
Returns the selection end line.
Returns the [TextEdit]'s' tab size.
Returns the total width of all gutters and internal padding.
Returns the total amount of lines that could be draw.
Returns the current version of the [TextEdit]. The version is a count of recorded operations by the undo/redo history.
Returns the number of visible lines, including wrapped text.
Returns the word at [code]position[/code].
Returns a [String] text with the word under the caret's location.
Returns if the user has IME text.
Returns [code]true[/code] if a "redo" action is available.
Returns [code]true[/code] if the user has selected text.
Returns [code]true[/code] if an "undo" action is available.
Inserts a new line with [code]text[/code] at [code]line[/code].
Insert the specified text at the caret position.
Returns [code]true[/code] if the caret is visible on the screen.
Returns [code]true[/code] if the user is dragging their mouse for scrolling or selecting.
Returns whether the gutter is clickable.
Returns whether the gutter is currently drawn.
Returns whether the gutter is overwritable.
Returns whether the gutter on the given line is clickable.
Returns if the given line is wrapped.
Returns whether the menu is visible. Use this instead of [code]get_menu().visible[/code] to improve performance (so the creation of the menu is avoided).
Returns whether the user is in overtype mode.
Triggers a right-click menu action by the specified index. See [enum MenuItems] for a list of available indexes.
Merge the gutters from [code]from_line[/code] into [code]to_line[/code]. Only overwritable gutters will be copied.
Paste at the current location. Can be overridden with [method _paste].
Perform redo operation.
Removes the gutter from this [TextEdit].
Removes text between the given positions.
[b]Note:[/b]This does not adjust the caret or selection, which as a result it can end up in an invalid position.
Perform a search inside the text. Search flags can be specified in the [enum SearchFlags] enum.
In the returned vector, [code]x[/code] is the column, [code]y[/code] is the line. If no results are found, both are equal to [code]-1[/code].
[codeblocks]
[gdscript]
var result = search("print", SEARCH_WHOLE_WORDS, 0, 0)
if result.x != -1:
# Result found.
var line_number = result.y
var column_number = result.x
[/gdscript]
[csharp]
Vector2i result = Search("print", (uint)TextEdit.SearchFlags.WholeWords, 0, 0);
if (result.Length > 0)
{
// Result found.
int lineNumber = result.y;
int columnNumber = result.x;
}
[/csharp]
[/codeblocks]
Perform selection, from line/column to line/column.
If [member selecting_enabled] is [code]false[/code], no selection will occur.
Select all the text.
If [member selecting_enabled] is [code]false[/code], no selection will occur.
Selects the word under the caret.
Moves the caret to the specified [code]column[/code] index.
If [code]adjust_viewport[/code] is [code]true[/code], the viewport will center at the caret position after the move occurs.
Moves the caret to the specified [code]line[/code] index.
If [code]adjust_viewport[/code] is [code]true[/code], the viewport will center at the caret position after the move occurs.
If [code]can_be_hidden[/code] is [code]true[/code], the specified [code]line[/code] can be hidden.
Sets the gutter as clickable. This will change the mouse cursor to a pointing hand when hovering over the gutter.
Set a custom draw method for the gutter. The callback method must take the following args: [code]line: int, gutter: int, Area: Rect2[/code].
Sets whether the gutter should be drawn.
Sets the name of the gutter.
Sets the gutter to overwritable. See [method merge_gutters].
Sets the type of gutter.
Set the width of the gutter.
Sets the text for a specific line.
Positions the [code]wrap_index[/code] of [code]line[/code] at the center of the viewport.
Positions the [code]wrap_index[/code] of [code]line[/code] at the top of the viewport.
Positions the [code]wrap_index[/code] of [code]line[/code] at the bottom of the viewport.
Sets the current background color of the line. Set to [code]Color(0, 0, 0, 0)[/code] for no color.
Sets the [code]gutter[/code] on [code]line[/code] as clickable.
Sets the icon for [code]gutter[/code] on [code]line[/code].
Sets the color for [code]gutter[/code] on [code]line[/code].
Sets the metadata for [code]gutter[/code] on [code]line[/code].
Sets the text for [code]gutter[/code] on [code]line[/code].
Sets OpenType feature [code]tag[/code]. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags]OpenType feature tags[/url].
If [code]true[/code], sets the user into overtype mode. When the user types in this mode, it will override existing text.
Sets the search flags. This is used with [method set_search_text] to highlight occurrences of the searched text. Search flags can be specified from the [enum SearchFlags] enum.
Sets the search text. See [method set_search_flags].
Sets the current selection mode.
Sets the tab size for the [TextEdit] to use.
Provide custom tooltip text. The callback method must take the following args: [code]hovered_word: String, data: Variant[/code]
Swaps the two lines.
Tag the current version as saved.
Perform undo operation.
Sets if the caret should blink.
Duration (in seconds) of a caret's blinking cycle.
Allow moving caret, selecting and removing the individual composite character components.
Note: [kbd]Backspace[/kbd] is always removing individual composite character components.
If [code]true[/code], a right-click moves the caret at the mouse position before displaying the context menu.
If [code]false[/code], the context menu disregards mouse location.
Set the type of caret to draw.
If [code]true[/code], a right-click displays the context menu.
If [code]true[/code], control characters are displayed.
If [code]true[/code], the "space" character will have a visible representation.
If [code]true[/code], the "tab" character will have a visible representation.
If [code]false[/code], existing text cannot be modified and new text cannot be added.
If [code]true[/code], all occurrences of the selected text will be highlighted.
If [code]true[/code], the line containing the cursor is highlighted.
Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
If [code]true[/code], a minimap is shown, providing an outline of your source code.
The width, in pixels, of the minimap.
If [code]true[/code], custom [code]font_selected_color[/code] will be used for selected text.
If there is a horizontal scrollbar, this determines the current horizontal scroll value in pixels.
Allow scrolling past the last line into "virtual" space.
Scroll smoothly over the text rather then jumping to the next location.
Sets the scroll speed with the minimap or when [member scroll_smooth] is enabled.
If there is a vertical scrollbar, this determines the current vertical scroll value in line numbers, starting at 0 for the top line.
If [code]true[/code], text can be selected.
If [code]false[/code], text can not be selected by the user or by the [method select] or [method select_all] methods.
If [code]true[/code], shortcut keys for context menu items are enabled, even if the context menu is disabled.
Set BiDi algorithm override for the structured text.
Set additional options for BiDi override.
Sets the [SyntaxHighlighter] to use.
String value of the [TextEdit].
Base text writing direction.
If [code]true[/code], the native virtual keyboard is shown when focused on platforms that support it.
Sets the line wrapping mode to use.
Emitted when the caret changes position.
Emitted when a gutter is added.
Emitted when a gutter is clicked.
Emitted when a gutter is removed.
Emitted immediately when the text changes.
When text is added [code]from_line[/code] will be less then [code]to_line[/code]. On a remove [code]to_line[/code] will be less then [code]from_line[/code].
Emitted when the text changes.
Emitted when [method clear] is called or [member text] is set.
Cuts (copies and clears) the selected text.
Copies the selected text.
Pastes the clipboard text over the selected text (or at the cursor's position).
Erases the whole [TextEdit] text.
Selects the whole [TextEdit] text.
Undoes the previous action.
Redoes the previous action.
Sets text direction to inherited.
Sets text direction to automatic.
Sets text direction to left-to-right.
Sets text direction to right-to-left.
Toggles control character display.
Inserts left-to-right mark (LRM) character.
Inserts right-to-left mark (RLM) character.
Inserts start of left-to-right embedding (LRE) character.
Inserts start of right-to-left embedding (RLE) character.
Inserts start of left-to-right override (LRO) character.
Inserts start of right-to-left override (RLO) character.
Inserts pop direction formatting (PDF) character.
Inserts Arabic letter mark (ALM) character.
Inserts left-to-right isolate (LRI) character.
Inserts right-to-left isolate (RLI) character.
Inserts first strong isolate (FSI) character.
Inserts pop direction isolate (PDI) character.
Inserts zero width joiner (ZWJ) character.
Inserts zero width non-joiner (ZWNJ) character.
Inserts word joiner (WJ) character.
Inserts soft hyphen (SHY) character.
Represents the size of the [enum MenuItems] enum.
Match case when searching.
Match whole words when searching.
Search from end to beginning.
Vertical line caret.
Block caret.
Not selecting.
Select as if [code]shift[/code] is pressed.
Select single characters as if the user single clicked.
Select whole words as if the user double clicked.
Select whole lines as if the user tripped clicked.
Line wrapping is disabled.
Line wrapping occurs at the control boundary, beyond what would normally be visible.
Draw a string.
Draw an icon.
Custom draw.
Sets the background [Color] of this [TextEdit].
[Color] of the text behind the caret when using a block caret.
[Color] of the caret.
Background [Color] of the line containing the caret.
Sets the [StyleBox] when in focus.
Sets the default [Font].
Sets the font [Color].
The tint of text outline of the [TextEdit].
Sets the font [Color] when [member editable] is disabled.
Sets the [Color] of the selected text. [member override_selected_font_color] has to be enabled.
Sets default font size.
Sets the spacing between the lines.
Sets the [StyleBox] of this [TextEdit].
The size of the text outline.
Sets the [StyleBox] of this [TextEdit] when [member editable] is disabled.
[Color] of the border around text that matches the search query.
[Color] behind the text that matches the search query.
Sets the highlight [Color] of text selections.
Sets a custom [Texture2D] for space text characters.
Sets a custom [Texture2D] for tab text characters.
Sets the highlight [Color] of multiple occurrences. [member highlight_all_occurrences] has to be enabled.