Browse Source

Merge branch 'oyvangforgi' of bitbucket.org:cppit/juci into oyvangforgi

merge-requests/365/head
tedjk 11 years ago
parent
commit
bf4b148abd
  1. 2
      juci/config.json
  2. 2
      juci/notebook.cc
  3. 23
      juci/terminal.cc

2
juci/config.json

@ -32,7 +32,7 @@
"edit_undo": "<control>z",
"save": "<control>s",
"save_as": "<control><shift>s",
"compile_and_run": "<control><alt>r>",
"compile_and_run": "<control><alt>r",
"compile": "<control>r"
},
"directoryfilter": {

2
juci/notebook.cc

@ -273,7 +273,7 @@ bool Notebook::Controller::ScrollEventCallback(GdkEventScroll* scroll_event) {
}
Notebook::Controller::~Controller() {
INFO("Notebook destructor");
for (auto &i : text_vec_) delete i;
for (auto &i : text_vec_) delete i;
for (auto &i : linenumbers_vec_) delete i;
for (auto &i : editor_vec_) delete i;
for (auto &i : scrolledtext_vec_) delete i;

23
juci/terminal.cc

@ -1,8 +1,7 @@
#include "terminal.h"
#include <iostream>
#include <thread>
// #include <pstream.h>
// #include <string>
#include "logging.h"
Terminal::View::View(){
@ -19,31 +18,43 @@ Terminal::Controller::Controller() {
void Terminal::Controller::SetFolderCommand( boost::filesystem::path
CMake_path) {
INFO("Terminal: SetFolderCommand");
path_ = CMake_path.string();
folder_command_ = "cd "+ path_ + "; ";
}
void Terminal::Controller::Compile(){
INFO("Terminal: Compile");
Terminal().get_buffer()->set_text("");
DEBUG("Terminal: Compile: running cmake command");
ExecuteCommand("cmake .", "r");
if (ExistInConsole(cmake_sucsess)){
DEBUG("Terminal: Compile: running make command");
ExecuteCommand("make", "r");
}
}
PrintMessage("\n");
DEBUG("Terminal: Compile: compile done");
}
void Terminal::Controller::Run(std::string executable) {
INFO("Terminal: Run");
PrintMessage("juCi++ execute: " + executable + "\n");
DEBUG("Terminal: Compile: running run command: ");
DEBUG_VAR(executable);
ExecuteCommand("./"+executable, "r");
PrintMessage("\n");
}
void Terminal::Controller::PrintMessage(std::string message){
INFO("Terminal: PrintMessage");
Terminal().get_buffer()->
insert(Terminal().get_buffer()-> end(),"> "+message);
}
bool Terminal::Controller::ExistInConsole(std::string string) {
INFO("Terminal: ExistInConsole");
DEBUG("Terminal: PrintMessage: finding string in buffer");
double pos = Terminal().get_buffer()->
get_text().find(string);
if (pos == std::string::npos) return false;
@ -51,8 +62,10 @@ bool Terminal::Controller::ExistInConsole(std::string string) {
}
void Terminal::Controller::ExecuteCommand(std::string command, std::string mode) {
INFO("Terminal: ExecuteCommand");
command = folder_command_+command;
std::cout << "EXECUTE COMMAND: "<< command << std::endl;
DEBUG("Terminal: PrintMessage: Running command");
DEBUG_VAR(command);
FILE* p = popen(command.c_str(), mode.c_str());
if (p == NULL) {

Loading…
Cancel
Save