Browse Source

Fixed extensions and compile bug

master
oyvang 11 years ago
parent
commit
6bb936e059
  1. 1
      juci/config.cc
  2. 8
      juci/notebook.cc
  3. 2
      juci/source.cc
  4. 5
      juci/source.h
  5. 16
      juci/terminal.cc
  6. 46
      juci/window.cc

1
juci/config.cc

@ -25,7 +25,6 @@ void MainConfig::GenerateSource() {
for (auto &i : extensions_json) { for (auto &i : extensions_json) {
source_cfg_.InsertExtension(i.second.get_value<std::string>()); source_cfg_.InsertExtension(i.second.get_value<std::string>());
} }
DEBUG("Source cfg fetched"); DEBUG("Source cfg fetched");
} }

8
juci/notebook.cc

@ -3,8 +3,8 @@
#include "logging.h" #include "logging.h"
Notebook::Model::Model() { Notebook::Model::Model() {
cc_extension_ = ".cc"; cc_extension_ = ".cpp";
h_extension_ = ".h"; h_extension_ = ".hpp";
scrollvalue_ = 50; scrollvalue_ = 50;
} }
@ -17,7 +17,6 @@ Notebook::Controller::Controller(Gtk::Window* window,
Keybindings::Controller& keybindings, Keybindings::Controller& keybindings,
Source::Config& source_cfg, Source::Config& source_cfg,
Directories::Config& dir_cfg) : Directories::Config& dir_cfg) :
source_config_(source_cfg),
directories_(dir_cfg), directories_(dir_cfg),
index_(0, 1) { index_(0, 1) {
window_ = window; window_ = window;
@ -25,6 +24,7 @@ Notebook::Controller::Controller(Gtk::Window* window,
refClipboard_ = Gtk::Clipboard::get(); refClipboard_ = Gtk::Clipboard::get();
ispopup = false; ispopup = false;
view().pack1(directories_.widget(), true, true); view().pack1(directories_.widget(), true, true);
source_config_ = source_cfg;
CreateKeybindings(keybindings); CreateKeybindings(keybindings);
INFO("Notebook Controller Success"); INFO("Notebook Controller Success");
} // Constructor } // Constructor
@ -719,7 +719,7 @@ 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 =
source_config().extensiontable(); source_config().extensiontable();
std::cout << e << std::endl;
if (find(extensions.begin(), extensions.end(), e) != extensions.end()) { if (find(extensions.begin(), extensions.end(), e) != extensions.end()) {
DEBUG("Legal extension"); DEBUG("Legal extension");
return true; return true;

2
juci/source.cc

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

5
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;
const std::vector<std::string>& extensiontable() const; std::vector<std::string>& extensiontable();
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);
@ -28,10 +28,11 @@ namespace Source {
&tagtable); &tagtable);
void InsertType(const std::string &key, const std::string &value); void InsertType(const std::string &key, const std::string &value);
void InsertExtension(const std::string &ext); void InsertExtension(const std::string &ext);
std::vector<std::string> extensiontable_;
private: private:
std::unordered_map<std::string, std::string> tagtable_; std::unordered_map<std::string, std::string> tagtable_;
std::unordered_map<std::string, std::string> typetable_; std::unordered_map<std::string, std::string> typetable_;
std::vector<std::string> extensiontable_;
std::string background_; std::string background_;
}; // class Config }; // class Config

16
juci/terminal.cc

@ -27,10 +27,12 @@ void Terminal::Controller::Compile(){
INFO("Terminal: Compile"); INFO("Terminal: Compile");
Terminal().get_buffer()->set_text(""); Terminal().get_buffer()->set_text("");
DEBUG("Terminal: Compile: running cmake command"); 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)){ if (ExistInConsole(cmake_sucsess)){
DEBUG("Terminal: Compile: running make command"); DEBUG("Terminal: Compile: running make command");
ExecuteCommand("make", "r"); ExecuteCommand("cd ./build/; make", "r");
} }
PrintMessage("\n"); PrintMessage("\n");
DEBUG("Terminal: Compile: compile done"); DEBUG("Terminal: Compile: compile done");
@ -41,7 +43,7 @@ void Terminal::Controller::Run(std::string executable) {
PrintMessage("juCi++ execute: " + executable + "\n"); PrintMessage("juCi++ execute: " + executable + "\n");
DEBUG("Terminal: Compile: running run command: "); DEBUG("Terminal: Compile: running run command: ");
DEBUG_VAR(executable); DEBUG_VAR(executable);
ExecuteCommand("./"+executable, "r"); ExecuteCommand("cd ./build/; ./"+executable, "r");
PrintMessage("\n"); PrintMessage("\n");
} }
@ -65,16 +67,18 @@ void Terminal::Controller::ExecuteCommand(std::string command, std::string mode)
INFO("Terminal: ExecuteCommand"); INFO("Terminal: ExecuteCommand");
command = folder_command_+command; command = folder_command_+command;
DEBUG("Terminal: PrintMessage: Running command"); DEBUG("Terminal: PrintMessage: Running command");
DEBUG_VAR(command); FILE* p = NULL;
FILE* p = popen(command.c_str(), mode.c_str()); p = popen(command.c_str(), mode.c_str());
std::cout << "KJØRTE FINT!" << std::endl;
if (p == NULL) { if (p == NULL) {
PrintMessage("juCi++ ERROR: Failed to run command" + command + "\n"); PrintMessage("juCi++ ERROR: Failed to run command" + command + "\n");
}else { }else {
std::cout << "SKRIVER UT KOMMANDO RESULAT" << std::endl;
char buffer[1028]; char buffer[1028];
while (fgets(buffer, 1028, p) != NULL) { while (fgets(buffer, 1028, p) != NULL) {
PrintMessage(buffer); PrintMessage(buffer);
} }
pclose(p); pclose(p);
} }
} }

46
juci/window.cc

@ -49,29 +49,29 @@ Window::Window() :
}); });
keybindings_. keybindings_.
action_group_menu()-> action_group_menu()->
add(Gtk::Action::create("ProjectCompileAndRun", add(Gtk::Action::create("ProjectCompileAndRun",
"Compile And Run"), "Compile And Run"),
Gtk::AccelKey(keybindings_.config_ Gtk::AccelKey(keybindings_.config_
.key_map()["compile_and_run"]), .key_map()["compile_and_run"]),
[this]() { [this]() {
notebook_.OnSaveFile(); notebook_.OnSaveFile();
if (running.try_lock()) { if (running.try_lock()) {
std::thread execute([=]() { std::thread execute([=]() {
std::string path = notebook_.CurrentPagePath(); std::string path = notebook_.CurrentPagePath();
int pos = path.find_last_of("/\\"); int pos = path.find_last_of("/\\");
if(pos != std::string::npos) { if(pos != std::string::npos) {
path.erase(path.begin()+pos,path.end()); path.erase(path.begin()+pos,path.end());
terminal_.SetFolderCommand(path); terminal_.SetFolderCommand(path);
} }
terminal_.Compile(); terminal_.Compile();
std::string executable = notebook_.directories(). std::string executable = notebook_.directories().
GetCmakeVarValue(path,"add_executable"); GetCmakeVarValue(path,"add_executable");
terminal_.Run(executable); terminal_.Run(executable);
}); });
execute.detach(); execute.detach();
running.unlock(); running.unlock();
} }
}); });
keybindings_. keybindings_.
action_group_menu()-> action_group_menu()->

Loading…
Cancel
Save