diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-04-29 18:38:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-29 18:38:38 +0200 |
commit | 23147ae2c3740e73f0247cf4bff24ba9326683a4 (patch) | |
tree | 1961e8a8448169c84cbd208c0fc11de562adc02d /editor | |
parent | 82fcc9957336ffd79b059a4d3718314c72c4ecf2 (diff) | |
parent | 9bfa63496a6310a45ca337acf38f67361c89a6ec (diff) |
Merge pull request #28101 from MunWolf/debugger_cursor
Added a marker in text_edit that tells which row is executing.
Diffstat (limited to 'editor')
-rw-r--r-- | editor/code_editor.cpp | 8 | ||||
-rw-r--r-- | editor/code_editor.h | 2 | ||||
-rw-r--r-- | editor/editor_settings.cpp | 1 | ||||
-rw-r--r-- | editor/editor_themes.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 36 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.h | 4 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 10 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.h | 2 | ||||
-rw-r--r-- | editor/plugins/shader_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/text_editor.cpp | 11 | ||||
-rw-r--r-- | editor/plugins/text_editor.h | 2 | ||||
-rw-r--r-- | editor/script_editor_debugger.cpp | 20 | ||||
-rw-r--r-- | editor/script_editor_debugger.h | 2 |
13 files changed, 102 insertions, 0 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index a9ec776693..d655f52f5d 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1177,6 +1177,14 @@ void CodeTextEditor::goto_line_selection(int p_line, int p_begin, int p_end) { text_editor->select(p_line, p_begin, p_line, p_end); } +void CodeTextEditor::set_executing_line(int p_line) { + text_editor->set_executing_line(p_line); +} + +void CodeTextEditor::clear_executing_line() { + text_editor->clear_executing_line(); +} + Variant CodeTextEditor::get_edit_state() { Dictionary state; diff --git a/editor/code_editor.h b/editor/code_editor.h index e3dbfe1ce0..b98af377ce 100644 --- a/editor/code_editor.h +++ b/editor/code_editor.h @@ -217,6 +217,8 @@ public: void goto_line(int p_line); void goto_line_selection(int p_line, int p_begin, int p_end); + void set_executing_line(int p_line); + void clear_executing_line(); Variant get_edit_state(); void set_edit_state(const Variant &p_state); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 54bd9cae20..bf582ca004 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -645,6 +645,7 @@ void EditorSettings::_load_default_text_editor_theme() { _initial_set("text_editor/highlighting/member_variable_color", Color::html("e64e59")); _initial_set("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4)); _initial_set("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2)); + _initial_set("text_editor/highlighting/executing_line_color", Color(0.2, 0.8, 0.2, 0.4)); _initial_set("text_editor/highlighting/code_folding_color", Color(0.8, 0.8, 0.8, 0.8)); _initial_set("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1)); _initial_set("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1)); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 2e9c664108..b8dd29cecc 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1116,6 +1116,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { const Color member_variable_color = main_color.linear_interpolate(mono_color, 0.6); const Color mark_color = Color(error_color.r, error_color.g, error_color.b, 0.3); const Color breakpoint_color = error_color; + const Color executing_line_color = Color(0.2, 0.8, 0.2, 0.4); const Color code_folding_color = alpha3; const Color search_result_color = alpha1; const Color search_result_border_color = alpha3; @@ -1151,6 +1152,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { setting->set_initial_value("text_editor/highlighting/member_variable_color", member_variable_color, true); setting->set_initial_value("text_editor/highlighting/mark_color", mark_color, true); setting->set_initial_value("text_editor/highlighting/breakpoint_color", breakpoint_color, true); + setting->set_initial_value("text_editor/highlighting/executing_line_color", executing_line_color, true); setting->set_initial_value("text_editor/highlighting/code_folding_color", code_folding_color, true); setting->set_initial_value("text_editor/highlighting/search_result_color", search_result_color, true); setting->set_initial_value("text_editor/highlighting/search_result_border_color", search_result_border_color, true); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 03287b8cf9..d84a5a1e48 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -312,6 +312,38 @@ void ScriptEditor::_goto_script_line(REF p_script, int p_line) { } } +void ScriptEditor::_set_execution(REF p_script, int p_line) { + Ref<Script> script = Object::cast_to<Script>(*p_script); + if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) { + for (int i = 0; i < tab_container->get_child_count(); i++) { + + ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); + if (!se) + continue; + + if ((script != NULL && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == script->get_path()) { + se->set_executing_line(p_line); + } + } + } +} + +void ScriptEditor::_clear_execution(REF p_script) { + Ref<Script> script = Object::cast_to<Script>(*p_script); + if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) { + for (int i = 0; i < tab_container->get_child_count(); i++) { + + ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); + if (!se) + continue; + + if ((script != NULL && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == script->get_path()) { + se->clear_executing_line(); + } + } + } +} + ScriptEditorBase *ScriptEditor::_get_current_editor() const { int selected = tab_container->get_current_tab(); @@ -2878,6 +2910,8 @@ void ScriptEditor::_bind_methods() { ClassDB::bind_method("_res_saved_callback", &ScriptEditor::_res_saved_callback); ClassDB::bind_method("_goto_script_line", &ScriptEditor::_goto_script_line); ClassDB::bind_method("_goto_script_line2", &ScriptEditor::_goto_script_line2); + ClassDB::bind_method("_set_execution", &ScriptEditor::_set_execution); + ClassDB::bind_method("_clear_execution", &ScriptEditor::_clear_execution); ClassDB::bind_method("_help_search", &ScriptEditor::_help_search); ClassDB::bind_method("_save_history", &ScriptEditor::_save_history); ClassDB::bind_method("_copy_script_path", &ScriptEditor::_copy_script_path); @@ -3168,6 +3202,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { debugger = memnew(ScriptEditorDebugger(editor)); debugger->connect("goto_script_line", this, "_goto_script_line"); + debugger->connect("set_execution", this, "_set_execution"); + debugger->connect("clear_execution", this, "_clear_execution"); debugger->connect("show_debugger", this, "_show_debugger"); disk_changed = memnew(ConfirmationDialog); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index f13308dec7..a17fed1e06 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -96,6 +96,8 @@ public: 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; + virtual void set_executing_line(int p_line) = 0; + virtual void clear_executing_line() = 0; virtual void trim_trailing_whitespace() = 0; virtual void convert_indent_to_spaces() = 0; virtual void convert_indent_to_tabs() = 0; @@ -318,6 +320,8 @@ class ScriptEditor : public PanelContainer { void _goto_script_line2(int p_line); void _goto_script_line(REF p_script, int p_line); + void _set_execution(REF p_script, int p_line); + void _clear_execution(REF p_script); void _breaked(bool p_breaked, bool p_can_debug); void _show_debugger(bool p_show); void _update_window_menu(); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 46b2e8a5f8..d40e67cc8c 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -214,6 +214,7 @@ void ScriptTextEditor::_load_theme_settings() { Color member_variable_color = EDITOR_GET("text_editor/highlighting/member_variable_color"); Color mark_color = EDITOR_GET("text_editor/highlighting/mark_color"); Color breakpoint_color = EDITOR_GET("text_editor/highlighting/breakpoint_color"); + Color executing_line_color = EDITOR_GET("text_editor/highlighting/executing_line_color"); Color code_folding_color = EDITOR_GET("text_editor/highlighting/code_folding_color"); Color search_result_color = EDITOR_GET("text_editor/highlighting/search_result_color"); Color search_result_border_color = EDITOR_GET("text_editor/highlighting/search_result_border_color"); @@ -245,6 +246,7 @@ void ScriptTextEditor::_load_theme_settings() { text_edit->add_color_override("function_color", function_color); text_edit->add_color_override("member_variable_color", member_variable_color); text_edit->add_color_override("breakpoint_color", breakpoint_color); + text_edit->add_color_override("executing_line_color", executing_line_color); text_edit->add_color_override("mark_color", mark_color); text_edit->add_color_override("code_folding_color", code_folding_color); text_edit->add_color_override("search_result_color", search_result_color); @@ -479,6 +481,14 @@ void ScriptTextEditor::goto_line_selection(int p_line, int p_begin, int p_end) { code_editor->goto_line_selection(p_line, p_begin, p_end); } +void ScriptTextEditor::set_executing_line(int p_line) { + code_editor->set_executing_line(p_line); +} + +void ScriptTextEditor::clear_executing_line() { + code_editor->clear_executing_line(); +} + void ScriptTextEditor::ensure_focus() { code_editor->get_text_edit()->grab_focus(); diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index 4edb1c3c67..0dbc884594 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -196,6 +196,8 @@ public: virtual void goto_line(int p_line, bool p_with_error = false); void goto_line_selection(int p_line, int p_begin, int p_end); + virtual void set_executing_line(int p_line); + virtual void clear_executing_line(); virtual void reload(bool p_soft); virtual void get_breakpoints(List<int> *p_breakpoints); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index d39e521113..31660a9e19 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -85,6 +85,7 @@ void ShaderTextEditor::_load_theme_settings() { Color member_variable_color = EDITOR_GET("text_editor/highlighting/member_variable_color"); Color mark_color = EDITOR_GET("text_editor/highlighting/mark_color"); Color breakpoint_color = EDITOR_GET("text_editor/highlighting/breakpoint_color"); + Color executing_line_color = EDITOR_GET("text_editor/highlighting/executing_line_color"); Color code_folding_color = EDITOR_GET("text_editor/highlighting/code_folding_color"); Color search_result_color = EDITOR_GET("text_editor/highlighting/search_result_color"); Color search_result_border_color = EDITOR_GET("text_editor/highlighting/search_result_border_color"); @@ -113,6 +114,7 @@ void ShaderTextEditor::_load_theme_settings() { get_text_edit()->add_color_override("member_variable_color", member_variable_color); get_text_edit()->add_color_override("mark_color", mark_color); get_text_edit()->add_color_override("breakpoint_color", breakpoint_color); + get_text_edit()->add_color_override("executing_line_color", executing_line_color); get_text_edit()->add_color_override("code_folding_color", code_folding_color); get_text_edit()->add_color_override("search_result_color", search_result_color); get_text_edit()->add_color_override("search_result_border_color", search_result_border_color); diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 2886b3dc51..becaae3567 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -94,6 +94,7 @@ void TextEditor::_load_theme_settings() { Color member_variable_color = EDITOR_GET("text_editor/highlighting/member_variable_color"); Color mark_color = EDITOR_GET("text_editor/highlighting/mark_color"); Color breakpoint_color = EDITOR_GET("text_editor/highlighting/breakpoint_color"); + Color executing_line_color = EDITOR_GET("text_editor/highlighting/executing_line_color"); Color code_folding_color = EDITOR_GET("text_editor/highlighting/code_folding_color"); Color search_result_color = EDITOR_GET("text_editor/highlighting/search_result_color"); Color search_result_border_color = EDITOR_GET("text_editor/highlighting/search_result_border_color"); @@ -124,6 +125,7 @@ void TextEditor::_load_theme_settings() { text_edit->add_color_override("function_color", function_color); text_edit->add_color_override("member_variable_color", member_variable_color); text_edit->add_color_override("breakpoint_color", breakpoint_color); + text_edit->add_color_override("executing_line_color", executing_line_color); text_edit->add_color_override("mark_color", mark_color); text_edit->add_color_override("code_folding_color", code_folding_color); text_edit->add_color_override("search_result_color", search_result_color); @@ -268,6 +270,15 @@ void TextEditor::goto_line(int p_line, bool p_with_error) { code_editor->goto_line(p_line); } +void TextEditor::set_executing_line(int p_line) { + + code_editor->set_executing_line(p_line); +} + +void TextEditor::clear_executing_line() { + code_editor->clear_executing_line(); +} + void TextEditor::ensure_focus() { code_editor->get_text_edit()->grab_focus(); diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h index 3c136277df..767001e2f6 100644 --- a/editor/plugins/text_editor.h +++ b/editor/plugins/text_editor.h @@ -123,6 +123,8 @@ public: virtual Vector<String> get_functions(); virtual void get_breakpoints(List<int> *p_breakpoints); virtual void goto_line(int p_line, bool p_with_error = false); + virtual void set_executing_line(int p_line); + virtual void clear_executing_line(); virtual void trim_trailing_whitespace(); virtual void convert_indent_to_spaces(); virtual void convert_indent_to_tabs(); diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index 82117b9505..1da8bf874c 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -209,6 +209,7 @@ void ScriptEditorDebugger::debug_next() { Array msg; msg.push_back("next"); ppeer->put_var(msg); + _clear_execution(); stack_dump->clear(); } void ScriptEditorDebugger::debug_step() { @@ -220,6 +221,7 @@ void ScriptEditorDebugger::debug_step() { Array msg; msg.push_back("step"); ppeer->put_var(msg); + _clear_execution(); stack_dump->clear(); } @@ -243,6 +245,7 @@ void ScriptEditorDebugger::debug_continue() { OS::get_singleton()->enable_for_stealing_focus(EditorNode::get_singleton()->get_child_process_id()); Array msg; + _clear_execution(); msg.push_back("continue"); ppeer->put_var(msg); } @@ -422,6 +425,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da } else if (p_msg == "debug_exit") { breaked = false; + _clear_execution(); copy->set_disabled(true); step->set_disabled(true); next->set_disabled(true); @@ -1270,6 +1274,18 @@ void ScriptEditorDebugger::_notification(int p_what) { } } +void ScriptEditorDebugger::_clear_execution() { + TreeItem *ti = stack_dump->get_selected(); + if (!ti) + return; + + Dictionary d = ti->get_metadata(0); + + stack_script = ResourceLoader::load(d["file"]); + emit_signal("clear_execution", stack_script); + stack_script.unref(); +} + void ScriptEditorDebugger::start() { stop(); @@ -1310,6 +1326,7 @@ void ScriptEditorDebugger::stop() { set_process(false); breaked = false; + _clear_execution(); server->stop(); _clear_remote_objects(); @@ -1390,6 +1407,7 @@ void ScriptEditorDebugger::_stack_dump_frame_selected() { stack_script = ResourceLoader::load(d["file"]); emit_signal("goto_script_line", stack_script, int(d["line"]) - 1); + emit_signal("set_execution", stack_script, int(d["line"]) - 1); stack_script.unref(); if (connection.is_valid() && connection->is_connected_to_host()) { @@ -1963,6 +1981,8 @@ void ScriptEditorDebugger::_bind_methods() { ClassDB::bind_method(D_METHOD("_scene_tree_property_value_edited"), &ScriptEditorDebugger::_scene_tree_property_value_edited); ADD_SIGNAL(MethodInfo("goto_script_line")); + ADD_SIGNAL(MethodInfo("set_execution", PropertyInfo("script"), PropertyInfo(Variant::INT, "line"))); + ADD_SIGNAL(MethodInfo("clear_execution", PropertyInfo("script"))); ADD_SIGNAL(MethodInfo("breaked", PropertyInfo(Variant::BOOL, "reallydid"), PropertyInfo(Variant::BOOL, "can_debug"))); ADD_SIGNAL(MethodInfo("show_debugger", PropertyInfo(Variant::BOOL, "reallydid"))); } diff --git a/editor/script_editor_debugger.h b/editor/script_editor_debugger.h index 5f21602579..f7afe6bf72 100644 --- a/editor/script_editor_debugger.h +++ b/editor/script_editor_debugger.h @@ -205,6 +205,8 @@ class ScriptEditorDebugger : public Control { void _export_csv(); + void _clear_execution(); + protected: void _notification(int p_what); static void _bind_methods(); |