A multiline text editor designed for editing code.
CodeEdit is a specialized [TextEdit] designed for editing plain text code files. It has many features commonly found in code editors such as line numbers, line folding, code completion, indent management, and string/comment management. [b]Note:[/b] Regardless of locale, [CodeEdit] will by default always use left-to-right text direction to correctly display source code.
Override this method to define how the selected entry should be inserted. If [param replace] is [code]true[/code], any existing text should be replaced.
Override this method to define what items in [param candidates] should be displayed. Both [param candidates] and the return is a [Array] of [Dictionary], see [method get_code_completion_option] for [Dictionary] content.
Override this method to define what happens when the user requests code completion. If [param force] is [code]true[/code], any checks should be bypassed.
Adds a brace pair. Both the start and end keys must be symbols. Only the start key has to be unique.
Submits an item to the queue of potential candidates for the autocomplete menu. Call [method update_code_completion_options] to update the list. [param location] indicates location of the option relative to the location of the code completion query. See [enum CodeEdit.CodeCompletionLocation] for how to set this value. [b]Note:[/b] This list will replace all current candidates.
Adds a comment delimiter from [param start_key] to [param end_key]. Both keys should be symbols, and [param start_key] must not be shared with other delimiters. If [param line_only] is [code]true[/code] or [param end_key] is an empty [String], the region does not carry over to the next line.
Defines a string delimiter from [param start_key] to [param end_key]. Both keys should be symbols, and [param start_key] must not be shared with other delimiters. If [param line_only] is [code]true[/code] or [param end_key] is an empty [String], the region does not carry over to the next line.
Returns [code]true[/code] if the given line is foldable. A line is foldable if it is the start of a valid code region (see [method get_code_region_start_tag]), if it is the start of a comment or string block, or if the next non-empty line is more indented (see [method TextEdit.get_indent_level]).
Cancels the autocomplete menu.
Clears all bookmarked lines.
Clears all breakpointed lines.
Removes all comment delimiters.
Clears all executed lines.
Removes all string delimiters.
Inserts the selected entry into the text. If [param replace] is [code]true[/code], any existing text is replaced rather than merged.
Converts the indents of lines between [param from_line] and [param to_line] to tabs or spaces as set by [member indent_use_spaces]. Values of [code]-1[/code] convert the entire text.
Creates a new code region with the selection. At least one single line comment delimiter have to be defined (see [method add_comment_delimiter]). A code region is a part of code that is highlighted when folded and can help organize your script. Code region start and end tags can be customized (see [method set_code_region_tags]). Code regions are delimited using start and end tags (respectively [code]region[/code] and [code]endregion[/code] by default) preceded by one line comment delimiter. (eg. [code]#region[/code] and [code]#endregion[/code])
Deletes all lines that are selected or have a caret on them.
If there is no selection, indentation is inserted at the caret. Otherwise, the selected lines are indented like [method indent_lines]. Equivalent to the [member ProjectSettings.input/ui_text_indent] action. The indentation characters used depend on [member indent_use_spaces] and [member indent_size].
Duplicates all lines currently selected with any caret. Duplicates the entire line beneath the current one no matter where the caret is within the line.
Duplicates all selected text and duplicates all lines with a caret on them.
Folds all lines that are possible to be folded (see [method can_fold_line]).
Folds the given line, if possible (see [method can_fold_line]).
Gets the matching auto brace close key for [param open_key].
Gets all bookmarked lines.
Gets all breakpointed lines.
Gets the completion option at [param index]. The return [Dictionary] has the following key-values: [code]kind[/code]: [enum CodeCompletionKind] [code]display_text[/code]: Text that is shown on the autocomplete menu. [code]insert_text[/code]: Text that is to be inserted when this item is selected. [code]font_color[/code]: Color of the text on the autocomplete menu. [code]icon[/code]: Icon to draw on the autocomplete menu. [code]default_value[/code]: Value of the symbol.
Gets all completion options, see [method get_code_completion_option] for return content.
Gets the index of the current selected completion option.
Returns the code region end tag (without comment delimiter).
Returns the code region start tag (without comment delimiter).
Gets the end key for a string or comment region index.
If [param line] [param column] is in a string or comment, returns the end position of the region. If not or no end could be found, both [Vector2] values will be [code]-1[/code].
Gets the start key for a string or comment region index.
If [param line] [param column] is in a string or comment, returns the start position of the region. If not or no start could be found, both [Vector2] values will be [code]-1[/code].
Gets all executing lines.
Returns all lines that are currently folded.
Returns the full text with char [code]0xFFFF[/code] at the caret location.
Returns the full text with char [code]0xFFFF[/code] at the cursor location.
Returns the full text with char [code]0xFFFF[/code] at the specified location.
Returns [code]true[/code] if close key [param close_key] exists.
Returns [code]true[/code] if open key [param open_key] exists.
Returns [code]true[/code] if comment [param start_key] exists.
Returns [code]true[/code] if string [param start_key] exists.
Indents all lines that are selected or have a caret on them. Uses spaces or a tab depending on [member indent_use_spaces]. See [method unindent_lines].
Returns delimiter index if [param line] [param column] is in a comment. If [param column] is not provided, will return delimiter index if the entire [param line] is a comment. Otherwise [code]-1[/code].
Returns the delimiter index if [param line] [param column] is in a string. If [param column] is not provided, will return the delimiter index if the entire [param line] is a string. Otherwise [code]-1[/code].
Returns [code]true[/code] if the given line is bookmarked. See [method set_line_as_bookmarked].
Returns [code]true[/code] if the given line is breakpointed. See [method set_line_as_breakpoint].
Returns [code]true[/code] if the given line is a code region end. See [method set_code_region_tags].
Returns [code]true[/code] if the given line is a code region start. See [method set_code_region_tags].
Returns [code]true[/code] if the given line is marked as executing. See [method set_line_as_executing].
Returns [code]true[/code] if the given line is folded. See [method fold_line].
Moves all lines down that are selected or have a caret on them.
Moves all lines up that are selected or have a caret on them.
Removes the comment delimiter with [param start_key].
Removes the string delimiter with [param start_key].
Emits [signal code_completion_requested], if [param force] is [code]true[/code] will bypass all checks. Otherwise will check that the caret is in a word or in front of a prefix. Will ignore the request if all current options are of type file path, node path, or signal.
Sets the current selected completion option.
Sets the code hint text. Pass an empty string to clear.
If [code]true[/code], the code hint will draw below the main caret. If [code]false[/code], the code hint will draw above the main caret. See [method set_code_hint].
Sets the code region start and end tags (without comment delimiter).
Sets the given line as bookmarked. If [code]true[/code] and [member gutters_draw_bookmarks] is [code]true[/code], draws the [theme_item bookmark] icon in the gutter for this line. See [method get_bookmarked_lines] and [method is_line_bookmarked].
Sets the given line as a breakpoint. If [code]true[/code] and [member gutters_draw_breakpoints_gutter] is [code]true[/code], draws the [theme_item breakpoint] icon in the gutter for this line. See [method get_breakpointed_lines] and [method is_line_breakpointed].
Sets the given line as executing. If [code]true[/code] and [member gutters_draw_executing_lines] is [code]true[/code], draws the [theme_item executing_line] icon in the gutter for this line. See [method get_executing_lines] and [method is_line_executing].
Sets the symbol emitted by [signal symbol_validate] as a valid lookup.
Toggle the folding of the code block at the given line.
Toggle the folding of the code block on all lines with a caret on them.
Unfolds all lines that are folded.
Unfolds the given line if it is folded or if it is hidden under a folded line.
Unindents all lines that are selected or have a caret on them. Uses spaces or a tab depending on [member indent_use_spaces]. Equivalent to the [member ProjectSettings.input/ui_text_dedent] action. See [method indent_lines].
Submits all completion options added with [method add_code_completion_option]. Will try to force the autocomplete menu to popup, if [param force] is [code]true[/code]. [b]Note:[/b] This will replace all current candidates.
- If [code]true[/code], uses [member auto_brace_completion_pairs] to automatically insert the closing brace when the opening brace is inserted by typing or autocompletion. Also automatically removes the closing brace when using backspace on the opening brace.
- If [code]true[/code], highlights brace pairs when the caret is on either one, using [member auto_brace_completion_pairs]. If matching, the pairs will be underlined. If a brace is unmatched, it is colored with [theme_item brace_mismatch_color].
- Sets the brace pairs to be autocompleted. For each entry in the dictionary, the key is the opening brace and the value is the closing brace that matches it. A brace is a [String] made of symbols. See [member auto_brace_completion_enabled] and [member auto_brace_completion_highlight_matching].
- If [code]true[/code], the [member ProjectSettings.input/ui_text_completion_query] action requests code completion. To handle it, see [method _request_code_completion] or [signal code_completion_requested].
- Sets prefixes that will trigger code completion.
- Sets the comment delimiters. All existing comment delimiters will be removed.
- Sets the string delimiters. All existing string delimiters will be removed.
- If [code]true[/code], bookmarks are drawn in the gutter. This gutter is shared with breakpoints and executing lines. See [method set_line_as_bookmarked].
- If [code]true[/code], breakpoints are drawn in the gutter. This gutter is shared with bookmarks and executing lines. Clicking the gutter will toggle the breakpoint for the line, see [method set_line_as_breakpoint].
- If [code]true[/code], executing lines are marked in the gutter. This gutter is shared with breakpoints and bookmarks. See [method set_line_as_executing].
- If [code]true[/code], the fold gutter is drawn. In this gutter, the [theme_item can_fold_code_region] icon is drawn for each foldable line (see [method can_fold_line]) and the [theme_item folded_code_region] icon is drawn for each folded line (see [method is_line_folded]). These icons can be clicked to toggle the fold state, see [method toggle_foldable_line]. [member line_folding] must be [code]true[/code] to show icons.
- If [code]true[/code], the line number gutter is drawn. Line numbers start at [code]1[/code] and are incremented for each line of text. Clicking and dragging in the line number gutter will select entire lines of text.
- If [code]true[/code], line numbers drawn in the gutter are zero padded based on the total line count. Requires [member gutters_draw_line_numbers] to be set to [code]true[/code].
- If [code]true[/code], an extra indent is automatically inserted when a new line is added and a prefix in [member indent_automatic_prefixes] is found. If a brace pair opening key is found, the matching closing brace will be moved to another new line (see [member auto_brace_completion_pairs]).
- Prefixes to trigger an automatic indent. Used when [member indent_automatic] is set to [code]true[/code].
- Size of the tabulation indent (one [kbd]Tab[/kbd] press) in characters. If [member indent_use_spaces] is enabled the number of spaces to use.
- Use spaces instead of tabs for indentation.
- If [code]true[/code], lines can be folded. Otherwise, line folding methods like [method fold_line] will not work and [method can_fold_line] will always return [code]false[/code]. See [member gutters_draw_fold_gutter].
- Draws vertical lines at the provided columns. The first entry is considered a main hard guideline and is draw more prominently.
- Set when a validated word from [signal symbol_validate] is clicked, the [signal symbol_lookup] should be emitted.
- Set when a word is hovered, the [signal symbol_hovered] should be emitted.
Emitted when a breakpoint is added or removed from a line. If the line is moved via backspace a removed is emitted at the old line.
Emitted when the user requests code completion. This signal will not be sent if [method _request_code_completion] is overridden or [member code_completion_enabled] is [code]false[/code].
Emitted when the user hovers over a symbol. Unlike [signal Control.mouse_entered], this signal is not emitted immediately, but when the cursor is over the symbol for [member ProjectSettings.gui/timers/tooltip_delay_sec] seconds. [b]Note:[/b] [member symbol_tooltip_on_hover] must be [code]true[/code] for this signal to be emitted.
Emitted when the user has clicked on a valid symbol.
Emitted when the user hovers over a symbol. The symbol should be validated and responded to, by calling [method set_symbol_lookup_word_as_valid]. [b]Note:[/b] [member symbol_lookup_on_click] must be [code]true[/code] for this signal to be emitted.
Marks the option as a class.
Marks the option as a function.
Marks the option as a Godot signal.
Marks the option as a variable.
Marks the option as a member.
Marks the option as an enum entry.
Marks the option as a constant.
Marks the option as a Godot node path.
Marks the option as a file path.
Marks the option as unclassified or plain text.
The option is local to the location of the code completion query - e.g. a local variable. Subsequent value of location represent options from the outer class, the exact value represent how far they are (in terms of inner classes).
The option is from the containing class or a parent class, relative to the location of the code completion query. Perform a bitwise OR with the class depth (e.g. [code]0[/code] for the local class, [code]1[/code] for the parent, [code]2[/code] for the grandparent, etc.) to store the depth of an option in the class or a parent class.
The option is from user code which is not local and not in a derived class (e.g. Autoload Singletons).
The option is from other engine code, not covered by the other enum constants - e.g. built-in classes.
[Color] of the bookmark icon for bookmarked lines.
[Color] of the text to highlight mismatched braces.
[Color] of the breakpoint icon for bookmarked lines.
[Color] for all icons related to line folding.
Sets the background [Color] for the code completion popup.
Background highlight [Color] for matching text in code completion options.
[Color] of the scrollbar in the code completion popup.
[Color] of the scrollbar in the code completion popup when hovered.
Background highlight [Color] for the current selected option item in the code completion popup.
[Color] of the executing icon for executing lines.
[Color] of background line highlight for folded code region.
[Color] of the main line length guideline, secondary guidelines will have 50% alpha applied.
Sets the [Color] of line numbers.
Max number of options to display in the code completion popup at any one time.
Max width of options in the code completion popup. Options longer than this will be cut off.
Width of the scrollbar in the code completion popup.
Sets a custom [Texture2D] to draw in the bookmark gutter for bookmarked lines.
Sets a custom [Texture2D] to draw in the breakpoint gutter for breakpointed lines.
Sets a custom [Texture2D] to draw in the line folding gutter when a line can be folded.
Sets a custom [Texture2D] to draw in the line folding gutter when a code region can be folded.
Background panel for the color preview box in autocompletion (visible when the color is translucent).
Icon to draw in the executing gutter for executing lines.
Sets a custom [Texture2D] to draw in the line folding gutter when a line is folded and can be unfolded.
Sets a custom [Texture2D] to draw in the line folding gutter when a code region is folded and can be unfolded.
Sets a custom [Texture2D] to draw at the end of a folded line.
[StyleBox] for the code completion popup.