Browse Source

Fixed keybinding on compile and run

merge-requests/365/head
oyvang 11 years ago
parent
commit
0678ac68c8
  1. 2
      juci/config.json
  2. 2
      juci/notebook.cc
  3. 21
      juci/terminal.cc

2
juci/config.json

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

2
juci/notebook.cc

@ -272,7 +272,7 @@ bool Notebook::Controller::ScrollEventCallback(GdkEventScroll* scroll_event) {
} }
Notebook::Controller::~Controller() { Notebook::Controller::~Controller() {
INFO("Notebook destructor"); 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 : linenumbers_vec_) delete i;
for (auto &i : editor_vec_) delete i; for (auto &i : editor_vec_) delete i;
for (auto &i : scrolledtext_vec_) delete i; for (auto &i : scrolledtext_vec_) delete i;

21
juci/terminal.cc

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

Loading…
Cancel
Save