From 136e70d15b6fb24fbedf05205ba0682497e46eb0 Mon Sep 17 00:00:00 2001 From: tedjk Date: Fri, 15 May 2015 14:31:01 +0200 Subject: [PATCH] fixed legal extensions to parse in source and notebook, with GM --- juci/config.json | 13 ++++++++++--- juci/notebook.cc | 22 +++++++++++----------- juci/notebook.h | 4 ++-- juci/source.cc | 2 +- juci/source.h | 2 +- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/juci/config.json b/juci/config.json index 743f9f3..cc39637 100644 --- a/juci/config.json +++ b/juci/config.json @@ -18,9 +18,16 @@ "705": "comment" }, "extensions": [ - "ext1", - "ext2", - "ext3" + "c", + "cc", + "cpp", + "cxx", + "c++", + "h", + "hh", + "hpp", + "hxx", + "h++" ] }, "keybindings": { diff --git a/juci/notebook.cc b/juci/notebook.cc index 238b42b..0f16e40 100644 --- a/juci/notebook.cc +++ b/juci/notebook.cc @@ -160,7 +160,7 @@ bool Notebook::Controller::OnKeyRelease(GdkEventKey* key) { bool Notebook::Controller::GeneratePopup(int key_id) { INFO("Notebook genereate popup, getting iters"); std::string path = text_vec_.at(CurrentPage())->path(); - if(!LeagalExtension(path.substr(path.find_last_of(".") + 1))) return false; + if (!LegalExtension(path.substr(path.find_last_of(".") + 1))) return false; // Get function to fill popup with suggests item vector under is for testing Gtk::TextIter beg = CurrentTextView().get_buffer()->get_insert()->get_iter(); Gtk::TextIter end = CurrentTextView().get_buffer()->get_insert()->get_iter(); @@ -715,19 +715,19 @@ void Notebook::Controller::AskToSaveDialog() { } } -bool Notebook::Controller::LeagalExtension(std::string e) { +bool Notebook::Controller::LegalExtension(std::string e) { std::transform(e.begin(), e.end(),e.begin(), ::tolower); std::vector extensions = - text_vec_.at(CurrentPage).leagalParseExtensions(); - - if(std::find(extensions.begin(), extensions.end(), e)) { + source_config().extensiontable(); - // if(e=="c" ||e=="cc" ||e=="cpp" ||e=="cxx" || e=="c++"|| - // e=="h" ||e=="hh" ||e=="hpp" ||e=="hxx" || e=="h++"){ - DEBUG("Leagal extension"); - return true; - } - DEBUG("Ileagal extension"); + if (find(extensions.begin(), extensions.end(), e) != extensions.end()) { + DEBUG("Legal extension"); + return true; + + // if(e=="c" ||e=="cc" ||e=="cpp" ||e=="cxx" || e=="c++"|| + // e=="h" ||e=="hh" ||e=="hpp" ||e=="hxx" || e=="h++"){ + } + DEBUG("Ilegal extension"); return false; } diff --git a/juci/notebook.h b/juci/notebook.h index f5ef2ba..6991b32 100644 --- a/juci/notebook.h +++ b/juci/notebook.h @@ -68,7 +68,7 @@ namespace Notebook { Gtk::Paned& view(); bool GeneratePopup(int key); void Search(bool forward); - const Source::Config& source_config() { return source_config_; } + Source::Config& source_config() { return source_config_; } bool OnMouseRelease(GdkEventButton* button); bool OnKeyRelease(GdkEventKey* key); std::string OnSaveFileAs(); @@ -89,7 +89,7 @@ namespace Notebook { int ¤t_x, int ¤t_y); void AskToSaveDialog(); - bool LeagalExtension(std::string extension); + bool LegalExtension(std::string extension); Glib::RefPtr m_refBuilder; Glib::RefPtr refActionGroup; Source::Config source_config_; diff --git a/juci/source.cc b/juci/source.cc index 7b2dde2..6667450 100644 --- a/juci/source.cc +++ b/juci/source.cc @@ -70,7 +70,7 @@ const std::unordered_map& Source::Config::typetable() const { return typetable_; } - std::vector& Source::Config::extensiontable() { +const std::vector& Source::Config::extensiontable() const{ return extensiontable_; } diff --git a/juci/source.h b/juci/source.h index cbdcfc1..64b7618 100644 --- a/juci/source.h +++ b/juci/source.h @@ -20,7 +20,7 @@ namespace Source { Config(); const std::unordered_map& tagtable() const; const std::unordered_map& typetable() const; - std::vector& extensiontable(); + const std::vector& extensiontable() const; void SetTagTable(const std::unordered_map &tagtable); void InsertTag(const std::string &key, const std::string &value);