Browse Source

fixed legal extensions to parse in source and notebook, with GM

merge-requests/365/head
tedjk 11 years ago
parent
commit
136e70d15b
  1. 13
      juci/config.json
  2. 14
      juci/notebook.cc
  3. 4
      juci/notebook.h
  4. 2
      juci/source.cc
  5. 2
      juci/source.h

13
juci/config.json

@ -18,9 +18,16 @@
"705": "comment" "705": "comment"
}, },
"extensions": [ "extensions": [
"ext1", "c",
"ext2", "cc",
"ext3" "cpp",
"cxx",
"c++",
"h",
"hh",
"hpp",
"hxx",
"h++"
] ]
}, },
"keybindings": { "keybindings": {

14
juci/notebook.cc

@ -160,7 +160,7 @@ bool Notebook::Controller::OnKeyRelease(GdkEventKey* key) {
bool Notebook::Controller::GeneratePopup(int key_id) { bool Notebook::Controller::GeneratePopup(int key_id) {
INFO("Notebook genereate popup, getting iters"); INFO("Notebook genereate popup, getting iters");
std::string path = text_vec_.at(CurrentPage())->path(); 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 // 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 beg = CurrentTextView().get_buffer()->get_insert()->get_iter();
Gtk::TextIter end = 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::transform(e.begin(), e.end(),e.begin(), ::tolower);
std::vector<std::string> extensions = std::vector<std::string> extensions =
text_vec_.at(CurrentPage).leagalParseExtensions(); source_config().extensiontable();
if(std::find(extensions.begin(), extensions.end(), e)) { 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++"|| // if(e=="c" ||e=="cc" ||e=="cpp" ||e=="cxx" || e=="c++"||
// e=="h" ||e=="hh" ||e=="hpp" ||e=="hxx" || e=="h++"){ // e=="h" ||e=="hh" ||e=="hpp" ||e=="hxx" || e=="h++"){
DEBUG("Leagal extension");
return true;
} }
DEBUG("Ileagal extension"); DEBUG("Ilegal extension");
return false; return false;
} }

4
juci/notebook.h

@ -68,7 +68,7 @@ namespace Notebook {
Gtk::Paned& view(); Gtk::Paned& view();
bool GeneratePopup(int key); bool GeneratePopup(int key);
void Search(bool forward); void Search(bool forward);
const Source::Config& source_config() { return source_config_; } Source::Config& source_config() { return source_config_; }
bool OnMouseRelease(GdkEventButton* button); bool OnMouseRelease(GdkEventButton* button);
bool OnKeyRelease(GdkEventKey* key); bool OnKeyRelease(GdkEventKey* key);
std::string OnSaveFileAs(); std::string OnSaveFileAs();
@ -89,7 +89,7 @@ namespace Notebook {
int &current_x, int &current_x,
int &current_y); int &current_y);
void AskToSaveDialog(); void AskToSaveDialog();
bool LeagalExtension(std::string extension); bool LegalExtension(std::string extension);
Glib::RefPtr<Gtk::Builder> m_refBuilder; Glib::RefPtr<Gtk::Builder> m_refBuilder;
Glib::RefPtr<Gio::SimpleActionGroup> refActionGroup; Glib::RefPtr<Gio::SimpleActionGroup> refActionGroup;
Source::Config source_config_; Source::Config source_config_;

2
juci/source.cc

@ -70,7 +70,7 @@ const std::unordered_map<string, string>& Source::Config::typetable() const {
return typetable_; return typetable_;
} }
std::vector<string>& Source::Config::extensiontable() { const std::vector<string>& Source::Config::extensiontable() const{
return extensiontable_; return extensiontable_;
} }

2
juci/source.h

@ -20,7 +20,7 @@ namespace Source {
Config(); Config();
const std::unordered_map<std::string, std::string>& tagtable() const; const std::unordered_map<std::string, std::string>& tagtable() const;
const std::unordered_map<std::string, std::string>& typetable() const; const std::unordered_map<std::string, std::string>& typetable() const;
std::vector<std::string>& extensiontable(); const std::vector<std::string>& extensiontable() const;
void SetTagTable(const std::unordered_map<std::string, std::string> void SetTagTable(const std::unordered_map<std::string, std::string>
&tagtable); &tagtable);
void InsertTag(const std::string &key, const std::string &value); void InsertTag(const std::string &key, const std::string &value);

Loading…
Cancel
Save