Inherits: TextEdit < Control < CanvasItem < Node < Object
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.
Note: Regardless of locale, CodeEdit will by default always use left-to-right text direction to correctly display source code.
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
layout_direction |
| |
| ||
| ||
| ||
text_direction |
|
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
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.
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 set_symbol_lookup_word_as_valid.
0
Marks the option as a class.
1
Marks the option as a function.
2
Marks the option as a Godot signal.
3
Marks the option as a variable.
4
Marks the option as a member.
5
Marks the option as an enum entry.
6
Marks the option as a constant.
7
Marks the option as a Godot node path.
8
Marks the option as a file path.
9
Marks the option as unclassified or plain text.
0
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).
256
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. 0 for the local class, 1 for the parent, 2 for the grandparent, etc) to store the depth of an option in the class or a parent class.
512
The option is from user code which is not local and not in a derived class (e.g. Autoload Singletons).
1024
The option is from other engine code, not covered by the other enum constants - e.g. built-in classes.
false
Sets whether brace pairs should be autocompleted.
false
Highlight mismatching brace pairs.
{ "\"": "\"", "'": "'", "(": ")", "[": "]", "{": "}" }
Sets the brace pairs to be autocompleted.
false
Sets whether code completion is allowed.
[]
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.
false
Sets if bookmarked should be drawn in the gutter. This gutter is shared with breakpoints and executing lines.
false
Sets if breakpoints should be drawn in the gutter. This gutter is shared with bookmarks and executing lines.
false
Sets if executing lines should be marked in the gutter. This gutter is shared with breakpoints and bookmarks lines.
false
Sets if foldable lines icons should be drawn in the gutter.
false
Sets if line numbers should be drawn in the gutter.
false
Sets if line numbers drawn in the gutter are zero padded.
false
Sets whether automatic indent are enabled, this will add an extra indent if a prefix or brace is found.
[":", "{", "[", "("]
Prefixes to trigger an automatic indent.
4
Size of the tabulation indent (one Tab press) in characters. If indent_use_spaces is enabled the number of spaces to use.
false
Use spaces instead of tabs for indentation.
false
Sets whether line folding is allowed.
[]
Draws vertical lines at the provided columns. The first entry is considered a main hard guideline and is draw more prominently.
false
Set when a validated word from symbol_validate is clicked, the symbol_lookup should be emitted.
Override this method to define how the selected entry should be inserted. If replace is true, any existing text should be replaced.
Override this method to define what items in candidates should be displayed.
Both candidates and the return is a Array of Dictionary, see get_code_completion_option for Dictionary content.
Override this method to define what happens when the user requests code completion. If force is true, 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 update_code_completion_options to update the list.
location indicates location of the option relative to the location of the code completion query. See CodeCompletionLocation for how to set this value.
Note: This list will replace all current candidates.
Adds a comment delimiter.
Both the start and end keys must be symbols. Only the start key has to be unique.
line_only denotes if the region should continue until the end of the line or carry over on to the next line. If the end key is blank this is automatically set to true.
Adds a string delimiter.
Both the start and end keys must be symbols. Only the start key has to be unique.
line_only denotes if the region should continue until the end of the line or carry over on to the next line. If the end key is blank this is automatically set to true.
Returns if the given line is foldable, that is, it has indented lines right below it or a comment / string block.
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 replace is true, any existing text is replaced rather than merged.
Converts the indents of lines between from_line and to_line to tabs or spaces as set by indent_use_spaces.
Values of -1 convert the entire text.
Creates a new code region with the selection. At least one single line comment delimiter have to be defined (see 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 set_code_region_tags).
Code regions are delimited using start and end tags (respectively region and endregion by default) preceded by one line comment delimiter. (eg. #region and #endregion)
Perform an indent as if the user activated the "ui_text_indent" action.
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.
Folds all lines that are possible to be folded (see can_fold_line).
Folds the given line, if possible (see can_fold_line).
Gets the matching auto brace close key for open_key.
Gets all bookmarked lines.
Gets all breakpointed lines.
Gets the completion option at index. The return Dictionary has the following key-values:
kind: CodeCompletionKind
display_text: Text that is shown on the autocomplete menu.
insert_text: Text that is to be inserted when this item is selected.
font_color: Color of the text on the autocomplete menu.
icon: Icon to draw on the autocomplete menu.
default_value: Value of the symbol.
Gets all completion options, see 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 line 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 -1.
Gets the start key for a string or comment region index.
If line 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 -1.
Gets all executing lines.
Returns all lines that are current folded.
Returns the full text with char 0xFFFF at the caret location.
Returns the full text with char 0xFFFF at the cursor location.
Returns the full text with char 0xFFFF at the specified location.
Returns true if close key close_key exists.
Returns true if open key open_key exists.
Returns true if comment start_key exists.
Returns true if string start_key exists.
Indents selected lines, or in the case of no selection the caret line by one.
Returns delimiter index if line column is in a comment. If column is not provided, will return delimiter index if the entire line is a comment. Otherwise -1.
Returns the delimiter index if line column is in a string. If column is not provided, will return the delimiter index if the entire line is a string. Otherwise -1.
Returns whether the line at the specified index is bookmarked or not.
Returns whether the line at the specified index is breakpointed or not.
Returns whether the line at the specified index is a code region end.
Returns whether the line at the specified index is a code region start.
Returns whether the line at the specified index is marked as executing or not.
Returns whether the line at the specified index is folded or not.
Removes the comment delimiter with start_key.
Removes the string delimiter with start_key.
Emits code_completion_requested, if force is true 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.
Sets if the code hint should draw below the text.
Sets the code region start and end tags (without comment delimiter).
Sets the line as bookmarked.
Sets the line as breakpointed.
Sets the line as executing.
Sets the symbol emitted by symbol_validate as a valid lookup.
Toggle the folding of the code block at the given line.
Unfolds all lines, folded or not.
Unfolds all lines that were previously folded.
Unindents selected lines, or in the case of no selection the caret line by one. Same as performing "ui_text_unindent" action.
Submits all completion options added with add_code_completion_option. Will try to force the autocomplete menu to popup, if force is true.
Note: This will replace all current candidates.
Color(0.5, 0.64, 1, 0.8)
Color of the bookmark icon for bookmarked lines.
Color(1, 0.2, 0.2, 1)
Color of the text to highlight mismatched braces.
Color(0.9, 0.29, 0.3, 1)
Color of the breakpoint icon for bookmarked lines.
Color(0.8, 0.8, 0.8, 0.8)
Color for all icons related to line folding.
Color(0.17, 0.16, 0.2, 1)
Sets the background Color for the code completion popup.
Color(0.87, 0.87, 0.87, 0.13)
Background highlight Color for matching text in code completion options.
Color(1, 1, 1, 0.29)
Color of the scrollbar in the code completion popup.
Color(1, 1, 1, 0.4)
Color of the scrollbar in the code completion popup when hovered.
Color(0.26, 0.26, 0.27, 1)
Background highlight Color for the current selected option item in the code completion popup.
Color(0.98, 0.89, 0.27, 1)
Color of the executing icon for executing lines.
Color(0.68, 0.46, 0.77, 0.2)
Color of background line highlight for folded code region.
Color(0.3, 0.5, 0.8, 0.1)
Color of the main line length guideline, secondary guidelines will have 50% alpha applied.
Color(0.67, 0.67, 0.67, 0.4)
Sets the Color of line numbers.
7
Max number of options to display in the code completion popup at any one time.
50
Max width of options in the code completion popup. Options longer than this will be cut off.
6
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.
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.
© 2014–present Juan Linietsky, Ariel Manzur and the Godot community
Licensed under the Creative Commons Attribution Unported License v3.0.
https://docs.godotengine.org/en/4.2/classes/class_codeedit.html