From 258769856567da6bede34f3d461e6cd3d7ff7282 Mon Sep 17 00:00:00 2001 From: eidheim Date: Fri, 2 Feb 2018 21:30:03 +0100 Subject: [PATCH] Preference cleanup: added missing prefix to some menu item key names, and removed clang_types from preferences --- CMakeLists.txt | 2 +- src/config.cc | 6 ------ src/config.h | 1 - src/files.h | 51 ++++++++++++++++----------------------------- src/menu.cc | 36 ++++++++++++++++---------------- src/source_clang.cc | 26 +++++++++++++++++++---- src/source_clang.h | 1 + src/window.cc | 38 ++++++++++++++++----------------- 8 files changed, 79 insertions(+), 82 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c418d6..c489366 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 2.8.8) project(juci) -set(JUCI_VERSION "1.4.0.2") +set(JUCI_VERSION "1.4.0.3") set(CPACK_PACKAGE_NAME "jucipp") set(CPACK_PACKAGE_CONTACT "Ole Christian Eidheim ") diff --git a/src/config.cc b/src/config.cc index a461226..737fd31 100644 --- a/src/config.cc +++ b/src/config.cc @@ -171,12 +171,6 @@ void Config::read(const boost::property_tree::ptree &cfg) { source.wrap_lines = source_json.get("wrap_lines"); source.highlight_current_line = source_json.get("highlight_current_line"); source.show_line_numbers = source_json.get("show_line_numbers"); - for (auto &i : source_json.get_child("clang_types")) { - try { - source.clang_types[std::stoi(i.first)] = i.second.get_value(); - } - catch(const std::exception &) {} - } source.clang_format_style = source_json.get("clang_format_style"); source.clang_usages_threads = static_cast(source_json.get("clang_usages_threads")); auto pt_doc_search=cfg.get_child("documentation_searches"); diff --git a/src/config.h b/src/config.h index 1e9bff1..036d29f 100644 --- a/src/config.h +++ b/src/config.h @@ -85,7 +85,6 @@ public: bool highlight_current_line; bool show_line_numbers; - std::unordered_map clang_types; std::string clang_format_style; unsigned clang_usages_threads; diff --git a/src/files.h b/src/files.h index e50dc05..6b5a2e8 100644 --- a/src/files.h +++ b/src/files.h @@ -58,20 +58,6 @@ R"RAW( "wrap_lines": false, "highlight_current_line": true, "show_line_numbers": true, - "clang_types": { - "8": "def:function", - "21": "def:function", - "22": "def:identifier", - "24": "def:function", - "25": "def:function", - "43": "def:type", - "44": "def:type", - "45": "def:type", - "46": "def:identifier", - "109": "def:string", - "702": "def:statement", - "705": "def:comment" - }, "clang_format_style_comment": "IndentWidth, AccessModifierOffset and UseTab are set automatically. See http://clang.llvm.org/docs/ClangFormatStyleOptions.html", "clang_format_style": "ColumnLimit: 0, MaxEmptyLinesToKeep: 2, SpaceBeforeParens: Never, NamespaceIndentation: All, BreakBeforeBraces: Custom, BraceWrapping: {BeforeElse: true, BeforeCatch: true}", "clang_usages_threads_comment": "The number of threads used in finding usages in unparsed files. -1 corresponds to the number of cores available, and 0 disables the search", @@ -85,21 +71,20 @@ R"RAW( "keybindings": { "preferences": "comma", "quit": "q", - "new_file": "n", - "new_folder": "n", - "open_file": "o", - "open_folder": "o", - "reload_file": "", - "save": "s", - "save_as": "s", - "print": "", + "file_new_file": "n", + "file_new_folder": "n", + "file_open_file": "o", + "file_open_folder": "o", + "file_reload_file": "", + "file_save": "s", + "file_save_as": "s", + "file_print": "", "edit_undo": "z", "edit_redo": "z", "edit_cut": "x", "edit_copy": "c", "edit_paste": "v", "edit_find": "f", - "edit_set_tab": "", "source_spellcheck": "", "source_spellcheck_clear": "", "source_spellcheck_next_error": "e", @@ -128,11 +113,11 @@ R"RAW( "source_goto_next_diagnostic": "e", "source_apply_fix_its": "space", "project_set_run_arguments": "", - "compile_and_run": "Return", - "compile": "Return", - "run_command": "Return", - "kill_last_running": "Escape", - "force_kill_last_running": "Escape", + "project_compile_and_run": "Return", + "project_compile": "Return", + "project_run_command": "Return", + "project_kill_last_running": "Escape", + "project_force_kill_last_running": "Escape", "debug_set_run_arguments": "", "debug_start_continue": "y", "debug_stop": "y", @@ -147,15 +132,15 @@ R"RAW( "debug_goto_stop": "l",)RAW" #ifdef __linux R"RAW( - "next_tab": "Tab", - "previous_tab": "Tab",)RAW" + "window_next_tab": "Tab", + "window_previous_tab": "Tab",)RAW" #else R"RAW( - "next_tab": "Right", - "previous_tab": "Left",)RAW" + "window_next_tab": "Right", + "window_previous_tab": "Left",)RAW" #endif R"RAW( - "close_tab": "w", + "window_close_tab": "w", "window_toggle_split": "",)RAW" #ifdef __APPLE__ R"RAW( diff --git a/src/menu.cc b/src/menu.cc index f9bb0f3..a79d156 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -113,54 +113,54 @@ const Glib::ustring menu_xml= R"RAW(
_New _File - app.new_file + app.file_new_file _New _Folder - app.new_folder + app.file_new_folder _New _Project C - app.new_project_c + app.file_new_project_c C++ - app.new_project_cpp + app.file_new_project_cpp
_Open _File - app.open_file + app.file_open_file _Open _Folder - app.open_folder + app.file_open_folder
_Reload _File - app.reload_file + app.file_reload_file
_Save - app.save + app.file_save _Save _As - app.save_as + app.file_save_as
_Print - app.print + app.file_print
@@ -343,11 +343,11 @@ const Glib::ustring menu_xml= R"RAW( _Compile _and _Run - app.compile_and_run + app.project_compile_and_run _Compile - app.compile + app.project_compile _Recreate _Build @@ -357,15 +357,15 @@ const Glib::ustring menu_xml= R"RAW(
_Run _Command - app.run_command + app.project_run_command _Kill _Last _Process - app.kill_last_running + app.project_kill_last_running _Force _Kill _Last _Process - app.force_kill_last_running + app.project_force_kill_last_running
@@ -439,15 +439,15 @@ const Glib::ustring menu_xml= R"RAW(
_Next _Tab - app.next_tab + app.window_next_tab _Previous _Tab - app.previous_tab + app.window_previous_tab _Close _Tab - app.close_tab + app.window_close_tab
diff --git a/src/source_clang.cc b/src/source_clang.cc index 9ef9b02..f73b00f 100644 --- a/src/source_clang.cc +++ b/src/source_clang.cc @@ -21,7 +21,7 @@ Source::ClangViewParse::ClangViewParse(const boost::filesystem::path &file_path, Usages::Clang::erase_cache(file_path); auto tag_table=get_buffer()->get_tag_table(); - for (auto &item : Config::get().source.clang_types) { + for (auto &item : clang_types()) { if(!tag_table->lookup(item.second)) { get_buffer()->create_tag(item.second); } @@ -55,7 +55,7 @@ void Source::ClangViewParse::configure() { auto scheme = get_source_buffer()->get_style_scheme(); auto tag_table=get_buffer()->get_tag_table(); - for (auto &item : Config::get().source.clang_types) { + for (auto &item : clang_types()) { auto tag = get_buffer()->get_tag_table()->lookup(item.second); if(tag) { auto style = scheme->get_style(item.second); @@ -208,11 +208,29 @@ void Source::ClangViewParse::soft_reparse(bool delayed) { }, delayed?1000:0); } +const std::unordered_map &Source::ClangViewParse::clang_types() { + static std::unordered_map types{ + {8, "def:function"}, + {21, "def:function"}, + {22, "def:identifier"}, + {24, "def:function"}, + {25, "def:function"}, + {43, "def:type"}, + {44, "def:type"}, + {45, "def:type"}, + {46, "def:identifier"}, + {109, "def:string"}, + {702, "def:statement"}, + {705, "def:comment"} + }; + return types; +} + void Source::ClangViewParse::update_syntax() { auto buffer=get_buffer(); const auto apply_tag=[this, buffer](const std::pair &offsets, int type) { - auto type_it=Config::get().source.clang_types.find(type); - if(type_it!=Config::get().source.clang_types.end()) { + auto type_it=clang_types().find(type); + if(type_it!=clang_types().end()) { last_syntax_tags.emplace(type_it->second); Gtk::TextIter begin_iter = buffer->get_iter_at_line_index(offsets.first.line-1, offsets.first.index-1); Gtk::TextIter end_iter = buffer->get_iter_at_line_index(offsets.second.line-1, offsets.second.index-1); diff --git a/src/source_clang.h b/src/source_clang.h index d347c6a..0823da6 100644 --- a/src/source_clang.h +++ b/src/source_clang.h @@ -45,6 +45,7 @@ namespace Source { private: Glib::ustring parse_thread_buffer; + static const std::unordered_map &clang_types(); void update_syntax(); std::set last_syntax_tags; diff --git a/src/window.cc b/src/window.cc index 6411481..9af6c79 100644 --- a/src/window.cc +++ b/src/window.cc @@ -148,7 +148,7 @@ void Window::set_menu_actions() { close(); }); - menu.add_action("new_file", [this]() { + menu.add_action("file_new_file", [this]() { boost::filesystem::path path = Dialog::new_file(Notebook::get().get_current_folder()); if(path!="") { if(boost::filesystem::exists(path)) { @@ -168,7 +168,7 @@ void Window::set_menu_actions() { } } }); - menu.add_action("new_folder", [this]() { + menu.add_action("file_new_folder", [this]() { auto time_now=std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); boost::filesystem::path path = Dialog::new_folder(Notebook::get().get_current_folder()); if(path!="" && boost::filesystem::exists(path)) { @@ -184,7 +184,7 @@ void Window::set_menu_actions() { Directories::get().select(path); } }); - menu.add_action("new_project_c", [this]() { + menu.add_action("file_new_project_c", [this]() { boost::filesystem::path project_path = Dialog::new_folder(Notebook::get().get_current_folder()); if(project_path!="") { auto project_name=project_path.filename().string(); @@ -216,7 +216,7 @@ void Window::set_menu_actions() { Terminal::get().print("Error: Could not create project "+project_path.string()+"\n", true); } }); - menu.add_action("new_project_cpp", [this]() { + menu.add_action("file_new_project_cpp", [this]() { boost::filesystem::path project_path = Dialog::new_folder(Notebook::get().get_current_folder()); if(project_path!="") { auto project_name=project_path.filename().string(); @@ -249,7 +249,7 @@ void Window::set_menu_actions() { } }); - menu.add_action("open_file", [this]() { + menu.add_action("file_open_file", [this]() { auto folder_path=Notebook::get().get_current_folder(); if(auto view=Notebook::get().get_current_view()) { if(!Directories::get().path.empty() && !filesystem::file_in_path(view->file_path, Directories::get().path)) @@ -259,13 +259,13 @@ void Window::set_menu_actions() { if(path!="") Notebook::get().open(path); }); - menu.add_action("open_folder", [this]() { + menu.add_action("file_open_folder", [this]() { auto path = Dialog::open_folder(Notebook::get().get_current_folder()); if (path!="" && boost::filesystem::exists(path)) Directories::get().open(path); }); - menu.add_action("reload_file", [this]() { + menu.add_action("file_reload_file", [this]() { if(auto view=Notebook::get().get_current_view()) { Gtk::MessageDialog dialog(*static_cast(get_toplevel()), "Reload file!", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO); dialog.set_default_response(Gtk::RESPONSE_YES); @@ -299,7 +299,7 @@ void Window::set_menu_actions() { } }); - menu.add_action("save", [this]() { + menu.add_action("file_save", [this]() { if(auto view=Notebook::get().get_current_view()) { if(Notebook::get().save_current()) { if(view->file_path==Config::get().home_juci_path/"config"/"config.json") { @@ -312,7 +312,7 @@ void Window::set_menu_actions() { } } }); - menu.add_action("save_as", [this]() { + menu.add_action("file_save_as", [this]() { if(auto view=Notebook::get().get_current_view()) { auto path = Dialog::save_file_as(view->file_path); if(path!="") { @@ -331,7 +331,7 @@ void Window::set_menu_actions() { } }); - menu.add_action("print", [this]() { + menu.add_action("file_print", [this]() { if(auto view=Notebook::get().get_current_view()) { auto print_operation=Gtk::PrintOperation::create(); auto print_compositor=Gsv::PrintCompositor::create(*view); @@ -948,7 +948,7 @@ void Window::set_menu_actions() { }); EntryBox::get().show(); }); - menu.add_action("compile_and_run", [this]() { + menu.add_action("project_compile_and_run", [this]() { if(Project::compiling || Project::debugging) { Info::get().print("Compile or debug in progress"); return; @@ -961,7 +961,7 @@ void Window::set_menu_actions() { Project::current->compile_and_run(); }); - menu.add_action("compile", [this]() { + menu.add_action("project_compile", [this]() { if(Project::compiling || Project::debugging) { Info::get().print("Compile or debug in progress"); return; @@ -985,7 +985,7 @@ void Window::set_menu_actions() { Project::current->recreate_build(); }); - menu.add_action("run_command", [this]() { + menu.add_action("project_run_command", [this]() { EntryBox::get().clear(); EntryBox::get().labels.emplace_back(); auto label_it=EntryBox::get().labels.begin(); @@ -1013,10 +1013,10 @@ void Window::set_menu_actions() { EntryBox::get().show(); }); - menu.add_action("kill_last_running", [this]() { + menu.add_action("project_kill_last_running", [this]() { Terminal::get().kill_last_async_process(); }); - menu.add_action("force_kill_last_running", [this]() { + menu.add_action("project_force_kill_last_running", [this]() { Terminal::get().kill_last_async_process(true); }); @@ -1141,13 +1141,13 @@ void Window::set_menu_actions() { Project::debug_update_status(""); #endif - menu.add_action("next_tab", [this]() { + menu.add_action("window_next_tab", [this]() { Notebook::get().next(); }); - menu.add_action("previous_tab", [this]() { + menu.add_action("window_previous_tab", [this]() { Notebook::get().previous(); }); - menu.add_action("close_tab", [this]() { + menu.add_action("window_close_tab", [this]() { if(Notebook::get().get_current_view()) Notebook::get().close_current(); }); @@ -1172,7 +1172,7 @@ void Window::activate_menu_items() { auto &menu = Menu::get(); auto view=Notebook::get().get_current_view(); - menu.actions["reload_file"]->set_enabled(view); + menu.actions["file_reload_file"]->set_enabled(view); menu.actions["source_spellcheck"]->set_enabled(view); menu.actions["source_spellcheck_clear"]->set_enabled(view); menu.actions["source_spellcheck_next_error"]->set_enabled(view);