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/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/juci.cc b/src/juci.cc index 14e95a1..f609ce0 100644 --- a/src/juci.cc +++ b/src/juci.cc @@ -44,6 +44,26 @@ int Application::on_command_line(const Glib::RefPtr 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; + 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); + } + last_current_file=pt.get("current_file"); + } + catch(const std::exception &) {} + } + bool first_directory=true; for(auto &directory: directories) { if(first_directory) { @@ -73,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/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; }; 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 diff --git a/src/source_clang.cc b/src/source_clang.cc index 98d297d..d49aaab 100644 --- a/src/source_clang.cc +++ b/src/source_clang.cc @@ -413,7 +413,26 @@ 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; + } + else 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(); diff --git a/src/window.cc b/src/window.cc index 7d89495..23540bf 100644 --- a/src/window.cc +++ b/src/window.cc @@ -803,6 +803,21 @@ 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); + 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 &) {} + auto size=notebook.size(); for(int c=0;csignal_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;