|
|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
#include "terminal.h" |
|
|
|
|
#include <iostream> |
|
|
|
|
#include <thread> |
|
|
|
|
// #include <pstream.h>
|
|
|
|
|
// #include <string>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Terminal::View::View(){ |
|
|
|
|
@ -21,32 +23,17 @@ void Terminal::Controller::SetFolderCommand( boost::filesystem::path
|
|
|
|
|
folder_command_ = "cd "+ path_ + "; "; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Terminal::Controller::Compile(){ |
|
|
|
|
if (running.try_lock()) { |
|
|
|
|
std::thread execute([=]() { |
|
|
|
|
void Terminal::Controller::Compile(){ |
|
|
|
|
Terminal().get_buffer()->set_text(""); |
|
|
|
|
ExecuteCommand("cmake ."); |
|
|
|
|
ExecuteCommand("cmake .", "r"); |
|
|
|
|
if (ExistInConsole(cmake_sucsess)){ |
|
|
|
|
ExecuteCommand("make"); |
|
|
|
|
ExecuteCommand("make", "r"); |
|
|
|
|
}
|
|
|
|
|
}); |
|
|
|
|
execute.detach(); |
|
|
|
|
running.unlock(); |
|
|
|
|
if (ExistInConsole(make_built)) return true; |
|
|
|
|
} |
|
|
|
|
PrintMessage("juCi++ ERROR: Failed to compile project in directory" |
|
|
|
|
+ path_ + "\n"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Terminal::Controller::Run(std::string executable) { |
|
|
|
|
if (running.try_lock()) { |
|
|
|
|
std::thread execute([=]() { |
|
|
|
|
ExecuteCommand("./"+executable); |
|
|
|
|
}); |
|
|
|
|
execute.detach(); |
|
|
|
|
running.unlock(); |
|
|
|
|
} |
|
|
|
|
PrintMessage("juCi++ execute: " + executable + "\n"); |
|
|
|
|
ExecuteCommand("./"+executable, "r"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Terminal::Controller::PrintMessage(std::string message){ |
|
|
|
|
@ -54,22 +41,6 @@ void Terminal::Controller::PrintMessage(std::string message){
|
|
|
|
|
insert(Terminal().get_buffer()-> end(),"> "+message); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// bool Terminal::Controller::FindExecutable(std::string executable) {
|
|
|
|
|
// std::string build = Terminal().get_buffer()->get_text();
|
|
|
|
|
// double pos = build.find(make_built);
|
|
|
|
|
// Gtk::TextIter start = Terminal().get_buffer()->get_iter_at_offset(pos);
|
|
|
|
|
// Gtk::TextIter end = Terminal().get_buffer()->get_iter_at_offset(pos);
|
|
|
|
|
// while (!end.ends_line()) {
|
|
|
|
|
// end.forward_char();
|
|
|
|
|
// }
|
|
|
|
|
// build = Terminal().get_buffer()->get_text(start, end);
|
|
|
|
|
// pos = build.find_last_of(" ");
|
|
|
|
|
// build = build.substr(pos+1);
|
|
|
|
|
// std::cout << "DEBUG: BUILD TARGET = "<< build << std::endl;
|
|
|
|
|
// std::cout << "EDEBUG: ECUTABLE FILE = "<< executable << std::endl;
|
|
|
|
|
// if(build != executable) return false;
|
|
|
|
|
// return true;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
bool Terminal::Controller::ExistInConsole(std::string string) { |
|
|
|
|
double pos = Terminal().get_buffer()-> |
|
|
|
|
@ -78,10 +49,11 @@ bool Terminal::Controller::ExistInConsole(std::string string) {
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Terminal::Controller::ExecuteCommand(std::string command) { |
|
|
|
|
void Terminal::Controller::ExecuteCommand(std::string command, std::string mode) { |
|
|
|
|
command = folder_command_+command; |
|
|
|
|
std::cout << "EXECUTE COMMAND: "<< command << std::endl; |
|
|
|
|
FILE* p = popen(command.c_str(), "r"); |
|
|
|
|
FILE* p = popen(command.c_str(), mode.c_str()); |
|
|
|
|
|
|
|
|
|
if (p == NULL) { |
|
|
|
|
PrintMessage("juCi++ ERROR: Failed to run command" + command + "\n"); |
|
|
|
|
}else { |
|
|
|
|
|