TextEdit

Inherits: Control < CanvasItem < Node < Object

Inherited By: CodeEdit

Multiline text editing control.

Description

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.

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.

Methods

void

_backspace ( ) virtual

void

_copy ( ) virtual

void

_cut ( ) virtual

void

_handle_unicode_input ( int unicode_char ) virtual

void

_paste ( ) virtual

void

_paste_primary_clipboard ( ) virtual

void

add_gutter ( int at=-1 )

void

adjust_viewport_to_caret ( )

void

backspace ( )

void

begin_complex_operation ( )

void

center_viewport_to_caret ( )

void

clear ( )

void

clear_opentype_features ( )

void

clear_undo_history ( )

void

copy ( )

void

cut ( )

void

delete_selection ( )

void

deselect ( )

void

end_complex_operation ( )

int

get_caret_column ( ) const

Vector2

get_caret_draw_pos ( ) const

int

get_caret_line ( ) const

int

get_caret_wrap_index ( ) const

int

get_first_non_whitespace_column ( int line ) const

int

get_first_visible_line ( ) const

int

get_gutter_count ( ) const

String

get_gutter_name ( int gutter ) const

GutterType

get_gutter_type ( int gutter ) const

int

get_gutter_width ( int gutter ) const

int

get_indent_level ( int line ) const

int

get_last_full_visible_line ( ) const

int

get_last_full_visible_line_wrap_index ( ) const

int

get_last_unhidden_line ( ) const

String

get_line ( int line ) const

Color

get_line_background_color ( int line ) const

Vector2i

get_line_column_at_pos ( Vector2i position, bool allow_out_of_bounds=true ) const

int

get_line_count ( ) const

Texture2D

get_line_gutter_icon ( int line, int gutter ) const

Color

get_line_gutter_item_color ( int line, int gutter ) const

Variant

get_line_gutter_metadata ( int line, int gutter ) const

String

get_line_gutter_text ( int line, int gutter ) const

int

get_line_height ( ) const

int

get_line_width ( int line, int wrap_index=-1 ) const

int

get_line_wrap_count ( int line ) const

int

get_line_wrap_index_at_column ( int line, int column ) const

PackedStringArray

get_line_wrapped_text ( int line ) const

Vector2

get_local_mouse_pos ( ) const

PopupMenu

get_menu ( ) const

int

get_minimap_line_at_pos ( Vector2i position ) const

int

get_minimap_visible_lines ( ) const

Vector2i

get_next_visible_line_index_offset_from ( int line, int wrap_index, int visible_amount ) const

int

get_next_visible_line_offset_from ( int line, int visible_amount ) const

int

get_opentype_feature ( String tag ) const

int

get_saved_version ( ) const

float

get_scroll_pos_for_line ( int line, int wrap_index=0 ) const

String

get_selected_text ( ) const

int

get_selection_column ( ) const

int

get_selection_from_column ( ) const

int

get_selection_from_line ( ) const

int

get_selection_line ( ) const

SelectionMode

get_selection_mode ( ) const

int

get_selection_to_column ( ) const

int

get_selection_to_line ( ) const

int

get_tab_size ( ) const

int

get_total_gutter_width ( ) const

int

get_total_visible_line_count ( ) const

int

get_version ( ) const

int

get_visible_line_count ( ) const

int

get_visible_line_count_in_range ( int from_line, int to_line ) const

String

get_word_at_pos ( Vector2 position ) const

String

get_word_under_caret ( ) const

bool

has_ime_text ( ) const

bool

has_redo ( ) const

bool

has_selection ( ) const

bool

has_undo ( ) const

void

insert_line_at ( int line, String text )

void

insert_text_at_caret ( String text )

bool

is_caret_visible ( ) const

bool

is_dragging_cursor ( ) const

bool

is_gutter_clickable ( int gutter ) const

bool

is_gutter_drawn ( int gutter ) const

bool

