merge parts of script and text editor
This commit is contained in:
parent
98782b6c8c
commit
2363720b53
16 changed files with 2031 additions and 2637 deletions
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "editor/script/script_editor_base.h"
|
||||
#include "script_editor_plugin.h"
|
||||
|
||||
#include "editor/gui/code_editor.h"
|
||||
|
|
@ -54,40 +55,13 @@ public:
|
|||
ConnectionInfoDialog();
|
||||
};
|
||||
|
||||
class ScriptTextEditor : public ScriptEditorBase {
|
||||
GDCLASS(ScriptTextEditor, ScriptEditorBase);
|
||||
class ScriptTextEditor : public CodeEditorBase {
|
||||
GDCLASS(ScriptTextEditor, CodeEditorBase);
|
||||
|
||||
class EditMenusSTE : public HBoxContainer {
|
||||
GDCLASS(EditMenusSTE, HBoxContainer);
|
||||
MenuButton *edit_menu = nullptr;
|
||||
MenuButton *search_menu = nullptr;
|
||||
MenuButton *goto_menu = nullptr;
|
||||
PopupMenu *bookmarks_menu = nullptr;
|
||||
PopupMenu *breakpoints_menu = nullptr;
|
||||
PopupMenu *highlighter_menu = nullptr;
|
||||
|
||||
ScriptTextEditor *_get_active_editor();
|
||||
void _edit_option(int p_op);
|
||||
void _prepare_edit_menu();
|
||||
void _update_highlighter_menu();
|
||||
void _change_syntax_highlighter(int p_idx);
|
||||
void _update_bookmark_list();
|
||||
void _bookmark_item_pressed(int p_idx);
|
||||
void _update_breakpoint_list();
|
||||
void _breakpoint_item_pressed(int p_idx);
|
||||
|
||||
public:
|
||||
EditMenusSTE();
|
||||
};
|
||||
|
||||
CodeTextEditor *code_editor = nullptr;
|
||||
RichTextLabel *warnings_panel = nullptr;
|
||||
RichTextLabel *errors_panel = nullptr;
|
||||
|
||||
Ref<Script> script;
|
||||
Variant pending_state;
|
||||
bool script_is_valid = false;
|
||||
bool editor_enabled = false;
|
||||
|
||||
RichTextLabel *errors_panel = nullptr;
|
||||
|
||||
Vector<String> functions;
|
||||
List<ScriptLanguage::Warning> warnings;
|
||||
|
|
@ -97,9 +71,6 @@ class ScriptTextEditor : public ScriptEditorBase {
|
|||
|
||||
List<Connection> missing_connections;
|
||||
|
||||
static inline EditMenusSTE *edit_menus = nullptr;
|
||||
PopupMenu *context_menu = nullptr;
|
||||
|
||||
int inline_color_line = -1;
|
||||
int inline_color_start = -1;
|
||||
int inline_color_end = -1;
|
||||
|
|
@ -108,7 +79,6 @@ class ScriptTextEditor : public ScriptEditorBase {
|
|||
OptionButton *inline_color_options = nullptr;
|
||||
Ref<Texture2D> color_alpha_texture;
|
||||
|
||||
GotoLinePopup *goto_line_popup = nullptr;
|
||||
ScriptEditorQuickOpen *quick_open = nullptr;
|
||||
ConnectionInfoDialog *connection_info_dialog = nullptr;
|
||||
|
||||
|
|
@ -132,58 +102,21 @@ class ScriptTextEditor : public ScriptEditorBase {
|
|||
|
||||
bool theme_loaded = false;
|
||||
|
||||
LocalVector<Ref<EditorSyntaxHighlighter>> highlighters;
|
||||
|
||||
enum {
|
||||
EDIT_UNDO,
|
||||
EDIT_REDO,
|
||||
EDIT_CUT,
|
||||
EDIT_COPY,
|
||||
EDIT_PASTE,
|
||||
EDIT_SELECT_ALL,
|
||||
EDIT_COMPLETE,
|
||||
EDIT_AUTO_INDENT,
|
||||
EDIT_TRIM_TRAILING_WHITESAPCE,
|
||||
EDIT_TRIM_FINAL_NEWLINES,
|
||||
EDIT_CONVERT_INDENT_TO_SPACES,
|
||||
EDIT_CONVERT_INDENT_TO_TABS,
|
||||
EDIT_TOGGLE_COMMENT,
|
||||
EDIT_MOVE_LINE_UP,
|
||||
EDIT_MOVE_LINE_DOWN,
|
||||
EDIT_INDENT,
|
||||
EDIT_UNINDENT,
|
||||
EDIT_DELETE_LINE,
|
||||
EDIT_DUPLICATE_SELECTION,
|
||||
EDIT_DUPLICATE_LINES,
|
||||
EDIT_AUTO_INDENT = CODE_ENUM_COUNT,
|
||||
EDIT_PICK_COLOR,
|
||||
EDIT_TO_UPPERCASE,
|
||||
EDIT_TO_LOWERCASE,
|
||||
EDIT_CAPITALIZE,
|
||||
EDIT_EVALUATE,
|
||||
EDIT_TOGGLE_WORD_WRAP,
|
||||
EDIT_TOGGLE_FOLD_LINE,
|
||||
EDIT_FOLD_ALL_LINES,
|
||||
EDIT_CREATE_CODE_REGION,
|
||||
EDIT_UNFOLD_ALL_LINES,
|
||||
SEARCH_FIND,
|
||||
SEARCH_FIND_NEXT,
|
||||
SEARCH_FIND_PREV,
|
||||
SEARCH_REPLACE,
|
||||
|
||||
SEARCH_LOCATE_FUNCTION,
|
||||
SEARCH_GOTO_LINE,
|
||||
SEARCH_IN_FILES,
|
||||
REPLACE_IN_FILES,
|
||||
BOOKMARK_TOGGLE,
|
||||
BOOKMARK_GOTO_NEXT,
|
||||
BOOKMARK_GOTO_PREV,
|
||||
BOOKMARK_REMOVE_ALL,
|
||||
|
||||
DEBUG_TOGGLE_BREAKPOINT,
|
||||
DEBUG_REMOVE_ALL_BREAKPOINTS,
|
||||
DEBUG_GOTO_NEXT_BREAKPOINT,
|
||||
DEBUG_GOTO_PREV_BREAKPOINT,
|
||||
|
||||
HELP_CONTEXTUAL,
|
||||
LOOKUP_SYMBOL,
|
||||
EDIT_EMOJI_AND_SYMBOL,
|
||||
};
|
||||
|
||||
enum COLOR_MODE {
|
||||
|
|
@ -196,6 +129,17 @@ class ScriptTextEditor : public ScriptEditorBase {
|
|||
MODE_MAX
|
||||
};
|
||||
|
||||
class EditMenusSTE : public EditMenusCEB {
|
||||
GDCLASS(EditMenusSTE, EditMenusCEB);
|
||||
PopupMenu *breakpoints_menu = nullptr;
|
||||
|
||||
void _update_breakpoint_list();
|
||||
void _breakpoint_item_pressed(int p_idx);
|
||||
|
||||
public:
|
||||
EditMenusSTE();
|
||||
};
|
||||
|
||||
void _enable_code_editor();
|
||||
|
||||
struct DraggedExport {
|
||||
|
|
@ -210,24 +154,24 @@ class ScriptTextEditor : public ScriptEditorBase {
|
|||
String _get_dropped_resource_as_exported_member(const Ref<Resource> &p_resource, const Vector<ObjectID> &p_script_instance_obj_ids);
|
||||
void _assign_dragged_export_variables();
|
||||
|
||||
static ScriptEditorBase *create_editor(const Ref<Resource> &p_resource);
|
||||
|
||||
protected:
|
||||
void _breakpoint_toggled(int p_row);
|
||||
|
||||
void _on_caret_moved();
|
||||
|
||||
void _validate_script(); // No longer virtual.
|
||||
void _update_warnings();
|
||||
void _update_errors();
|
||||
|
||||
static void _code_complete_scripts(void *p_ud, const String &p_code, List<ScriptLanguage::CodeCompletionOption> *r_options, bool &r_force);
|
||||
void _code_complete_script(const String &p_code, List<ScriptLanguage::CodeCompletionOption> *r_options, bool &r_force);
|
||||
virtual void _code_complete_script(const String &p_code, List<ScriptLanguage::CodeCompletionOption> *r_options, bool &r_force) override;
|
||||
|
||||
void _load_theme_settings();
|
||||
void _set_theme_for_script();
|
||||
void _show_errors_panel(bool p_show);
|
||||
void _show_warnings_panel(bool p_show);
|
||||
void _error_clicked(const Variant &p_line);
|
||||
void _warning_clicked(const Variant &p_line);
|
||||
virtual bool _warning_clicked(const Variant &p_line) override;
|
||||
|
||||
bool _is_valid_color_info(const Dictionary &p_info);
|
||||
Array _inline_object_parse(const String &p_text);
|
||||
|
|
@ -241,82 +185,54 @@ protected:
|
|||
|
||||
void _notification(int p_what);
|
||||
|
||||
void _edit_option(int p_op);
|
||||
void _edit_option_toggle_inline_comment();
|
||||
void _make_context_menu(bool p_selection, bool p_color, bool p_foldable, bool p_open_docs, bool p_goto_definition, Vector2 p_pos);
|
||||
void _text_edit_gui_input(const Ref<InputEvent> &ev);
|
||||
void _color_changed(const Color &p_color);
|
||||
|
||||
void _goto_line(int p_line) { goto_line(p_line); }
|
||||
void _lookup_symbol(const String &p_symbol, int p_row, int p_column);
|
||||
void _validate_symbol(const String &p_symbol);
|
||||
|
||||
void _show_symbol_tooltip(const String &p_symbol, int p_row, int p_column);
|
||||
|
||||
void _convert_case(CodeTextEditor::CaseStyle p_case);
|
||||
|
||||
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
|
||||
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
|
||||
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
|
||||
|
||||
String _get_absolute_path(const String &rel_path);
|
||||
|
||||
void _goto_line(int p_line) { goto_line(p_line); }
|
||||
|
||||
void _make_context_menu(bool p_selection, bool p_color, bool p_foldable, bool p_open_docs, bool p_goto_definition, const Vector2 &p_pos);
|
||||
|
||||
virtual void _text_edit_gui_input(const Ref<InputEvent> &p_ev) override;
|
||||
virtual bool _edit_option(int p_op) override;
|
||||
|
||||
virtual void _load_theme_settings() override;
|
||||
virtual void _validate_script() override;
|
||||
|
||||
public:
|
||||
void _update_connected_methods();
|
||||
|
||||
virtual void add_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlighter) override;
|
||||
virtual void set_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlighter) override;
|
||||
void update_toggle_files_button() override;
|
||||
|
||||
virtual void apply_code() override;
|
||||
virtual Ref<Resource> get_edited_resource() const override;
|
||||
virtual void set_edited_resource(const Ref<Resource> &p_res) override;
|
||||
virtual void enable_editor() override;
|
||||
virtual Vector<String> get_functions() override;
|
||||
virtual void reload_text() override;
|
||||
virtual String get_name() override;
|
||||
|
||||
virtual Control *get_edit_menu() override;
|
||||
|
||||
virtual Ref<Texture2D> get_theme_icon() override;
|
||||
virtual bool is_unsaved() override;
|
||||
|
||||
virtual Variant get_edit_state() override;
|
||||
virtual void set_edit_state(const Variant &p_state) override;
|
||||
virtual Variant get_navigation_state() override;
|
||||
virtual void ensure_focus() override;
|
||||
virtual void trim_trailing_whitespace() override;
|
||||
virtual void trim_final_newlines() override;
|
||||
virtual void insert_final_newline() override;
|
||||
virtual void convert_indent() override;
|
||||
virtual void tag_saved_version() override;
|
||||
|
||||
virtual void goto_line(int p_line, int p_column = 0) override;
|
||||
void goto_line_selection(int p_line, int p_begin, int p_end);
|
||||
void goto_line_centered(int p_line, int p_column = 0);
|
||||
virtual void set_executing_line(int p_line) override;
|
||||
virtual void clear_executing_line() override;
|
||||
|
||||
virtual void reload(bool p_soft) override;
|
||||
virtual PackedInt32Array get_breakpoints() override;
|
||||
virtual void set_breakpoint(int p_line, bool p_enabled) override;
|
||||
virtual void clear_breakpoints() override;
|
||||
|
||||
virtual void add_callback(const String &p_function, const PackedStringArray &p_args) override;
|
||||
virtual void add_callback(const String &p_function, const PackedStringArray &p_args);
|
||||
virtual void update_settings() override;
|
||||
|
||||
virtual bool show_members_overview() override;
|
||||
|
||||
virtual void set_tooltip_request_func(const Callable &p_toolip_callback) override;
|
||||
|
||||
virtual void set_debugger_active(bool p_active) override;
|
||||
|
||||
virtual Control *get_edit_menu() override;
|
||||
virtual void set_find_replace_bar(FindReplaceBar *p_bar) override;
|
||||
|
||||
static void register_editor();
|
||||
|
||||
virtual Control *get_base_editor() const override;
|
||||
virtual CodeTextEditor *get_code_editor() const override;
|
||||
|
||||
virtual void validate() override;
|
||||
|
||||
Variant get_previous_state();
|
||||
void store_previous_state();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue