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: Most viewport, caret and edit methods contain a caret_index argument for caret_multiple 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.

Properties

bool

caret_blink

false

float

caret_blink_interval

0.65

bool

caret_mid_grapheme

true

bool

caret_move_on_right_click

true

bool

caret_multiple

true

CaretType

caret_type

0

bool

context_menu_enabled

true

bool

deselect_on_focus_loss_enabled

true

bool

drag_and_drop_selection_enabled

true

bool

draw_control_chars

false

bool

draw_spaces

false

bool

draw_tabs

false

bool

editable

true

FocusMode

focus_mode

2 (overrides Control)

bool

highlight_all_occurrences

false

bool

highlight_current_line

false

String

language

""

bool

middle_mouse_paste_enabled

true

bool

minimap_draw

false

int

minimap_width

80

CursorShape

mouse_default_cursor_shape

1 (overrides Control)

String

placeholder_text

""

bool

scroll_fit_content_height

false

int

scroll_horizontal

0

bool

scroll_past_end_of_file

false

bool

scroll_smooth

false

float

scroll_v_scroll_speed

80.0

float

scroll_vertical

0.0

bool

selecting_enabled

true

bool

shortcut_keys_enabled

true

StructuredTextParser

structured_text_bidi_override

0

Array

structured_text_bidi_override_options

[]

SyntaxHighlighter

syntax_highlighter

String

text

""

TextDirection

text_direction

0

bool

virtual_keyboard_enabled

true

LineWrappingMode

wrap_mode

0

Methods

void

_backspace ( int caret_index ) virtual

void

_copy ( int caret_index ) virtual

void

_cut ( int caret_index ) virtual

void

_handle_unicode_input ( int unicode_char, int caret_index ) virtual

void

_paste ( int caret_index ) virtual

void

_paste_primary_clipboard ( int caret_index ) virtual

int

add_caret ( int line, int col )

void

add_caret_at_carets ( bool below )

void

add_gutter ( int at=-1 )

void

add_selection_for_next_occurrence ( )

void

adjust_carets_after_edit ( int caret, int from_line, int from_col, int to_line, int to_col )

void

adjust_viewport_to_caret ( int caret_index=0 )

void

backspace ( int caret_index=-1 )

void

begin_complex_operation ( )

void

center_viewport_to_caret ( int caret_index=0 )

void

clear ( )

void

clear_undo_history ( )

void

copy ( int caret_index=-1 )

void

cut ( int caret_index=-1 )

void

delete_selection ( int caret_index=-1 )

void

deselect ( int caret_index=-1 )

void

end_action ( )

void

end_complex_operation ( )

int

get_caret_column ( int caret_index=0 ) const

int

get_caret_count ( ) const

Vector2

get_caret_draw_pos ( int caret_index=0 ) const

PackedInt32Array

get_caret_index_edit_order ( )

int

get_caret_line ( int caret_index=0 ) const

int

get_caret_wrap_index ( int caret_index=0 ) 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

HScrollBar

get_h_scroll_bar ( ) 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

Vector2i

get_pos_at_line_column ( int line, int column ) const

Rect2i

get_rect_at_line_column ( int line, int column ) const

int

get_saved_version ( ) const

float

get_scroll_pos_for_line ( int line, int wrap_index=0 ) const

String

get_selected_text ( int caret_index=-1 )

int

get_selection_column ( int caret_index=0 ) const

int

get_selection_from_column ( int caret_index=0 ) const

int

get_selection_from_line ( int caret_index=0 ) const

int

get_selection_line ( int caret_index=0 ) const

SelectionMode

get_selection_mode ( ) const

int

get_selection_to_column ( int caret_index=0 ) const

int

get_selection_to_line ( int caret_index=0 ) const

int

get_tab_size ( ) const

int

get_total_gutter_width ( ) const

int

get_total_visible_line_count ( ) const

VScrollBar

get_v_scroll_bar ( ) 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 ( int caret_index=-1 ) const

bool

has_ime_text ( ) const

bool

has_redo ( ) const

bool

has_selection ( int caret_index=-1 ) const

bool

has_undo ( ) const

void

insert_line_at ( int line, String text )

void

insert_text_at_caret ( String text, int caret_index=-1 )

bool

is_caret_visible ( int caret_index=0 ) 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_mouse_over_selection ( bool edges, int caret_index=-1 ) const

bool

is_overtype_mode_enabled ( ) const

void

menu_option ( int option )

void

merge_gutters ( int from_line, int to_line )

void

merge_overlapping_carets ( )

void

paste ( int caret_index=-1 )

void

paste_primary_clipboard ( int caret_index=-1 )

void

redo ( )

void

remove_caret ( int caret )

void

remove_gutter ( int gutter )

void

remove_secondary_carets ( )

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, int caret_index=0 )

void

select_all ( )

void

select_word_under_caret ( int caret_index=-1 )

void

set_caret_column ( int column, bool adjust_viewport=true, int caret_index=0 )

void

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

void

set_gutter_clickable ( int gutter, bool clickable )

void

set_gutter_custom_draw ( int column, Callable draw_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_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, int caret_index=0 )

void

set_tab_size ( int size )

void

set_tooltip_request_func ( Callable callback )

void

start_action ( EditAction action )

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.875, 0.875, 0.875, 1)

Color

current_line_color

Color(0.25, 0.25, 0.26, 0.8)

Color

font_color

Color(0.875, 0.875, 0.875, 1)

Color

font_outline_color

Color(1, 1, 1, 1)

Color

font_placeholder_color

Color(0.875, 0.875, 0.875, 0.6)

Color

font_readonly_color

Color(0.875, 0.875, 0.875, 0.5)

Color

font_selected_color

Color(0, 0, 0, 0)

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.5, 0.5, 0.5, 1)

Color

word_highlighted_color

Color(0.5, 0.5, 0.5, 0.25)

int

caret_width

1

int

line_spacing

4

int

outline_size

0

Font

font

int

font_size

Texture2D

space

Texture2D

tab

StyleBox

focus

StyleBox

normal

StyleBox

read_only


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 ( )

Em