github_url: | hide |
---|
Inherits: :ref:`Control<class_Control>` < :ref:`CanvasItem<class_CanvasItem>` < :ref:`Node<class_Node>` < :ref:`Object<class_Object>`
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.
:ref:`Color<class_Color>` | background_color | Color( 0, 0, 0, 0 ) |
:ref:`Color<class_Color>` | bookmark_color | Color( 0.08, 0.49, 0.98, 1 ) |
:ref:`Color<class_Color>` | brace_mismatch_color | Color( 1, 0.2, 0.2, 1 ) |
:ref:`Color<class_Color>` | breakpoint_color | Color( 0.8, 0.8, 0.4, 0.2 ) |
:ref:`Color<class_Color>` | caret_background_color | Color( 0, 0, 0, 1 ) |
:ref:`Color<class_Color>` | caret_color | Color( 0.88, 0.88, 0.88, 1 ) |
:ref:`Color<class_Color>` | code_folding_color | Color( 0.8, 0.8, 0.8, 0.8 ) |
:ref:`StyleBox<class_StyleBox>` | completion | |
:ref:`Color<class_Color>` | completion_background_color | Color( 0.17, 0.16, 0.2, 1 ) |
:ref:`Color<class_Color>` | completion_existing_color | Color( 0.87, 0.87, 0.87, 0.13 ) |
:ref:`Color<class_Color>` | completion_font_color | Color( 0.67, 0.67, 0.67, 1 ) |
:ref:`int<class_int>` | completion_lines | 7 |
:ref:`int<class_int>` | completion_max_width | 50 |
:ref:`Color<class_Color>` | completion_scroll_color | Color( 1, 1, 1, 1 ) |
:ref:`int<class_int>` | completion_scroll_width | 3 |
:ref:`Color<class_Color>` | completion_selected_color | Color( 0.26, 0.26, 0.27, 1 ) |
:ref:`Color<class_Color>` | current_line_color | Color( 0.25, 0.25, 0.26, 0.8 ) |
:ref:`Color<class_Color>` | executing_line_color | Color( 0.2, 0.8, 0.2, 0.4 ) |
:ref:`StyleBox<class_StyleBox>` | focus | |
:ref:`Texture2D<class_Texture2D>` | fold | |
:ref:`Texture2D<class_Texture2D>` | folded | |
:ref:`Font<class_Font>` | font | |
:ref:`Color<class_Color>` | font_color | Color( 0.88, 0.88, 0.88, 1 ) |
:ref:`Color<class_Color>` | font_color_readonly | Color( 0.88, 0.88, 0.88, 0.5 ) |
:ref:`Color<class_Color>` | font_color_selected | Color( 0, 0, 0, 1 ) |
:ref:`Color<class_Color>` | function_color | Color( 0.4, 0.64, 0.81, 1 ) |
:ref:`Color<class_Color>` | line_number_color | Color( 0.67, 0.67, 0.67, 0.4 ) |
:ref:`int<class_int>` | line_spacing | 4 |
:ref:`Color<class_Color>` | mark_color | Color( 1, 0.4, 0.4, 0.4 ) |
:ref:`Color<class_Color>` | member_variable_color | Color( 0.9, 0.31, 0.35, 1 ) |
:ref:`StyleBox<class_StyleBox>` | normal | |
:ref:`Color<class_Color>` | number_color | Color( 0.92, 0.58, 0.2, 1 ) |
:ref:`StyleBox<class_StyleBox>` | read_only | |
:ref:`Color<class_Color>` | safe_line_number_color | Color( 0.67, 0.78, 0.67, 0.6 ) |
:ref:`Color<class_Color>` | selection_color | Color( 0.49, 0.49, 0.49, 1 ) |
:ref:`Texture2D<class_Texture2D>` | space | |
:ref:`Color<class_Color>` | symbol_color | Color( 0.94, 0.94, 0.94, 1 ) |
:ref:`Texture2D<class_Texture2D>` | tab | |
:ref:`Color<class_Color>` | word_highlighted_color | Color( 0.8, 0.9, 0.9, 0.15 ) |
- breakpoint_toggled ( :ref:`int<class_int>` row )
Emitted when a breakpoint is placed via the breakpoint gutter.
- cursor_changed ( )
Emitted when the cursor changes.
- info_clicked ( :ref:`int<class_int>` row, :ref:`String<class_String>` info )
Emitted when the info icon is clicked.
- request_completion ( )
- symbol_lookup ( :ref:`String<class_String>` symbol, :ref:`int<class_int>` row, :ref:`int<class_int>` column )
- symbol_validate ( :ref:`String<class_String>` symbol )
- text_changed ( )
Emitted when the text changes.
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 SearchResult:
- SEARCH_RESULT_COLUMN = 0 --- Used to access the result column from :ref:`search<class_TextEdit_method_search>`.
- SEARCH_RESULT_LINE = 1 --- Used to access the result line from :ref:`search<class_TextEdit_method_search>`.
- 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_MAX = 7 --- Represents the size of the :ref:`MenuItems<enum_TextEdit_MenuItems>` enum.
- :ref:`bool<class_bool>` breakpoint_gutter
Default | false |
Setter | set_breakpoint_gutter_enabled(value) |
Getter | is_breakpoint_gutter_enabled() |
If true
, the breakpoint gutter is visible.
- :ref:`bool<class_bool>` caret_blink
Default | false |
Setter | cursor_set_blink_enabled(value) |
Getter | cursor_get_blink_enabled() |
If true
, the caret (visual cursor) blinks.
- :ref:`float<class_float>` caret_blink_speed
Default | 0.65 |
Setter | cursor_set_blink_speed(value) |
Getter | cursor_get_blink_speed() |
Duration (in seconds) of a caret's blinking cycle.
- :ref:`bool<class_bool>` caret_block_mode
Default | false |
Setter | cursor_set_block_mode(value) |
Getter | cursor_is_block_mode() |
If true
, the caret displays as a rectangle.
If false
, the caret displays as a bar.
- :ref:`bool<class_bool>` caret_moving_by_right_click
Default | true |
Setter | set_right_click_moves_caret(value) |
Getter | is_right_click_moving_caret() |
If true
, a right-click moves the cursor at the mouse position before displaying the context menu.
If false
, the context menu disregards mouse location.
Default | true |
Setter | set_context_menu_enabled(value) |
Getter | is_context_menu_enabled() |
If true
, a right-click displays the context menu.
- :ref:`bool<class_bool>` draw_spaces
Default | false |
Setter | set_draw_spaces(value) |
Getter | is_drawing_spaces() |
If true
, the "space" character will have a visible representation.
- :ref:`bool<class_bool>` draw_tabs
Default | false |
Setter | set_draw_tabs(value) |
Getter | is_drawing_tabs() |
If true
, the "tab" character will have a visible representation.
- :ref:`bool<class_bool>` fold_gutter
Default | false |
Setter | set_draw_fold_gutter(value) |
Getter | is_drawing_fold_gutter() |
If true
, the fold gutter is visible. This enables folding groups of indented lines.
- :ref:`bool<class_bool>` hiding_enabled
Default | false |
Setter | set_hiding_enabled(value) |
Getter | is_hiding_enabled() |
If true
, all lines that have been set to hidden by :ref:`set_line_as_hidden<class_TextEdit_method_set_line_as_hidden>`, will not be visible.
- :ref:`bool<class_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.
- :ref:`bool<class_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.
- :ref:`bool<class_bool>` minimap_draw
Default | false |
Setter | draw_minimap(value) |
Getter | is_drawing_minimap() |
- :ref:`int<class_int>` minimap_width
Default | 80 |
Setter | set_minimap_width(value) |
Getter | get_minimap_width() |
- :ref:`bool<class_bool>` override_selected_font_color
Default | false |
Setter | set_override_selected_font_color(value) |
Getter | is_overriding_selected_font_color() |
- :ref:`bool<class_bool>` readonly
Default | false |
Setter | set_readonly(value) |
Getter | is_readonly() |
If true
, read-only mode is enabled. Existing text cannot be modified and new text cannot be added.
- :ref:`int<class_int>` scroll_horizontal
Default | 0 |
Setter | set_h_scroll(value) |
Getter | get_h_scroll() |
The current horizontal scroll value.
- :ref:`float<class_float>` scroll_vertical
Default | 0.0 |
Setter | set_v_scroll(value) |
Getter | get_v_scroll() |
The current vertical scroll value.
- :ref:`bool<class_bool>` selecting_enabled
Default | true |
Setter | set_selecting_enabled(value) |
Getter | is_selecting_enabled() |
- :ref:`bool<class_bool>` shortcut_keys_enabled
Default | true |
Setter | set_shortcut_keys_enabled(value) |
Getter | is_shortcut_keys_enabled() |
- :ref:`bool<class_bool>` show_line_numbers
Default | false |
Setter | set_show_line_numbers(value) |
Getter | is_show_line_numbers_enabled() |
If true
, line numbers are displayed to the left of the text.
- :ref:`bool<class_bool>` smooth_scrolling
Default | false |
Setter | set_smooth_scroll_enable(value) |
Getter | is_smooth_scroll_enabled() |
If true
, sets the step
of the scrollbars to 0.25
which results in smoother scrolling.
- :ref:`bool<class_bool>` syntax_highlighting
Default | false |
Setter | set_syntax_coloring(value) |
Getter | is_syntax_coloring_enabled() |
If true
, any custom color properties that have been set for this TextEdit
will be visible.
Default | "" |
Setter | set_text(value) |
Getter | get_text() |
String value of the TextEdit
.
- :ref:`float<class_float>` v_scroll_speed
Default | 80.0 |
Setter | set_v_scroll_speed(value) |
Getter | get_v_scroll_speed() |
Vertical scroll sensitivity.
- :ref:`bool<class_bool>` wrap_enabled
Default | false |
Setter | set_wrap_enabled(value) |
Getter | is_wrap_enabled() |
If true
, enables text wrapping when it goes beyond the edge of what is visible.
- void add_color_region ( :ref:`String<class_String>` begin_key, :ref:`String<class_String>` end_key, :ref:`Color<class_Color>` color, :ref:`bool<class_bool>` line_only=false )
Adds color region (given the delimiters) and its colors.
- void add_keyword_color ( :ref:`String<class_String>` keyword, :ref:`Color<class_Color>` color )
Adds a keyword
and its :ref:`Color<class_Color>`.
- :ref:`bool<class_bool>` can_fold ( :ref:`int<class_int>` line ) const
Returns if the given line is foldable, that is, it has indented lines right below it.
- void center_viewport_to_cursor ( )
- void clear_colors ( )
Clears all custom syntax coloring information previously added with :ref:`add_color_region<class_TextEdit_method_add_color_region>` or :ref:`add_keyword_color<class_TextEdit_method_add_keyword_color>`.
- void clear_undo_history ( )
Clears the undo history.
- void copy ( )
Copy's the current text selection.
- :ref:`int<class_int>` cursor_get_column ( ) const
Returns the column the editing cursor is at.
- :ref:`int<class_int>` cursor_get_line ( ) const
Returns the line the editing cursor is at.
- void cursor_set_column ( :ref:`int<class_int>` column, :ref:`bool<class_bool>` adjust_viewport=true )
Moves the cursor at the specified column
index.
If adjust_viewport
is set to true
, the viewport will center at the cursor position after the move occurs.
- void cursor_set_line ( :ref:`int<class_int>` line, :ref:`bool<class_bool>` adjust_viewport=true, :ref:`bool<class_bool>` can_be_hidden=true, :ref:`int<class_int>` wrap_index=0 )
Moves the cursor at the specified line
index.
If adjust_viewport
is set to true
, the viewport will center at the cursor position after the move occurs.
If can_be_hidden
is set to true
, the specified line
can be hidden using :ref:`set_line_as_hidden<class_TextEdit_method_set_line_as_hidden>`.
- void cut ( )
Cut's the current selection.
- void deselect ( )
Deselects the current selection.
- void fold_all_lines ( )
Folds all lines that are possible to be folded (see :ref:`can_fold<class_TextEdit_method_can_fold>`).
- void fold_line ( :ref:`int<class_int>` line )
Folds the given line, if possible (see :ref:`can_fold<class_TextEdit_method_can_fold>`).
- :ref:`Array<class_Array>` get_breakpoints ( ) const
Returns an array containing the line number of each breakpoint.
- :ref:`Color<class_Color>` get_keyword_color ( :ref:`String<class_String>` keyword ) const
Returns the :ref:`Color<class_Color>` of the specified keyword
.
- :ref:`String<class_String>` get_line ( :ref:`int<class_int>` line ) const
Returns the text of a specific line.
- :ref:`int<class_int>` get_line_count ( ) const
Returns the amount of total lines in the text.
Returns the :ref:`PopupMenu<class_PopupMenu>` of this TextEdit
. By default, this menu is displayed when right-clicking on the TextEdit
.
- :ref:`int<class_int>` get_selection_from_column ( ) const
Returns the selection begin column.
- :ref:`int<class_int>` get_selection_from_line ( ) const
Returns the selection begin line.
- :ref:`String<class_String>` get_selection_text ( ) const
Returns the text inside the selection.
- :ref:`int<class_int>` get_selection_to_column ( ) const
Returns the selection end column.
- :ref:`int<class_int>` get_selection_to_line ( ) const
Returns the selection end line.
- :ref:`String<class_String>` get_word_under_cursor ( ) const
Returns a :ref:`String<class_String>` text with the word under the mouse cursor location.
- :ref:`bool<class_bool>` has_keyword_color ( :ref:`String<class_String>` keyword ) const
Returns whether the specified keyword
has a color set to it or not.
- void insert_text_at_cursor ( :ref:`String<class_String>` text )
Insert the specified text at the cursor position.
- :ref:`bool<class_bool>` is_folded ( :ref:`int<class_int>` line ) const
Returns whether the line at the specified index is folded or not.
Returns whether the line at the specified index is hidden or not.
- :ref:`bool<class_bool>` is_selection_active ( ) const
Returns true
if the selection is active.
Triggers a right-click menu action by the specified index. See :ref:`MenuItems<enum_TextEdit_MenuItems>` for a list of available indexes.
- void paste ( )
Paste the current selection.
- void redo ( )
Perform redo operation.
- void remove_breakpoints ( )
Removes all the breakpoints. This will not fire the :ref:`breakpoint_toggled<class_TextEdit_signal_breakpoint_toggled>` signal.
- :ref:`PackedInt32Array<class_PackedInt32Array>` search ( :ref:`String<class_String>` key, :ref:`int<class_int>` flags, :ref:`int<class_int>` from_line, :ref:`int<class_int>` from_column ) const
Perform a search inside the text. Search flags can be specified in the :ref:`SearchFlags<enum_TextEdit_SearchFlags>` enum.
Returns an empty PackedInt32Array
if no result was found. Otherwise, the result line and column can be accessed at indices specified in the :ref:`SearchResult<enum_TextEdit_SearchResult>` enum, e.g:
var result = search(key, flags, line, column) if result.size() > 0: # Result found. var res_line = result[TextEdit.SEARCH_RESULT_LINE] var res_column = result[TextEdit.SEARCH_RESULT_COLUMN]
- void select ( :ref:`int<class_int>` from_line, :ref:`int<class_int>` from_column, :ref:`int<class_int>` to_line, :ref:`int<class_int>` to_column )
Perform selection, from line/column to line/column.
- void select_all ( )
Select all the text.
If true
, hides the line of the specified index.
- void toggle_fold_line ( :ref:`int<class_int>` line )
Toggle the folding of the code block at the given line.
- void undo ( )
Perform undo operation.
- void unfold_line ( :ref:`int<class_int>` line )
Unfolds the given line, if folded.
- void unhide_all_lines ( )
Unhide all lines that were previously set to hidden by :ref:`set_line_as_hidden<class_TextEdit_method_set_line_as_hidden>`.