is_gutter_overwritable ( int gutter ) const

bool

is_line_gutter_clickable ( int line, int gutter ) const

bool

is_line_wrapped ( int line ) const

bool

is_menu_visible ( ) const

bool

is_overtype_mode_enabled ( ) const

void

menu_option ( int option )

void

merge_gutters ( int from_line, int to_line )

void

paste ( )

void

redo ( )

void

remove_gutter ( int gutter )

void

remove_text ( int from_line, int from_column, int to_line, int to_column )

Vector2i

search ( String text, int flags, int from_line, int from_colum ) const

void

select ( int from_line, int from_column, int to_line, int to_column )

void

select_all ( )

void

select_word_under_caret ( )

void

set_caret_column ( int column, bool adjust_viewport=true )

void

set_caret_line ( int line, bool adjust_viewport=true, bool can_be_hidden=true, int wrap_index=0 )

void

set_gutter_clickable ( int gutter, bool clickable )

void

set_gutter_custom_draw ( int column, Object object, StringName callback )

void

set_gutter_draw ( int gutter, bool draw )

void

set_gutter_name ( int gutter, String name )

void

set_gutter_overwritable ( int gutter, bool overwritable )

void

set_gutter_type ( int gutter, GutterType type )

void

set_gutter_width ( int gutter, int width )

void

set_line ( int line, String new_text )

void

set_line_as_center_visible ( int line, int wrap_index=0 )

void

set_line_as_first_visible ( int line, int wrap_index=0 )

void

set_line_as_last_visible ( int line, int wrap_index=0 )

void

set_line_background_color ( int line, Color color )

void

set_line_gutter_clickable ( int line, int gutter, bool clickable )

void

set_line_gutter_icon ( int line, int gutter, Texture2D icon )

void

set_line_gutter_item_color ( int line, int gutter, Color color )

void

set_line_gutter_metadata ( int line, int gutter, Variant metadata )

void

set_line_gutter_text ( int line, int gutter, String text )

void

set_opentype_feature ( String tag, int value )

void

set_overtype_mode_enabled ( bool enabled )

void

set_search_flags ( int flags )

void

set_search_text ( String search_text )

void

set_selection_mode ( SelectionMode mode, int line=-1, int column=-1 )

void

set_tab_size ( int size )

void

set_tooltip_request_func ( Object object, StringName callback, Variant data )

void

swap_lines ( int from_line, int to_line )

void

tag_saved_version ( )

void

undo ( )

Theme Properties

Color

background_color

Color(0, 0, 0, 0)

Color

caret_background_color

Color(0, 0, 0, 1)

Color

caret_color

Color(0.88, 0.88, 0.88, 1)

Color

current_line_color

Color(0.25, 0.25, 0.26, 0.8)

StyleBox

focus

Font

font

Color

font_color

Color(0.88, 0.88, 0.88, 1)

Color

font_outline_color

Color(1, 1, 1, 1)

Color

font_readonly_color

Color(0.88, 0.88, 0.88, 0.5)

Color

font_selected_color

Color(0, 0, 0, 1)

int

font_size

int

line_spacing

4

StyleBox

normal

int

outline_size

0

StyleBox

read_only

Color

search_result_border_color

Color(0.3, 0.3, 0.3, 0.4)

Color

search_result_color

Color(0.3, 0.3, 0.3, 1)

Color

selection_color

Color(0.49, 0.49, 0.49, 1)

Texture2D

space

Texture2D

tab

Color

word_highlighted_color

Color(0.8, 0.9, 0.9, 0.15)

Signals

  • caret_changed ( )

Emitted when the caret changes position.


  • gutter_added ( )

Emitted when a gutter is added.


  • gutter_clicked ( int line, int gutter )

Emitted when a gutter is clicked.


  • gutter_removed ( )

Emitted when a gutter is removed.


  • lines_edited_from ( int from_line, int to_line )

