From 46bb7da23433b04eb59f462e36443e1a962be07a Mon Sep 17 00:00:00 2001 From: eidheim Date: Sat, 6 Feb 2016 10:42:35 +0100 Subject: [PATCH] Solves #159, added option to save project files on compile/run --- src/config.cc | 1 + src/config.h | 1 + src/files.h | 5 +++-- src/notebook.cc | 13 +++++++++++++ src/notebook.h | 1 + src/window.cc | 10 ++++++++++ 6 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/config.cc b/src/config.cc index b04ec8a..1d79e39 100644 --- a/src/config.cc +++ b/src/config.cc @@ -84,6 +84,7 @@ void Config::retrieve_config() { window.theme_variant=cfg.get("gtk_theme.variant"); window.version = cfg.get("version"); window.default_size = {cfg.get("default_window_size.width"), cfg.get("default_window_size.height")}; + window.save_on_compile_or_run=cfg.get("project.save_on_compile_or_run"); terminal.default_build_path=cfg.get("project.default_build_path"); terminal.debug_build_path=cfg.get("project.debug_build_path"); diff --git a/src/config.h b/src/config.h index 8ebba6f..7e6069b 100644 --- a/src/config.h +++ b/src/config.h @@ -20,6 +20,7 @@ public: std::string theme_variant; std::string version; std::pair default_size; + bool save_on_compile_or_run; }; class Terminal { diff --git a/src/files.h b/src/files.h index 0970ccf..3ad9ae0 100644 --- a/src/files.h +++ b/src/files.h @@ -2,7 +2,7 @@ #define JUCI_FILES_H_ #include -#define JUCI_VERSION "1.1.0-4" +#define JUCI_VERSION "1.1.0-5" const std::string configjson = "{\n" @@ -130,7 +130,8 @@ const std::string configjson = #else " \"cmake_command\": \"cmake\",\n" #endif -" \"make_command\": \"cmake --build .\"\n" +" \"make_command\": \"cmake --build .\",\n" +" \"save_on_compile_or_run\": false" " },\n" " \"documentation_searches\": {\n" " \"clang\": {\n" diff --git a/src/notebook.cc b/src/notebook.cc index a0aa6f3..9e3b73f 100644 --- a/src/notebook.cc +++ b/src/notebook.cc @@ -283,6 +283,19 @@ bool Notebook::save_current() { return save(get_current_page()); } +void Notebook::save_project_files() { + if(get_current_page()==-1) + return; + auto current_view=get_current_view(); + for(int c=0;cget_buffer()->get_modified()) { + if(current_view->project_path==view->project_path) + save(c); + } + } +} + bool Notebook::close(int page) { JDEBUG("start"); if (page!=-1) { diff --git a/src/notebook.h b/src/notebook.h index 086d862..1b6f2d8 100644 --- a/src/notebook.h +++ b/src/notebook.h @@ -27,6 +27,7 @@ public: void open(const boost::filesystem::path &file_path); bool save(int page); bool save_current(); + void save_project_files(); void configure(int view_nr); boost::filesystem::path get_current_folder(); diff --git a/src/window.cc b/src/window.cc index 2c55f69..ad492d6 100644 --- a/src/window.cc +++ b/src/window.cc @@ -640,6 +640,9 @@ void Window::set_menu_actions() { if(compiling) return; + if(Config::get().window.save_on_compile_or_run) + notebook.save_project_files(); + auto cmake=get_cmake(); if(!cmake) return; @@ -687,6 +690,10 @@ void Window::set_menu_actions() { menu.add_action("compile", [this]() { if(compiling) return; + + if(Config::get().window.save_on_compile_or_run) + notebook.save_project_files(); + auto cmake=get_cmake(); if(!cmake) return; @@ -789,6 +796,9 @@ void Window::set_menu_actions() { return; } + if(Config::get().window.save_on_compile_or_run) + notebook.save_project_files(); + auto cmake=get_cmake(); if(!cmake) return;