From 81dd9e5a5d1495542b652fa6b63a133235dc50da Mon Sep 17 00:00:00 2001 From: oyvang Date: Fri, 15 May 2015 15:12:28 +0200 Subject: [PATCH 1/3] removed commen in LegalExtension --- juci/notebook.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/juci/notebook.cc b/juci/notebook.cc index 0f16e40..dcd7c54 100644 --- a/juci/notebook.cc +++ b/juci/notebook.cc @@ -723,9 +723,6 @@ bool Notebook::Controller::LegalExtension(std::string 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++"|| - // e=="h" ||e=="hh" ||e=="hpp" ||e=="hxx" || e=="h++"){ } DEBUG("Ilegal extension"); return false; From 6bb936e059155832a6415d4125fd3395120c305a Mon Sep 17 00:00:00 2001 From: oyvang Date: Mon, 18 May 2015 10:46:27 +0200 Subject: [PATCH 2/3] Fixed extensions and compile bug --- juci/config.cc | 1 - juci/notebook.cc | 8 ++++---- juci/source.cc | 2 +- juci/source.h | 5 +++-- juci/terminal.cc | 16 ++++++++++------ juci/window.cc | 46 +++++++++++++++++++++++----------------------- 6 files changed, 41 insertions(+), 37 deletions(-) diff --git a/juci/config.cc b/juci/config.cc index b320a6c..727904a 100644 --- a/juci/config.cc +++ b/juci/config.cc @@ -25,7 +25,6 @@ void MainConfig::GenerateSource() { for (auto &i : extensions_json) { source_cfg_.InsertExtension(i.second.get_value()); } - DEBUG("Source cfg fetched"); } diff --git a/juci/notebook.cc b/juci/notebook.cc index dcd7c54..3590d49 100644 --- a/juci/notebook.cc +++ b/juci/notebook.cc @@ -3,8 +3,8 @@ #include "logging.h" Notebook::Model::Model() { - cc_extension_ = ".cc"; - h_extension_ = ".h"; + cc_extension_ = ".cpp"; + h_extension_ = ".hpp"; scrollvalue_ = 50; } @@ -17,7 +17,6 @@ Notebook::Controller::Controller(Gtk::Window* window, Keybindings::Controller& keybindings, Source::Config& source_cfg, Directories::Config& dir_cfg) : - source_config_(source_cfg), directories_(dir_cfg), index_(0, 1) { window_ = window; @@ -25,6 +24,7 @@ Notebook::Controller::Controller(Gtk::Window* window, refClipboard_ = Gtk::Clipboard::get(); ispopup = false; view().pack1(directories_.widget(), true, true); + source_config_ = source_cfg; CreateKeybindings(keybindings); INFO("Notebook Controller Success"); } // Constructor @@ -719,7 +719,7 @@ bool Notebook::Controller::LegalExtension(std::string e) { std::transform(e.begin(), e.end(),e.begin(), ::tolower); std::vector extensions = source_config().extensiontable(); - + std::cout << e << std::endl; if (find(extensions.begin(), extensions.end(), e) != extensions.end()) { DEBUG("Legal extension"); return true; diff --git a/juci/source.cc b/juci/source.cc index 6667450..36b2ade 100644 --- a/juci/source.cc +++ b/juci/source.cc @@ -70,7 +70,7 @@ const std::unordered_map& Source::Config::typetable() const { return typetable_; } -const std::vector& Source::Config::extensiontable() const{ +std::vector& Source::Config::extensiontable(){ return extensiontable_; } diff --git a/juci/source.h b/juci/source.h index 64b7618..8db62f3 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; - const std::vector& extensiontable() const; + std::vector& extensiontable(); void SetTagTable(const std::unordered_map &tagtable); void InsertTag(const std::string &key, const std::string &value); @@ -28,10 +28,11 @@ namespace Source { &tagtable); void InsertType(const std::string &key, const std::string &value); void InsertExtension(const std::string &ext); + std::vector extensiontable_; private: std::unordered_map tagtable_; std::unordered_map typetable_; - std::vector extensiontable_; + std::string background_; }; // class Config diff --git a/juci/terminal.cc b/juci/terminal.cc index 1ea2029..98971c2 100644 --- a/juci/terminal.cc +++ b/juci/terminal.cc @@ -27,10 +27,12 @@ void Terminal::Controller::Compile(){ INFO("Terminal: Compile"); Terminal().get_buffer()->set_text(""); DEBUG("Terminal: Compile: running cmake command"); - ExecuteCommand("cmake .", "r"); + ExecuteCommand("rm -rf ./build", "r"); + ExecuteCommand("mkdir ./build", "r"); + ExecuteCommand("cmake -B./build -H.", "r"); if (ExistInConsole(cmake_sucsess)){ DEBUG("Terminal: Compile: running make command"); - ExecuteCommand("make", "r"); + ExecuteCommand("cd ./build/; make", "r"); } PrintMessage("\n"); DEBUG("Terminal: Compile: compile done"); @@ -41,7 +43,7 @@ void Terminal::Controller::Run(std::string executable) { PrintMessage("juCi++ execute: " + executable + "\n"); DEBUG("Terminal: Compile: running run command: "); DEBUG_VAR(executable); - ExecuteCommand("./"+executable, "r"); + ExecuteCommand("cd ./build/; ./"+executable, "r"); PrintMessage("\n"); } @@ -65,16 +67,18 @@ void Terminal::Controller::ExecuteCommand(std::string command, std::string mode) INFO("Terminal: ExecuteCommand"); command = folder_command_+command; DEBUG("Terminal: PrintMessage: Running command"); - DEBUG_VAR(command); - FILE* p = popen(command.c_str(), mode.c_str()); - + FILE* p = NULL; + p = popen(command.c_str(), mode.c_str()); + std::cout << "KJØRTE FINT!" << std::endl; if (p == NULL) { PrintMessage("juCi++ ERROR: Failed to run command" + command + "\n"); }else { + std::cout << "SKRIVER UT KOMMANDO RESULAT" << std::endl; char buffer[1028]; while (fgets(buffer, 1028, p) != NULL) { PrintMessage(buffer); } pclose(p); } + } diff --git a/juci/window.cc b/juci/window.cc index 1ed2936..c48be55 100644 --- a/juci/window.cc +++ b/juci/window.cc @@ -49,29 +49,29 @@ Window::Window() : }); keybindings_. action_group_menu()-> - add(Gtk::Action::create("ProjectCompileAndRun", - "Compile And Run"), - Gtk::AccelKey(keybindings_.config_ - .key_map()["compile_and_run"]), - [this]() { - notebook_.OnSaveFile(); - if (running.try_lock()) { - std::thread execute([=]() { - std::string path = notebook_.CurrentPagePath(); - int pos = path.find_last_of("/\\"); - if(pos != std::string::npos) { - path.erase(path.begin()+pos,path.end()); - terminal_.SetFolderCommand(path); - } - terminal_.Compile(); - std::string executable = notebook_.directories(). - GetCmakeVarValue(path,"add_executable"); - terminal_.Run(executable); - }); - execute.detach(); - running.unlock(); - } - }); + add(Gtk::Action::create("ProjectCompileAndRun", + "Compile And Run"), + Gtk::AccelKey(keybindings_.config_ + .key_map()["compile_and_run"]), + [this]() { + notebook_.OnSaveFile(); + if (running.try_lock()) { + std::thread execute([=]() { + std::string path = notebook_.CurrentPagePath(); + int pos = path.find_last_of("/\\"); + if(pos != std::string::npos) { + path.erase(path.begin()+pos,path.end()); + terminal_.SetFolderCommand(path); + } + terminal_.Compile(); + std::string executable = notebook_.directories(). + GetCmakeVarValue(path,"add_executable"); + terminal_.Run(executable); + }); + execute.detach(); + running.unlock(); + } + }); keybindings_. action_group_menu()-> From 98d187611a17c0916901e3a2256ac4823eee1b18 Mon Sep 17 00:00:00 2001 From: oyvang Date: Mon, 18 May 2015 11:36:36 +0200 Subject: [PATCH 3/3] fixing config bugs --- juci/notebook.cc | 1 - juci/terminal.cc | 29 +++++++++++++++++++++++------ juci/terminal.h | 10 ++++++++++ 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/juci/notebook.cc b/juci/notebook.cc index 3590d49..6992658 100644 --- a/juci/notebook.cc +++ b/juci/notebook.cc @@ -719,7 +719,6 @@ bool Notebook::Controller::LegalExtension(std::string e) { std::transform(e.begin(), e.end(),e.begin(), ::tolower); std::vector extensions = source_config().extensiontable(); - std::cout << e << std::endl; if (find(extensions.begin(), extensions.end(), e) != extensions.end()) { DEBUG("Legal extension"); return true; diff --git a/juci/terminal.cc b/juci/terminal.cc index 98971c2..beab086 100644 --- a/juci/terminal.cc +++ b/juci/terminal.cc @@ -4,6 +4,18 @@ #include "logging.h" +Terminal::Config::Config() { +} +Terminal::Config::Config(Terminal::Config& original) { + for (auto it = 0; original.compile_commands().size(); ++it) { + InsertCompileCommand(original.compile_commands().at(it)); + } +} + +void Terminal::Config::InsertCompileCommand(std::string command){ + compile_commands_.push_back(command); +} + Terminal::View::View(){ scrolledwindow_.add(textview_); scrolledwindow_.set_size_request(-1,150); @@ -27,13 +39,18 @@ void Terminal::Controller::Compile(){ INFO("Terminal: Compile"); Terminal().get_buffer()->set_text(""); DEBUG("Terminal: Compile: running cmake command"); - ExecuteCommand("rm -rf ./build", "r"); - ExecuteCommand("mkdir ./build", "r"); - ExecuteCommand("cmake -B./build -H.", "r"); - if (ExistInConsole(cmake_sucsess)){ - DEBUG("Terminal: Compile: running make command"); - ExecuteCommand("cd ./build/; make", "r"); + std::vector commands = config().compile_commands(); + for (auto it = 0; it < commands.size(); ++it) { + ExecuteCommand(commands.at(it), "r"); + } + // ExecuteCommand("rm -rf ./.build", "r"); + // ExecuteCommand("mkdir ./.build", "r"); + // ExecuteCommand("cmake -B./build -H.", "r"); + // if (ExistInConsole(cmake_sucsess)){ + // DEBUG("Terminal: Compile: running make command"); + // ExecuteCommand("cd ./.build/; make", "r"); + // } PrintMessage("\n"); DEBUG("Terminal: Compile: compile done"); } diff --git a/juci/terminal.h b/juci/terminal.h index a3fa6a6..4caa429 100644 --- a/juci/terminal.h +++ b/juci/terminal.h @@ -7,6 +7,16 @@ namespace Terminal { + class Config { + public: + Config (); + Config(Terminal::Config& original); + std::vector& compile_commands() {return &compile_commands_;} + void InsertCompileCommand(std::string command); + private: + std::vector compile_commands_; + }; + class View { public: View();