2020-07-24 14:50:35 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
/* code_edit.h */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/**************************************************************************/
|
|
|
|
|
2022-07-23 21:41:51 +00:00
|
|
|
#ifndef CODE_EDIT_H
|
|
|
|
#define CODE_EDIT_H
|
2020-07-24 14:50:35 +00:00
|
|
|
|
2023-09-06 19:02:52 +00:00
|
|
|
#include "core/object/script_language.h"
|
2020-07-24 14:50:35 +00:00
|
|
|
#include "scene/gui/text_edit.h"
|
|
|
|
|
|
|
|
class CodeEdit : public TextEdit {
|
|
|
|
GDCLASS(CodeEdit, TextEdit)
|
|
|
|
|
2020-09-13 20:14:20 +00:00
|
|
|
public:
|
2023-05-23 03:12:34 +00:00
|
|
|
// Keep enums in sync with:
|
|
|
|
// core/object/script_language.h - ScriptLanguage::CodeCompletionKind
|
2020-09-13 20:14:20 +00:00
|
|
|
enum CodeCompletionKind {
|
|
|
|
KIND_CLASS,
|
|
|
|
KIND_FUNCTION,
|
|
|
|
KIND_SIGNAL,
|
|
|
|
KIND_VARIABLE,
|
|
|
|
KIND_MEMBER,
|
|
|
|
KIND_ENUM,
|
|
|
|
KIND_CONSTANT,
|
|
|
|
KIND_NODE_PATH,
|
|
|
|
KIND_FILE_PATH,
|
|
|
|
KIND_PLAIN_TEXT,
|
|
|
|
};
|
|
|
|
|
2023-05-23 03:12:34 +00:00
|
|
|
// core/object/script_language.h - ScriptLanguage::CodeCompletionLocation
|
|
|
|
enum CodeCompletionLocation {
|
|
|
|
LOCATION_LOCAL = 0,
|
|
|
|
LOCATION_PARENT_MASK = 1 << 8,
|
|
|
|
LOCATION_OTHER_USER_CODE = 1 << 9,
|
|
|
|
LOCATION_OTHER = 1 << 10,
|
|
|
|
};
|
|
|
|
|
2020-07-24 14:50:35 +00:00
|
|
|
private:
|
2021-06-15 14:05:01 +00:00
|
|
|
/* Indent management */
|
|
|
|
int indent_size = 4;
|
|
|
|
String indent_text = "\t";
|
|
|
|
|
|
|
|
bool auto_indent = false;
|
2022-05-19 15:00:06 +00:00
|
|
|
HashSet<char32_t> auto_indent_prefixes;
|
2021-06-15 14:05:01 +00:00
|
|
|
|
|
|
|
bool indent_using_spaces = false;
|
|
|
|
int _calculate_spaces_till_next_left_indent(int p_column) const;
|
|
|
|
int _calculate_spaces_till_next_right_indent(int p_column) const;
|
|
|
|
|
|
|
|
void _new_line(bool p_split_current_line = true, bool p_above = false);
|
|
|
|
|
2021-06-28 16:14:44 +00:00
|
|
|
/* Auto brace completion */
|
|
|
|
bool auto_brace_completion_enabled = false;
|
|
|
|
|
|
|
|
/* BracePair open_key must be uniquie and ordered by length. */
|
|
|
|
struct BracePair {
|
|
|
|
String open_key = "";
|
|
|
|
String close_key = "";
|
|
|
|
};
|
|
|
|
Vector<BracePair> auto_brace_completion_pairs;
|
|
|
|
|
|
|
|
int _get_auto_brace_pair_open_at_pos(int p_line, int p_col);
|
|
|
|
int _get_auto_brace_pair_close_at_pos(int p_line, int p_col);
|
|
|
|
|
2020-07-26 14:57:23 +00:00
|
|
|
/* Main Gutter */
|
|
|
|
enum MainGutterType {
|
|
|
|
MAIN_GUTTER_BREAKPOINT = 0x01,
|
|
|
|
MAIN_GUTTER_BOOKMARK = 0x02,
|
|
|
|
MAIN_GUTTER_EXECUTING = 0x04
|
|
|
|
};
|
|
|
|
|
|
|
|
int main_gutter = -1;
|
|
|
|
void _update_draw_main_gutter();
|
|
|
|
void _main_gutter_draw_callback(int p_line, int p_gutter, const Rect2 &p_region);
|
|
|
|
|
|
|
|
// breakpoints
|
|
|
|
HashMap<int, bool> breakpointed_lines;
|
|
|
|
bool draw_breakpoints = false;
|
|
|
|
|
|
|
|
// bookmarks
|
|
|
|
bool draw_bookmarks = false;
|
|
|
|
|
|
|
|
// executing lines
|
|
|
|
bool draw_executing_lines = false;
|
2020-07-25 17:27:35 +00:00
|
|
|
|
|
|
|
/* Line numbers */
|
|
|
|
int line_number_gutter = -1;
|
2023-03-07 09:53:46 +00:00
|
|
|
int line_number_digits = 1;
|
2020-07-25 17:27:35 +00:00
|
|
|
String line_number_padding = " ";
|
|
|
|
void _line_number_draw_callback(int p_line, int p_gutter, const Rect2 &p_region);
|
|
|
|
|
2020-07-27 12:54:12 +00:00
|
|
|
/* Fold Gutter */
|
|
|
|
int fold_gutter = -1;
|
|
|
|
bool draw_fold_gutter = false;
|
|
|
|
void _fold_gutter_draw_callback(int p_line, int p_gutter, Rect2 p_region);
|
|
|
|
|
2020-07-25 17:27:35 +00:00
|
|
|
void _gutter_clicked(int p_line, int p_gutter);
|
|
|
|
void _update_gutter_indexes();
|
|
|
|
|
2021-03-13 14:09:49 +00:00
|
|
|
/* Line Folding */
|
2021-07-01 16:40:59 +00:00
|
|
|
bool line_folding_enabled = false;
|
2023-03-12 16:48:37 +00:00
|
|
|
String code_region_start_string;
|
|
|
|
String code_region_end_string;
|
|
|
|
String code_region_start_tag = "region";
|
|
|
|
String code_region_end_tag = "endregion";
|
|
|
|
void _update_code_region_tags();
|
2021-03-13 14:09:49 +00:00
|
|
|
|
2020-09-10 20:25:40 +00:00
|
|
|
/* Delimiters */
|
|
|
|
enum DelimiterType {
|
|
|
|
TYPE_STRING,
|
|
|
|
TYPE_COMMENT,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Delimiter {
|
|
|
|
DelimiterType type;
|
|
|
|
String start_key = "";
|
|
|
|
String end_key = "";
|
|
|
|
bool line_only = true;
|
|
|
|
};
|
|
|
|
bool setting_delimiters = false;
|
|
|
|
Vector<Delimiter> delimiters;
|
|
|
|
/*
|
|
|
|
* Vector entry per line, contains a Map of column numbers to delimiter index, -1 marks the end of a region.
|
|
|
|
* e.g the following text will be stored as so:
|
|
|
|
*
|
|
|
|
* 0: nothing here
|
|
|
|
* 1:
|
|
|
|
* 2: # test
|
|
|
|
* 3: "test" text "multiline
|
|
|
|
* 4:
|
|
|
|
* 5: test
|
|
|
|
* 6: string"
|
|
|
|
*
|
|
|
|
* Vector [
|
|
|
|
* 0 = []
|
|
|
|
* 1 = []
|
|
|
|
* 2 = [
|
|
|
|
* 1 = 1
|
|
|
|
* 6 = -1
|
|
|
|
* ]
|
|
|
|
* 3 = [
|
|
|
|
* 1 = 0
|
|
|
|
* 6 = -1
|
|
|
|
* 13 = 0
|
|
|
|
* ]
|
|
|
|
* 4 = [
|
|
|
|
* 0 = 0
|
|
|
|
* ]
|
|
|
|
* 5 = [
|
|
|
|
* 5 = 0
|
|
|
|
* ]
|
|
|
|
* 6 = [
|
|
|
|
* 7 = -1
|
|
|
|
* ]
|
|
|
|
* ]
|
|
|
|
*/
|
2022-05-13 13:04:37 +00:00
|
|
|
Vector<RBMap<int, int>> delimiter_cache;
|
2020-09-10 20:25:40 +00:00
|
|
|
|
|
|
|
void _update_delimiter_cache(int p_from_line = 0, int p_to_line = -1);
|
|
|
|
int _is_in_delimiter(int p_line, int p_column, DelimiterType p_type) const;
|
|
|
|
|
|
|
|
void _add_delimiter(const String &p_start_key, const String &p_end_key, bool p_line_only, DelimiterType p_type);
|
|
|
|
void _remove_delimiter(const String &p_start_key, DelimiterType p_type);
|
|
|
|
bool _has_delimiter(const String &p_start_key, DelimiterType p_type) const;
|
|
|
|
|
|
|
|
void _set_delimiters(const TypedArray<String> &p_delimiters, DelimiterType p_type);
|
|
|
|
void _clear_delimiters(DelimiterType p_type);
|
|
|
|
TypedArray<String> _get_delimiters(DelimiterType p_type) const;
|
|
|
|
|
2020-09-18 19:45:47 +00:00
|
|
|
/* Code Hint */
|
|
|
|
String code_hint = "";
|
|
|
|
|
|
|
|
bool code_hint_draw_below = true;
|
|
|
|
int code_hint_xpos = -0xFFFF;
|
|
|
|
|
2020-09-13 20:14:20 +00:00
|
|
|
/* Code Completion */
|
|
|
|
bool code_completion_enabled = false;
|
|
|
|
bool code_completion_forced = false;
|
|
|
|
|
|
|
|
bool code_completion_active = false;
|
2022-06-27 09:27:17 +00:00
|
|
|
bool is_code_completion_scroll_hovered = false;
|
|
|
|
bool is_code_completion_scroll_pressed = false;
|
2023-03-09 13:56:52 +00:00
|
|
|
bool is_code_completion_drag_started = false;
|
2022-03-26 15:48:43 +00:00
|
|
|
Vector<ScriptLanguage::CodeCompletionOption> code_completion_options;
|
2020-09-13 20:14:20 +00:00
|
|
|
int code_completion_line_ofs = 0;
|
|
|
|
int code_completion_current_selected = 0;
|
2022-10-28 23:22:28 +00:00
|
|
|
int code_completion_force_item_center = -1;
|
2020-09-13 20:14:20 +00:00
|
|
|
int code_completion_longest_line = 0;
|
|
|
|
Rect2i code_completion_rect;
|
2022-06-27 09:27:17 +00:00
|
|
|
Rect2i code_completion_scroll_rect;
|
2024-07-14 20:30:58 +00:00
|
|
|
float code_completion_pan_offset = 0.0f;
|
2020-09-13 20:14:20 +00:00
|
|
|
|
2022-05-19 15:00:06 +00:00
|
|
|
HashSet<char32_t> code_completion_prefixes;
|
2022-03-26 15:48:43 +00:00
|
|
|
List<ScriptLanguage::CodeCompletionOption> code_completion_option_submitted;
|
|
|
|
List<ScriptLanguage::CodeCompletionOption> code_completion_option_sources;
|
2020-09-13 20:14:20 +00:00
|
|
|
String code_completion_base;
|
|
|
|
|
2022-06-27 09:27:17 +00:00
|
|
|
void _update_scroll_selected_line(float p_mouse_y);
|
2021-08-22 01:52:44 +00:00
|
|
|
void _filter_code_completion_candidates_impl();
|
2023-09-14 02:30:48 +00:00
|
|
|
bool _should_reset_selected_option_for_new_options(const Vector<ScriptLanguage::CodeCompletionOption> &p_new_options);
|
2020-09-13 20:14:20 +00:00
|
|
|
|
2021-06-30 17:03:32 +00:00
|
|
|
/* Line length guidelines */
|
|
|
|
TypedArray<int> line_length_guideline_columns;
|
|
|
|
|
2021-07-01 16:10:54 +00:00
|
|
|
/* Symbol lookup */
|
|
|
|
bool symbol_lookup_on_click_enabled = false;
|
|
|
|
|
|
|
|
String symbol_lookup_new_word = "";
|
|
|
|
String symbol_lookup_word = "";
|
2022-10-09 09:17:10 +00:00
|
|
|
Point2i symbol_lookup_pos;
|
2021-07-01 16:10:54 +00:00
|
|
|
|
2021-07-10 10:41:38 +00:00
|
|
|
/* Visual */
|
2023-04-03 16:01:10 +00:00
|
|
|
struct ThemeCache {
|
|
|
|
/* Gutters */
|
|
|
|
Color code_folding_color = Color(1, 1, 1);
|
2023-03-12 16:48:37 +00:00
|
|
|
Color folded_code_region_color = Color(1, 1, 1);
|
2023-04-03 16:01:10 +00:00
|
|
|
Ref<Texture2D> can_fold_icon;
|
|
|
|
Ref<Texture2D> folded_icon;
|
2023-03-12 16:48:37 +00:00
|
|
|
Ref<Texture2D> can_fold_code_region_icon;
|
|
|
|
Ref<Texture2D> folded_code_region_icon;
|
2023-04-03 16:01:10 +00:00
|
|
|
Ref<Texture2D> folded_eol_icon;
|
2024-08-08 15:46:41 +00:00
|
|
|
Ref<Texture2D> completion_color_bg;
|
2023-04-03 16:01:10 +00:00
|
|
|
|
|
|
|
Color breakpoint_color = Color(1, 1, 1);
|
|
|
|
Ref<Texture2D> breakpoint_icon = Ref<Texture2D>();
|
|
|
|
|
|
|
|
Color bookmark_color = Color(1, 1, 1);
|
|
|
|
Ref<Texture2D> bookmark_icon = Ref<Texture2D>();
|
|
|
|
|
|
|
|
Color executing_line_color = Color(1, 1, 1);
|
|
|
|
Ref<Texture2D> executing_line_icon = Ref<Texture2D>();
|
|
|
|
|
|
|
|
Color line_number_color = Color(1, 1, 1);
|
|
|
|
|
|
|
|
/* Code Completion */
|
|
|
|
Ref<StyleBox> code_completion_style;
|
|
|
|
int code_completion_icon_separation = 0;
|
2021-07-10 10:41:38 +00:00
|
|
|
|
2023-04-03 16:01:10 +00:00
|
|
|
int code_completion_max_width = 0;
|
|
|
|
int code_completion_max_lines = 7;
|
|
|
|
int code_completion_scroll_width = 0;
|
|
|
|
Color code_completion_scroll_color = Color(0, 0, 0, 0);
|
|
|
|
Color code_completion_scroll_hovered_color = Color(0, 0, 0, 0);
|
|
|
|
Color code_completion_background_color = Color(0, 0, 0, 0);
|
|
|
|
Color code_completion_selected_color = Color(0, 0, 0, 0);
|
|
|
|
Color code_completion_existing_color = Color(0, 0, 0, 0);
|
2021-07-10 10:41:38 +00:00
|
|
|
|
2023-04-03 16:01:10 +00:00
|
|
|
/* Code hint */
|
|
|
|
Ref<StyleBox> code_hint_style;
|
|
|
|
Color code_hint_color;
|
|
|
|
|
|
|
|
/* Line length guideline */
|
|
|
|
Color line_length_guideline_color;
|
|
|
|
|
|
|
|
/* Other visuals */
|
|
|
|
Ref<StyleBox> style_normal;
|
|
|
|
|
2023-09-12 13:01:42 +00:00
|
|
|
Color brace_mismatch_color;
|
|
|
|
|
2023-04-03 16:01:10 +00:00
|
|
|
Ref<Font> font;
|
|
|
|
int font_size = 16;
|
|
|
|
int line_spacing = 1;
|
|
|
|
} theme_cache;
|
2021-07-10 10:41:38 +00:00
|
|
|
|
2023-09-12 13:01:42 +00:00
|
|
|
virtual Color _get_brace_mismatch_color() const override;
|
|
|
|
virtual Color _get_code_folding_color() const override;
|
|
|
|
virtual Ref<Texture2D> _get_folded_eol_icon() const override;
|
|
|
|
|
2021-07-11 16:07:29 +00:00
|
|
|
/* Callbacks */
|
2021-10-06 12:12:04 +00:00
|
|
|
int lines_edited_changed = 0;
|
2021-07-11 16:07:29 +00:00
|
|
|
int lines_edited_from = -1;
|
|
|
|
int lines_edited_to = -1;
|
|
|
|
|
|
|
|
void _lines_edited_from(int p_from_line, int p_to_line);
|
|
|
|
void _text_set();
|
|
|
|
void _text_changed();
|
|
|
|
|
2020-07-24 14:50:35 +00:00
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2023-08-02 12:45:44 +00:00
|
|
|
#ifndef DISABLE_DEPRECATED
|
|
|
|
String _get_text_for_symbol_lookup_bind_compat_73196();
|
2024-01-30 20:03:28 +00:00
|
|
|
void _add_code_completion_option_compat_84906(CodeCompletionKind p_type, const String &p_display_text, const String &p_insert_text, const Color &p_text_color = Color(1, 1, 1), const Ref<Resource> &p_icon = Ref<Resource>(), const Variant &p_value = Variant::NIL, int p_location = LOCATION_OTHER);
|
2023-08-02 12:45:44 +00:00
|
|
|
static void _bind_compatibility_methods();
|
|
|
|
#endif
|
|
|
|
|
2024-01-22 23:26:16 +00:00
|
|
|
virtual void _unhide_carets() override;
|
|
|
|
|
2021-07-08 15:48:58 +00:00
|
|
|
/* Text manipulation */
|
|
|
|
|
|
|
|
// Overridable actions
|
2022-06-03 16:47:37 +00:00
|
|
|
virtual void _handle_unicode_input_internal(const uint32_t p_unicode, int p_caret) override;
|
|
|
|
virtual void _backspace_internal(int p_caret) override;
|
2024-01-22 23:27:19 +00:00
|
|
|
virtual void _cut_internal(int p_caret) override;
|
2021-08-22 01:52:44 +00:00
|
|
|
|
|
|
|
GDVIRTUAL1(_confirm_code_completion, bool)
|
|
|
|
GDVIRTUAL1(_request_code_completion, bool)
|
2022-08-05 01:41:48 +00:00
|
|
|
GDVIRTUAL1RC(TypedArray<Dictionary>, _filter_code_completion_candidates, TypedArray<Dictionary>)
|
2021-07-08 15:48:58 +00:00
|
|
|
|
2020-07-24 14:50:35 +00:00
|
|
|
public:
|
2021-06-28 16:14:44 +00:00
|
|
|
/* General overrides */
|
2021-07-05 17:21:13 +00:00
|
|
|
virtual void gui_input(const Ref<InputEvent> &p_gui_input) override;
|
2020-09-13 20:14:20 +00:00
|
|
|
virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const override;
|
|
|
|
|
2021-06-15 14:05:01 +00:00
|
|
|
/* Indent management */
|
|
|
|
void set_indent_size(const int p_size);
|
|
|
|
int get_indent_size() const;
|
|
|
|
|
|
|
|
void set_indent_using_spaces(const bool p_use_spaces);
|
|
|
|
bool is_indent_using_spaces() const;
|
|
|
|
|
|
|
|
void set_auto_indent_enabled(bool p_enabled);
|
|
|
|
bool is_auto_indent_enabled() const;
|
|
|
|
|
|
|
|
void set_auto_indent_prefixes(const TypedArray<String> &p_prefixes);
|
|
|
|
TypedArray<String> get_auto_indent_prefixes() const;
|
|
|
|
|
|
|
|
void do_indent();
|
|
|
|
|
|
|
|
void indent_lines();
|
|
|
|
void unindent_lines();
|
|
|
|
|
2023-05-01 20:41:50 +00:00
|
|
|
void convert_indent(int p_from_line = -1, int p_to_line = -1);
|
|
|
|
|
2021-06-28 16:14:44 +00:00
|
|
|
/* Auto brace completion */
|
|
|
|
void set_auto_brace_completion_enabled(bool p_enabled);
|
|
|
|
bool is_auto_brace_completion_enabled() const;
|
|
|
|
|
2021-06-30 10:58:13 +00:00
|
|
|
void set_highlight_matching_braces_enabled(bool p_enabled);
|
|
|
|
bool is_highlight_matching_braces_enabled() const;
|
|
|
|
|
2021-06-28 16:14:44 +00:00
|
|
|
void add_auto_brace_completion_pair(const String &p_open_key, const String &p_close_key);
|
|
|
|
void set_auto_brace_completion_pairs(const Dictionary &p_auto_brace_completion_pairs);
|
|
|
|
Dictionary get_auto_brace_completion_pairs() const;
|
|
|
|
|
|
|
|
bool has_auto_brace_completion_open_key(const String &p_open_key) const;
|
|
|
|
bool has_auto_brace_completion_close_key(const String &p_close_key) const;
|
|
|
|
|
|
|
|
String get_auto_brace_completion_close_key(const String &p_open_key) const;
|
|
|
|
|
2020-07-26 14:57:23 +00:00
|
|
|
/* Main Gutter */
|
|
|
|
void set_draw_breakpoints_gutter(bool p_draw);
|
|
|
|
bool is_drawing_breakpoints_gutter() const;
|
|
|
|
|
|
|
|
void set_draw_bookmarks_gutter(bool p_draw);
|
|
|
|
bool is_drawing_bookmarks_gutter() const;
|
|
|
|
|
|
|
|
void set_draw_executing_lines_gutter(bool p_draw);
|
|
|
|
bool is_drawing_executing_lines_gutter() const;
|
|
|
|
|
|
|
|
// breakpoints
|
|
|
|
void set_line_as_breakpoint(int p_line, bool p_breakpointed);
|
|
|
|
bool is_line_breakpointed(int p_line) const;
|
|
|
|
void clear_breakpointed_lines();
|
2022-08-05 01:41:48 +00:00
|
|
|
PackedInt32Array get_breakpointed_lines() const;
|
2020-07-26 14:57:23 +00:00
|
|
|
|
|
|
|
// bookmarks
|
|
|
|
void set_line_as_bookmarked(int p_line, bool p_bookmarked);
|
|
|
|
bool is_line_bookmarked(int p_line) const;
|
|
|
|
void clear_bookmarked_lines();
|
2022-08-05 01:41:48 +00:00
|
|
|
PackedInt32Array get_bookmarked_lines() const;
|
2020-07-26 14:57:23 +00:00
|
|
|
|
|
|
|
// executing lines
|
|
|
|
void set_line_as_executing(int p_line, bool p_executing);
|
|
|
|
bool is_line_executing(int p_line) const;
|
|
|
|
void clear_executing_lines();
|
2022-08-05 01:41:48 +00:00
|
|
|
PackedInt32Array get_executing_lines() const;
|
2020-07-26 14:57:23 +00:00
|
|
|
|
2020-07-25 17:27:35 +00:00
|
|
|
/* Line numbers */
|
|
|
|
void set_draw_line_numbers(bool p_draw);
|
|
|
|
bool is_draw_line_numbers_enabled() const;
|
|
|
|
void set_line_numbers_zero_padded(bool p_zero_padded);
|
|
|
|
bool is_line_numbers_zero_padded() const;
|
|
|
|
|
2020-07-27 12:54:12 +00:00
|
|
|
/* Fold gutter */
|
|
|
|
void set_draw_fold_gutter(bool p_draw);
|
|
|
|
bool is_drawing_fold_gutter() const;
|
|
|
|
|
2021-03-13 14:09:49 +00:00
|
|
|
/* Line Folding */
|
|
|
|
void set_line_folding_enabled(bool p_enabled);
|
|
|
|
bool is_line_folding_enabled() const;
|
|
|
|
|
|
|
|
bool can_fold_line(int p_line) const;
|
|
|
|
|
|
|
|
void fold_line(int p_line);
|
|
|
|
void unfold_line(int p_line);
|
|
|
|
void fold_all_lines();
|
|
|
|
void unfold_all_lines();
|
|
|
|
void toggle_foldable_line(int p_line);
|
2024-01-22 23:27:19 +00:00
|
|
|
void toggle_foldable_lines_at_carets();
|
2021-03-13 14:09:49 +00:00
|
|
|
|
|
|
|
bool is_line_folded(int p_line) const;
|
|
|
|
TypedArray<int> get_folded_lines() const;
|
|
|
|
|
2023-03-12 16:48:37 +00:00
|
|
|
/* Code region */
|
|
|
|
void create_code_region();
|
|
|
|
String get_code_region_start_tag() const;
|
|
|
|
String get_code_region_end_tag() const;
|
|
|
|
void set_code_region_tags(const String &p_start = "region", const String &p_end = "endregion");
|
|
|
|
bool is_line_code_region_start(int p_line) const;
|
|
|
|
bool is_line_code_region_end(int p_line) const;
|
|
|
|
|
2020-09-10 20:25:40 +00:00
|
|
|
/* Delimiters */
|
|
|
|
void add_string_delimiter(const String &p_start_key, const String &p_end_key, bool p_line_only = false);
|
|
|
|
void remove_string_delimiter(const String &p_start_key);
|
|
|
|
bool has_string_delimiter(const String &p_start_key) const;
|
|
|
|
|
|
|
|
void set_string_delimiters(const TypedArray<String> &p_string_delimiters);
|
|
|
|
void clear_string_delimiters();
|
|
|
|
TypedArray<String> get_string_delimiters() const;
|
|
|
|
|
|
|
|
int is_in_string(int p_line, int p_column = -1) const;
|
|
|
|
|
|
|
|
void add_comment_delimiter(const String &p_start_key, const String &p_end_key, bool p_line_only = false);
|
|
|
|
void remove_comment_delimiter(const String &p_start_key);
|
|
|
|
bool has_comment_delimiter(const String &p_start_key) const;
|
|
|
|
|
|
|
|
void set_comment_delimiters(const TypedArray<String> &p_comment_delimiters);
|
|
|
|
void clear_comment_delimiters();
|
|
|
|
TypedArray<String> get_comment_delimiters() const;
|
|
|
|
|
|
|
|
int is_in_comment(int p_line, int p_column = -1) const;
|
|
|
|
|
|
|
|
String get_delimiter_start_key(int p_delimiter_idx) const;
|
|
|
|
String get_delimiter_end_key(int p_delimiter_idx) const;
|
|
|
|
|
|
|
|
Point2 get_delimiter_start_position(int p_line, int p_column) const;
|
|
|
|
Point2 get_delimiter_end_position(int p_line, int p_column) const;
|
|
|
|
|
2020-09-18 19:45:47 +00:00
|
|
|
/* Code hint */
|
|
|
|
void set_code_hint(const String &p_hint);
|
|
|
|
void set_code_hint_draw_below(bool p_below);
|
|
|
|
|
2020-09-13 20:14:20 +00:00
|
|
|
/* Code Completion */
|
|
|
|
void set_code_completion_enabled(bool p_enable);
|
|
|
|
bool is_code_completion_enabled() const;
|
|
|
|
|
|
|
|
void set_code_completion_prefixes(const TypedArray<String> &p_prefixes);
|
|
|
|
TypedArray<String> get_code_completion_prefixes() const;
|
|
|
|
|
|
|
|
String get_text_for_code_completion() const;
|
|
|
|
|
|
|
|
void request_code_completion(bool p_force = false);
|
|
|
|
|
2024-01-30 20:03:28 +00:00
|
|
|
void add_code_completion_option(CodeCompletionKind p_type, const String &p_display_text, const String &p_insert_text, const Color &p_text_color = Color(1, 1, 1), const Ref<Resource> &p_icon = Ref<Resource>(), const Variant &p_value = Variant(), int p_location = LOCATION_OTHER);
|
2020-09-13 20:14:20 +00:00
|
|
|
void update_code_completion_options(bool p_forced = false);
|
|
|
|
|
|
|
|
TypedArray<Dictionary> get_code_completion_options() const;
|
|
|
|
Dictionary get_code_completion_option(int p_index) const;
|
|
|
|
|
|
|
|
int get_code_completion_selected_index() const;
|
|
|
|
void set_code_completion_selected_index(int p_index);
|
|
|
|
|
|
|
|
void confirm_code_completion(bool p_replace = false);
|
|
|
|
void cancel_code_completion();
|
|
|
|
|
2021-06-30 17:03:32 +00:00
|
|
|
/* Line length guidelines */
|
|
|
|
void set_line_length_guidelines(TypedArray<int> p_guideline_columns);
|
|
|
|
TypedArray<int> get_line_length_guidelines() const;
|
|
|
|
|
2021-07-01 16:10:54 +00:00
|
|
|
/* Symbol lookup */
|
|
|
|
void set_symbol_lookup_on_click_enabled(bool p_enabled);
|
|
|
|
bool is_symbol_lookup_on_click_enabled() const;
|
|
|
|
|
2023-02-13 04:33:10 +00:00
|
|
|
String get_text_for_symbol_lookup() const;
|
|
|
|
String get_text_with_cursor_char(int p_line, int p_column) const;
|
2021-07-01 16:10:54 +00:00
|
|
|
|
|
|
|
void set_symbol_lookup_word_as_valid(bool p_valid);
|
|
|
|
|
2022-09-28 15:09:45 +00:00
|
|
|
/* Text manipulation */
|
2024-01-22 23:27:19 +00:00
|
|
|
void move_lines_up();
|
|
|
|
void move_lines_down();
|
|
|
|
void delete_lines();
|
|
|
|
void duplicate_selection();
|
2022-09-28 15:09:45 +00:00
|
|
|
void duplicate_lines();
|
|
|
|
|
2020-07-24 14:50:35 +00:00
|
|
|
CodeEdit();
|
|
|
|
~CodeEdit();
|
|
|
|
};
|
|
|
|
|
2020-09-13 20:14:20 +00:00
|
|
|
VARIANT_ENUM_CAST(CodeEdit::CodeCompletionKind);
|
2023-05-23 03:12:34 +00:00
|
|
|
VARIANT_ENUM_CAST(CodeEdit::CodeCompletionLocation);
|
|
|
|
|
|
|
|
// The custom comparer which will sort completion options.
|
|
|
|
struct CodeCompletionOptionCompare {
|
|
|
|
_FORCE_INLINE_ bool operator()(const ScriptLanguage::CodeCompletionOption &l, const ScriptLanguage::CodeCompletionOption &r) const;
|
|
|
|
};
|
2020-09-13 20:14:20 +00:00
|
|
|
|
2022-07-23 21:41:51 +00:00
|
|
|
#endif // CODE_EDIT_H
|