diff --git a/juci/config.json b/juci/config.json index 893b7b1..6587e57 100644 --- a/juci/config.json +++ b/juci/config.json @@ -57,10 +57,11 @@ "edit_undo": "z", "edit_redo": "y", "edit_find": "f", - "goto_declaration": "d", - "goto_method": "m", - "compile_and_run": "r", - "compile": "r" + "source_goto_declaration": "d", + "source_goto_method": "m", + "source_rename": "r", + "compile_and_run": "Return", + "compile": "Return" }, "directoryfilter": { "ignore": [ diff --git a/juci/menu.xml b/juci/menu.xml index d9937d8..d93305f 100644 --- a/juci/menu.xml +++ b/juci/menu.xml @@ -21,6 +21,7 @@ + diff --git a/juci/notebook.cc b/juci/notebook.cc index 2c223f2..9babea7 100644 --- a/juci/notebook.cc +++ b/juci/notebook.cc @@ -89,7 +89,7 @@ void Notebook::Controller::CreateKeybindings() { INFO("Done Redo"); }); - menu->action_group->add(Gtk::Action::create("SourceGotoDeclaration", "Go to declaration"), Gtk::AccelKey(menu->key_map["goto_declaration"]), [this]() { + menu->action_group->add(Gtk::Action::create("SourceGotoDeclaration", "Go to declaration"), Gtk::AccelKey(menu->key_map["source_goto_declaration"]), [this]() { if(CurrentPage()!=-1) { if(CurrentSourceView()->get_declaration_location) { auto location=CurrentSourceView()->get_declaration_location(); @@ -104,13 +104,22 @@ void Notebook::Controller::CreateKeybindings() { } }); - menu->action_group->add(Gtk::Action::create("SourceGotoMethod", "Go to method"), Gtk::AccelKey(menu->key_map["goto_method"]), [this]() { + menu->action_group->add(Gtk::Action::create("SourceGotoMethod", "Go to method"), Gtk::AccelKey(menu->key_map["source_goto_method"]), [this]() { if(CurrentPage()!=-1) { if(CurrentSourceView()->goto_method) { CurrentSourceView()->goto_method(); } } }); + + menu->action_group->add(Gtk::Action::create("SourceRename", "Rename function/variable"), Gtk::AccelKey(menu->key_map["source_rename"]), [this]() { + if(CurrentPage()!=-1) { + if(CurrentSourceView()->get_token) { + auto token=CurrentSourceView()->get_token(); + CurrentSourceView()->tag_similar_tokens(token); + } + } + }); INFO("Notebook signal handlers sucsess"); } diff --git a/juci/source.cc b/juci/source.cc index 15aa49c..e65c38c 100644 --- a/juci/source.cc +++ b/juci/source.cc @@ -897,8 +897,7 @@ Source::ClangViewAutocomplete(file_path, project_path) { } }); - get_token=[this](){ - std::string usr; + get_token=[this]() -> std::string { if(clang_readable) { for(auto &token: *clang_tokens) { if(token.get_kind()==clang::Token_Identifier && token.has_type()) { @@ -906,12 +905,12 @@ Source::ClangViewAutocomplete(file_path, project_path) { if(insert_offset>=token.offsets.first && insert_offset<=token.offsets.second) { auto referenced=token.get_cursor().get_referenced(); if(referenced) - usr=referenced.get_usr(); + return referenced.get_usr(); } } } } - return usr; + return ""; }; tag_similar_tokens=[this](const std::string &usr){ diff --git a/juci/source.h b/juci/source.h index b778f69..b1c120d 100644 --- a/juci/source.h +++ b/juci/source.h @@ -66,9 +66,9 @@ public: std::function()> get_declaration_location; std::function goto_method; - std::function get_token; + std::function get_token; std::function tag_similar_tokens; - std::function rename_similar_tokens; + std::function rename_similar_tokens; protected: bool on_key_press_event(GdkEventKey* key); private: