From ff3442896cabcac70e870894080c88653bd7ee17 Mon Sep 17 00:00:00 2001 From: tedjk Date: Mon, 18 May 2015 11:39:08 +0200 Subject: [PATCH] fixing bugs with config, with --- juci/config.cc | 9 +++++++++ juci/config.h | 9 ++++++++- juci/config.json | 10 +++++++++- juci/keybindings.h | 2 +- juci/source.h | 1 - juci/terminal.cc | 3 ++- juci/terminal.h | 4 +++- juci/window.cc | 1 + 8 files changed, 33 insertions(+), 6 deletions(-) diff --git a/juci/config.cc b/juci/config.cc index b320a6c..74c450f 100644 --- a/juci/config.cc +++ b/juci/config.cc @@ -8,6 +8,7 @@ MainConfig::MainConfig() : GenerateSource(); GenerateKeybindings(); GenerateDirectoryFilter(); + GenerateTerminalCommands(); } void MainConfig::GenerateSource() { @@ -29,6 +30,14 @@ void MainConfig::GenerateSource() { DEBUG("Source cfg fetched"); } +void MainConfig::GenerateTerminalCommands() { + boost::property_tree::ptree source_json = cfg_.get_child("project"); + boost::property_tree::ptree commands_json = source_json.get_child("compile_commands"); + for (auto &i : commands_json) { + terminal_cfg_.InsertCompileCommand(i.second.get_value()); + } +} + void MainConfig::GenerateKeybindings() { DEBUG("Fetching keybindings"); std::string line; diff --git a/juci/config.h b/juci/config.h index edcb5fc..2b7b596 100644 --- a/juci/config.h +++ b/juci/config.h @@ -1,3 +1,5 @@ +#ifndef +#define JUCI_CONFIG_H_ #include #include #include @@ -5,21 +7,26 @@ #include "keybindings.h" #include "source.h" #include "directories.h" +#include "terminal.h" class MainConfig { public: MainConfig(); Source::Config& source_cfg() { return source_cfg_; } Keybindings::Config& keybindings_cfg() { return keybindings_cfg_; } - Directories::Config& dir_cfg() { return dir_cfg_; } + Directories::Config& dir_cfg() { return dir_cfg_; } + Terminal::Config& terminal_cfg() { return terminal_cfg_; } void PrintMenu(); void GenerateSource(); void GenerateKeybindings(); void GenerateDirectoryFilter(); + void GenerateTerminalCommands(); private: boost::property_tree::ptree cfg_; boost::property_tree::ptree key_tree_; Source::Config source_cfg_; Keybindings::Config keybindings_cfg_; Directories::Config dir_cfg_; + Terminal::Config terminal_cfg_; }; +#endif diff --git a/juci/config.json b/juci/config.json index bdbbeec..e4dc14b 100644 --- a/juci/config.json +++ b/juci/config.json @@ -55,7 +55,15 @@ "cmakelists.txt", "in-lowercase.pls" ] - }, + }, + "project": { + "compile_commands": [ + "rm -rf ./build", + "mkdir build", + "cmake -B./build -H.", + "cd ./.build/; make" + ] + }, "example": { "key": "value", "key2": [ diff --git a/juci/keybindings.h b/juci/keybindings.h index 8273a38..eafccd5 100644 --- a/juci/keybindings.h +++ b/juci/keybindings.h @@ -15,7 +15,7 @@ namespace Keybindings { Config(); std::string& menu_xml() { return menu_xml_; } std::unordered_map& key_map() { return key_map_; } - void AppendXml(std::string &child); + void AppendXml(std::string &child); void SetMenu(std::string &menu_xml); void SetKeyMap(std::unordered_map &key_map); private: diff --git a/juci/source.h b/juci/source.h index 64b7618..3bb3c12 100644 --- a/juci/source.h +++ b/juci/source.h @@ -157,7 +157,6 @@ namespace Source { void set_is_saved(bool isSaved) { is_saved_ = isSaved; } void set_is_changed(bool isChanged) { is_changed_ = isChanged; } void set_file_path(std::string path) { model().set_file_path(path); } - private: void OnLineEdit(); diff --git a/juci/terminal.cc b/juci/terminal.cc index 1ea2029..8d65303 100644 --- a/juci/terminal.cc +++ b/juci/terminal.cc @@ -12,7 +12,8 @@ Terminal::View::View(){ } -Terminal::Controller::Controller() { +Terminal::Controller::Controller(Terminal::Config& cfg) : + config_(cfg) { folder_command_ = ""; } diff --git a/juci/terminal.h b/juci/terminal.h index a3fa6a6..b3cdca0 100644 --- a/juci/terminal.h +++ b/juci/terminal.h @@ -20,13 +20,15 @@ namespace Terminal { class Controller { public: - Controller(); + Controller(Terminal::Config& cfg); Gtk::HBox& view() {return view_.view();} Gtk::TextView& Terminal(){return view_.textview();} void SetFolderCommand(boost::filesystem::path CMake_path); void Run(std::string executable); void Compile(); + Terminal::Config& config() { return config_; } private: + Terminal::Config config_; void ExecuteCommand(std::string command, std::string mode); bool OnButtonRealeaseEvent(GdkEventKey* key); bool ExistInConsole(std::string string); diff --git a/juci/window.cc b/juci/window.cc index 1ed2936..cae5b5e 100644 --- a/juci/window.cc +++ b/juci/window.cc @@ -5,6 +5,7 @@ Window::Window() : window_box_(Gtk::ORIENTATION_VERTICAL), main_config_(), keybindings_(main_config_.keybindings_cfg()), + terminal_(main_config_.terminal_cfg()), notebook_(this,keybindings(), main_config_.source_cfg(), main_config_.dir_cfg()),