diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-09-12 10:52:29 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-09-12 10:53:31 -0300 |
commit | 37f1e86108a84c9b371e37c3854d8a03c8aea743 (patch) | |
tree | eca23dd9556df6a398b0a667009f34a200ef363d /tools/editor/plugins/script_editor_plugin.cpp | |
parent | 78f92dbcb9b193fb7a100ca7096c15a6899199fc (diff) | |
download | redot-engine-37f1e86108a84c9b371e37c3854d8a03c8aea743.tar.gz |
Do ctrl-click on any code identifier to go to definiton or help page.
Diffstat (limited to 'tools/editor/plugins/script_editor_plugin.cpp')
-rw-r--r-- | tools/editor/plugins/script_editor_plugin.cpp | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 77b4106473..340e5cca4e 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -43,6 +43,17 @@ /*** SCRIPT EDITOR ****/ + +void ScriptEditorBase::_bind_methods() { + + ADD_SIGNAL(MethodInfo("name_changed")); + ADD_SIGNAL(MethodInfo("request_help_search",PropertyInfo(Variant::STRING,"topic"))); + ADD_SIGNAL(MethodInfo("request_open_script_at_line",PropertyInfo(Variant::OBJECT,"script"),PropertyInfo(Variant::INT,"line"))); + ADD_SIGNAL(MethodInfo("request_save_history")); + ADD_SIGNAL(MethodInfo("go_to_help",PropertyInfo(Variant::STRING,"what"))); + +} + static bool _can_open_in_editor(Script* p_script) { String path = p_script->get_path(); @@ -346,6 +357,34 @@ void ScriptEditor::_update_history_arrows() { script_forward->set_disabled( history_pos>=history.size()-1 ); } +void ScriptEditor::_save_history() { + + + if (history_pos>=0 && history_pos<history.size() && history[history_pos].control==tab_container->get_current_tab_control()) { + + Node *n = tab_container->get_current_tab_control(); + + if (n->cast_to<ScriptEditorBase>()) { + + history[history_pos].state=n->cast_to<ScriptEditorBase>()->get_edit_state(); + } + if (n->cast_to<EditorHelp>()) { + + history[history_pos].state=n->cast_to<EditorHelp>()->get_scroll(); + } + } + + history.resize(history_pos+1); + ScriptHistory sh; + sh.control=tab_container->get_current_tab_control(); + sh.state=Variant(); + + history.push_back(sh); + history_pos++; + + _update_history_arrows(); +} + void ScriptEditor::_go_to_tab(int p_idx) { @@ -1535,6 +1574,11 @@ void ScriptEditor::edit(const Ref<Script>& p_script, bool p_grab_focus) { _save_layout(); se->connect("name_changed",this,"_update_script_names"); se->connect("request_help_search",this,"_help_search"); + se->connect("request_open_script_at_line",this,"_goto_script_line"); + se->connect("go_to_help",this,"_help_class_goto"); + se->connect("request_save_history",this,"_save_history"); + + //test for modification, maybe the script was not edited but was loaded @@ -1840,7 +1884,6 @@ void ScriptEditor::_help_class_open(const String& p_class) { void ScriptEditor::_help_class_goto(const String& p_desc) { - String cname=p_desc.get_slice(":",1); for(int i=0;i<tab_container->get_child_count();i++) { @@ -2021,6 +2064,8 @@ void ScriptEditor::_bind_methods() { ObjectTypeDB::bind_method("_goto_script_line",&ScriptEditor::_goto_script_line); ObjectTypeDB::bind_method("_goto_script_line2",&ScriptEditor::_goto_script_line2); ObjectTypeDB::bind_method("_help_search",&ScriptEditor::_help_search); + ObjectTypeDB::bind_method("_save_history",&ScriptEditor::_save_history); + ObjectTypeDB::bind_method("_breaked",&ScriptEditor::_breaked); |