|
|
|
@ -4,13 +4,13 @@ |
|
|
|
Window::Window() : |
|
|
|
Window::Window() : |
|
|
|
window_box_(Gtk::ORIENTATION_VERTICAL), |
|
|
|
window_box_(Gtk::ORIENTATION_VERTICAL), |
|
|
|
main_config_(), |
|
|
|
main_config_(), |
|
|
|
keybindings_(main_config_.keybindings_cfg()), |
|
|
|
keybindings_(main_config_.keybindings_cfg), |
|
|
|
terminal_(main_config_.terminal_cfg()), |
|
|
|
terminal(main_config_.terminal_cfg), |
|
|
|
notebook_(this,keybindings(), |
|
|
|
notebook(keybindings(), terminal, |
|
|
|
main_config_.source_cfg, |
|
|
|
main_config_.source_cfg, |
|
|
|
main_config_.dir_cfg()), |
|
|
|
main_config_.dir_cfg), |
|
|
|
menu_(keybindings()), |
|
|
|
menu_(keybindings()), |
|
|
|
api_(menu_, notebook_) { |
|
|
|
api_(menu_, notebook) { |
|
|
|
INFO("Create Window"); |
|
|
|
INFO("Create Window"); |
|
|
|
set_title("juCi++"); |
|
|
|
set_title("juCi++"); |
|
|
|
set_default_size(600, 400); |
|
|
|
set_default_size(600, 400); |
|
|
|
@ -66,16 +66,16 @@ Window::Window() : |
|
|
|
SaveFile(); |
|
|
|
SaveFile(); |
|
|
|
if (running.try_lock()) { |
|
|
|
if (running.try_lock()) { |
|
|
|
std::thread execute([=]() { |
|
|
|
std::thread execute([=]() { |
|
|
|
std::string path = notebook_.CurrentTextView().file_path; |
|
|
|
std::string path = notebook.CurrentTextView().file_path; |
|
|
|
size_t pos = path.find_last_of("/\\"); |
|
|
|
size_t 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); |
|
|
|
running.unlock(); |
|
|
|
running.unlock(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
execute.detach(); |
|
|
|
execute.detach(); |
|
|
|
@ -92,13 +92,13 @@ Window::Window() : |
|
|
|
SaveFile(); |
|
|
|
SaveFile(); |
|
|
|
if (running.try_lock()) { |
|
|
|
if (running.try_lock()) { |
|
|
|
std::thread execute([=]() {
|
|
|
|
std::thread execute([=]() {
|
|
|
|
std::string path = notebook_.CurrentTextView().file_path; |
|
|
|
std::string path = notebook.CurrentTextView().file_path; |
|
|
|
size_t pos = path.find_last_of("/\\"); |
|
|
|
size_t 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(); |
|
|
|
running.unlock(); |
|
|
|
running.unlock(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
execute.detach(); |
|
|
|
execute.detach(); |
|
|
|
@ -111,10 +111,10 @@ Window::Window() : |
|
|
|
|
|
|
|
|
|
|
|
window_box_.pack_start(menu_.view(), Gtk::PACK_SHRINK); |
|
|
|
window_box_.pack_start(menu_.view(), Gtk::PACK_SHRINK); |
|
|
|
|
|
|
|
|
|
|
|
window_box_.pack_start(notebook_.entry, Gtk::PACK_SHRINK); |
|
|
|
window_box_.pack_start(notebook.entry, Gtk::PACK_SHRINK); |
|
|
|
paned_.set_position(300); |
|
|
|
paned_.set_position(300); |
|
|
|
paned_.pack1(notebook_.view(), true, false); |
|
|
|
paned_.pack1(notebook.view, true, false); |
|
|
|
paned_.pack2(terminal_.view(), true, true); |
|
|
|
paned_.pack2(terminal.view, true, true); |
|
|
|
window_box_.pack_end(paned_); |
|
|
|
window_box_.pack_end(paned_); |
|
|
|
show_all_children(); |
|
|
|
show_all_children(); |
|
|
|
INFO("Window created"); |
|
|
|
INFO("Window created"); |
|
|
|
@ -139,8 +139,8 @@ void Window::OnFileOpenFolder() { |
|
|
|
case(Gtk::RESPONSE_OK): |
|
|
|
case(Gtk::RESPONSE_OK): |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::string project_path=dialog.get_filename(); |
|
|
|
std::string project_path=dialog.get_filename(); |
|
|
|
notebook_.project_path=project_path; |
|
|
|
notebook.project_path=project_path; |
|
|
|
notebook_.directories.open_folder(project_path); |
|
|
|
notebook.directories.open_folder(project_path); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
case(Gtk::RESPONSE_CANCEL): |
|
|
|
case(Gtk::RESPONSE_CANCEL): |
|
|
|
@ -188,7 +188,7 @@ void Window::OnOpenFile() { |
|
|
|
switch (result) { |
|
|
|
switch (result) { |
|
|
|
case(Gtk::RESPONSE_OK): { |
|
|
|
case(Gtk::RESPONSE_OK): { |
|
|
|
std::string path = dialog.get_filename(); |
|
|
|
std::string path = dialog.get_filename(); |
|
|
|
notebook_.OnOpenFile(path); |
|
|
|
notebook.OnOpenFile(path); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
case(Gtk::RESPONSE_CANCEL): { |
|
|
|
case(Gtk::RESPONSE_CANCEL): { |
|
|
|
@ -201,20 +201,20 @@ void Window::OnOpenFile() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool Window::SaveFile() { |
|
|
|
bool Window::SaveFile() { |
|
|
|
if(notebook_.OnSaveFile()) { |
|
|
|
if(notebook.OnSaveFile()) { |
|
|
|
terminal_.PrintMessage("File saved to: " + |
|
|
|
terminal.PrintMessage("File saved to: " + |
|
|
|
notebook_.CurrentTextView().file_path+"\n"); |
|
|
|
notebook.CurrentTextView().file_path+"\n"); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
terminal_.PrintMessage("File not saved"); |
|
|
|
terminal.PrintMessage("File not saved"); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
bool Window::SaveFileAs() { |
|
|
|
bool Window::SaveFileAs() { |
|
|
|
if(notebook_.OnSaveFile(notebook_.OnSaveFileAs())){ |
|
|
|
if(notebook.OnSaveFile(notebook.OnSaveFileAs())){ |
|
|
|
terminal_.PrintMessage("File saved to: " + |
|
|
|
terminal.PrintMessage("File saved to: " + |
|
|
|
notebook_.CurrentTextView().file_path+"\n"); |
|
|
|
notebook.CurrentTextView().file_path+"\n"); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
terminal_.PrintMessage("File not saved"); |
|
|
|
terminal.PrintMessage("File not saved"); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|