Emitted immediately when the text changes.

When text is added from_line will be less then to_line. On a remove to_line will be less then from_line.


  • text_changed ( )

Emitted when the text changes.


  • text_set ( )

Emitted when clear is called or text is set.

Enumerations

enum MenuItems:

  • MENU_CUT = 0 --- Cuts (copies and clears) the selected text.

  • MENU_COPY = 1 --- Copies the selected text.

  • MENU_PASTE = 2 --- Pastes the clipboard text over the selected text (or at the cursor's position).

  • MENU_CLEAR = 3 --- Erases the whole TextEdit text.

  • MENU_SELECT_ALL = 4 --- Selects the whole TextEdit text.

  • MENU_UNDO = 5 --- Undoes the previous action.

  • MENU_REDO = 6 --- Redoes the previous action.

  • MENU_DIR_INHERITED = 7 --- Sets text direction to inherited.

  • MENU_DIR_AUTO = 8 --- Sets text direction to automatic.

  • MENU_DIR_LTR = 9 --- Sets text direction to left-to-right.

  • MENU_DIR_RTL = 10 --- Sets text direction to right-to-left.

  • MENU_DISPLAY_UCC = 11 --- Toggles control character display.

  • MENU_INSERT_LRM = 12 --- Inserts left-to-right mark (LRM) character.

  • MENU_INSERT_RLM = 13 --- Inserts right-to-left mark (RLM) character.

  • MENU_INSERT_LRE = 14 --- Inserts start of left-to-right embedding (LRE) character.

  • MENU_INSERT_RLE = 15 --- Inserts start of right-to-left embedding (RLE) character.

  • MENU_INSERT_LRO = 16 --- Inserts start of left-to-right override (LRO) character.

  • MENU_INSERT_RLO = 17 --- Inserts start of right-to-left override (RLO) character.

  • MENU_INSERT_PDF = 18 --- Inserts pop direction formatting (PDF) character.

  • MENU_INSERT_ALM = 19 --- Inserts Arabic letter mark (ALM) character.

  • MENU_INSERT_LRI = 20 --- Inserts left-to-right isolate (LRI) character.

  • MENU_INSERT_RLI = 21 --- Inserts right-to-left isolate (RLI) character.

  • MENU_INSERT_FSI = 22 --- Inserts first strong isolate (FSI) character.

  • MENU_INSERT_PDI = 23 --- Inserts pop direction isolate (PDI) character.

  • MENU_INSERT_ZWJ = 24 --- Inserts zero width joiner (ZWJ) character.

  • MENU_INSERT_ZWNJ = 25 --- Inserts zero width non-joiner (ZWNJ) character.

  • MENU_INSERT_WJ = 26 --- Inserts word joiner (WJ) character.

  • MENU_INSERT_SHY = 27 --- Inserts soft hyphen (SHY) character.

  • MENU_MAX = 28 --- Represents the size of the MenuItems enum.


enum SearchFlags:

  • 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.


enum CaretType:

  • CARET_TYPE_LINE = 0 --- Vertical line caret.

  • CARET_TYPE_BLOCK = 1 --- Block caret.


enum SelectionMode:

  • 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 tripped clicked.


enum LineWrappingMode:

  • 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.


enum GutterType:

  • GUTTER_TYPE_STRING = 0 --- Draw a string.

  • GUTTER_TYPE_ICON = 1 --- Draw an icon.

  • GUTTER_TYPE_CUSTOM = 2 --- Custom draw.

Property Descriptions

Default

false

Setter

set_caret_blink_enabled(value)

Getter

is_caret_blink_enabled()

Sets if the caret should blink.


Default

0.65

Setter

set_caret_blink_speed(value)

Getter

get_caret_blink_speed()

Duration (in seconds) of a caret's blinking cycle.


  • bool caret_mid_grapheme

Default

false

Setter

set_caret_mid_grapheme_enabled(value)

Getter

is_caret_mid_grapheme_enabled()

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

Note: Backspace is always removing individual composite character components.


  • bool caret_move_on_right_click

Default

true

Setter

set_move_caret_on_right_click_enabled(value)

Getter

is_move_caret_on_right_click_enabled()

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

If false, the context menu disregards mouse location.


Default

0

Setter

set_caret_type(value)

Getter

get_caret_type()

Set the type of caret to draw.


  • bool context_menu_enabled

Default

true

Setter

set_context_menu_enabled(value)

Getter

is_context_menu_enabled()

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


  • bool deselect_on_focus_loss_enabled

Default

true

Setter

set_deselect_on_focus_loss_enabled(value)

Getter

is_deselect_on_focus_loss_enabled()

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


  • bool draw_control_chars

Default

false

Setter

set_draw_control_chars(value)

Getter

get_draw_control_chars()

If true, control characters are displayed.


Default

false

Setter

set_draw_spaces(value)

Getter

is_drawing_spaces()

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


Default

false

Setter

set_draw_tabs(value)

Getter

is_drawing_tabs()

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


Default

true

Setter

set_editable(value)

Getter

is_editable()

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


  • bool highlight_all_occurrences

Default

false

Setter

set_highlight_all_occurrences(value)

Getter

is_highlight_all_occurrences_enabled()

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


  • bool highlight_current_line

Default

false

Setter

set_highlight_current_line(value)

Getter

is_highlight_current_line_enabled()

If true, the line containing the cursor is highlighted.


Default

""

Setter

set_language(value)

Getter

get_language()

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


  • bool middle_mouse_paste_enabled

Default

true

Setter

set_middle_mouse_paste_enabled(value)

Getter

is_middle_mouse_paste_enabled()

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

Note: This method is only implemented on Linux.


Default

false

Setter

set_draw_minimap(value)

Getter

is_drawing_minimap()

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


  • int minimap_width

Default

80

Setter

set_minimap_width(value)

Getter

get_minimap_width()

The width, in pixels, of the minimap.


  • bool override_selected_font_color

Default

false

Setter

set_override_selected_font_color(value)

Getter

is_overriding_selected_font_color()

If true, custom font_selected_color will be used for selected text.


  • int scroll_horizontal

Default

0

Setter

set_h_scroll(value)

Getter

get_h_scroll()

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


  • bool scroll_past_end_of_file

Default

false

Setter

set_scroll_past_end_of_file_enabled(value)

Getter

is_scroll_past_end_of_file_enabled()

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


  • bool scroll_smooth

Default

false

Setter

set_smooth_scroll_enable(value)

Getter

is_smooth_scroll_enabled()

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


  • float scroll_v_scroll_speed

Default

80.0

Setter

set_v_scroll_speed(value)

Getter

get_v_scroll_speed()

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


Default

0.0

Setter

set_v_scroll(value)

Getter

get_v_scroll()

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


  • bool selecting_enabled

Default

true

Setter

set_selecting_enabled(value)

Getter

is_selecting_enabled()

If true, text can be selected.

If false, text can not be selected by the user or by the select or select_all methods.


  • bool shortcut_keys_enabled

Default

true

Setter

set_shortcut_keys_enabled(value)

Getter

is_shortcut_keys_enabled()

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


Default

0

Setter

set_structured_text_bidi_override(value)

Getter

get_structured_text_bidi_override()

Set BiDi algorithm override for the structured text.


  • Array structured_text_bidi_override_options

Default

[]

Setter

set_structured_text_bidi_override_options(value)

Getter

get_structured_text_bidi_override_options()

Set additional options for BiDi override.


Setter

set_syntax_highlighter(value)

Getter

get_syntax_highlighter()

Sets the SyntaxHighlighter to use.


Default

""

Setter

set_text(value)

Getter

get_text()

String value of the TextEdit.


Default

0

Setter

set_text_direction(value)

Getter

get_text_direction()

Base text writing direction.


  • bool virtual_keyboard_enabled

Default

true

Setter

set_virtual_keyboard_enabled(value)

Getter

is_virtual_keyboard_enabled()

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


Default

0

Setter

set_line_wrapping_mode(value)

Getter

get_line_wrapping_mode()

Sets the line wrapping mode to use.

Method Descriptions

  • void _backspace ( ) virtual

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


  • void _copy ( ) virtual

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


  • void _cut ( ) virtual

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


  • void _handle_unicode_input ( int unicode_char ) virtual

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


  • void _paste ( ) virtual

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


  • void _paste_primary_clipboard ( ) virtual

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.


  • void add_gutter ( int at=-1 )

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.


  • void adjust_viewport_to_caret ( )

Adjust the viewport so the caret is visible.


  • void backspace ( )

Called when the user presses the backspace key. Can be overridden with _backspace.


  • void begin_complex_operation ( )

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


  • void center_viewport_to_caret ( )

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


  • void clear ( )

Performs a full reset of TextEdit, including undo history.


  • void clear_opentype_features ( )

Removes all OpenType features.


  • void clear_undo_history ( )

Clears the undo history.


  • void copy ( )

Copies the current text selection. Can be overridden with _copy.


  • void cut ( )

Cut's the current selection. Can be overridden with _cut.


  • void delete_selection ( )

Deletes the selected text.


  • void deselect ( )

Deselects the current selection.


  • void end_complex_operation ( )

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.


  • int get_caret_column ( ) const

Returns the column the editing caret is at.


  • Vector2 get_caret_draw_pos ( ) const

Returns the caret pixel draw position.


  • int get_caret_line ( ) const

Returns the line the editing caret is on.


  • int get_caret_wrap_index ( ) const

Returns the wrap index the editing caret is on.


  • int get_first_non_whitespace_column ( int line ) const

Returns the first column containing a non-whitespace character.


  • int get_first_visible_line ( ) const

Returns the first visible line.


  • int get_gutter_count ( ) const

Returns the total amount of gutters registered.


  • String get_gutter_name ( int gutter ) const

Returns the name of the gutter at the given index.


Returns the type of the gutter at the given index.


  • int get_gutter_width ( int gutter ) const

Returns the width of the gutter at the given index.


  • int get_indent_level ( int line ) const

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


  • int get_last_full_visible_line ( ) const

Return the last visible line. Use get_last_full_visible_line_wrap_index for the wrap index.


  • int get_last_full_visible_line_wrap_index ( ) const

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


  • int get_last_unhidden_line ( ) const

Returns the last unhidden line in the entire TextEdit.


Returns the text of a specific line.


  • Color get_line_background_color ( int line ) const

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.


  • int get_line_count ( ) const

Returns the amount of total lines in the text.


Returns the icon currently in gutter at line.


  • Color get_line_gutter_item_color ( int line, int gutter ) const

Returns the color currently in gutter at line.


  • Variant get_line_gutter_metadata ( int line, int gutter ) const

Returns the metadata currently in gutter at line.


  • String get_line_gutter_text ( int line, int gutter ) const

Returns the text currently in gutter at line.


  • int get_line_height ( ) const

Returns the height of a largest line.


  • int get_line_width ( int line, int wrap_index=-1 ) const

Returns the width in pixels of the wrap_index on line.


  • int get_line_wrap_count ( int line ) const

Returns the number of times the given line is wrapped.


  • int get_line_wrap_index_at_column ( int line, int column ) const

Returns the wrap index of the given line column.


Returns an array of Strings representing each wrapped index.


  • Vector2 get_local_mouse_pos ( ) const

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.

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.


  • int get_minimap_line_at_pos ( Vector2i position ) const

Returns the equivalent minimap line at position


  • int get_minimap_visible_lines ( ) const

Returns the total amount of lines that can be draw on the minimap.


  • Vector2i get_next_visible_line_index_offset_from ( int line, int wrap_index, int visible_amount ) const

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.


  • int get_next_visible_line_offset_from ( int line, int visible_amount ) const

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.


  • int get_opentype_feature ( String tag ) const

Returns OpenType feature tag.


  • int get_saved_version ( ) const

Returns the last tagged saved version from tag_saved_version


  • float get_scroll_pos_for_line ( int line, int wrap_index=0 ) const

Returns the scroll position for wrap_index of line.


  • String get_selected_text ( ) const

Returns the text inside the selection.


  • int get_selection_column ( ) const

Returns the original start column of the selection.


  • int get_selection_from_column ( ) const

Returns the selection begin column.


  • int get_selection_from_line ( ) const

Returns the selection begin line.


  • int get_selection_line ( ) const

Returns the original start line of the selection.


Returns the current selection mode.


  • int get_selection_to_column ( ) const

Returns the selection end column.


  • int get_selection_to_line ( ) const

Returns the selection end line.


  • int get_tab_size ( ) const

Returns the TextEdit's' tab size.


  • int get_total_gutter_width ( ) const

Returns the total width of all gutters and internal padding.


  • int get_total_visible_line_count ( ) const

Returns the total amount of lines that could be draw.


  • int get_version ( ) const

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


  • int get_visible_line_count ( ) const

Returns the number of visible lines, including wrapped text.


  • int get_visible_line_count_in_range ( int from_line, int to_line ) const

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


Returns the word at position.


  • String get_word_under_caret ( ) const

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


  • bool has_ime_text ( ) const

Returns if the user has IME text.


  • bool has_redo ( ) const

Returns true if a "redo" action is available.


  • bool has_selection ( ) const

Returns true if the user has selected text.


  • bool has_undo ( ) const

Returns true if an "undo" action is available.


  • void insert_line_at ( int line, String text )

Inserts a new line with text at line.


  • void insert_text_at_caret ( String text )

Insert the specified text at the caret position.


  • bool is_caret_visible ( ) const

Returns true if the caret is visible on the screen.


  • bool is_dragging_cursor ( ) const

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


  • bool is_gutter_clickable ( int gutter ) const

Returns whether the gutter is clickable.


  • bool is_gutter_drawn ( int gutter ) const

Returns whether the gutter is currently drawn.


  • bool is_gutter_overwritable ( int gutter ) const

Returns whether the gutter is overwritable.


  • bool is_line_gutter_clickable ( int line, int gutter ) const

Returns whether the gutter on the given line is clickable.


  • bool is_line_wrapped ( int line ) const

Returns if the given line is wrapped.


  • bool is_menu_visible ( ) const

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


  • bool is_overtype_mode_enabled ( ) const

Returns whether the user is in overtype mode.


  • void menu_option ( int option )

Triggers a right-click menu action by the specified index. See MenuItems for a list of available indexes.


  • void merge_gutters ( int from_line, int to_line )

Merge the gutters from from_line into to_line. Only overwritable gutters will be copied.


  • void paste ( )

Paste at the current location. Can be overridden with _paste.


  • void redo ( )

Perform redo operation.


  • void remove_gutter ( int gutter )

Removes the gutter from this TextEdit.


  • void remove_text ( int from_line, int from_column, int to_line, int to_column )

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.

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

  • void select ( int from_line, int from_column, int to_line, int to_column )

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

If selecting_enabled is false, no selection will occur.


  • void select_all ( )

Select all the text.

If selecting_enabled is false, no selection will occur.


  • void select_word_under_caret ( )

Selects the word under the caret.


  • void set_caret_column ( int column, bool adjust_viewport=true )

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.


  • void set_caret_line ( int line, bool adjust_viewport=true, bool can_be_hidden=true, int wrap_index=0 )

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.


  • void set_gutter_clickable ( int gutter, bool clickable )

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.