2016-08-03 15:16:20 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* script_text_editor.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2016-08-03 15:16:20 +00:00
|
|
|
/*************************************************************************/
|
2020-01-01 10:16:22 +00:00
|
|
|
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
2016-08-03 15:16:20 +00: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-04 23:50:27 +00:00
|
|
|
|
2016-08-02 22:11:05 +00:00
|
|
|
#ifndef SCRIPT_TEXT_EDITOR_H
|
|
|
|
#define SCRIPT_TEXT_EDITOR_H
|
|
|
|
|
2016-09-29 07:12:45 +00:00
|
|
|
#include "scene/gui/color_picker.h"
|
2019-04-20 11:51:25 +00:00
|
|
|
#include "scene/gui/dialogs.h"
|
|
|
|
#include "scene/gui/tree.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "script_editor_plugin.h"
|
2016-08-02 22:11:05 +00:00
|
|
|
|
2019-04-20 11:51:25 +00:00
|
|
|
class ConnectionInfoDialog : public AcceptDialog {
|
|
|
|
|
|
|
|
GDCLASS(ConnectionInfoDialog, AcceptDialog);
|
|
|
|
|
|
|
|
Label *method;
|
|
|
|
Tree *tree;
|
|
|
|
|
|
|
|
virtual void ok_pressed();
|
|
|
|
|
|
|
|
public:
|
|
|
|
void popup_connections(String p_method, Vector<Node *> p_nodes);
|
|
|
|
|
|
|
|
ConnectionInfoDialog();
|
|
|
|
};
|
|
|
|
|
2016-08-02 22:11:05 +00:00
|
|
|
class ScriptTextEditor : public ScriptEditorBase {
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
GDCLASS(ScriptTextEditor, ScriptEditorBase);
|
2016-08-02 22:11:05 +00:00
|
|
|
|
2019-12-18 19:32:25 +00:00
|
|
|
CodeTextEditor *code_editor;
|
2018-07-01 16:17:40 +00:00
|
|
|
RichTextLabel *warnings_panel;
|
2016-08-02 22:11:05 +00:00
|
|
|
|
|
|
|
Ref<Script> script;
|
2019-11-02 13:38:25 +00:00
|
|
|
bool script_is_valid;
|
2016-08-02 22:11:05 +00:00
|
|
|
|
|
|
|
Vector<String> functions;
|
|
|
|
|
2019-04-20 11:51:25 +00:00
|
|
|
List<Connection> missing_connections;
|
|
|
|
|
2018-01-12 14:00:41 +00:00
|
|
|
Vector<String> member_keywords;
|
|
|
|
|
2016-08-02 22:11:05 +00:00
|
|
|
HBoxContainer *edit_hb;
|
|
|
|
|
|
|
|
MenuButton *edit_menu;
|
|
|
|
MenuButton *search_menu;
|
2019-07-01 19:00:05 +00:00
|
|
|
PopupMenu *bookmarks_menu;
|
|
|
|
PopupMenu *breakpoints_menu;
|
2018-06-01 19:32:19 +00:00
|
|
|
PopupMenu *highlighter_menu;
|
2017-03-05 15:44:50 +00:00
|
|
|
PopupMenu *context_menu;
|
2016-08-02 22:11:05 +00:00
|
|
|
|
|
|
|
GotoLineDialog *goto_line_dialog;
|
|
|
|
ScriptEditorQuickOpen *quick_open;
|
2019-04-20 11:51:25 +00:00
|
|
|
ConnectionInfoDialog *connection_info_dialog;
|
2016-08-02 22:11:05 +00:00
|
|
|
|
2016-09-29 07:12:45 +00:00
|
|
|
PopupPanel *color_panel;
|
|
|
|
ColorPicker *color_picker;
|
2019-08-02 20:32:33 +00:00
|
|
|
Vector2 color_position;
|
2016-09-29 07:12:45 +00:00
|
|
|
String color_args;
|
|
|
|
|
2018-01-12 14:00:41 +00:00
|
|
|
void _update_member_keywords();
|
|
|
|
|
2017-10-02 23:33:42 +00:00
|
|
|
struct ColorsCache {
|
|
|
|
Color symbol_color;
|
|
|
|
Color keyword_color;
|
|
|
|
Color basetype_color;
|
|
|
|
Color type_color;
|
2019-09-28 10:11:06 +00:00
|
|
|
Color usertype_color;
|
2017-10-02 23:33:42 +00:00
|
|
|
Color comment_color;
|
|
|
|
Color string_color;
|
|
|
|
} colors_cache;
|
|
|
|
|
|
|
|
bool theme_loaded;
|
|
|
|
|
2016-08-02 22:11:05 +00:00
|
|
|
enum {
|
|
|
|
EDIT_UNDO,
|
|
|
|
EDIT_REDO,
|
|
|
|
EDIT_CUT,
|
|
|
|
EDIT_COPY,
|
|
|
|
EDIT_PASTE,
|
|
|
|
EDIT_SELECT_ALL,
|
|
|
|
EDIT_COMPLETE,
|
|
|
|
EDIT_AUTO_INDENT,
|
|
|
|
EDIT_TRIM_TRAILING_WHITESAPCE,
|
2017-04-16 15:47:59 +00:00
|
|
|
EDIT_CONVERT_INDENT_TO_SPACES,
|
|
|
|
EDIT_CONVERT_INDENT_TO_TABS,
|
2016-08-02 22:11:05 +00:00
|
|
|
EDIT_TOGGLE_COMMENT,
|
|
|
|
EDIT_MOVE_LINE_UP,
|
|
|
|
EDIT_MOVE_LINE_DOWN,
|
|
|
|
EDIT_INDENT_RIGHT,
|
|
|
|
EDIT_INDENT_LEFT,
|
2017-08-20 12:31:30 +00:00
|
|
|
EDIT_DELETE_LINE,
|
2016-08-02 22:11:05 +00:00
|
|
|
EDIT_CLONE_DOWN,
|
2016-09-29 07:12:45 +00:00
|
|
|
EDIT_PICK_COLOR,
|
2017-04-24 18:59:55 +00:00
|
|
|
EDIT_TO_UPPERCASE,
|
|
|
|
EDIT_TO_LOWERCASE,
|
|
|
|
EDIT_CAPITALIZE,
|
2019-08-07 14:31:33 +00:00
|
|
|
EDIT_EVALUATE,
|
2017-12-08 18:17:10 +00:00
|
|
|
EDIT_TOGGLE_FOLD_LINE,
|
2017-11-16 04:00:27 +00:00
|
|
|
EDIT_FOLD_ALL_LINES,
|
2017-11-12 23:12:17 +00:00
|
|
|
EDIT_UNFOLD_ALL_LINES,
|
2016-08-02 22:11:05 +00:00
|
|
|
SEARCH_FIND,
|
|
|
|
SEARCH_FIND_NEXT,
|
|
|
|
SEARCH_FIND_PREV,
|
|
|
|
SEARCH_REPLACE,
|
|
|
|
SEARCH_LOCATE_FUNCTION,
|
|
|
|
SEARCH_GOTO_LINE,
|
2018-02-12 01:36:15 +00:00
|
|
|
SEARCH_IN_FILES,
|
2019-04-19 23:51:25 +00:00
|
|
|
BOOKMARK_TOGGLE,
|
|
|
|
BOOKMARK_GOTO_NEXT,
|
|
|
|
BOOKMARK_GOTO_PREV,
|
|
|
|
BOOKMARK_REMOVE_ALL,
|
2016-08-02 22:11:05 +00:00
|
|
|
DEBUG_TOGGLE_BREAKPOINT,
|
|
|
|
DEBUG_REMOVE_ALL_BREAKPOINTS,
|
|
|
|
DEBUG_GOTO_NEXT_BREAKPOINT,
|
|
|
|
DEBUG_GOTO_PREV_BREAKPOINT,
|
|
|
|
HELP_CONTEXTUAL,
|
2018-01-02 07:10:49 +00:00
|
|
|
LOOKUP_SYMBOL,
|
2016-08-02 22:11:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
protected:
|
2019-07-01 19:00:05 +00:00
|
|
|
void _update_breakpoint_list();
|
|
|
|
void _breakpoint_item_pressed(int p_idx);
|
2016-08-02 22:11:05 +00:00
|
|
|
void _breakpoint_toggled(int p_row);
|
|
|
|
|
2019-05-21 08:07:48 +00:00
|
|
|
void _validate_script(); // No longer virtual.
|
|
|
|
void _update_bookmark_list();
|
|
|
|
void _bookmark_item_pressed(int p_idx);
|
2019-06-13 09:17:20 +00:00
|
|
|
|
|
|
|
static void _code_complete_scripts(void *p_ud, const String &p_code, List<ScriptCodeCompletionOption> *r_options, bool &r_force);
|
|
|
|
void _code_complete_script(const String &p_code, List<ScriptCodeCompletionOption> *r_options, bool &r_force);
|
|
|
|
|
2016-08-02 22:11:05 +00:00
|
|
|
void _load_theme_settings();
|
2017-10-02 23:33:42 +00:00
|
|
|
void _set_theme_for_script();
|
2019-02-13 09:12:31 +00:00
|
|
|
void _show_warnings_panel(bool p_show);
|
2019-02-01 16:20:59 +00:00
|
|
|
void _error_pressed();
|
2018-07-01 16:17:40 +00:00
|
|
|
void _warning_clicked(Variant p_line);
|
2016-08-02 22:11:05 +00:00
|
|
|
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2018-04-02 11:41:44 +00:00
|
|
|
Map<String, SyntaxHighlighter *> highlighters;
|
|
|
|
void _change_syntax_highlighter(int p_idx);
|
|
|
|
|
2016-08-02 22:11:05 +00:00
|
|
|
void _edit_option(int p_op);
|
2019-02-04 19:17:44 +00:00
|
|
|
void _edit_option_toggle_inline_comment();
|
2019-06-22 18:22:52 +00:00
|
|
|
void _make_context_menu(bool p_selection, bool p_color, bool p_foldable, bool p_open_docs, bool p_goto_definition, Vector2 p_pos);
|
2017-05-20 15:38:03 +00:00
|
|
|
void _text_edit_gui_input(const Ref<InputEvent> &ev);
|
2017-03-05 15:44:50 +00:00
|
|
|
void _color_changed(const Color &p_color);
|
2016-08-02 22:11:05 +00:00
|
|
|
|
|
|
|
void _goto_line(int p_line) { goto_line(p_line); }
|
2017-03-05 15:44:50 +00:00
|
|
|
void _lookup_symbol(const String &p_symbol, int p_row, int p_column);
|
2016-09-11 14:28:01 +00:00
|
|
|
|
2019-04-20 11:51:25 +00:00
|
|
|
void _lookup_connections(int p_row, String p_method);
|
|
|
|
|
2018-05-25 22:49:35 +00:00
|
|
|
void _convert_case(CodeTextEditor::CaseStyle p_case);
|
2017-04-24 18:59:55 +00:00
|
|
|
|
2017-03-05 15:44:50 +00: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);
|
2016-09-11 14:28:01 +00:00
|
|
|
|
2016-08-02 22:11:05 +00:00
|
|
|
public:
|
2019-04-20 11:51:25 +00:00
|
|
|
void _update_connected_methods();
|
|
|
|
|
2018-04-02 11:41:44 +00:00
|
|
|
virtual void add_syntax_highlighter(SyntaxHighlighter *p_highlighter);
|
|
|
|
virtual void set_syntax_highlighter(SyntaxHighlighter *p_highlighter);
|
2019-12-18 19:32:25 +00:00
|
|
|
void update_toggle_scripts_button();
|
2018-04-02 11:41:44 +00:00
|
|
|
|
2016-08-02 22:11:05 +00:00
|
|
|
virtual void apply_code();
|
2018-05-28 15:52:28 +00:00
|
|
|
virtual RES get_edited_resource() const;
|
|
|
|
virtual void set_edited_resource(const RES &p_res);
|
2017-03-05 15:44:50 +00:00
|
|
|
virtual Vector<String> get_functions();
|
2016-08-02 22:11:05 +00:00
|
|
|
virtual void reload_text();
|
2017-03-05 15:44:50 +00:00
|
|
|
virtual String get_name();
|
2019-06-11 18:43:37 +00:00
|
|
|
virtual Ref<Texture2D> get_icon();
|
2016-08-02 22:11:05 +00:00
|
|
|
virtual bool is_unsaved();
|
|
|
|
virtual Variant get_edit_state();
|
2017-03-05 15:44:50 +00:00
|
|
|
virtual void set_edit_state(const Variant &p_state);
|
2016-08-02 22:11:05 +00:00
|
|
|
virtual void ensure_focus();
|
|
|
|
virtual void trim_trailing_whitespace();
|
2019-05-28 21:27:32 +00:00
|
|
|
virtual void insert_final_newline();
|
2017-04-16 15:47:59 +00:00
|
|
|
virtual void convert_indent_to_spaces();
|
|
|
|
virtual void convert_indent_to_tabs();
|
2016-08-02 22:11:05 +00:00
|
|
|
virtual void tag_saved_version();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
virtual void goto_line(int p_line, bool p_with_error = false);
|
2018-02-12 01:36:15 +00:00
|
|
|
void goto_line_selection(int p_line, int p_begin, int p_end);
|
2019-01-04 12:09:01 +00:00
|
|
|
void goto_line_centered(int p_line);
|
2019-04-22 16:20:27 +00:00
|
|
|
virtual void set_executing_line(int p_line);
|
|
|
|
virtual void clear_executing_line();
|
2016-08-02 22:11:05 +00:00
|
|
|
|
|
|
|
virtual void reload(bool p_soft);
|
|
|
|
virtual void get_breakpoints(List<int> *p_breakpoints);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
virtual void add_callback(const String &p_function, PoolStringArray p_args);
|
2016-08-02 22:11:05 +00:00
|
|
|
virtual void update_settings();
|
|
|
|
|
2017-05-28 14:20:38 +00:00
|
|
|
virtual bool show_members_overview();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
virtual void set_tooltip_request_func(String p_method, Object *p_obj);
|
2016-08-02 22:11:05 +00:00
|
|
|
|
2016-08-06 22:00:54 +00:00
|
|
|
virtual void set_debugger_active(bool p_active);
|
|
|
|
|
2016-08-02 22:11:05 +00:00
|
|
|
Control *get_edit_menu();
|
2017-07-01 00:30:17 +00:00
|
|
|
virtual void clear_edit_menu();
|
2016-08-02 22:11:05 +00:00
|
|
|
static void register_editor();
|
|
|
|
|
2019-05-08 16:49:49 +00:00
|
|
|
virtual void validate();
|
|
|
|
|
2016-08-02 22:11:05 +00:00
|
|
|
ScriptTextEditor();
|
2019-07-25 16:30:48 +00:00
|
|
|
~ScriptTextEditor();
|
2016-08-02 22:11:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SCRIPT_TEXT_EDITOR_H
|