2014-02-10 09:10:30 +08:00
|
|
|
/*************************************************************************/
|
|
|
|
/* script_editor_plugin.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 20:16:55 +08:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 09:10:30 +08:00
|
|
|
/*************************************************************************/
|
2021-01-02 03:13:46 +08:00
|
|
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
2014-02-10 09:10:30 +08:00
|
|
|
/* */
|
|
|
|
/* 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. */
|
|
|
|
/*************************************************************************/
|
2018-01-05 07:50:27 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
#ifndef SCRIPT_EDITOR_PLUGIN_H
|
|
|
|
#define SCRIPT_EDITOR_PLUGIN_H
|
|
|
|
|
2020-11-08 06:33:38 +08:00
|
|
|
#include "core/object/script_language.h"
|
2017-03-05 23:44:50 +08:00
|
|
|
#include "editor/code_editor.h"
|
|
|
|
#include "editor/editor_help.h"
|
2017-12-11 07:56:49 +08:00
|
|
|
#include "editor/editor_help_search.h"
|
2017-03-05 21:21:25 +08:00
|
|
|
#include "editor/editor_plugin.h"
|
|
|
|
#include "editor/script_create_dialog.h"
|
2017-03-05 23:44:50 +08:00
|
|
|
#include "scene/gui/item_list.h"
|
2019-06-04 03:57:06 +08:00
|
|
|
#include "scene/gui/line_edit.h"
|
2017-03-05 23:44:50 +08:00
|
|
|
#include "scene/gui/menu_button.h"
|
|
|
|
#include "scene/gui/split_container.h"
|
2014-02-10 09:10:30 +08:00
|
|
|
#include "scene/gui/tab_container.h"
|
|
|
|
#include "scene/gui/text_edit.h"
|
|
|
|
#include "scene/gui/tree.h"
|
|
|
|
#include "scene/main/timer.h"
|
2018-05-28 23:52:28 +08:00
|
|
|
#include "scene/resources/text_file.h"
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2020-05-04 00:08:15 +08:00
|
|
|
class EditorSyntaxHighlighter : public SyntaxHighlighter {
|
|
|
|
GDCLASS(EditorSyntaxHighlighter, SyntaxHighlighter)
|
|
|
|
|
|
|
|
private:
|
|
|
|
REF edited_resourse;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual String _get_name() const;
|
|
|
|
virtual Array _get_supported_languages() const;
|
|
|
|
|
|
|
|
void _set_edited_resource(const RES &p_res) { edited_resourse = p_res; }
|
|
|
|
REF _get_edited_resource() { return edited_resourse; }
|
|
|
|
|
|
|
|
virtual Ref<EditorSyntaxHighlighter> _create() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
class EditorStandardSyntaxHighlighter : public EditorSyntaxHighlighter {
|
|
|
|
GDCLASS(EditorStandardSyntaxHighlighter, EditorSyntaxHighlighter)
|
|
|
|
|
|
|
|
private:
|
|
|
|
Ref<CodeHighlighter> highlighter;
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual void _update_cache() override;
|
|
|
|
virtual Dictionary _get_line_syntax_highlighting(int p_line) override { return highlighter->get_line_syntax_highlighting(p_line); }
|
|
|
|
|
|
|
|
virtual String _get_name() const override { return TTR("Standard"); }
|
|
|
|
|
|
|
|
virtual Ref<EditorSyntaxHighlighter> _create() const override;
|
|
|
|
|
2021-06-18 06:03:09 +08:00
|
|
|
EditorStandardSyntaxHighlighter() { highlighter.instantiate(); }
|
2020-05-04 00:08:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class EditorPlainTextSyntaxHighlighter : public EditorSyntaxHighlighter {
|
|
|
|
GDCLASS(EditorPlainTextSyntaxHighlighter, EditorSyntaxHighlighter)
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual String _get_name() const override { return TTR("Plain Text"); }
|
|
|
|
|
|
|
|
virtual Ref<EditorSyntaxHighlighter> _create() const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
class ScriptEditorQuickOpen : public ConfirmationDialog {
|
2019-03-20 02:35:57 +08:00
|
|
|
GDCLASS(ScriptEditorQuickOpen, ConfirmationDialog);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
LineEdit *search_box;
|
|
|
|
Tree *search_options;
|
|
|
|
String function;
|
|
|
|
|
|
|
|
void _update_search();
|
|
|
|
|
2017-05-20 23:38:03 +08:00
|
|
|
void _sbox_input(const Ref<InputEvent> &p_ie);
|
2014-02-10 09:10:30 +08:00
|
|
|
Vector<String> functions;
|
|
|
|
|
|
|
|
void _confirmed();
|
2017-03-05 23:44:50 +08:00
|
|
|
void _text_changed(const String &p_newtext);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
public:
|
2018-10-02 18:07:44 +08:00
|
|
|
void popup_dialog(const Vector<String> &p_functions, bool p_dontclear = false);
|
2014-02-10 09:10:30 +08:00
|
|
|
ScriptEditorQuickOpen();
|
|
|
|
};
|
|
|
|
|
2020-02-07 09:52:05 +08:00
|
|
|
class EditorDebuggerNode;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2018-06-11 06:10:32 +08:00
|
|
|
class ScriptEditorBase : public VBoxContainer {
|
2019-03-20 02:35:57 +08:00
|
|
|
GDCLASS(ScriptEditorBase, VBoxContainer);
|
2017-03-05 23:44:50 +08:00
|
|
|
|
2016-09-12 21:52:29 +08:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
public:
|
2020-05-04 00:08:15 +08:00
|
|
|
virtual void add_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlighter) = 0;
|
|
|
|
virtual void set_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlighter) = 0;
|
2018-04-02 19:41:44 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
virtual void apply_code() = 0;
|
2018-05-28 23:52:28 +08:00
|
|
|
virtual RES get_edited_resource() const = 0;
|
2017-03-05 23:44:50 +08:00
|
|
|
virtual Vector<String> get_functions() = 0;
|
2018-05-28 23:52:28 +08:00
|
|
|
virtual void set_edited_resource(const RES &p_res) = 0;
|
2019-11-20 17:09:59 +08:00
|
|
|
virtual void enable_editor() = 0;
|
2017-03-05 23:44:50 +08:00
|
|
|
virtual void reload_text() = 0;
|
|
|
|
virtual String get_name() = 0;
|
2020-03-12 20:37:40 +08:00
|
|
|
virtual Ref<Texture2D> get_theme_icon() = 0;
|
2017-03-05 23:44:50 +08:00
|
|
|
virtual bool is_unsaved() = 0;
|
|
|
|
virtual Variant get_edit_state() = 0;
|
|
|
|
virtual void set_edit_state(const Variant &p_state) = 0;
|
|
|
|
virtual void goto_line(int p_line, bool p_with_error = false) = 0;
|
2019-04-23 00:20:27 +08:00
|
|
|
virtual void set_executing_line(int p_line) = 0;
|
|
|
|
virtual void clear_executing_line() = 0;
|
2017-03-05 23:44:50 +08:00
|
|
|
virtual void trim_trailing_whitespace() = 0;
|
2019-05-29 05:27:32 +08:00
|
|
|
virtual void insert_final_newline() = 0;
|
2017-04-17 21:46:00 +08:00
|
|
|
virtual void convert_indent_to_spaces() = 0;
|
|
|
|
virtual void convert_indent_to_tabs() = 0;
|
2017-03-05 23:44:50 +08:00
|
|
|
virtual void ensure_focus() = 0;
|
|
|
|
virtual void tag_saved_version() = 0;
|
2018-05-28 23:52:28 +08:00
|
|
|
virtual void reload(bool p_soft) {}
|
2020-07-26 22:57:23 +08:00
|
|
|
virtual Array get_breakpoints() = 0;
|
2020-02-18 05:06:54 +08:00
|
|
|
virtual void add_callback(const String &p_function, PackedStringArray p_args) = 0;
|
2017-03-05 23:44:50 +08:00
|
|
|
virtual void update_settings() = 0;
|
|
|
|
virtual void set_debugger_active(bool p_active) = 0;
|
2016-08-26 04:45:20 +08:00
|
|
|
virtual bool can_lose_focus_on_node_selection() { return true; }
|
2016-08-03 06:11:05 +08:00
|
|
|
|
2017-05-28 22:20:38 +08:00
|
|
|
virtual bool show_members_overview() = 0;
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
virtual void set_tooltip_request_func(String p_method, Object *p_obj) = 0;
|
|
|
|
virtual Control *get_edit_menu() = 0;
|
2017-07-01 08:30:17 +08:00
|
|
|
virtual void clear_edit_menu() = 0;
|
2021-06-03 07:05:41 +08:00
|
|
|
virtual void set_find_replace_bar(FindReplaceBar *p_bar) = 0;
|
2016-08-03 06:11:05 +08:00
|
|
|
|
2021-05-14 03:50:25 +08:00
|
|
|
virtual Control *get_base_editor() const = 0;
|
|
|
|
|
2019-05-09 00:49:49 +08:00
|
|
|
virtual void validate() = 0;
|
|
|
|
|
2016-08-03 06:11:05 +08:00
|
|
|
ScriptEditorBase() {}
|
|
|
|
};
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2018-05-28 23:52:28 +08:00
|
|
|
typedef ScriptEditorBase *(*CreateScriptEditorFunc)(const RES &p_resource);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2015-06-26 12:14:31 +08:00
|
|
|
class EditorScriptCodeCompletionCache;
|
2018-02-12 09:36:15 +08:00
|
|
|
class FindInFilesDialog;
|
|
|
|
class FindInFilesPanel;
|
2015-06-26 12:14:31 +08:00
|
|
|
|
2017-07-15 12:40:17 +08:00
|
|
|
class ScriptEditor : public PanelContainer {
|
|
|
|
GDCLASS(ScriptEditor, PanelContainer);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
EditorNode *editor;
|
|
|
|
enum {
|
2015-08-10 07:39:59 +08:00
|
|
|
FILE_NEW,
|
2018-08-15 06:41:23 +08:00
|
|
|
FILE_NEW_TEXTFILE,
|
2014-02-10 09:10:30 +08:00
|
|
|
FILE_OPEN,
|
2019-08-01 03:06:15 +08:00
|
|
|
FILE_REOPEN_CLOSED,
|
2017-04-27 23:07:39 +08:00
|
|
|
FILE_OPEN_RECENT,
|
2014-02-10 09:10:30 +08:00
|
|
|
FILE_SAVE,
|
|
|
|
FILE_SAVE_AS,
|
|
|
|
FILE_SAVE_ALL,
|
2018-06-21 17:10:43 +08:00
|
|
|
FILE_THEME,
|
2017-08-28 06:03:19 +08:00
|
|
|
FILE_RUN,
|
2015-06-22 11:03:19 +08:00
|
|
|
FILE_CLOSE,
|
2016-07-18 06:18:48 +08:00
|
|
|
CLOSE_DOCS,
|
2016-08-13 08:56:38 +08:00
|
|
|
CLOSE_ALL,
|
2017-11-20 13:15:40 +08:00
|
|
|
CLOSE_OTHER_TABS,
|
2017-07-10 20:11:31 +08:00
|
|
|
TOGGLE_SCRIPTS_PANEL,
|
2018-01-02 10:11:54 +08:00
|
|
|
SHOW_IN_FILE_SYSTEM,
|
2017-12-07 11:57:41 +08:00
|
|
|
FILE_COPY_PATH,
|
2016-06-09 07:00:02 +08:00
|
|
|
FILE_TOOL_RELOAD,
|
|
|
|
FILE_TOOL_RELOAD_SOFT,
|
2019-05-03 07:07:06 +08:00
|
|
|
SEARCH_IN_FILES,
|
2020-02-09 17:10:58 +08:00
|
|
|
REPLACE_IN_FILES,
|
2016-08-03 06:11:05 +08:00
|
|
|
SEARCH_HELP,
|
|
|
|
SEARCH_WEBSITE,
|
|
|
|
HELP_SEARCH_FIND,
|
|
|
|
HELP_SEARCH_FIND_NEXT,
|
2019-10-09 23:41:49 +08:00
|
|
|
HELP_SEARCH_FIND_PREVIOUS,
|
2017-11-12 10:42:56 +08:00
|
|
|
WINDOW_MOVE_UP,
|
|
|
|
WINDOW_MOVE_DOWN,
|
2015-11-17 20:46:08 +08:00
|
|
|
WINDOW_NEXT,
|
|
|
|
WINDOW_PREV,
|
2017-11-12 10:42:56 +08:00
|
|
|
WINDOW_SORT,
|
2017-03-05 23:44:50 +08:00
|
|
|
WINDOW_SELECT_BASE = 100
|
2014-02-10 09:10:30 +08:00
|
|
|
};
|
2017-03-05 23:44:50 +08:00
|
|
|
|
2018-06-21 17:10:43 +08:00
|
|
|
enum {
|
|
|
|
THEME_IMPORT,
|
|
|
|
THEME_RELOAD,
|
|
|
|
THEME_SAVE,
|
|
|
|
THEME_SAVE_AS
|
|
|
|
};
|
|
|
|
|
2017-02-02 20:31:01 +08:00
|
|
|
enum ScriptSortBy {
|
|
|
|
SORT_BY_NAME,
|
|
|
|
SORT_BY_PATH,
|
2018-02-15 00:32:33 +08:00
|
|
|
SORT_BY_NONE
|
2017-02-02 20:31:01 +08:00
|
|
|
};
|
2017-03-05 23:44:50 +08:00
|
|
|
|
2017-02-02 20:31:01 +08:00
|
|
|
enum ScriptListName {
|
|
|
|
DISPLAY_NAME,
|
|
|
|
DISPLAY_DIR_AND_NAME,
|
|
|
|
DISPLAY_FULL_PATH,
|
|
|
|
};
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
HBoxContainer *menu_hb;
|
|
|
|
MenuButton *file_menu;
|
|
|
|
MenuButton *edit_menu;
|
2015-11-17 20:46:08 +08:00
|
|
|
MenuButton *script_search_menu;
|
2014-02-10 09:10:30 +08:00
|
|
|
MenuButton *debug_menu;
|
2017-11-12 05:36:46 +08:00
|
|
|
PopupMenu *context_menu;
|
2015-05-05 10:32:40 +08:00
|
|
|
Timer *autosave_timer;
|
2014-02-10 09:10:30 +08:00
|
|
|
uint64_t idle;
|
|
|
|
|
2017-04-27 23:07:39 +08:00
|
|
|
PopupMenu *recent_scripts;
|
2018-06-21 17:10:43 +08:00
|
|
|
PopupMenu *theme_submenu;
|
2017-04-27 23:07:39 +08:00
|
|
|
|
2015-11-17 20:46:08 +08:00
|
|
|
Button *help_search;
|
|
|
|
Button *site_search;
|
|
|
|
EditorHelpSearch *help_search_dialog;
|
|
|
|
|
2015-06-22 11:03:19 +08:00
|
|
|
ItemList *script_list;
|
|
|
|
HSplitContainer *script_split;
|
2017-05-28 22:20:38 +08:00
|
|
|
ItemList *members_overview;
|
2019-06-04 03:57:06 +08:00
|
|
|
LineEdit *filter_scripts;
|
|
|
|
LineEdit *filter_methods;
|
|
|
|
VBoxContainer *scripts_vbox;
|
2018-06-02 08:28:49 +08:00
|
|
|
VBoxContainer *overview_vbox;
|
|
|
|
HBoxContainer *buttons_hbox;
|
2018-06-06 05:18:11 +08:00
|
|
|
Label *filename;
|
2020-06-20 02:49:04 +08:00
|
|
|
Button *members_overview_alphabeta_sort_button;
|
2017-05-28 22:20:38 +08:00
|
|
|
bool members_overview_enabled;
|
2017-09-14 08:56:37 +08:00
|
|
|
ItemList *help_overview;
|
|
|
|
bool help_overview_enabled;
|
2017-05-28 22:20:38 +08:00
|
|
|
VSplitContainer *list_split;
|
2014-02-10 09:10:30 +08:00
|
|
|
TabContainer *tab_container;
|
2016-04-12 22:45:31 +08:00
|
|
|
EditorFileDialog *file_dialog;
|
2018-01-08 08:31:36 +08:00
|
|
|
AcceptDialog *error_dialog;
|
2014-02-10 09:10:30 +08:00
|
|
|
ConfirmationDialog *erase_tab_confirm;
|
2015-08-10 07:39:59 +08:00
|
|
|
ScriptCreateDialog *script_create_dialog;
|
2020-06-20 02:49:04 +08:00
|
|
|
Button *scripts_visible;
|
2021-06-03 07:05:41 +08:00
|
|
|
FindReplaceBar *find_replace_bar;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2016-04-12 22:45:31 +08:00
|
|
|
String current_theme;
|
|
|
|
|
2017-01-13 05:27:27 +08:00
|
|
|
TextureRect *script_icon;
|
2015-11-17 20:46:08 +08:00
|
|
|
Label *script_name_label;
|
|
|
|
|
2020-06-20 02:49:04 +08:00
|
|
|
Button *script_back;
|
|
|
|
Button *script_forward;
|
2015-11-17 20:46:08 +08:00
|
|
|
|
2018-02-12 09:36:15 +08:00
|
|
|
FindInFilesDialog *find_in_files_dialog;
|
|
|
|
FindInFilesPanel *find_in_files;
|
|
|
|
Button *find_in_files_button;
|
|
|
|
|
2016-08-03 06:11:05 +08:00
|
|
|
enum {
|
2018-04-02 19:41:44 +08:00
|
|
|
SCRIPT_EDITOR_FUNC_MAX = 32,
|
2016-08-03 06:11:05 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static int script_editor_func_count;
|
|
|
|
static CreateScriptEditorFunc script_editor_funcs[SCRIPT_EDITOR_FUNC_MAX];
|
2015-11-17 20:46:08 +08:00
|
|
|
|
2020-05-04 00:08:15 +08:00
|
|
|
Vector<Ref<EditorSyntaxHighlighter>> syntax_highlighters;
|
2018-04-02 19:41:44 +08:00
|
|
|
|
2015-11-17 20:46:08 +08:00
|
|
|
struct ScriptHistory {
|
2020-11-24 17:12:55 +08:00
|
|
|
Control *control = nullptr;
|
2016-08-03 06:11:05 +08:00
|
|
|
Variant state;
|
2015-11-17 20:46:08 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
Vector<ScriptHistory> history;
|
|
|
|
int history_pos;
|
|
|
|
|
2019-08-01 03:06:15 +08:00
|
|
|
List<String> previous_scripts;
|
2015-11-17 20:46:08 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
void _tab_changed(int p_which);
|
2017-08-13 00:52:50 +08:00
|
|
|
void _menu_option(int p_option);
|
2018-06-21 17:10:43 +08:00
|
|
|
void _theme_option(int p_option);
|
2019-05-23 23:18:24 +08:00
|
|
|
void _show_save_theme_as_dialog();
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
Tree *disk_changed_list;
|
|
|
|
ConfirmationDialog *disk_changed;
|
|
|
|
|
2015-06-22 11:03:19 +08:00
|
|
|
bool restoring_layout;
|
|
|
|
|
2017-08-13 00:52:50 +08:00
|
|
|
String _get_debug_tooltip(const String &p_text, Node *_se);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void _resave_scripts(const String &p_str);
|
2014-02-10 09:10:30 +08:00
|
|
|
void _reload_scripts();
|
|
|
|
|
2018-05-28 23:52:28 +08:00
|
|
|
bool _test_script_times_on_disk(RES p_for_script = Ref<Resource>());
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2017-04-27 23:07:39 +08:00
|
|
|
void _add_recent_script(String p_path);
|
|
|
|
void _update_recent_scripts();
|
|
|
|
void _open_recent_script(int p_idx);
|
|
|
|
|
2018-01-08 08:31:36 +08:00
|
|
|
void _show_error_dialog(String p_path);
|
|
|
|
|
2018-02-07 05:32:03 +08:00
|
|
|
void _close_tab(int p_idx, bool p_save = true, bool p_history_back = true);
|
2021-06-24 21:38:29 +08:00
|
|
|
void _update_find_replace_bar();
|
2016-07-07 07:35:49 +08:00
|
|
|
|
2021-03-04 08:04:31 +08:00
|
|
|
void _close_current_tab(bool p_save = true);
|
2017-03-05 23:44:50 +08:00
|
|
|
void _close_discard_current_tab(const String &p_str);
|
2016-07-18 06:18:48 +08:00
|
|
|
void _close_docs_tab();
|
2017-11-20 13:15:40 +08:00
|
|
|
void _close_other_tabs();
|
2016-08-13 08:56:38 +08:00
|
|
|
void _close_all_tabs();
|
|
|
|
|
2017-12-07 11:57:41 +08:00
|
|
|
void _copy_script_path();
|
|
|
|
|
2016-08-13 08:56:38 +08:00
|
|
|
void _ask_close_current_unsaved_tab(ScriptEditorBase *current);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2015-06-22 11:03:19 +08:00
|
|
|
bool grab_focus_block;
|
|
|
|
|
2016-06-03 23:34:11 +08:00
|
|
|
bool pending_auto_reload;
|
|
|
|
bool auto_reload_running_scripts;
|
2021-08-17 16:32:23 +08:00
|
|
|
void _trigger_live_script_reload();
|
2016-06-03 23:34:11 +08:00
|
|
|
void _live_auto_reload_running_scripts();
|
|
|
|
|
2016-08-03 06:11:05 +08:00
|
|
|
void _update_selected_editor_menu();
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2015-06-26 12:14:31 +08:00
|
|
|
EditorScriptCodeCompletionCache *completion_cache;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
void _editor_stop();
|
|
|
|
|
2015-11-17 20:46:08 +08:00
|
|
|
int edit_pass;
|
|
|
|
|
2020-02-18 05:06:54 +08:00
|
|
|
void _add_callback(Object *p_obj, const String &p_function, const PackedStringArray &p_args);
|
2017-03-05 23:44:50 +08:00
|
|
|
void _res_saved_callback(const Ref<Resource> &p_res);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2016-04-24 02:21:34 +08:00
|
|
|
bool trim_trailing_whitespace_on_save;
|
2017-04-17 21:46:00 +08:00
|
|
|
bool use_space_indentation;
|
|
|
|
bool convert_indent_on_save;
|
2016-04-24 02:21:34 +08:00
|
|
|
|
|
|
|
void _trim_trailing_whitespace(TextEdit *tx);
|
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
void _goto_script_line2(int p_line);
|
2017-03-05 23:44:50 +08:00
|
|
|
void _goto_script_line(REF p_script, int p_line);
|
2019-04-23 00:20:27 +08:00
|
|
|
void _set_execution(REF p_script, int p_line);
|
|
|
|
void _clear_execution(REF p_script);
|
2017-03-05 23:44:50 +08:00
|
|
|
void _breaked(bool p_breaked, bool p_can_debug);
|
2014-02-10 09:10:30 +08:00
|
|
|
void _update_window_menu();
|
2015-08-10 07:39:59 +08:00
|
|
|
void _script_created(Ref<Script> p_script);
|
2014-05-06 17:43:14 +08:00
|
|
|
|
2018-02-12 09:36:15 +08:00
|
|
|
ScriptEditorBase *_get_current_editor() const;
|
2020-03-07 22:29:44 +08:00
|
|
|
Array _get_open_script_editors() const;
|
2018-02-12 09:36:15 +08:00
|
|
|
|
2016-07-18 23:30:43 +08:00
|
|
|
void _save_layout();
|
2015-05-05 10:32:40 +08:00
|
|
|
void _editor_settings_changed();
|
2020-07-23 20:21:28 +08:00
|
|
|
void _filesystem_changed();
|
|
|
|
void _file_removed(const String &p_file);
|
2015-05-05 10:32:40 +08:00
|
|
|
void _autosave_scripts();
|
2019-10-11 04:19:47 +08:00
|
|
|
void _update_autosave_timer();
|
2015-05-05 10:32:40 +08:00
|
|
|
|
2017-05-28 22:20:38 +08:00
|
|
|
void _update_members_overview_visibility();
|
|
|
|
void _update_members_overview();
|
2018-04-30 20:27:00 +08:00
|
|
|
void _toggle_members_overview_alpha_sort(bool p_alphabetic_sort);
|
2019-06-04 03:57:06 +08:00
|
|
|
void _filter_scripts_text_changed(const String &p_newtext);
|
|
|
|
void _filter_methods_text_changed(const String &p_newtext);
|
2015-06-22 11:03:19 +08:00
|
|
|
void _update_script_names();
|
2019-04-20 19:51:25 +08:00
|
|
|
void _update_script_connections();
|
2017-11-12 10:42:56 +08:00
|
|
|
bool _sort_list_on_update;
|
2015-06-22 11:03:19 +08:00
|
|
|
|
2017-05-28 22:20:38 +08:00
|
|
|
void _members_overview_selected(int p_idx);
|
2015-06-22 11:03:19 +08:00
|
|
|
void _script_selected(int p_idx);
|
|
|
|
|
2017-09-14 08:56:37 +08:00
|
|
|
void _update_help_overview_visibility();
|
|
|
|
void _update_help_overview();
|
|
|
|
void _help_overview_selected(int p_idx);
|
|
|
|
|
2020-03-17 14:33:00 +08:00
|
|
|
void _find_scripts(Node *p_base, Node *p_current, Set<Ref<Script>> &used);
|
2015-06-22 11:03:19 +08:00
|
|
|
|
|
|
|
void _tree_changed();
|
|
|
|
|
|
|
|
void _script_split_dragged(float);
|
|
|
|
|
2017-11-12 10:42:56 +08:00
|
|
|
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);
|
|
|
|
|
2020-09-17 09:40:00 +08:00
|
|
|
void _unhandled_key_input(const Ref<InputEvent> &p_event);
|
2016-06-26 08:02:17 +08:00
|
|
|
|
2017-11-12 05:36:46 +08:00
|
|
|
void _script_list_gui_input(const Ref<InputEvent> &ev);
|
|
|
|
void _make_script_list_context_menu();
|
|
|
|
|
2016-08-03 06:11:05 +08:00
|
|
|
void _help_search(String p_text);
|
2017-05-26 22:34:41 +08:00
|
|
|
void _help_index(String p_text);
|
2015-11-17 20:46:08 +08:00
|
|
|
|
|
|
|
void _history_forward();
|
|
|
|
void _history_back();
|
|
|
|
|
2015-06-22 11:03:19 +08:00
|
|
|
bool waiting_update_names;
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void _help_class_open(const String &p_class);
|
|
|
|
void _help_class_goto(const String &p_desc);
|
2015-11-17 20:46:08 +08:00
|
|
|
void _update_history_arrows();
|
2016-09-12 21:52:29 +08:00
|
|
|
void _save_history();
|
2015-11-17 20:46:08 +08:00
|
|
|
void _go_to_tab(int p_idx);
|
|
|
|
void _update_history_pos(int p_new_pos);
|
|
|
|
void _update_script_colors();
|
2017-03-05 23:44:50 +08:00
|
|
|
void _update_modified_scripts_for_external_editor(Ref<Script> p_for_script = Ref<Script>());
|
2015-11-17 20:46:08 +08:00
|
|
|
|
2017-08-19 03:43:23 +08:00
|
|
|
void _script_changed();
|
2016-04-12 22:45:31 +08:00
|
|
|
int file_dialog_option;
|
|
|
|
void _file_dialog_action(String p_file);
|
2015-11-17 20:46:08 +08:00
|
|
|
|
2017-07-06 15:18:20 +08:00
|
|
|
Ref<Script> _get_current_script();
|
2017-07-20 01:47:43 +08:00
|
|
|
Array _get_open_scripts() const;
|
2017-07-06 15:18:20 +08:00
|
|
|
|
2018-05-28 23:52:28 +08:00
|
|
|
Ref<TextFile> _load_text_file(const String &p_path, Error *r_error);
|
|
|
|
Error _save_text_file(Ref<TextFile> p_text_file, const String &p_path);
|
|
|
|
|
2018-02-12 09:36:15 +08:00
|
|
|
void _on_find_in_files_requested(String text);
|
2020-02-09 17:10:58 +08:00
|
|
|
void _on_replace_in_files_requested(String text);
|
2018-02-12 09:36:15 +08:00
|
|
|
void _on_find_in_files_result_selected(String fpath, int line_number, int begin, int end);
|
|
|
|
void _start_find_in_files(bool with_replace);
|
2020-02-18 05:06:54 +08:00
|
|
|
void _on_find_in_files_modified_files(PackedStringArray paths);
|
2018-02-12 09:36:15 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
static void _open_script_request(const String &p_path);
|
2016-08-26 04:45:20 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
static ScriptEditor *script_editor;
|
2017-03-05 23:44:50 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
public:
|
2014-02-10 09:10:30 +08:00
|
|
|
static ScriptEditor *get_singleton() { return script_editor; }
|
|
|
|
|
2019-12-19 03:32:25 +08:00
|
|
|
bool toggle_scripts_panel();
|
2019-12-15 21:35:16 +08:00
|
|
|
bool is_scripts_panel_toggled();
|
2014-02-10 09:10:30 +08:00
|
|
|
void apply_scripts() const;
|
2017-12-14 01:41:28 +08:00
|
|
|
void open_script_create_dialog(const String &p_base_name, const String &p_base_path);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
void ensure_select_current();
|
2017-04-16 01:48:10 +08:00
|
|
|
|
2018-05-28 23:52:28 +08:00
|
|
|
_FORCE_INLINE_ bool edit(const RES &p_resource, bool p_grab_focus = true) { return edit(p_resource, -1, 0, p_grab_focus); }
|
|
|
|
bool edit(const RES &p_resource, int p_line, int p_col, bool p_grab_focus = true);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
void get_breakpoints(List<String> *p_breakpoints);
|
|
|
|
|
2021-05-09 18:29:50 +08:00
|
|
|
void save_current_script();
|
2016-02-03 08:10:52 +08:00
|
|
|
void save_all_scripts();
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2015-06-22 11:03:19 +08:00
|
|
|
void set_window_layout(Ref<ConfigFile> p_layout);
|
|
|
|
void get_window_layout(Ref<ConfigFile> p_layout);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void set_scene_root_script(Ref<Script> p_script);
|
2020-03-17 14:33:00 +08:00
|
|
|
Vector<Ref<Script>> get_open_scripts() const;
|
2015-11-17 20:46:08 +08:00
|
|
|
|
2017-04-16 01:48:10 +08:00
|
|
|
bool script_goto_method(Ref<Script> p_script, const String &p_method);
|
2016-06-12 07:01:17 +08:00
|
|
|
|
2015-12-09 20:08:41 +08:00
|
|
|
virtual void edited_scene_changed();
|
|
|
|
|
2017-07-06 15:18:20 +08:00
|
|
|
void notify_script_close(const Ref<Script> &p_script);
|
|
|
|
void notify_script_changed(const Ref<Script> &p_script);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void close_builtin_scripts_from_scene(const String &p_scene);
|
2016-07-07 07:35:49 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void goto_help(const String &p_desc) { _help_class_goto(p_desc); }
|
2020-11-29 10:37:57 +08:00
|
|
|
void update_doc(const String &p_name);
|
2016-08-24 10:15:16 +08:00
|
|
|
|
2016-08-26 04:45:20 +08:00
|
|
|
bool can_take_away_focus() const;
|
|
|
|
|
2017-07-01 08:30:17 +08:00
|
|
|
VSplitContainer *get_left_list_split() { return list_split; }
|
|
|
|
|
2016-06-03 23:34:11 +08:00
|
|
|
void set_live_auto_reload_running_scripts(bool p_enabled);
|
2015-08-02 23:29:37 +08:00
|
|
|
|
2020-05-04 00:08:15 +08:00
|
|
|
void register_syntax_highlighter(const Ref<EditorSyntaxHighlighter> &p_syntax_highlighter);
|
|
|
|
void unregister_syntax_highlighter(const Ref<EditorSyntaxHighlighter> &p_syntax_highlighter);
|
2020-03-07 22:29:44 +08:00
|
|
|
|
2016-08-03 06:11:05 +08:00
|
|
|
static void register_create_script_editor_function(CreateScriptEditorFunc p_func);
|
2018-04-02 19:41:44 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
ScriptEditor(EditorNode *p_editor);
|
2015-06-26 12:14:31 +08:00
|
|
|
~ScriptEditor();
|
2014-02-10 09:10:30 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class ScriptEditorPlugin : public EditorPlugin {
|
2017-03-05 23:44:50 +08:00
|
|
|
GDCLASS(ScriptEditorPlugin, EditorPlugin);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
ScriptEditor *script_editor;
|
|
|
|
EditorNode *editor;
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
public:
|
2020-07-10 18:34:39 +08:00
|
|
|
virtual String get_name() const override { return "Script"; }
|
|
|
|
bool has_main_screen() const override { return true; }
|
|
|
|
virtual void edit(Object *p_object) override;
|
|
|
|
virtual bool handles(Object *p_object) const override;
|
|
|
|
virtual void make_visible(bool p_visible) override;
|
|
|
|
virtual void selected_notify() override;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2020-07-10 18:34:39 +08:00
|
|
|
virtual void save_external_data() override;
|
|
|
|
virtual void apply_changes() override;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2020-07-10 18:34:39 +08:00
|
|
|
virtual void restore_global_state() override;
|
|
|
|
virtual void save_global_state() override;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2020-07-10 18:34:39 +08:00
|
|
|
virtual void set_window_layout(Ref<ConfigFile> p_layout) override;
|
|
|
|
virtual void get_window_layout(Ref<ConfigFile> p_layout) override;
|
2015-06-22 11:03:19 +08:00
|
|
|
|
2020-07-10 18:34:39 +08:00
|
|
|
virtual void get_breakpoints(List<String> *p_breakpoints) override;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2020-07-10 18:34:39 +08:00
|
|
|
virtual void edited_scene_changed() override;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
ScriptEditorPlugin(EditorNode *p_node);
|
|
|
|
~ScriptEditorPlugin();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SCRIPT_EDITOR_PLUGIN_H
|