From 033f5e76de0995a64e9226e4e72a5823582e3309 Mon Sep 17 00:00:00 2001 From: eidheim Date: Fri, 25 Mar 2016 15:52:33 +0100 Subject: [PATCH 1/8] Now reopens folder and files from last session if starting juci without parameters. Related to issue mentioned in #170 --- src/juci.cc | 17 +++++++++++++++++ src/window.cc | 13 +++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/juci.cc b/src/juci.cc index 14e95a1..6cb92e8 100644 --- a/src/juci.cc +++ b/src/juci.cc @@ -44,6 +44,23 @@ int Application::on_command_line(const Glib::RefPtr void Application::on_activate() { add_window(Window::get()); Window::get().show(); + + if(directories.empty() && files.empty()) { + try { + boost::property_tree::ptree pt; + boost::property_tree::read_json((Config::get().juci_home_path()/"last_session.json").string(), pt); + auto folder=pt.get("folder"); + if(!folder.empty()) + directories.emplace_back(folder); + for(auto &v: pt.get_child("files")) { + std::string file=v.second.data(); + if(!file.empty()) + files.emplace_back(file); + } + } + catch(const std::exception &e) {} + } + bool first_directory=true; for(auto &directory: directories) { if(first_directory) { diff --git a/src/window.cc b/src/window.cc index 2adcea4..e1d7389 100644 --- a/src/window.cc +++ b/src/window.cc @@ -803,6 +803,19 @@ bool Window::on_key_press_event(GdkEventKey *event) { } bool Window::on_delete_event(GdkEventAny *event) { + try { + boost::property_tree::ptree pt_root, pt_files; + pt_root.put("folder", Directories::get().path.string()); + for(int c=0;cfile_path.string()); + pt_files.push_back(std::make_pair("", pt_child)); + } + pt_root.add_child("files", pt_files); + boost::property_tree::write_json((Config::get().juci_home_path()/"last_session.json").string(), pt_root); + } + catch(const std::exception &) {} + auto size=notebook.size(); for(int c=0;c Date: Fri, 25 Mar 2016 16:26:25 +0100 Subject: [PATCH 2/8] Now opens the last current file tab when starting juci without parameters --- src/juci.cc | 8 +++++++- src/window.cc | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/juci.cc b/src/juci.cc index 6cb92e8..f609ce0 100644 --- a/src/juci.cc +++ b/src/juci.cc @@ -45,6 +45,8 @@ void Application::on_activate() { add_window(Window::get()); Window::get().show(); + std::string last_current_file; + if(directories.empty() && files.empty()) { try { boost::property_tree::ptree pt; @@ -57,8 +59,9 @@ void Application::on_activate() { if(!file.empty()) files.emplace_back(file); } + last_current_file=pt.get("current_file"); } - catch(const std::exception &e) {} + catch(const std::exception &) {} } bool first_directory=true; @@ -90,6 +93,9 @@ void Application::on_activate() { for(auto &error: errors) Terminal::get().print(error, true); + + if(!last_current_file.empty()) + Notebook::get().open(last_current_file); } void Application::on_startup() { diff --git a/src/window.cc b/src/window.cc index e1d7389..3a22d37 100644 --- a/src/window.cc +++ b/src/window.cc @@ -812,6 +812,8 @@ bool Window::on_delete_event(GdkEventAny *event) { pt_files.push_back(std::make_pair("", pt_child)); } pt_root.add_child("files", pt_files); + if(notebook.get_current_page()!=-1) + pt_root.put("current_file", notebook.get_current_view()->file_path.string()); boost::property_tree::write_json((Config::get().juci_home_path()/"last_session.json").string(), pt_root); } catch(const std::exception &) {} From 95981f6b6a2dab670654d738cf20493902874442 Mon Sep 17 00:00:00 2001 From: eidheim Date: Fri, 25 Mar 2016 18:39:06 +0100 Subject: [PATCH 3/8] Improved debug value tooltips --- src/debug_clang.cc | 2 +- src/source_clang.cc | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/debug_clang.cc b/src/debug_clang.cc index 54f0d45..63b53fd 100644 --- a/src/debug_clang.cc +++ b/src/debug_clang.cc @@ -405,7 +405,7 @@ std::string Debug::Clang::get_value(const std::string &variable, const boost::fi } if(variable_value.empty()) { //In case a variable is missing file and line number, only do check on name - auto value=frame.FindVariable(variable.c_str()); + auto value=frame.GetValueForVariablePath(variable.c_str()); if(value.IsValid()) { lldb::SBStream stream; value.GetDescription(stream); diff --git a/src/source_clang.cc b/src/source_clang.cc index 98d297d..e3bed92 100644 --- a/src/source_clang.cc +++ b/src/source_clang.cc @@ -413,7 +413,22 @@ void Source::ClangViewParse::show_type_tooltips(const Gdk::Rectangle &rectangle) if(Debug::Clang::get().is_stopped()) { auto location=token.get_cursor().get_referenced().get_source_location(); Glib::ustring value_type="Value"; - Glib::ustring debug_value=Debug::Clang::get().get_value(token.get_spelling(), location.get_path(), location.get_offset().line, location.get_offset().index); + + auto start=get_buffer()->get_iter_at_line_index(token.offsets.first.line-1, token.offsets.first.index-1); + auto end=get_buffer()->get_iter_at_line_index(token.offsets.second.line-1, token.offsets.second.index-1); + auto iter=start; + while((*iter>='a' && *iter<='z') || (*iter>='A' && *iter<='Z') || (*iter>='0' && *iter<='9') || *iter=='_' || *iter=='.') { + start=iter; + if(!iter.backward_char()) + break; + if(*iter=='>') { + if(!(iter.backward_char() && *iter=='-' && iter.backward_char())) + break; + } + } + auto spelling=get_buffer()->get_text(start, end).raw(); + + Glib::ustring debug_value=Debug::Clang::get().get_value(spelling, location.get_path(), location.get_offset().line, location.get_offset().index); if(debug_value.empty()) { value_type="Return value"; auto cursor=token.get_cursor(); From 6dfdcb9ac45d6ef76c559e8a00e562948a5f162a Mon Sep 17 00:00:00 2001 From: eidheim Date: Sat, 26 Mar 2016 09:53:47 +0100 Subject: [PATCH 4/8] Improved debug value tooltips for static variables (SomeClass::some_variable) --- src/source_clang.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/source_clang.cc b/src/source_clang.cc index e3bed92..d49aaab 100644 --- a/src/source_clang.cc +++ b/src/source_clang.cc @@ -425,6 +425,10 @@ void Source::ClangViewParse::show_type_tooltips(const Gdk::Rectangle &rectangle) if(!(iter.backward_char() && *iter=='-' && iter.backward_char())) break; } + else if(*iter==':') { + if(!(iter.backward_char() && *iter==':' && iter.backward_char())) + break; + } } auto spelling=get_buffer()->get_text(start, end).raw(); From 6f18cbbb326ba4d290e2879934839dc618bd1bf7 Mon Sep 17 00:00:00 2001 From: eidheim Date: Sat, 26 Mar 2016 13:30:45 +0100 Subject: [PATCH 5/8] Improved undo/redo for backspace to line above --- src/source.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/source.cc b/src/source.cc index cb90111..8376501 100644 --- a/src/source.cc +++ b/src/source.cc @@ -1307,8 +1307,9 @@ bool Source::View::on_key_press_event_basic(GdkEventKey* key) { return true; } + auto stop=Gsv::View::on_key_press_event(key); get_source_buffer()->end_user_action(); - return Gsv::View::on_key_press_event(key); + return stop; } //Bracket language indentation From 31d54f0b3c0d74f16c5fd52c8ac8f92dddcfa0b9 Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 31 Mar 2016 11:54:47 +0200 Subject: [PATCH 6/8] Added tooltips with file path to tabs --- src/directories.cc | 4 +++- src/notebook.cc | 15 +++++++++------ src/notebook.h | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/directories.cc b/src/directories.cc index c73c004..5898c4c 100644 --- a/src/directories.cc +++ b/src/directories.cc @@ -95,10 +95,12 @@ bool Directories::TreeStore::drag_data_received_vfunc(const TreeModel::Path &pat for(;file_it!=view->file_path.end();file_it++) new_file_path/=*file_it; view->file_path=new_file_path; + g_signal_emit_by_name(view->get_buffer()->gobj(), "modified_changed"); } } - if(view->file_path==source_path) { + else if(view->file_path==source_path) { view->file_path=target_path; + g_signal_emit_by_name(view->get_buffer()->gobj(), "modified_changed"); break; } } diff --git a/src/notebook.cc b/src/notebook.cc index 9a43194..8c68a83 100644 --- a/src/notebook.cc +++ b/src/notebook.cc @@ -25,9 +25,10 @@ namespace sigc { #endif } -Notebook::TabLabel::TabLabel(const std::string &title) : Gtk::Box(Gtk::ORIENTATION_HORIZONTAL) { +Notebook::TabLabel::TabLabel(const boost::filesystem::path &path) : Gtk::Box(Gtk::ORIENTATION_HORIZONTAL) { set_can_focus(false); - label.set_text(title+' '); + set_tooltip_text(path.string()); + label.set_text(path.filename().string()+' '); label.set_can_focus(false); button.set_image_from_icon_name("window-close-symbolic", Gtk::ICON_SIZE_MENU); button.set_can_focus(false); @@ -135,8 +136,7 @@ void Notebook::open(const boost::filesystem::path &file_path) { configure(source_views.size()-1); //Set up tab label - std::string title=file_path.filename().string(); - tab_labels.emplace_back(new TabLabel(title)); + tab_labels.emplace_back(new TabLabel(file_path)); auto source_view=source_views.back(); tab_labels.back()->button.signal_clicked().connect([this, source_view](){ for(int c=0;clabel.set_text(title); + if(page!=-1) { + auto &tab_label=tab_labels.at(get_index(page)); + tab_label->label.set_text(title); + tab_label->set_tooltip_text(source_view->file_path.string()); + } }); JDEBUG("end"); diff --git a/src/notebook.h b/src/notebook.h index 6bb3127..db38ee6 100644 --- a/src/notebook.h +++ b/src/notebook.h @@ -12,7 +12,7 @@ class Notebook : public Gtk::Notebook { class TabLabel : public Gtk::Box { public: - TabLabel(const std::string &title); + TabLabel(const boost::filesystem::path &path); Gtk::Label label; Gtk::Button button; }; From 8de16e33ebd81bd2474be996255d67e28cf16712 Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 31 Mar 2016 18:24:25 +0200 Subject: [PATCH 7/8] Improvements to the find/replace box --- src/window.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/window.cc b/src/window.cc index ba6e3f8..7ec1374 100644 --- a/src/window.cc +++ b/src/window.cc @@ -891,34 +891,39 @@ void Window::search_and_replace_entry() { replace_entry_it->signal_changed().connect([this, replace_entry_it](){ last_replace=replace_entry_it->get_text(); }); + EntryBox::get().buttons.emplace_back("↑", [this](){ if(notebook.get_current_page()!=-1) notebook.get_current_view()->search_backward(); }); - EntryBox::get().buttons.back().set_tooltip_text("Find previous\n\nShortcut: press Shift+Enter in the search field"); + EntryBox::get().buttons.back().set_tooltip_text("Find Previous (Shortcut: ⇧Enter in Entry)"); EntryBox::get().buttons.emplace_back("⇄", [this, replace_entry_it](){ if(notebook.get_current_page()!=-1) { notebook.get_current_view()->replace_forward(replace_entry_it->get_text()); } }); - EntryBox::get().buttons.back().set_tooltip_text("Replace current selection\n\nShortcut: press Enter in the replacement field"); + EntryBox::get().buttons.back().set_tooltip_text("Replace Next (Shortcut: Enter in Entry)"); EntryBox::get().buttons.emplace_back("↓", [this](){ if(notebook.get_current_page()!=-1) notebook.get_current_view()->search_forward(); }); - EntryBox::get().buttons.back().set_tooltip_text("Find next\n\nShortcut: press Enter in the search field"); - EntryBox::get().buttons.emplace_back("Replace all", [this, replace_entry_it](){ + EntryBox::get().buttons.back().set_tooltip_text("Find Next (Shortcut: Enter in Entry)"); + EntryBox::get().buttons.emplace_back("Replace All", [this, replace_entry_it](){ if(notebook.get_current_page()!=-1) notebook.get_current_view()->replace_all(replace_entry_it->get_text()); }); - EntryBox::get().toggle_buttons.emplace_back("Match case"); + EntryBox::get().buttons.back().set_tooltip_text("Replace All"); + + EntryBox::get().toggle_buttons.emplace_back("Aa"); + EntryBox::get().toggle_buttons.back().set_tooltip_text("Match Case"); EntryBox::get().toggle_buttons.back().set_active(case_sensitive_search); EntryBox::get().toggle_buttons.back().on_activate=[this, search_entry_it](){ case_sensitive_search=!case_sensitive_search; if(notebook.get_current_page()!=-1) notebook.get_current_view()->search_highlight(search_entry_it->get_text(), case_sensitive_search, regex_search); }; - EntryBox::get().toggle_buttons.emplace_back("Use regex"); + EntryBox::get().toggle_buttons.emplace_back(".*"); + EntryBox::get().toggle_buttons.back().set_tooltip_text("Use Regex"); EntryBox::get().toggle_buttons.back().set_active(regex_search); EntryBox::get().toggle_buttons.back().on_activate=[this, search_entry_it](){ regex_search=!regex_search; From 87cf9306df5aabed5ff9c90e195b536de7d43d1a Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 31 Mar 2016 18:37:09 +0200 Subject: [PATCH 8/8] Minor spelling fixes --- src/window.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/window.cc b/src/window.cc index 7ec1374..23540bf 100644 --- a/src/window.cc +++ b/src/window.cc @@ -896,18 +896,18 @@ void Window::search_and_replace_entry() { if(notebook.get_current_page()!=-1) notebook.get_current_view()->search_backward(); }); - EntryBox::get().buttons.back().set_tooltip_text("Find Previous (Shortcut: ⇧Enter in Entry)"); + EntryBox::get().buttons.back().set_tooltip_text("Find Previous (shortcut: ⇧Enter in entry)"); EntryBox::get().buttons.emplace_back("⇄", [this, replace_entry_it](){ if(notebook.get_current_page()!=-1) { notebook.get_current_view()->replace_forward(replace_entry_it->get_text()); } }); - EntryBox::get().buttons.back().set_tooltip_text("Replace Next (Shortcut: Enter in Entry)"); + EntryBox::get().buttons.back().set_tooltip_text("Replace Next (shortcut: Enter in entry)"); EntryBox::get().buttons.emplace_back("↓", [this](){ if(notebook.get_current_page()!=-1) notebook.get_current_view()->search_forward(); }); - EntryBox::get().buttons.back().set_tooltip_text("Find Next (Shortcut: Enter in Entry)"); + EntryBox::get().buttons.back().set_tooltip_text("Find Next (shortcut: Enter in entry)"); EntryBox::get().buttons.emplace_back("Replace All", [this, replace_entry_it](){ if(notebook.get_current_page()!=-1) notebook.get_current_view()->replace_all(replace_entry_it->get_text());