From b3ccd4bb89fb2efe72bd7589d651d46a3157a6f0 Mon Sep 17 00:00:00 2001 From: eidheim Date: Mon, 4 Jul 2016 11:20:22 +0200 Subject: [PATCH] Removed Ubuntu specific code, and fixed Ctags::get_result on older systems --- src/CMakeLists.txt | 11 - src/ctags.cc | 25 +- src/ctags.h | 2 +- src/menu.cc | 749 ++++++++++++++++++++------------------------ src/source_clang.cc | 2 +- src/window.cc | 2 +- 6 files changed, 353 insertions(+), 438 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b41f0aa..a4b9547 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,14 +1,3 @@ -if(UNIX) #Checking if compiling on Ubuntu that for instance has a buggy menu system - find_program(LSB_RELEASE_BIN lsb_release) - if(LSB_RELEASE_BIN) - execute_process(COMMAND ${LSB_RELEASE_BIN} -is - OUTPUT_VARIABLE DISTRIBUTION OUTPUT_STRIP_TRAILING_WHITESPACE) - if((DISTRIBUTION STREQUAL Ubuntu) OR (DISTRIBUTION STREQUAL LinuxMint)) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DJUCI_UBUNTU") - endif() - endif() -endif() - if(MSYS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMSYS_PROCESS_USE_SH") endif() diff --git a/src/ctags.cc b/src/ctags.cc index 45b86e2..1dd1f25 100644 --- a/src/ctags.cc +++ b/src/ctags.cc @@ -13,12 +13,19 @@ std::pair > Ctags::g auto run_path=build->project_path; std::string exclude; if(!run_path.empty()) { - auto path=filesystem::get_relative_path(build->get_default_path(), build->project_path); - if(!path.empty()) - exclude+=" --exclude="+path.string(); - path=filesystem::get_relative_path(build->get_debug_path(), build->project_path); - if(!path.empty()) - exclude+=" --exclude="+path.string(); + boost::system::error_code ec; + auto default_path=boost::filesystem::canonical(build->get_default_path(), ec); + if(!ec) { + auto path=filesystem::get_relative_path(default_path, build->project_path); + if(!path.empty()) + exclude+=" --exclude="+path.string(); + } + auto debug_path=boost::filesystem::canonical(build->get_debug_path(), ec); + if(!ec) { + auto path=filesystem::get_relative_path(debug_path, build->project_path); + if(!path.empty()) + exclude+=" --exclude="+path.string(); + } } else { if(!Directories::get().path.empty()) @@ -30,12 +37,12 @@ std::pair > Ctags::g std::stringstream stdin_stream; //TODO: when debian stable gets newer g++ version that supports move on streams, remove unique_ptr below std::unique_ptr stdout_stream(new std::stringstream()); - auto command=Config::get().project.ctags_command+exclude+" --fields=n --sort=foldcase -I \"override noexcept\" -f- -R *"; + auto command=Config::get().project.ctags_command+exclude+" --fields=n --sort=foldcase -I \"override noexcept\" -f - -R *"; Terminal::get().process(stdin_stream, *stdout_stream, command, run_path); return {run_path, std::move(stdout_stream)}; } -Ctags::Location Ctags::parse_line(const std::string &line, bool markup) { +Ctags::Location Ctags::get_location(const std::string &line, bool markup) { Location location; const static std::regex regex("^([^\t]+)\t([^\t]+)\t(?:/\\^)?([ \t]*)(.+)$"); @@ -133,7 +140,7 @@ Ctags::Location Ctags::get_location(const boost::filesystem::path &path, const s while(std::getline(*result.second, line)) { if(line.find(name)==std::string::npos) continue; - auto location=Ctags::parse_line(line, false); + auto location=Ctags::get_location(line, false); location.file_path=result.first/location.file_path; //Find match score diff --git a/src/ctags.h b/src/ctags.h index 062d9c7..7119af5 100644 --- a/src/ctags.h +++ b/src/ctags.h @@ -18,7 +18,7 @@ public: static std::pair > get_result(const boost::filesystem::path &path); - static Location parse_line(const std::string &line, bool markup); + static Location get_location(const std::string &line, bool markup); static Location get_location(const boost::filesystem::path &path, const std::string &name, const std::string &type); }; diff --git a/src/menu.cc b/src/menu.cc index e8888e6..64a613b 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -3,422 +3,341 @@ #include #include -//TODO: if Ubuntu ever gets fixed, cleanup the Ubuntu specific code Menu::Menu() { - auto accels=Config::get().menu.keys; - for(auto &accel: accels) { -#ifdef JUCI_UBUNTU - size_t pos=0; - std::string second=accel.second; - while((pos=second.find('<', pos))!=std::string::npos) { - second.replace(pos, 1, "<"); - pos+=4; - } - pos=0; - while((pos=second.find('>', pos))!=std::string::npos) { - second.replace(pos, 1, ">"); - pos+=4; - } - if(second.size()>0) - accel.second=""+second+""; - else - accel.second=""; -#else - accel.second=""; -#endif - } - - ui_xml = - "" - " " - "
" - " " - " _About" - " app.about" - +accels["about"]+ //For Ubuntu... - " " - "
" - "
" - " " - " _Preferences" - " app.preferences" - +accels["preferences"]+ //For Ubuntu... - " " - "
" - "
" - " " - " _Quit" - " app.quit" - +accels["quit"]+ //For Ubuntu... - " " - "
" - "
" - "" - " " - " " - " _File" - "
" - " " - " _New _File" - " app.new_file" - +accels["new_file"]+ //For Ubuntu... - " " - " " - " _New _Folder" - " app.new_folder" - +accels["new_folder"]+ //For Ubuntu... - " " - " " - " _New _Project" - " " - " C++" - " app.new_project_cpp" - +accels["new_project_cpp"]+ //For Ubuntu... - " " - " " - "
" - "
" - " " - " _Open _File" - " app.open_file" - +accels["open_file"]+ //For Ubuntu... - " " - " " - " _Open _Folder" - " app.open_folder" - +accels["open_folder"]+ //For Ubuntu... - " " - "
" - "
" - " " - " _Save" - " app.save" - +accels["save"]+ //For Ubuntu... - " " - " " - " _Save _As" - " app.save_as" - +accels["save_as"]+ //For Ubuntu... - " " - "
" - "
" - " " - " _Print" - " app.print" - +accels["print"]+ //For Ubuntu... - " " - "
" - "
" - "" - " " - " _Edit" - "
" - " " - " _Undo" - " app.edit_undo" - +accels["edit_undo"]+ //For Ubuntu... - " " - " " - " _Redo" - " app.edit_redo" - +accels["edit_redo"]+ //For Ubuntu... - " " - "
" - "
" - " " - " _Cut" - " app.edit_cut" - +accels["edit_cut"]+ //For Ubuntu... - " " - " " - " _Copy" - " app.edit_copy" - +accels["edit_copy"]+ //For Ubuntu... - " " - " " - " _Paste" - " app.edit_paste" - +accels["edit_paste"]+ //For Ubuntu... - " " - "
" - "
" - " " - " _Find" - " app.edit_find" - +accels["edit_find"]+ //For Ubuntu... - " " - "
" - "
" - "" - " " - " _Source" - "
" - " " - " _Spell _Check" - " " - " _Spell _Check _Buffer" - " app.source_spellcheck" - +accels["source_spellcheck"]+ //For Ubuntu... - " " - " " - " _Clear _Spelling _Errors" - " app.source_spellcheck_clear" - +accels["source_spellcheck_clear"]+ //For Ubuntu... - " " - " " - " _Go _to _Next _Spelling _Error" - " app.source_spellcheck_next_error" - +accels["source_spellcheck_next_error"]+ //For Ubuntu... - " " - " " - "
" - "
" - " " - " _Git" - " " - " _Go _to _Next _Diff" - " app.source_git_next_diff" - +accels["source_git_next_diff"]+ //For Ubuntu... - " " - " " - " _Show _Diff" - " app.source_git_show_diff" - +accels["source_git_show_diff"]+ //For Ubuntu... - " " - " " - "
" - "
" - " " - " _Indentation" - " " - " _Set _Current _Buffer _Tab" - " app.source_indentation_set_buffer_tab" - +accels["source_indentation_set_buffer_tab"]+ //For Ubuntu... - " " - " " - " _Auto-Indent _Current _Buffer" - " app.source_indentation_auto_indent_buffer" - +accels["source_indentation_auto_indent_buffer"]+ //For Ubuntu... - " " - " " - "
" - "
" - " " - " _Go _to _Line" - " app.source_goto_line" - +accels["source_goto_line"]+ //For Ubuntu... - " " - " " - " _Center _Cursor" - " app.source_center_cursor" - +accels["source_center_cursor"]+ //For Ubuntu... - " " - "
" - "
" - " " - " _Find _Symbol (Ctags)" - " app.source_find_symbol_ctags" - +accels["source_find_symbol_ctags"]+ //For Ubuntu... - " " - "
" - "
" - " " - " _Find _Documentation" - " app.source_find_documentation" - +accels["source_find_documentation"]+ //For Ubuntu... - " " - "
" - "
" - " " - " _Go to Declaration" - " app.source_goto_declaration" - +accels["source_goto_declaration"]+ //For Ubuntu... - " " - " " - " _Go to Implementation" - " app.source_goto_implementation" - +accels["source_goto_implementation"]+ //For Ubuntu... - " " - " " - " _Go to Usage" - " app.source_goto_usage" - +accels["source_goto_usage"]+ //For Ubuntu... - " " - " " - " _Go to Method" - " app.source_goto_method" - +accels["source_goto_method"]+ //For Ubuntu... - " " - " " - " _Rename" - " app.source_rename" - +accels["source_rename"]+ //For Ubuntu... - " " - " " - " _Implement _Method" - " app.source_implement_method" - +accels["source_implement_method"]+ //For Ubuntu... - " " - "
" - "
" - " " - " _Go to Next Diagnostic" - " app.source_goto_next_diagnostic" - +accels["source_goto_next_diagnostic"]+ //For Ubuntu... - " " - " " - " _Apply Fix-Its" - " app.source_apply_fix_its" - +accels["source_apply_fix_its"]+ //For Ubuntu... - " " - "
" - "
" - "" - " " - " _Project" - "
" - " " - " _Set _Run _Arguments" - " app.project_set_run_arguments" - +accels["project_set_run_arguments"]+ //For Ubuntu... - " " - " " - " _Compile _and _Run" - " app.compile_and_run" - +accels["compile_and_run"]+ //For Ubuntu... - " " - " " - " _Compile" - " app.compile" - +accels["compile"]+ //For Ubuntu... - " " - "
" - "
" - " " - " _Run _Command" - " app.run_command" - +accels["run_command"]+ //For Ubuntu... - " " - " " - " _Kill _Last _Process" - " app.kill_last_running" - +accels["kill_last_running"]+ //For Ubuntu... - " " - " " - " _Force _Kill _Last _Process" - " app.force_kill_last_running" - +accels["force_kill_last_running"]+ //For Ubuntu... - " " - "
" - "
" - "" - " " - " _Debug" - "
" - " " - " _Set _Run _Arguments" - " app.debug_set_run_arguments" - +accels["debug_set_run_arguments"]+ //For Ubuntu... - " " - " " - " _Start/_Continue" - " app.debug_start_continue" - +accels["debug_start_continue"]+ //For Ubuntu... - " " - " " - " _Stop" - " app.debug_stop" - +accels["debug_stop"]+ //For Ubuntu... - " " - " " - " _Kill" - " app.debug_kill" - +accels["debug_kill"]+ //For Ubuntu... - " " - "
" - "
" - " " - " _Step _Over" - " app.debug_step_over" - +accels["debug_step_over"]+ //For Ubuntu... - " " - " " - " _Step _Into" - " app.debug_step_into" - +accels["debug_step_into"]+ //For Ubuntu... - " " - " " - " _Step _Out" - " app.debug_step_out" - +accels["debug_step_out"]+ //For Ubuntu... - " " - "
" - "
" - " " - " _Backtrace" - " app.debug_backtrace" - +accels["debug_backtrace"]+ //For Ubuntu... - " " - " " - " _Show _Variables" - " app.debug_show_variables" - +accels["debug_show_variables"]+ //For Ubuntu... - " " - "
" - "
" - " " - " _Run Command" - " app.debug_run_command" - +accels["debug_run_command"]+ //For Ubuntu... - " " - "
" - "
" - " " - " _Toggle _Breakpoint" - " app.debug_toggle_breakpoint" - +accels["debug_toggle_breakpoint"]+ //For Ubuntu... - " " - "
" - "
" - " " - " _Go _to _Stop" - " app.debug_goto_stop" - +accels["debug_goto_stop"]+ //For Ubuntu... - " " - "
" - "
" - "" - " " - " _Window" - "
" - " " - " _Next _Tab" - " app.next_tab" - +accels["next_tab"]+ //For Ubuntu... - " " - " " - " _Previous _Tab" - " app.previous_tab" - +accels["previous_tab"]+ //For Ubuntu... - " " - "
" - "
" - " " - " _Close _Tab" - " app.close_tab" - +accels["close_tab"]+ //For Ubuntu... - " " - "
" - "
" - " " - " _Toggle _Split" - " app.window_toggle_split" - +accels["window_toggle_split"]+ //For Ubuntu... - " " - "
" - "
" - "
" - "
"; + ui_xml = R"RAW( + + +
+ + _About + app.about + +
+
+ + _Preferences + app.preferences + +
+
+ + _Quit + app.quit + +
+
+ + + + _File +
+ + _New _File + app.new_file + + + _New _Folder + app.new_folder + + + _New _Project + + C++ + app.new_project_cpp + + +
+
+ + _Open _File + app.open_file + + + _Open _Folder + app.open_folder + +
+
+ + _Save + app.save + + + _Save _As + app.save_as + +
+
+ + _Print + app.print + +
+
+ + + _Edit +
+ + _Undo + app.edit_undo + + + _Redo + app.edit_redo + +
+
+ + _Cut + app.edit_cut + + + _Copy + app.edit_copy + + + _Paste + app.edit_paste + +
+
+ + _Find + app.edit_find + +
+
+ + + _Source +
+ + _Spell _Check + + _Spell _Check _Buffer + app.source_spellcheck + + + _Clear _Spelling _Errors + app.source_spellcheck_clear + + + _Go _to _Next _Spelling _Error + app.source_spellcheck_next_error + + +
+
+ + _Git + + _Go _to _Next _Diff + app.source_git_next_diff + + + _Show _Diff + app.source_git_show_diff + + +
+
+ + _Indentation + + _Set _Current _Buffer _Tab + app.source_indentation_set_buffer_tab + + + _Auto-Indent _Current _Buffer + app.source_indentation_auto_indent_buffer + + +
+
+ + _Go _to _Line + app.source_goto_line + + + _Center _Cursor + app.source_center_cursor + +
+
+ + _Find _Symbol (Ctags) + app.source_find_symbol_ctags + +
+
+ + _Find _Documentation + app.source_find_documentation + +
+
+ + _Go to Declaration + app.source_goto_declaration + + + _Go to Implementation + app.source_goto_implementation + + + _Go to Usage + app.source_goto_usage + + + _Go to Method + app.source_goto_method + + + _Rename + app.source_rename + + + _Implement _Method + app.source_implement_method + +
+
+ + _Go to Next Diagnostic + app.source_goto_next_diagnostic + + + _Apply Fix-Its + app.source_apply_fix_its + +
+
+ + + _Project +
+ + _Set _Run _Arguments + app.project_set_run_arguments + + + _Compile _and _Run + app.compile_and_run + + + _Compile + app.compile + +
+
+ + _Run _Command + app.run_command + + + _Kill _Last _Process + app.kill_last_running + + + _Force _Kill _Last _Process + app.force_kill_last_running + +
+
+ + + _Debug +
+ + _Set _Run _Arguments + app.debug_set_run_arguments + + + _Start/_Continue + app.debug_start_continue + + + _Stop + app.debug_stop + + + _Kill + app.debug_kill + +
+
+ + _Step _Over + app.debug_step_over + + + _Step _Into + app.debug_step_into + + + _Step _Out + app.debug_step_out + +
+
+ + _Backtrace + app.debug_backtrace + + + _Show _Variables + app.debug_show_variables + +
+
+ + _Run Command + app.debug_run_command + +
+
+ + _Toggle _Breakpoint + app.debug_toggle_breakpoint + +
+
+ + _Go _to _Stop + app.debug_goto_stop + +
+
+ + + _Window +
+ + _Next _Tab + app.next_tab + + + _Previous _Tab + app.previous_tab + +
+
+ + _Close _Tab + app.close_tab + +
+
+ + _Toggle _Split + app.window_toggle_split + +
+
+
+
+)RAW"; } void Menu::add_action(const std::string &name, std::function action) { diff --git a/src/source_clang.cc b/src/source_clang.cc index 58930ae..0084802 100644 --- a/src/source_clang.cc +++ b/src/source_clang.cc @@ -805,7 +805,7 @@ std::unordered_map Source::ClangViewAutocomplete::auto Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file_path, Glib::RefPtr language) : Source::ClangViewParse(file_path, language) { similar_identifiers_tag=get_buffer()->create_tag(); - similar_identifiers_tag->property_weight()=1000; //TODO: replace with Pango::WEIGHT_ULTRAHEAVY in 2016 or so (when Ubuntu 14 is history) + similar_identifiers_tag->property_weight()=1000; //TODO: Replace 1000 with Pango::WEIGHT_ULTRAHEAVY when debian stable gets updated in 2017 get_buffer()->signal_changed().connect([this]() { if(!renaming && last_tagged_identifier) { diff --git a/src/window.cc b/src/window.cc index 6df4059..10d05ae 100644 --- a/src/window.cc +++ b/src/window.cc @@ -457,7 +457,7 @@ void Window::set_menu_actions() { std::string line; while(std::getline(*stream, line)) { - auto location=Ctags::parse_line(line, true); + auto location=Ctags::get_location(line, true); std::string row=location.file_path.string()+":"+std::to_string(location.line+1)+": "+location.source; (*rows)[row]=Source::Offset(location.line, location.index, location.file_path);