TextEdit

    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.

    Properties

    void ( String begin_key, end_key, Color color, line_only=false )
    voidadd_keyword_color ( keyword, Color color )
    can_fold ( line ) const
    voidcenter_viewport_to_cursor ( )
    void ( )
    voidclear_undo_history ( )
    void ( )
    int ( ) const
    int ( ) const
    voidcursor_set_column ( column, bool adjust_viewport=true )
    void ( int line, adjust_viewport=true, bool can_be_hidden=true, wrap_index=0 )
    voidcut ( )
    void ( )
    voidfold_all_lines ( )
    void ( int line )
    get_breakpoints ( ) const
    get_keyword_color ( keyword ) const
    String ( int line ) const
    get_line_count ( ) const
    get_menu ( ) const
    get_selection_from_column ( ) const
    get_selection_from_line ( ) const
    get_selection_text ( ) const
    get_selection_to_column ( ) const
    get_selection_to_line ( ) const
    get_word_under_cursor ( ) const
    has_keyword_color ( keyword ) const
    voidinsert_text_at_cursor ( text )
    bool ( int line ) const
    is_line_hidden ( line ) const
    bool ( ) const
    voidmenu_option ( option )
    voidpaste ( )
    void ( )
    voidremove_breakpoints ( )
    search ( key, int flags, from_line, int from_column ) const
    void ( int from_line, from_column, int to_line, to_column )
    voidselect_all ( )
    void ( int line, new_text )
    voidset_line_as_hidden ( line, bool enable )
    void ( int line )
    void ( )
    voidunfold_line ( line )
    voidunhide_all_lines ( )

    Theme Properties

    background_colorColor( 0, 0, 0, 0 )
    Colorbookmark_colorColor( 0.08, 0.49, 0.98, 1 )
    brace_mismatch_colorColor( 1, 0.2, 0.2, 1 )
    Colorbreakpoint_colorColor( 0.8, 0.8, 0.4, 0.2 )
    caret_background_colorColor( 0, 0, 0, 1 )
    Colorcaret_colorColor( 0.88, 0.88, 0.88, 1 )
    code_folding_colorColor( 0.8, 0.8, 0.8, 0.8 )
    StyleBoxcompletion 
    completion_background_colorColor( 0.17, 0.16, 0.2, 1 )
    Colorcompletion_existing_colorColor( 0.87, 0.87, 0.87, 0.13 )
    completion_font_colorColor( 0.67, 0.67, 0.67, 1 )
    intcompletion_lines7
    completion_max_width50
    Colorcompletion_scroll_colorColor( 1, 1, 1, 1 )
    completion_scroll_width3
    Colorcompletion_selected_colorColor( 0.26, 0.26, 0.27, 1 )
    current_line_colorColor( 0.25, 0.25, 0.26, 0.8 )
    Colorexecuting_line_colorColor( 0.2, 0.8, 0.2, 0.4 )
    focus 
    Texturefold 
    folded 
    Fontfont 
    font_colorColor( 0.88, 0.88, 0.88, 1 )
    Colorfont_color_readonlyColor( 0.88, 0.88, 0.88, 0.5 )
    font_color_selectedColor( 0, 0, 0, 1 )
    Colorfunction_colorColor( 0.4, 0.64, 0.81, 1 )
    line_number_colorColor( 0.67, 0.67, 0.67, 0.4 )
    intline_spacing4
    mark_colorColor( 1, 0.4, 0.4, 0.4 )
    Colormember_variable_colorColor( 0.9, 0.31, 0.35, 1 )
    normal 
    Colornumber_colorColor( 0.92, 0.58, 0.2, 1 )
    read_only 
    Colorsafe_line_number_colorColor( 0.67, 0.78, 0.67, 0.6 )
    selection_colorColor( 0.49, 0.49, 0.49, 1 )
    Texturespace 
    symbol_colorColor( 0.94, 0.94, 0.94, 1 )
    Texturetab 
    word_highlighted_colorColor( 0.8, 0.9, 0.9, 0.15 )
    • breakpoint_toggled ( int row )

    Emitted when a breakpoint is placed via the breakpoint gutter.


    • cursor_changed ( )

    Emitted when the cursor changes.


    • info_clicked ( row, String info )

    Emitted when the info icon is clicked.


    • request_completion ( )

    • symbol_lookup ( symbol, int row, column )

    • text_changed ( )

    Emitted when the text changes.

    Enumerations

    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 search.
    • SEARCH_RESULT_LINE = 1 —- Used to access the result line from .

    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_MAX = 7 —- Represents the size of the MenuItems enum.
    • breakpoint_gutter
    Defaultfalse
    Setterset_breakpoint_gutter_enabled(value)
    Getteris_breakpoint_gutter_enabled()

    If true, the breakpoint gutter is visible.


    Defaultfalse
    Settercursor_set_blink_enabled(value)
    Gettercursor_get_blink_enabled()

    If true, the caret (visual cursor) blinks.


    • caret_blink_speed
    Default
    Settercursor_set_blink_speed(value)
    Gettercursor_get_blink_speed()

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


    • bool caret_block_mode
    Defaultfalse
    Settercursor_set_block_mode(value)
    Gettercursor_is_block_mode()

    If true, the caret displays as a rectangle.

    If false, the caret displays as a bar.


    • caret_moving_by_right_click
    Defaulttrue
    Setterset_right_click_moves_caret(value)
    Getteris_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.


    Defaulttrue
    Setterset_context_menu_enabled(value)
    Getteris_context_menu_enabled()

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


    Defaultfalse
    Setterset_draw_spaces(value)
    Getteris_drawing_spaces()

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


    • draw_tabs

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


    Defaultfalse
    Setterset_draw_fold_gutter(value)
    Getteris_drawing_fold_gutter()

    If true, the fold gutter is visible. This enables folding groups of indented lines.


    • hiding_enabled
    Defaultfalse
    Setterset_hiding_enabled(value)
    Getteris_hiding_enabled()

    If true, all lines that have been set to hidden by set_line_as_hidden, will not be visible.


    • highlight_all_occurrences
    Defaultfalse
    Setterset_highlight_all_occurrences(value)
    Getteris_highlight_all_occurrences_enabled()

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


    • bool highlight_current_line
    Defaultfalse
    Setterset_highlight_current_line(value)
    Getteris_highlight_current_line_enabled()

    If true, the line containing the cursor is highlighted.


    • minimap_draw
    Defaultfalse
    Setterdraw_minimap(value)
    Getteris_drawing_minimap()

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


    • int minimap_width
    Default80
    Setterset_minimap_width(value)
    Getterget_minimap_width()

    The width, in pixels, of the minimap.


    • override_selected_font_color
    Defaultfalse
    Setterset_override_selected_font_color(value)
    Getteris_overriding_selected_font_color()

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


    Defaultfalse
    Setterset_readonly(value)
    Getteris_readonly()

    If true, read-only mode is enabled. Existing text cannot be modified and new text cannot be added.


    • scroll_horizontal
    Default0
    Setterset_h_scroll(value)
    Getterget_h_scroll()

    The current horizontal scroll value.


    The current vertical scroll value.


    • selecting_enabled
    Defaulttrue
    Setterset_selecting_enabled(value)
    Getteris_selecting_enabled()

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


    • bool shortcut_keys_enabled
    Defaulttrue
    Setterset_shortcut_keys_enabled(value)
    Getteris_shortcut_keys_enabled()

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


    • show_line_numbers
    Defaultfalse
    Setterset_show_line_numbers(value)
    Getteris_show_line_numbers_enabled()

    If true, line numbers are displayed to the left of the text.


    • bool smooth_scrolling
    Defaultfalse
    Setterset_smooth_scroll_enable(value)
    Getteris_smooth_scroll_enabled()

    If true, sets the step of the scrollbars to 0.25 which results in smoother scrolling.


    • syntax_highlighting
    Defaultfalse
    Setterset_syntax_coloring(value)
    Getteris_syntax_coloring_enabled()

    If true, any custom color properties that have been set for this TextEdit will be visible.


    Default“”
    Setterset_text(value)
    Getterget_text()

    String value of the TextEdit.


    • v_scroll_speed
    Default80.0
    Setterset_v_scroll_speed(value)
    Getterget_v_scroll_speed()

    Vertical scroll sensitivity.


    • bool virtual_keyboard_enabled
    Defaulttrue
    Setterset_virtual_keyboard_enabled(value)
    Getteris_virtual_keyboard_enabled()

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


    • wrap_enabled
    Defaultfalse
    Setterset_wrap_enabled(value)
    Getteris_wrap_enabled()

    If true, enables text wrapping when it goes beyond the edge of what is visible.

    Method Descriptions

    • void add_color_region ( String begin_key, end_key, Color color, line_only=false )

    Adds color region (given the delimiters) and its colors.


    • void add_keyword_color ( String keyword, color )

    Adds a keyword and its Color.


    • can_fold ( int line ) const

    Returns if the given line is foldable, that is, it has indented lines right below it.


    • void center_viewport_to_cursor ( )

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


    • void clear_colors ( )

    Clears all custom syntax coloring information previously added with add_color_region or .


    • void clear_undo_history ( )

    Clears the undo history.


    • void copy ( )

    Copy’s the current text selection.


    • int cursor_get_column ( ) const

    Returns the column the editing cursor is at.


    • cursor_get_line ( ) const

    Returns the line the editing cursor is at.


    • void cursor_set_column ( int column, 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 ( int line, adjust_viewport=true, bool can_be_hidden=true, 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 set_line_as_hidden.


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


    • void fold_line ( int line )

    Folds the given line, if possible (see ).


    • Array get_breakpoints ( ) const

    Returns an array containing the line number of each breakpoint.


    • get_keyword_color ( String keyword ) const

    Returns the of the specified keyword.


    • String get_line ( line ) const

    • int get_line_count ( ) const

    Returns the amount of total lines in the text.


    • get_menu ( ) const

    Returns the PopupMenu of this TextEdit. By default, this menu is displayed when right-clicking on the TextEdit.


    • get_selection_from_column ( ) const

    Returns the selection begin column.


    • int get_selection_from_line ( ) const

    Returns the selection begin line.


    • get_selection_text ( ) const

    Returns the text inside the selection.


    • int get_selection_to_column ( ) const

    Returns the selection end column.


    • get_selection_to_line ( ) const

    Returns the selection end line.


    • String get_word_under_cursor ( ) const

    Returns a text with the word under the caret (text cursor) location.


    • bool has_keyword_color ( keyword ) const

    Returns whether the specified keyword has a color set to it or not.


    • void insert_text_at_cursor ( String text )

    Insert the specified text at the cursor position.


    • is_folded ( int line ) const

    Returns whether the line at the specified index is folded or not.


    • is_line_hidden ( int line ) const

    Returns whether the line at the specified index is hidden or not.


    • is_selection_active ( ) const

    Returns true if the selection is active.


    • void menu_option ( int option )

    Triggers a right-click menu action by the specified index. See 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 breakpoint_toggled signal.


    • search ( String key, flags, int from_line, from_column ) const

    Perform a search inside the text. Search flags can be specified in the SearchFlags enum.

    Returns an empty PoolIntArray if no result was found. Otherwise, the result line and column can be accessed at indices specified in the enum, e.g:


    • void select ( int from_line, from_column, int to_line, 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 is , no selection will occur.


    • void set_line ( int line, new_text )

    Sets the text for a specific line.


    • void set_line_as_hidden ( int line, enable )

    If true, hides the line of the specified index.


    • void toggle_fold_line ( int line )

    Toggle the folding of the code block at the given line.


    • void undo ( )

    Perform undo operation.


    • void unfold_line ( line )

    Unfolds the given line, if folded.


    • void unhide_all_lines ( )

    Unhide all lines that were previously set to hidden by set_line_as_hidden.