Browse Source

added legal file-extensions to source

master
tedjk 11 years ago
parent
commit
41b745b83d
  1. 4
      juci/api.cc
  2. 17
      juci/config.cc
  3. 7
      juci/config.json
  4. 37
      juci/directories.cc
  5. 3
      juci/notebook.cc
  6. 9
      juci/source.cc
  7. 4
      juci/source.h
  8. 2
      juci/window.cc

4
juci/api.cc

@ -8,9 +8,12 @@ Notebook::Controller* PluginApi::notebook_;
/////////////////////////////
PluginApi::PluginApi(Menu::Controller& menu_ctl_,
Notebook::Controller& notebook_ctl_) {
DEBUG("Adding pointers for the API");
menu_ = &menu_ctl_;
notebook_ = &notebook_ctl_;
DEBUG("Initiating plugins(from plugins.py)..");
InitPlugins();
DEBUG("Plugins initiated..");
}
PluginApi::~PluginApi() {
@ -61,6 +64,7 @@ void PluginApi::InitPlugins() {
}
void PluginApi::AddMenuElement(std::string plugin_name) {
DEBUG("Adding menu element for "+plugin_name);
AddMenuXml(plugin_name, "PluginMenu");
std::string plugin_action_name = plugin_name+"Menu";
menu_->keybindings_.action_group_menu()

17
juci/config.cc

@ -11,21 +11,26 @@ MainConfig::MainConfig() :
}
void MainConfig::GenerateSource() {
INFO("Generating source cfg");
DEBUG("Fetching source cfg");
boost::property_tree::ptree source_json = cfg_.get_child("source");
boost::property_tree::ptree syntax_json = source_json.get_child("syntax");
boost::property_tree::ptree colors_json = source_json.get_child("colors");
boost::property_tree::ptree extensions_json = source_json.get_child("extensions");
for (auto &i : colors_json) {
source_cfg_.InsertTag(i.first, i.second.get_value<std::string>());
}
for (auto &i : syntax_json) {
source_cfg_.InsertType(i.first, i.second.get_value<std::string>());
}
INFO("Source cfg generated");
for (auto &i : extensions_json) {
source_cfg_.InsertExtension(i.second.get_value<std::string>());
}
DEBUG("Source cfg fetched");
}
void MainConfig::GenerateKeybindings() {
INFO("Generating keybindings");
DEBUG("Fetching keybindings");
std::string line;
std::ifstream menu_xml("menu.xml");
if (menu_xml.is_open()) {
@ -35,10 +40,11 @@ void MainConfig::GenerateKeybindings() {
boost::property_tree::ptree keys_json = cfg_.get_child("keybindings");
for (auto &i : keys_json)
keybindings_cfg_.key_map()[i.first] = i.second.get_value<std::string>();
INFO("Keybindings generated");
DEBUG("Keybindings fetched");
}
void MainConfig::GenerateDirectoryFilter() {
DEBUG("Fetching directory filter");
boost::property_tree::ptree dir_json = cfg_.get_child("directoryfilter");
boost::property_tree::ptree ignore_json = dir_json.get_child("ignore");
boost::property_tree::ptree except_json = dir_json.get_child("exceptions");
@ -46,6 +52,5 @@ void MainConfig::GenerateDirectoryFilter() {
dir_cfg_.AddException(i.second.get_value<std::string>());
for ( auto &i : ignore_json )
dir_cfg_.AddIgnore(i.second.get_value<std::string>());
DEBUG("Directory filter fetched");
}

7
juci/config.json

@ -16,7 +16,12 @@
"702": "keyword",
"703": "own",
"705": "comment"
}
},
"extensions": [
"ext1",
"ext2",
"ext3"
]
},
"keybindings": {
"split_window": "<control><alt>s",

37
juci/directories.cc

@ -29,7 +29,6 @@ open_folder(const boost::filesystem::path& dir_path) {
bool Directories::Controller::IsIgnored(std::string path) {
DEBUG("Checking if file-/directory is filtered");
std::transform(path.begin(), path.end(), path.begin(), ::tolower);
// std::cout << "ignored?: " << path << std::endl;
if (config().IsException(path)) {
return false;
}
@ -48,7 +47,7 @@ list_dirs(const boost::filesystem::path& dir_path,
unsigned file_counter = 0;
Gtk::TreeModel::Row child;
Gtk::TreeModel::Row row;
DEBUG_VAR(dir_path);
DEBUG("");
// Fill the treeview
for ( boost::filesystem::directory_iterator itr( dir_path );
itr != end_itr;
@ -80,15 +79,17 @@ list_dirs(const boost::filesystem::path& dir_path,
}
}
}
int Directories::Controller::count(const std::string path) {
int count = 0;
for (int i = 0; i < path.size(); i++)
if (path[i] == '/') count++;
if (path[i] == '/')
count++;
return count;
}
std::string Directories::Controller::
GetCmakeVarValue(const boost::filesystem::path& dir_path, std::string command_name) {
std::string Directories::Controller::
GetCmakeVarValue(const boost::filesystem::path& dir_path, std::string command_name) {
INFO("fetches cmake variable value for: "+command_name);
std::string project_name;
std::string project_name_var;
@ -155,32 +156,32 @@ int Directories::Controller::count(const std::string path) {
}
INFO("Couldn't find value in CMakeLists.txt");
return "no project name";
}
}
Directories::Config::Config() {
}
Directories::Config::Config(Directories::Config& cfg) :
Directories::Config::Config() {
}
Directories::Config::Config(Directories::Config& cfg) :
ignore_list_(cfg.ignore_list()), exception_list_(cfg.exception_list()) {
}
}
void Directories::Config::AddIgnore(std::string filter) {
void Directories::Config::AddIgnore(std::string filter) {
ignore_list_.push_back(filter);
}
}
void Directories::Config::AddException(std::string filter) {
void Directories::Config::AddException(std::string filter) {
exception_list_.push_back(filter);
}
}
bool Directories::Config::IsIgnored(std::string str) {
bool Directories::Config::IsIgnored(std::string str) {
for ( auto &i : ignore_list() )
if (str.find(i, 0) != std::string::npos)
return true;
return false;
}
}
bool Directories::Config::IsException(std::string str) {
bool Directories::Config::IsException(std::string str) {
for ( std::string &i : exception_list() )
if (i == str)
return true;
return false;
}
}

3
juci/notebook.cc

@ -13,7 +13,8 @@ Notebook::View::View() : notebook_() {
view_.set_position(120);
}
Notebook::Controller::Controller(Gtk::Window* window, Keybindings::Controller& keybindings,
Notebook::Controller::Controller(Gtk::Window* window,
Keybindings::Controller& keybindings,
Source::Config& source_cfg,
Directories::Config& dir_cfg) :
source_config_(source_cfg),

9
juci/source.cc

@ -70,9 +70,18 @@ const std::unordered_map<string, string>& Source::Config::typetable() const {
return typetable_;
}
std::vector<string>& Source::Config::extensiontable() {
return extensiontable_;
}
void Source::Config::InsertTag(const string &key, const string &value) {
tagtable_[key] = value;
}
void Source::Config::InsertExtension(const string &ext) {
extensiontable_.push_back(ext);
}
// Source::View::Config::SetTagTable()
// sets the tagtable for the view
void Source::Config::

4
juci/source.h

@ -20,16 +20,18 @@ namespace Source {
Config();
const std::unordered_map<std::string, std::string>& tagtable() const;
const std::unordered_map<std::string, std::string>& typetable() const;
std::vector<std::string>& extensiontable();
void SetTagTable(const std::unordered_map<std::string, std::string>
&tagtable);
void InsertTag(const std::string &key, const std::string &value);
void SetTypeTable(const std::unordered_map<std::string, std::string>
&tagtable);
void InsertType(const std::string &key, const std::string &value);
void InsertExtension(const std::string &ext);
private:
std::unordered_map<std::string, std::string> tagtable_;
std::unordered_map<std::string, std::string> typetable_;
std::vector<std::string> extensiontable_;
std::string background_;
}; // class Config

2
juci/window.cc

@ -59,7 +59,7 @@ Window::Window() :
std::thread execute([=]() {
std::string path = notebook_.CurrentPagePath();
int pos = path.find_last_of("/\\");
if(pos != std::string::npos){
if(pos != std::string::npos) {
path.erase(path.begin()+pos,path.end());
terminal_.SetFolderCommand(path);
}

Loading…
Cancel
Save