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.
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 from_line
will be less than to_line
. On a remove to_line
will be less than from_line
.
Emitted when the text changes.
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.
ID of "Text Writing Direction" submenu.
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.
ID of "Insert Control Character" submenu.
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 MenuItems enum.
ACTION_NONE = 0
No current action.
ACTION_TYPING = 1
A typing action.
ACTION_BACKSPACE = 2
A backwards delete action.
ACTION_DELETE = 3
A forward delete action.
SEARCH_MATCH_CASE = 1
Match case when searching.
SEARCH_WHOLE_WORDS = 2
Match whole words when searching.
SEARCH_BACKWARDS = 4
Search from end to beginning.
CARET_TYPE_LINE = 0
Vertical line caret.
CARET_TYPE_BLOCK = 1
Block caret.
SELECTION_MODE_NONE = 0
Not selecting.
SELECTION_MODE_SHIFT = 1
Select as if shift
is pressed.
SELECTION_MODE_POINTER = 2
Select single characters as if the user single clicked.
SELECTION_MODE_WORD = 3
Select whole words as if the user double clicked.
SELECTION_MODE_LINE = 4
Select whole lines as if the user triple clicked.
LINE_WRAPPING_NONE = 0
Line wrapping is disabled.
LINE_WRAPPING_BOUNDARY = 1
Line wrapping occurs at the control boundary, beyond what would normally be visible.
GUTTER_TYPE_STRING = 0
Draw a string.
GUTTER_TYPE_ICON = 1
Draw an icon.
GUTTER_TYPE_CUSTOM = 2
Custom draw.
If wrap_mode is set to LINE_WRAPPING_BOUNDARY, sets text wrapping mode. To see how each mode behaves, see AutowrapMode.
If true
, makes the caret blink.
The interval at which the caret blinks (in seconds).
If true
, caret will be visible when editable is disabled.
Allow moving caret, selecting and removing the individual composite character components.
Note: Backspace is always removing individual composite character components.
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.
Sets if multiple carets are allowed.
Set the type of caret to draw.
If true
, a right-click displays the context menu.
If true
, the selected text will be deselected when focus is lost.
If true
, allow drag and drop of selected text.
If true
, control characters are displayed.
If true
, the "space" character will have a visible representation.
If true
, the "tab" character will have a visible representation.
If false
, existing text cannot be modified and new text cannot be added.
If true
, all occurrences of the selected text will be highlighted.
If true
, 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 false
, using middle mouse button to paste clipboard will be disabled.
Note: This method is only implemented on Linux.
If true
, a minimap is shown, providing an outline of your source code.
The width, in pixels, of the minimap.
Text shown when the TextEdit is empty. It is not the TextEdit's default value (see text).
If true
, TextEdit will disable vertical scroll and fit minimum height to the number of visible lines.
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 than jumping to the next location.
Sets the scroll speed with the minimap or when 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 true
, text can be selected.
If false
, text can not be selected by the user or by the select or select_all methods.
If true
, 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 true
, the native virtual keyboard is shown when focused on platforms that support it.
Sets the line wrapping mode to use.
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 user types in the provided key unicode_char
.
Override this method to define what happens when the user performs a paste operation.
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.
Adds a new caret at the given location. Returns the index of the new caret, or -1
if the location is invalid.
Adds an additional caret above or below every caret. If below
is true the new caret will be added below and above otherwise.
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.
Adds a selection and a caret for the next occurrence of the current selection. If there is no active selection, selects word under caret.
Reposition the carets affected by the edit. This assumes edits are applied in edit order, see get_caret_index_edit_order.
Adjust the viewport so the caret is visible.
Called when the user presses the backspace key. Can be overridden with _backspace.
Starts a multipart edit. All edits will be treated as one action until end_complex_operation is called.
Centers the viewport on the line the editing caret is at. This also resets the scroll_horizontal value to 0
.
Performs a full reset of TextEdit, including undo history.
Clears the undo history.
Copies the current text selection. Can be overridden with _copy.
Cut's the current selection. Can be overridden with _cut.
Deletes the selected text.
Deselects the current selection.
Marks the end of steps in the current action started with start_action.
Ends a multipart edit, started with 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 number of carets in this TextEdit.
Returns the caret pixel draw position.
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 insert_text_at_caret are applied.
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 number 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 HScrollBar used by TextEdit.
Returns the number of spaces and tab * tab_size
before the first char.
Returns the last visible line. Use 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. Color(0, 0, 0, 0)
is returned if no color is set.
Returns the line and column at the given position. In the returned vector, x
is the column, y
is the line. If allow_out_of_bounds
is false
and the position is not over the text, both vector values will be set to -1
.
Returns the number of lines in the text.
Returns the icon currently in gutter
at line
.
Returns the color currently in gutter
at line
.
Returns the metadata currently in gutter
at line
.
Returns the text currently in gutter
at line
.
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
.
Returns the width in pixels of the wrap_index
on line
.
Returns the number of times the given line is wrapped.
Returns the wrap index of the given line column.
Returns an array of Strings 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.
You can add custom menu items or remove standard ones. Make sure your IDs don't conflict with the standard ones (see MenuItems). For example:
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 Window.visible property.
Returns the equivalent minimap line at position
.
Returns the number of lines that may be drawn on the minimap.
Similar to get_next_visible_line_offset_from, but takes into account the line wrap indexes. In the returned vector, x
is the line, y
is the wrap index.
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.
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 get_rect_at_line_column to get the top side position.
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 get_pos_at_line_column which returns the bottom side.
Returns the last tagged saved version from tag_saved_version.
Returns the scroll position for wrap_index
of line
.
Returns the text inside the selection of a caret, or all the carets if caret_index
is its default value -1
.
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 number of lines that may be drawn.
Returns the VScrollBar of the TextEdit.
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 total number of visible + wrapped lines between the two lines.
Returns the word at position
.
Returns a String text with the word under the caret's location.
Returns if the user has IME text.
Returns true
if a "redo" action is available.
Returns true
if the user has selected text.
Returns true
if an "undo" action is available.
Inserts a new line with text
at line
.
Insert the specified text at the caret position.
Returns true
if the caret is visible on the screen.
Returns true
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 get_menu().visible
to improve performance (so the creation of the menu is avoided).
Returns whether the mouse is over selection. If edges
is true
, the edges are considered part of the selection.
Returns whether the user is in overtype mode.
Executes a given action as defined in the MenuItems enum.
Merge the gutters from from_line
into to_line
. Only overwritable gutters will be copied.
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.
Paste at the current location. Can be overridden with _paste.
Pastes the primary clipboard.
Perform redo operation.
Removes the given caret index.
Note: This can result in adjustment of all other caret indices.
Removes the gutter from this TextEdit.
Removes all additional carets.
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.
Perform a search inside the text. Search flags can be specified in the SearchFlags enum.
In the returned vector, x
is the column, y
is the line. If no results are found, both are equal to -1
.
Perform selection, from line/column to line/column.
If selecting_enabled is false
, no selection will occur.
Select all the text.
If selecting_enabled is false
, no selection will occur.
Selects the word under the caret.
Moves the caret to the specified column
index.
If adjust_viewport
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 merge_overlapping_carets.
Moves the caret to the specified line
index.
If adjust_viewport
is true
, the viewport will center at the caret position after the move occurs.
If can_be_hidden
is true
, the specified line
can be hidden.
Note: If supporting multiple carets this will not check for any overlap. See merge_overlapping_carets.
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: line: int, gutter: int, Area: Rect2
.
Sets whether the gutter should be drawn.
Sets the name of the gutter.
Sets the gutter to overwritable. See merge_gutters.
Sets the type of gutter.
Set the width of the gutter.
Sets the text for a specific line.
Positions the wrap_index
of line
at the center of the viewport.
Positions the wrap_index
of line
at the top of the viewport.
Positions the wrap_index
of line
at the bottom of the viewport.
Sets the current background color of the line. Set to Color(0, 0, 0, 0)
for no color.
If clickable
is true
, makes the gutter
on line
clickable. See gutter_clicked.
Sets the icon for gutter
on line
to icon
.
Sets the color for gutter
on line
to color
.
Sets the metadata for gutter
on line
to metadata
.
Sets the text for gutter
on line
to text
.
If true
, 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 set_search_text to highlight occurrences of the searched text. Search flags can be specified from the SearchFlags enum.
Sets the search text. See 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: hovered_word: String
.
Starts an action, will end the current action if action
is different.
An action will also end after a call to end_action, after ProjectSettings.gui/timers/text_edit_idle_detect_sec is triggered or a new undoable step outside the start_action and end_action calls.
Swaps the two lines.
Tag the current version as saved.
Perform undo operation.