Browse Source

Merge pull request #66 from eidheim/master

Minor bug fixes
merge-requests/365/head
Ole Christian Eidheim 10 years ago
parent
commit
03dbdad621
  1. 11
      src/notebook.cc
  2. 21
      src/source.cc
  3. 2
      src/source.h

11
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<std::string>(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
}

21
src/source.cc

@ -1210,17 +1210,22 @@ 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<CompletionBuffer> &completion_buffer, const boost::property_tree::ptree &pt) {
void Source::GenericView::parse_language_file(Glib::RefPtr<CompletionBuffer> &completion_buffer, bool &has_context_class, const boost::property_tree::ptree &pt) {
bool case_insensitive=false;
for(auto &node: pt) {
if(node.first=="<xmlcomment>") {
if(static_cast<std::string>(node.second.data())==" case insensitive ")
auto data=static_cast<std::string>(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") {
@ -1231,8 +1236,14 @@ void Source::GenericView::add_keywords(Glib::RefPtr<CompletionBuffer> &completio
completion_buffer->insert_at_cursor(data+'\n');
}
}
else if(!has_context_class && node.first=="context") {
auto class_attribute=node.second.get<std::string>("<xmlattr>.class", "");
auto class_disabled_attribute=node.second.get<std::string>("<xmlattr>.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) {
}
@ -2125,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);
}

2
src/source.h

@ -171,7 +171,7 @@ namespace Source {
public:
GenericView(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language);
void add_keywords(Glib::RefPtr<CompletionBuffer> &completion_buffer, const boost::property_tree::ptree &pt);
void parse_language_file(Glib::RefPtr<CompletionBuffer> &completion_buffer, bool &has_context_class, const boost::property_tree::ptree &pt);
};
class ClangViewParse : public View {

Loading…
Cancel
Save