2016-08-03 17:16:20 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* script_text_editor.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* http://www.godotengine.org */
|
|
|
|
/*************************************************************************/
|
2017-01-01 22:01:57 +01:00
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2017-04-08 00:11:42 +02:00
|
|
|
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
|
2016-08-03 17:16:20 +02: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. */
|
|
|
|
/*************************************************************************/
|
2016-08-03 00:11:05 +02:00
|
|
|
#ifndef SCRIPT_TEXT_EDITOR_H
|
|
|
|
#define SCRIPT_TEXT_EDITOR_H
|
|
|
|
|
2016-09-29 09:12:45 +02:00
|
|
|
#include "scene/gui/color_picker.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "script_editor_plugin.h"
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
class ScriptTextEditor : public ScriptEditorBase {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
GDCLASS(ScriptTextEditor, ScriptEditorBase);
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
CodeTextEditor *code_editor;
|
|
|
|
|
|
|
|
Ref<Script> script;
|
|
|
|
|
|
|
|
Vector<String> functions;
|
|
|
|
|
|
|
|
HBoxContainer *edit_hb;
|
|
|
|
|
|
|
|
MenuButton *edit_menu;
|
|
|
|
MenuButton *search_menu;
|
2017-03-05 16:44:50 +01:00
|
|
|
PopupMenu *context_menu;
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
GotoLineDialog *goto_line_dialog;
|
|
|
|
ScriptEditorQuickOpen *quick_open;
|
|
|
|
|
2016-09-29 09:12:45 +02:00
|
|
|
PopupPanel *color_panel;
|
|
|
|
ColorPicker *color_picker;
|
|
|
|
int color_line;
|
|
|
|
String color_args;
|
|
|
|
|
2016-08-03 00:11:05 +02: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 17:47:59 +02:00
|
|
|
EDIT_CONVERT_INDENT_TO_SPACES,
|
|
|
|
EDIT_CONVERT_INDENT_TO_TABS,
|
2016-08-03 00:11:05 +02:00
|
|
|
EDIT_TOGGLE_COMMENT,
|
|
|
|
EDIT_MOVE_LINE_UP,
|
|
|
|
EDIT_MOVE_LINE_DOWN,
|
|
|
|
EDIT_INDENT_RIGHT,
|
|
|
|
EDIT_INDENT_LEFT,
|
|
|
|
EDIT_CLONE_DOWN,
|
2016-09-29 09:12:45 +02:00
|
|
|
EDIT_PICK_COLOR,
|
2017-04-24 20:59:55 +02:00
|
|
|
EDIT_TO_UPPERCASE,
|
|
|
|
EDIT_TO_LOWERCASE,
|
|
|
|
EDIT_CAPITALIZE,
|
2016-08-03 00:11:05 +02:00
|
|
|
SEARCH_FIND,
|
|
|
|
SEARCH_FIND_NEXT,
|
|
|
|
SEARCH_FIND_PREV,
|
|
|
|
SEARCH_REPLACE,
|
|
|
|
SEARCH_LOCATE_FUNCTION,
|
|
|
|
SEARCH_GOTO_LINE,
|
|
|
|
DEBUG_TOGGLE_BREAKPOINT,
|
|
|
|
DEBUG_REMOVE_ALL_BREAKPOINTS,
|
|
|
|
DEBUG_GOTO_NEXT_BREAKPOINT,
|
|
|
|
DEBUG_GOTO_PREV_BREAKPOINT,
|
|
|
|
HELP_CONTEXTUAL,
|
|
|
|
};
|
|
|
|
|
|
|
|
protected:
|
2017-03-05 16:44:50 +01:00
|
|
|
static void _code_complete_scripts(void *p_ud, const String &p_code, List<String> *r_options);
|
2016-08-03 00:11:05 +02:00
|
|
|
void _breakpoint_toggled(int p_row);
|
|
|
|
|
|
|
|
//no longer virtual
|
|
|
|
void _validate_script();
|
2017-03-05 16:44:50 +01:00
|
|
|
void _code_complete_script(const String &p_code, List<String> *r_options);
|
2016-08-03 00:11:05 +02:00
|
|
|
void _load_theme_settings();
|
|
|
|
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
void _edit_option(int p_op);
|
2016-09-29 09:12:45 +02:00
|
|
|
void _make_context_menu(bool p_selection, bool p_color);
|
2017-03-05 16:44:50 +01:00
|
|
|
void _text_edit_gui_input(const InputEvent &ev);
|
|
|
|
void _color_changed(const Color &p_color);
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
void _goto_line(int p_line) { goto_line(p_line); }
|
2017-03-05 16:44:50 +01:00
|
|
|
void _lookup_symbol(const String &p_symbol, int p_row, int p_column);
|
2016-09-11 16:28:01 +02:00
|
|
|
|
2017-04-24 20:59:55 +02:00
|
|
|
enum CaseStyle {
|
|
|
|
UPPER,
|
|
|
|
LOWER,
|
|
|
|
CAPITALIZE,
|
|
|
|
};
|
|
|
|
void _convert_case(CaseStyle p_case);
|
|
|
|
|
2017-03-05 16:44:50 +01: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 16:28:01 +02:00
|
|
|
|
2016-08-03 00:11:05 +02:00
|
|
|
public:
|
|
|
|
virtual void apply_code();
|
|
|
|
virtual Ref<Script> get_edited_script() const;
|
2017-03-05 16:44:50 +01:00
|
|
|
virtual Vector<String> get_functions();
|
|
|
|
virtual void set_edited_script(const Ref<Script> &p_script);
|
2016-08-03 00:11:05 +02:00
|
|
|
virtual void reload_text();
|
2017-03-05 16:44:50 +01:00
|
|
|
virtual String get_name();
|
|
|
|
virtual Ref<Texture> get_icon();
|
2016-08-03 00:11:05 +02:00
|
|
|
virtual bool is_unsaved();
|
|
|
|
|
|
|
|
virtual Variant get_edit_state();
|
2017-03-05 16:44:50 +01:00
|
|
|
virtual void set_edit_state(const Variant &p_state);
|
2016-08-03 00:11:05 +02:00
|
|
|
virtual void ensure_focus();
|
|
|
|
virtual void trim_trailing_whitespace();
|
2017-04-16 17:47:59 +02:00
|
|
|
virtual void convert_indent_to_spaces();
|
|
|
|
virtual void convert_indent_to_tabs();
|
2016-08-03 00:11:05 +02:00
|
|
|
virtual void tag_saved_version();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
virtual void goto_line(int p_line, bool p_with_error = false);
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
virtual void reload(bool p_soft);
|
|
|
|
virtual void get_breakpoints(List<int> *p_breakpoints);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
virtual void add_callback(const String &p_function, PoolStringArray p_args);
|
2016-08-03 00:11:05 +02:00
|
|
|
virtual void update_settings();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
virtual void set_tooltip_request_func(String p_method, Object *p_obj);
|
2016-08-03 00:11:05 +02:00
|
|
|
|
2016-08-07 00:00:54 +02:00
|
|
|
virtual void set_debugger_active(bool p_active);
|
|
|
|
|
2016-08-03 00:11:05 +02:00
|
|
|
Control *get_edit_menu();
|
|
|
|
|
|
|
|
static void register_editor();
|
|
|
|
|
|
|
|
ScriptTextEditor();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SCRIPT_TEXT_EDITOR_H
|