From 00b8a08c9a4ecda0a41b5fc8c96b9b0cc3ee1c33 Mon Sep 17 00:00:00 2001 From: eidheim Date: Sat, 3 Oct 2015 11:43:22 +0200 Subject: [PATCH 1/4] Source map show/hide configuration is now working. --- src/notebook.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/notebook.cc b/src/notebook.cc index 5b09708..e6d138a 100644 --- a/src/notebook.cc +++ b/src/notebook.cc @@ -107,7 +107,6 @@ void Notebook::open(const boost::filesystem::path &file_path) { #if GTK_VERSION_GE(3, 18) source_maps.emplace_back(Glib::wrap(gtk_source_map_new())); - hboxes.back()->pack_end(*source_maps.back(), Gtk::PACK_SHRINK); gtk_source_map_set_view(GTK_SOURCE_MAP(source_maps.back()->gobj()), source_views.back()->gobj()); #endif configure(source_views.size()-1); @@ -146,10 +145,12 @@ void Notebook::configure(int view_nr) { auto source_font_description=Pango::FontDescription(Singleton::Config::source()->font); auto source_map_font_desc=Pango::FontDescription(static_cast(source_font_description.get_family())+" "+Singleton::Config::source()->map_font_size); source_maps.at(view_nr)->override_font(source_map_font_desc); - if(Singleton::Config::source()->show_map) - source_maps.at(view_nr)->show(); - else - source_maps.at(view_nr)->hide(); + if(Singleton::Config::source()->show_map) { + if(hboxes.at(view_nr)->get_children().size()==1) + hboxes.at(view_nr)->pack_end(*source_maps.at(view_nr), Gtk::PACK_SHRINK); + } + else if(hboxes.at(view_nr)->get_children().size()==2) + hboxes.at(view_nr)->remove(*source_maps.at(view_nr)); #endif } From f7d8b9c9e9e3f97efc5f9ea87f2830813d3a285f Mon Sep 17 00:00:00 2001 From: eidheim Date: Sat, 3 Oct 2015 11:45:48 +0200 Subject: [PATCH 2/4] Improved spellcheck context settings for non-clang files. --- src/source.cc | 15 ++++++++++++--- src/source.h | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/source.cc b/src/source.cc index 4536f16..c9ef005 100644 --- a/src/source.cc +++ b/src/source.cc @@ -1210,13 +1210,16 @@ Source::GenericView::GenericView(const boost::filesystem::path &file_path, Glib: catch(const std::exception &e) { Singleton::terminal()->print("Error: error parsing language file "+language_file.string()+": "+e.what()+'\n'); } - add_keywords(completion_buffer_keywords, pt); + bool has_context_class=false; + parse_language_file(completion_buffer_keywords, has_context_class, pt); + if(!has_context_class) + spellcheck_all=false; completion_words->register_provider(completion_buffer_keywords); } } } -void Source::GenericView::add_keywords(Glib::RefPtr &completion_buffer, const boost::property_tree::ptree &pt) { +void Source::GenericView::parse_language_file(Glib::RefPtr &completion_buffer, bool &has_context_class, const boost::property_tree::ptree &pt) { bool case_insensitive=false; for(auto &node: pt) { if(node.first=="") { @@ -1231,8 +1234,14 @@ void Source::GenericView::add_keywords(Glib::RefPtr &completio completion_buffer->insert_at_cursor(data+'\n'); } } + else if(!has_context_class && node.first=="context") { + auto class_attribute=node.second.get(".class", ""); + auto class_disabled_attribute=node.second.get(".class-disabled", ""); + if(class_attribute.size()>0 || class_disabled_attribute.size()>0) + has_context_class=true; + } try { - add_keywords(completion_buffer, node.second); + parse_language_file(completion_buffer, has_context_class, node.second); } catch(const std::exception &e) { } diff --git a/src/source.h b/src/source.h index 4cb7ece..c69f178 100644 --- a/src/source.h +++ b/src/source.h @@ -171,7 +171,7 @@ namespace Source { public: GenericView(const boost::filesystem::path &file_path, Glib::RefPtr language); - void add_keywords(Glib::RefPtr &completion_buffer, const boost::property_tree::ptree &pt); + void parse_language_file(Glib::RefPtr &completion_buffer, bool &has_context_class, const boost::property_tree::ptree &pt); }; class ClangViewParse : public View { From 50174e5e12450da06ad5ab86df9c9f6d6df8bce5 Mon Sep 17 00:00:00 2001 From: eidheim Date: Sat, 3 Oct 2015 12:11:05 +0200 Subject: [PATCH 3/4] More robust case insensitive search for completion on non-clang files. --- src/source.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/source.cc b/src/source.cc index c9ef005..60e8ac0 100644 --- a/src/source.cc +++ b/src/source.cc @@ -1223,7 +1223,9 @@ void Source::GenericView::parse_language_file(Glib::RefPtr &co bool case_insensitive=false; for(auto &node: pt) { if(node.first=="") { - if(static_cast(node.second.data())==" case insensitive ") + auto data=static_cast(node.second.data()); + std::transform(data.begin(), data.end(), data.begin(), ::tolower); + if(data.find("case insensitive")!=std::string::npos) case_insensitive=true; } else if(node.first=="keyword") { From 997f3fc855df94dd2df918dc168868bead9b2186 Mon Sep 17 00:00:00 2001 From: eidheim Date: Sat, 3 Oct 2015 12:25:02 +0200 Subject: [PATCH 4/4] Fixed a bug where renamed tokens remained bold. --- src/source.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/source.cc b/src/source.cc index 60e8ac0..224ddb6 100644 --- a/src/source.cc +++ b/src/source.cc @@ -2136,7 +2136,7 @@ Source::ClangViewAutocomplete(file_path, project_path, language) { for(auto &mark: marks) { renaming=true; get_buffer()->erase(mark.first->get_iter(), mark.second->get_iter()); - get_buffer()->insert_with_tag(mark.first->get_iter(), text, similar_tokens_tag); + get_buffer()->insert(mark.first->get_iter(), text); get_buffer()->delete_mark(mark.first); get_buffer()->delete_mark(mark.second); }