From d378051ea70951c4d29df78510f35175c76ff6fc Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 18 Nov 2015 17:44:14 +0100 Subject: [PATCH 01/15] No longer crashes when doing spell check buffer with missing spell check language. --- src/source.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/source.cc b/src/source.cc index 2688854..c634aa3 100644 --- a/src/source.cc +++ b/src/source.cc @@ -655,6 +655,8 @@ void Source::View::set_info(const std::string &info) { } void Source::View::spellcheck(const Gtk::TextIter& start, const Gtk::TextIter& end) { + if(spellcheck_checker==NULL) + return; auto iter=start; while(iter && iter Date: Wed, 18 Nov 2015 17:51:58 +0100 Subject: [PATCH 02/15] Spellcheck encoding is now always utf-8. --- src/source.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/source.cc b/src/source.cc index c634aa3..2992f0d 100644 --- a/src/source.cc +++ b/src/source.cc @@ -371,8 +371,10 @@ void Source::View::configure() { note_tag->property_foreground()=style->property_foreground(); } - if(Singleton::config->source.spellcheck_language.size()>0) + if(Singleton::config->source.spellcheck_language.size()>0) { aspell_config_replace(spellcheck_config, "lang", Singleton::config->source.spellcheck_language.c_str()); + aspell_config_replace(spellcheck_config, "encoding", "utf-8"); + } spellcheck_possible_err=new_aspell_speller(spellcheck_config); if(spellcheck_checker!=NULL) delete_aspell_speller(spellcheck_checker); From 9d5ab766f6e222526eb5e86bb2cbf2ecc20afd2a Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 18 Nov 2015 18:33:39 +0100 Subject: [PATCH 03/15] Fixed crashes related to boost::filesystem::exists and ::last_write_time. --- src/directories.cc | 29 ++++++++++++++++++----------- src/window.cc | 4 +++- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/directories.cc b/src/directories.cc index b7e5c7e..1f70846 100644 --- a/src/directories.cc +++ b/src/directories.cc @@ -90,19 +90,19 @@ Directories::Directories() : stop_update_thread(false) { update_mutex.lock(); if(update_paths.size()==0) { for(auto it=last_write_times.begin();it!=last_write_times.end();) { - try { - if(boost::filesystem::exists(it->first)) { //Added for older boost versions (no exception thrown) - if(it->second.secondfirst)) { - update_paths.emplace_back(it->first); - } - it++; + boost::system::error_code ec; + auto exists=boost::filesystem::exists(it->first, ec); + std::time_t last_write_time; + if(!ec && exists) + last_write_time=boost::filesystem::last_write_time(it->first, ec); + if(!ec) { + if(it->second.secondfirst); } - else - it=last_write_times.erase(it); + it++; } - catch(const std::exception &e) { + else it=last_write_times.erase(it); - } } if(update_paths.size()>0) update_dispatcher(); @@ -198,7 +198,14 @@ void Directories::select(const boost::filesystem::path &path) { } void Directories::add_path(const boost::filesystem::path& dir_path, const Gtk::TreeModel::Row &parent) { - last_write_times[dir_path.string()]={parent, boost::filesystem::last_write_time(dir_path)}; + boost::system::error_code ec; + auto exists=boost::filesystem::exists(dir_path, ec); + if(ec || !exists) + return; + auto last_write_time=boost::filesystem::last_write_time(dir_path, ec); + if(ec) + return; + last_write_times[dir_path.string()]={parent, last_write_time}; std::unique_ptr children; //Gtk::TreeNodeChildren is missing default constructor... if(parent) children=std::unique_ptr(new Gtk::TreeNodeChildren(parent.children())); diff --git a/src/window.cc b/src/window.cc index b157296..3d8576d 100644 --- a/src/window.cc +++ b/src/window.cc @@ -172,7 +172,9 @@ void Window::set_menu_actions() { auto time_now=std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); boost::filesystem::path path = Dialog::new_folder(); if(path!="" && boost::filesystem::exists(path)) { - if(boost::filesystem::last_write_time(path)>=time_now) { + boost::system::error_code ec; + auto last_write_time=boost::filesystem::last_write_time(path, ec); + if(!ec && last_write_time>=time_now) { if(Singleton::directories->current_path!="") Singleton::directories->update(); Singleton::terminal->print("New folder "+path.string()+" created.\n"); From 6ca8fd6146c6f1874cdef422c1590aafafea7f0d Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 18 Nov 2015 18:42:47 +0100 Subject: [PATCH 04/15] Simplified boost::filesystem::last_write_time check. --- src/directories.cc | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/directories.cc b/src/directories.cc index 1f70846..89f19f6 100644 --- a/src/directories.cc +++ b/src/directories.cc @@ -91,10 +91,7 @@ Directories::Directories() : stop_update_thread(false) { if(update_paths.size()==0) { for(auto it=last_write_times.begin();it!=last_write_times.end();) { boost::system::error_code ec; - auto exists=boost::filesystem::exists(it->first, ec); - std::time_t last_write_time; - if(!ec && exists) - last_write_time=boost::filesystem::last_write_time(it->first, ec); + auto last_write_time=boost::filesystem::last_write_time(it->first, ec); if(!ec) { if(it->second.secondfirst); @@ -199,9 +196,6 @@ void Directories::select(const boost::filesystem::path &path) { void Directories::add_path(const boost::filesystem::path& dir_path, const Gtk::TreeModel::Row &parent) { boost::system::error_code ec; - auto exists=boost::filesystem::exists(dir_path, ec); - if(ec || !exists) - return; auto last_write_time=boost::filesystem::last_write_time(dir_path, ec); if(ec) return; From f7345110cb795404129d645ff0c08242b2e7ff16 Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 18 Nov 2015 18:56:41 +0100 Subject: [PATCH 05/15] Added error_code to boost::filesystem::current_path. --- src/dialogs.cc | 9 +++++++-- src/dialogs_win.cc | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/dialogs.cc b/src/dialogs.cc index 8f66ab0..5e32036 100644 --- a/src/dialogs.cc +++ b/src/dialogs.cc @@ -3,6 +3,9 @@ #include "singletons.h" #include +#include +using namespace std; + namespace sigc { #ifndef SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE template @@ -42,9 +45,11 @@ std::string Dialog::gtk_dialog(const std::string &title, dialog.set_transient_for(*application->window); auto current_path=application->window->notebook.get_current_folder(); + boost::system::error_code ec; if(current_path.empty()) - current_path=boost::filesystem::current_path(); - gtk_file_chooser_set_current_folder((GtkFileChooser*)dialog.gobj(), current_path.string().c_str()); + current_path=boost::filesystem::current_path(ec); + if(!ec) + gtk_file_chooser_set_current_folder((GtkFileChooser*)dialog.gobj(), current_path.string().c_str()); if (!file_name.empty()) gtk_file_chooser_set_filename((GtkFileChooser*)dialog.gobj(), file_name.c_str()); diff --git a/src/dialogs_win.cc b/src/dialogs_win.cc index 377bf16..72d1869 100644 --- a/src/dialogs_win.cc +++ b/src/dialogs_win.cc @@ -99,8 +99,11 @@ private: auto application=Glib::RefPtr::cast_static(gio_application); auto current_path=application->window->notebook.get_current_folder(); + boost::system::error_code ec; if(current_path.empty()) - current_path=boost::filesystem::current_path(); + current_path=boost::filesystem::current_path(ec); + if(ec) + return false; std::wstring path=current_path.native(); size_t pos=0; From 4af41896573e9fc68a0c7fa3db4921b98b638a58 Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 18 Nov 2015 19:11:11 +0100 Subject: [PATCH 06/15] Rename entry does not show anymore when no token is found. --- src/window.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/window.cc b/src/window.cc index 3d8576d..d2b5526 100644 --- a/src/window.cc +++ b/src/window.cc @@ -879,7 +879,7 @@ void Window::rename_token_entry() { if(notebook.get_current_page()!=-1) { if(notebook.get_current_view()->get_token) { auto token=std::make_shared(notebook.get_current_view()->get_token()); - if(token) { + if(*token) { entry_box.labels.emplace_back(); auto label_it=entry_box.labels.begin(); label_it->update=[label_it](int state, const std::string& message){ From d1f50f434629901e0146b96b72069faa546beb41 Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 18 Nov 2015 19:38:26 +0100 Subject: [PATCH 07/15] Fixed another paste crash. --- src/source.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/source.cc b/src/source.cc index 2992f0d..612ea3f 100644 --- a/src/source.cc +++ b/src/source.cc @@ -535,11 +535,10 @@ void Source::View::replace_all(const std::string &replacement) { void Source::View::paste() { std::string text=Gtk::Clipboard::get()->wait_for_text(); - //remove carriage returns (which leads to crash) + //replace carriage returns (which leads to crash) with newlines for(auto it=text.begin();it!=text.end();it++) { - if(*it=='\r') { - it=text.erase(it); - } + if(*it=='\r') + text.replace(it, it+1, "\n"); } auto line=get_line_before(); From 09499c4c032f149860bac5f2bbd73c00e072c81a Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 18 Nov 2015 20:00:47 +0100 Subject: [PATCH 08/15] Hopefully the last paste-bug-fix. --- src/source.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/source.cc b/src/source.cc index 612ea3f..c31c828 100644 --- a/src/source.cc +++ b/src/source.cc @@ -535,10 +535,14 @@ void Source::View::replace_all(const std::string &replacement) { void Source::View::paste() { std::string text=Gtk::Clipboard::get()->wait_for_text(); - //replace carriage returns (which leads to crash) with newlines - for(auto it=text.begin();it!=text.end();it++) { - if(*it=='\r') - text.replace(it, it+1, "\n"); + //Replace carriage returns (which leads to crash) with newlines + for(size_t c=0;c Date: Wed, 18 Nov 2015 20:15:59 +0100 Subject: [PATCH 09/15] Removed iostream and std namespace from dialogs.cc. --- src/dialogs.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/dialogs.cc b/src/dialogs.cc index 5e32036..afcd1e0 100644 --- a/src/dialogs.cc +++ b/src/dialogs.cc @@ -3,9 +3,6 @@ #include "singletons.h" #include -#include -using namespace std; - namespace sigc { #ifndef SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE template From 73d4889b68cec137f318335e3175e0ed7d2f05d6 Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 19 Nov 2015 17:48:12 +0100 Subject: [PATCH 10/15] Tokens are now bold when using go to usage and go to methods. --- src/selectiondialog.cc | 58 +++++++++++++++++++++++++++++------------- src/selectiondialog.h | 24 ++++++++++++++--- src/source_clang.cc | 47 ++++++++++++++++++++++++++++++---- src/window.cc | 2 +- 4 files changed, 105 insertions(+), 26 deletions(-) diff --git a/src/selectiondialog.cc b/src/selectiondialog.cc index 012ecb8..490371d 100644 --- a/src/selectiondialog.cc +++ b/src/selectiondialog.cc @@ -15,8 +15,31 @@ namespace sigc { #endif } -SelectionDialogBase::SelectionDialogBase(Gtk::TextView& text_view, Glib::RefPtr start_mark, bool show_search_entry): text_view(text_view), -start_mark(start_mark), show_search_entry(show_search_entry), list_view_text(1, false, Gtk::SelectionMode::SELECTION_BROWSE) { +ListViewText::ListViewText(bool use_markup) : Gtk::TreeView(), use_markup(use_markup) { + list_store = Gtk::ListStore::create(column_record); + set_model(list_store); + append_column("", cell_renderer); + if(use_markup) + get_column(0)->add_attribute(cell_renderer.property_markup(), column_record.text); + else + get_column(0)->add_attribute(cell_renderer.property_text(), column_record.text); + + get_selection()->set_mode(Gtk::SelectionMode::SELECTION_BROWSE); + set_enable_search(true); + set_headers_visible(false); + set_hscroll_policy(Gtk::ScrollablePolicy::SCROLL_NATURAL); + set_activate_on_single_click(true); + set_hover_selection(false); + set_rules_hint(true); +} + +void ListViewText::ListViewText::append(const std::string& value) { + auto new_row=list_store->append(); + new_row->set_value(column_record.text, value); +} + +SelectionDialogBase::SelectionDialogBase(Gtk::TextView& text_view, Glib::RefPtr start_mark, bool show_search_entry, bool use_markup): text_view(text_view), +list_view_text(use_markup), start_mark(start_mark), show_search_entry(show_search_entry) { if(!show_search_entry) window=std::unique_ptr(new Gtk::Window(Gtk::WindowType::WINDOW_POPUP)); else @@ -27,13 +50,6 @@ start_mark(start_mark), show_search_entry(show_search_entry), list_view_text(1, window->property_decorated()=false; window->set_skip_taskbar_hint(true); scrolled_window.set_policy(Gtk::PolicyType::POLICY_AUTOMATIC, Gtk::PolicyType::POLICY_AUTOMATIC); - list_view_text.set_enable_search(true); - list_view_text.set_headers_visible(false); - list_view_text.set_hscroll_policy(Gtk::ScrollablePolicy::SCROLL_NATURAL); - list_view_text.set_activate_on_single_click(true); - list_view_text.set_hover_selection(false); - list_view_text.set_rules_hint(true); - //list_view_text.set_fixed_height_mode(true); //TODO: This is buggy on OS X, remember to post an issue on GTK+ 3 list_view_text.signal_realize().connect([this](){ resize(); @@ -89,8 +105,8 @@ void SelectionDialogBase::hide() { } void SelectionDialogBase::update_tooltips() { - if(list_view_text.get_selected().size()>0) { - auto it=list_view_text.get_selection()->get_selected(); + auto it=list_view_text.get_selection()->get_selected(); + if(it) { std::string row; it->get_value(0, row); if(row!=last_row || last_row.size()==0) { @@ -155,7 +171,7 @@ void SelectionDialogBase::resize() { } } -SelectionDialog::SelectionDialog(Gtk::TextView& text_view, Glib::RefPtr start_mark, bool show_search_entry) : SelectionDialogBase(text_view, start_mark, show_search_entry) {} +SelectionDialog::SelectionDialog(Gtk::TextView& text_view, Glib::RefPtr start_mark, bool show_search_entry, bool use_markup) : SelectionDialogBase(text_view, start_mark, show_search_entry, use_markup) {} void SelectionDialog::show() { SelectionDialogBase::show(); @@ -168,6 +184,14 @@ void SelectionDialog::show() { auto search_key_lc=*search_key; std::transform(row_lc.begin(), row_lc.end(), row_lc.begin(), ::tolower); std::transform(search_key_lc.begin(), search_key_lc.end(), search_key_lc.begin(), ::tolower); + if(list_view_text.use_markup) { + size_t pos=0; + while((pos=row_lc.find('<', pos))!=std::string::npos) { + auto pos2=row_lc.find('>', pos+1); + row_lc.erase(pos, pos2-pos+1); + } + search_key_lc=Glib::Markup::escape_text(search_key_lc); + } if(row_lc.find(search_key_lc)!=std::string::npos) return true; return false; @@ -221,8 +245,8 @@ void SelectionDialog::show() { }); auto activate=[this](){ - if(on_select && list_view_text.get_selected().size()>0) { - auto it=list_view_text.get_selection()->get_selected(); + auto it=list_view_text.get_selection()->get_selected(); + if(on_select && it) { std::string row; it->get_value(0, row); on_select(row, true); @@ -288,7 +312,7 @@ bool SelectionDialog::on_key_press(GdkEventKey* key) { return false; } -CompletionDialog::CompletionDialog(Gtk::TextView& text_view, Glib::RefPtr start_mark) : SelectionDialogBase(text_view, start_mark, false) {} +CompletionDialog::CompletionDialog(Gtk::TextView& text_view, Glib::RefPtr start_mark) : SelectionDialogBase(text_view, start_mark, false, false) {} void CompletionDialog::show() { SelectionDialogBase::show(); @@ -344,8 +368,8 @@ void CompletionDialog::show() { void CompletionDialog::select(bool hide_window) { row_in_entry=true; - if(list_view_text.get_selected().size()>0) { - auto it=list_view_text.get_selection()->get_selected(); + auto it=list_view_text.get_selection()->get_selected(); + if(it) { std::string row; it->get_value(0, row); if(on_select) diff --git a/src/selectiondialog.h b/src/selectiondialog.h index 499c86f..b580176 100644 --- a/src/selectiondialog.h +++ b/src/selectiondialog.h @@ -6,9 +6,27 @@ #include "tooltips.h" #include +class ListViewText : public Gtk::TreeView { + class ColumnRecord : public Gtk::TreeModel::ColumnRecord { + public: + ColumnRecord() { + add(text); + } + Gtk::TreeModelColumn text; + }; +public: + bool use_markup; + ListViewText(bool use_markup); + void append(const std::string& value); +private: + Glib::RefPtr list_store; + ColumnRecord column_record; + Gtk::CellRendererText cell_renderer; +}; + class SelectionDialogBase { public: - SelectionDialogBase(Gtk::TextView& text_view, Glib::RefPtr start_mark, bool show_search_entry); + SelectionDialogBase(Gtk::TextView& text_view, Glib::RefPtr start_mark, bool show_search_entry, bool use_markup); ~SelectionDialogBase(); virtual void add_row(const std::string& row, const std::string& tooltip=""); virtual void show(); @@ -25,7 +43,7 @@ protected: std::unique_ptr window; Gtk::ScrolledWindow scrolled_window; - Gtk::ListViewText list_view_text; + ListViewText list_view_text; Gtk::Entry search_entry; bool show_search_entry; std::unique_ptr tooltips; @@ -37,7 +55,7 @@ private: class SelectionDialog : public SelectionDialogBase { public: - SelectionDialog(Gtk::TextView& text_view, Glib::RefPtr start_mark, bool show_search_entry=true); + SelectionDialog(Gtk::TextView& text_view, Glib::RefPtr start_mark, bool show_search_entry=true, bool use_markup=false); bool on_key_press(GdkEventKey* key); void show(); }; diff --git a/src/source_clang.cc b/src/source_clang.cc index 1173cfc..eb95b88 100644 --- a/src/source_clang.cc +++ b/src/source_clang.cc @@ -1059,13 +1059,36 @@ Source::ClangViewAutocomplete(file_path, project_path, language) { (token.language->get_id()=="chdr" || token.language->get_id()=="cpphdr" || token.language->get_id()=="c" || token.language->get_id()=="cpp" || token.language->get_id()=="objc")) { auto offsets=clang_tokens->get_similar_token_offsets(static_cast(token.type), token.spelling, token.usr); for(auto &offset: offsets) { + size_t whitespaces_removed=0; auto start_iter=get_buffer()->get_iter_at_line(offset.first.line-1); - while(!start_iter.ends_line() && (*start_iter==' ' || *start_iter=='\t')) + while(!start_iter.ends_line() && (*start_iter==' ' || *start_iter=='\t')) { start_iter.forward_char(); + whitespaces_removed++; + } auto end_iter=start_iter; while(!end_iter.ends_line()) end_iter.forward_char(); - usages.emplace_back(Offset(offset.first.line-1, offset.first.index-1, this->file_path), get_buffer()->get_text(start_iter, end_iter)); + std::string line=Glib::Markup::escape_text(get_buffer()->get_text(start_iter, end_iter)); + + //markup token as bold + size_t token_start_pos=offset.first.index-1-whitespaces_removed; + size_t token_end_pos=offset.second.index-1-whitespaces_removed; + size_t pos=0; + while((pos=line.find('&', pos))!=std::string::npos) { + size_t pos2=line.find(';', pos+2); + if(token_start_pos>pos) { + token_start_pos+=pos2-pos; + token_end_pos+=pos2-pos; + } + else if(token_end_pos>pos) + token_end_pos+=pos2-pos; + else + break; + pos=pos2+1; + } + line.insert(token_end_pos, ""); + line.insert(token_start_pos, ""); + usages.emplace_back(Offset(offset.first.line-1, offset.first.index-1, this->file_path), line); } } @@ -1083,14 +1106,28 @@ Source::ClangViewAutocomplete(file_path, project_path, language) { if(!visible_rect.intersects(iter_rect)) { get_iter_at_location(iter, 0, visible_rect.get_y()+visible_rect.get_height()/3); } - selection_dialog=std::unique_ptr(new SelectionDialog(*this, get_buffer()->create_mark(iter))); + selection_dialog=std::unique_ptr(new SelectionDialog(*this, get_buffer()->create_mark(iter), true, true)); auto rows=std::make_shared >(); auto methods=clang_tokens->get_cxx_methods(); if(methods.size()==0) return; for(auto &method: methods) { - (*rows)[method.first]=method.second; - selection_dialog->add_row(method.first); + std::string row=Glib::Markup::escape_text(method.first); + + //Add bold method token + size_t token_end_pos=row.find('('); + if(token_end_pos==0 || token_end_pos==std::string::npos) + continue; + auto pos=token_end_pos-1; + while(((row[pos]>='a' && row[pos]<='z') || + (row[pos]>='A' && row[pos]<='Z') || + (row[pos]>='0' && row[pos]<='9') || row[pos]=='_') && pos>0) + pos--; + row.insert(token_end_pos, ""); + row.insert(pos+1, ""); + + (*rows)[row]=method.second; + selection_dialog->add_row(row); } selection_dialog->on_select=[this, rows](const std::string& selected, bool hide_window) { auto offset=rows->at(selected); diff --git a/src/window.cc b/src/window.cc index d2b5526..0ddf799 100644 --- a/src/window.cc +++ b/src/window.cc @@ -427,7 +427,7 @@ void Window::set_menu_actions() { if(!visible_rect.intersects(iter_rect)) { current_view->get_iter_at_location(iter, 0, visible_rect.get_y()+visible_rect.get_height()/3); } - current_view->selection_dialog=std::unique_ptr(new SelectionDialog(*current_view, current_view->get_buffer()->create_mark(iter))); + current_view->selection_dialog=std::unique_ptr(new SelectionDialog(*current_view, current_view->get_buffer()->create_mark(iter), true, true)); auto rows=std::make_shared >(); //First add usages in current file From 0466a0eeaf0a3d973f507e28684de2742daaf66d Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 19 Nov 2015 21:25:43 +0100 Subject: [PATCH 11/15] Now clears list store on hide. --- src/selectiondialog.cc | 6 ++++++ src/selectiondialog.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/selectiondialog.cc b/src/selectiondialog.cc index 490371d..487b21e 100644 --- a/src/selectiondialog.cc +++ b/src/selectiondialog.cc @@ -38,6 +38,11 @@ void ListViewText::ListViewText::append(const std::string& value) { new_row->set_value(column_record.text, value); } +void ListViewText::ListViewText::hide() { + Gtk::TreeView::hide(); + list_store->clear(); +} + SelectionDialogBase::SelectionDialogBase(Gtk::TextView& text_view, Glib::RefPtr start_mark, bool show_search_entry, bool use_markup): text_view(text_view), list_view_text(use_markup), start_mark(start_mark), show_search_entry(show_search_entry) { if(!show_search_entry) @@ -99,6 +104,7 @@ void SelectionDialogBase::hide() { window->hide(); if(tooltips) tooltips->hide(); + list_view_text.hide(); if(on_hide && shown) on_hide(); shown=false; diff --git a/src/selectiondialog.h b/src/selectiondialog.h index b580176..b13fffb 100644 --- a/src/selectiondialog.h +++ b/src/selectiondialog.h @@ -18,6 +18,7 @@ public: bool use_markup; ListViewText(bool use_markup); void append(const std::string& value); + void hide(); private: Glib::RefPtr list_store; ColumnRecord column_record; From 9f03520586e284a8c8628b4e071dc07afacdfc1d Mon Sep 17 00:00:00 2001 From: "U-olece-PC\\olece" Date: Thu, 19 Nov 2015 21:56:44 +0100 Subject: [PATCH 12/15] list_view_text.hide() now only called once. --- src/selectiondialog.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/selectiondialog.cc b/src/selectiondialog.cc index 487b21e..ba1daaa 100644 --- a/src/selectiondialog.cc +++ b/src/selectiondialog.cc @@ -104,7 +104,6 @@ void SelectionDialogBase::hide() { window->hide(); if(tooltips) tooltips->hide(); - list_view_text.hide(); if(on_hide && shown) on_hide(); shown=false; From 578de1a83f796c41422f2a0d4129d70d251e277c Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 19 Nov 2015 22:05:42 +0100 Subject: [PATCH 13/15] Cleaned up go to usage abit. --- src/window.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/window.cc b/src/window.cc index 0ddf799..aa29431 100644 --- a/src/window.cc +++ b/src/window.cc @@ -466,10 +466,7 @@ void Window::set_menu_actions() { notebook.open(declaration_file); auto view=notebook.get_current_view(); view->get_buffer()->place_cursor(view->get_buffer()->get_iter_at_line_index(offset.line, offset.index)); - while(g_main_context_pending(NULL)) - g_main_context_iteration(NULL, false); - if(notebook.get_current_page()!=-1) - view->scroll_to(view->get_buffer()->get_insert(), 0.0, 1.0, 0.5); + view->scroll_to(view->get_buffer()->get_insert(), 0.0, 1.0, 0.5); view->delayed_tooltips_connection.disconnect(); }; current_view->selection_dialog->show(); From f4c9fa37802725159c5a7daaa1b9d6074739e5c2 Mon Sep 17 00:00:00 2001 From: eidheim Date: Sun, 22 Nov 2015 23:58:24 +0100 Subject: [PATCH 14/15] More correct bold use in goto method. --- src/source_clang.cc | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/source_clang.cc b/src/source_clang.cc index eb95b88..09e15c2 100644 --- a/src/source_clang.cc +++ b/src/source_clang.cc @@ -1113,19 +1113,34 @@ Source::ClangViewAutocomplete(file_path, project_path, language) { return; for(auto &method: methods) { std::string row=Glib::Markup::escape_text(method.first); - //Add bold method token size_t token_end_pos=row.find('('); if(token_end_pos==0 || token_end_pos==std::string::npos) continue; - auto pos=token_end_pos-1; - while(((row[pos]>='a' && row[pos]<='z') || - (row[pos]>='A' && row[pos]<='Z') || - (row[pos]>='0' && row[pos]<='9') || row[pos]=='_') && pos>0) + if(token_end_pos>8 && row.substr(token_end_pos-4, 4)==">") { + token_end_pos-=8; + size_t angle_bracket_count=1; + do { + if(row.substr(token_end_pos-4, 4)==">") { + angle_bracket_count++; + token_end_pos-=4; + } + else if(row.substr(token_end_pos-4, 4)=="<") { + angle_bracket_count--; + token_end_pos-=4; + } + else + token_end_pos--; + } while(angle_bracket_count>0 && token_end_pos>4); + } + auto pos=token_end_pos; + do { pos--; + } while(((row[pos]>='a' && row[pos]<='z') || + (row[pos]>='A' && row[pos]<='Z') || + (row[pos]>='0' && row[pos]<='9') || row[pos]=='_' || row[pos]=='~') && pos>0); row.insert(token_end_pos, ""); row.insert(pos+1, ""); - (*rows)[row]=method.second; selection_dialog->add_row(row); } From d56b4842350c344ce890787da3818f30e2a03651 Mon Sep 17 00:00:00 2001 From: eidheim Date: Mon, 23 Nov 2015 18:55:46 +0100 Subject: [PATCH 15/15] Added line numbers to goto method, and at the same time got rid of duplicate rows if declaration and implementation is in the same file. --- src/source_clang.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/source_clang.cc b/src/source_clang.cc index 09e15c2..8fb5ed0 100644 --- a/src/source_clang.cc +++ b/src/source_clang.cc @@ -1112,7 +1112,7 @@ Source::ClangViewAutocomplete(file_path, project_path, language) { if(methods.size()==0) return; for(auto &method: methods) { - std::string row=Glib::Markup::escape_text(method.first); + std::string row=std::to_string(method.second.line)+": "+Glib::Markup::escape_text(method.first); //Add bold method token size_t token_end_pos=row.find('('); if(token_end_pos==0 || token_end_pos==std::string::npos)