diff --git a/src/cmake.cc b/src/cmake.cc index f5d1260..cff8f1b 100644 --- a/src/cmake.cc +++ b/src/cmake.cc @@ -36,7 +36,7 @@ CMake::CMake(const boost::filesystem::path &path) { } boost::filesystem::path CMake::get_default_build_path(const boost::filesystem::path &project_path) { - boost::filesystem::path default_build_path=Config::get().terminal.default_build_path; + boost::filesystem::path default_build_path=Config::get().project.default_build_path; const std::string path_variable_project_directory_name=""; size_t pos=0; @@ -56,7 +56,7 @@ boost::filesystem::path CMake::get_default_build_path(const boost::filesystem::p } boost::filesystem::path CMake::get_debug_build_path(const boost::filesystem::path &project_path) { - boost::filesystem::path debug_build_path=Config::get().terminal.debug_build_path; + boost::filesystem::path debug_build_path=Config::get().project.debug_build_path; const std::string path_variable_project_directory_name=""; size_t pos=0; @@ -72,7 +72,7 @@ boost::filesystem::path CMake::get_debug_build_path(const boost::filesystem::pat const std::string path_variable_default_build_path=""; pos=0; debug_build_path_string=debug_build_path.string(); - auto default_build_path=Config::get().terminal.default_build_path; + auto default_build_path=Config::get().project.default_build_path; while((pos=debug_build_path_string.find(path_variable_default_build_path, pos))!=std::string::npos) { debug_build_path_string.replace(pos, path_variable_default_build_path.size(), default_build_path); pos+=default_build_path.size(); @@ -112,7 +112,7 @@ bool CMake::create_default_build(const boost::filesystem::path &project_path, bo auto compile_commands_path=default_build_path/"compile_commands.json"; Dialog::Message message("Creating/updating default build"); - auto exit_status=Terminal::get().process(Config::get().terminal.cmake_command+" "+ + auto exit_status=Terminal::get().process(Config::get().project.cmake_command+" "+ filesystem::escape_argument(project_path)+" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON", default_build_path); message.hide(); if(exit_status==EXIT_SUCCESS) { @@ -162,7 +162,7 @@ bool CMake::create_debug_build(const boost::filesystem::path &project_path) { std::unique_ptr message; message=std::unique_ptr(new Dialog::Message("Creating/updating debug build")); - auto exit_status=Terminal::get().process(Config::get().terminal.cmake_command+" "+ + auto exit_status=Terminal::get().process(Config::get().project.cmake_command+" "+ filesystem::escape_argument(project_path)+" -DCMAKE_BUILD_TYPE=Debug", debug_build_path); if(message) message->hide(); diff --git a/src/config.cc b/src/config.cc index 1d79e39..23ab06b 100644 --- a/src/config.cc +++ b/src/config.cc @@ -84,15 +84,15 @@ 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"); - terminal.make_command=cfg.get("project.make_command"); - terminal.cmake_command=cfg.get("project.cmake_command"); - terminal.history_size=cfg.get("terminal_history_size"); + project.save_on_compile_or_run=cfg.get("project.save_on_compile_or_run"); + project.default_build_path=cfg.get("project.default_build_path"); + project.debug_build_path=cfg.get("project.debug_build_path"); + project.make_command=cfg.get("project.make_command"); + project.cmake_command=cfg.get("project.cmake_command"); - terminal.clang_format_command=cfg.get("project.clang_format_command", "clang-format"); + terminal.history_size=cfg.get("terminal_history_size"); + terminal.clang_format_command="clang-format"; #ifdef __linux if(terminal.clang_format_command=="clang-format" && !boost::filesystem::exists("/usr/bin/clang-format") && !boost::filesystem::exists("/usr/local/bin/clang-format")) { diff --git a/src/config.h b/src/config.h index 7e6069b..e7ce328 100644 --- a/src/config.h +++ b/src/config.h @@ -20,17 +20,21 @@ public: std::string theme_variant; std::string version; std::pair default_size; - bool save_on_compile_or_run; }; class Terminal { + public: + std::string clang_format_command; + int history_size; + }; + + class Project { public: std::string default_build_path; std::string debug_build_path; std::string cmake_command; std::string make_command; - std::string clang_format_command; - int history_size; + bool save_on_compile_or_run; }; class Source { @@ -74,6 +78,7 @@ public: Menu menu; Window window; Terminal terminal; + Project project; Source source; const boost::filesystem::path& juci_home_path() const { return home; } diff --git a/src/project.cc b/src/project.cc index 306fbbc..e5f5cdb 100644 --- a/src/project.cc +++ b/src/project.cc @@ -141,7 +141,7 @@ void Project::Clang::compile() { return; compiling=true; Terminal::get().print("Compiling project "+cmake->project_path.string()+"\n"); - Terminal::get().async_process(Config::get().terminal.make_command, default_build_path, [this](int exit_status) { + Terminal::get().async_process(Config::get().project.make_command, default_build_path, [this](int exit_status) { compiling=false; }); } @@ -178,7 +178,7 @@ void Project::Clang::compile_and_run() { compiling=true; Terminal::get().print("Compiling and running "+arguments+"\n"); - Terminal::get().async_process(Config::get().terminal.make_command, default_build_path, [this, arguments, default_build_path](int exit_status){ + Terminal::get().async_process(Config::get().project.make_command, default_build_path, [this, arguments, default_build_path](int exit_status){ compiling=false; if(exit_status==EXIT_SUCCESS) { Terminal::get().async_process(arguments, default_build_path, [this, arguments](int exit_status){ @@ -266,7 +266,7 @@ void Project::Clang::debug_start() { debugging=true; Terminal::get().print("Compiling and debugging "+run_arguments+"\n"); - Terminal::get().async_process(Config::get().terminal.make_command, debug_build_path, [this, breakpoints, run_arguments, debug_build_path](int exit_status){ + Terminal::get().async_process(Config::get().project.make_command, debug_build_path, [this, breakpoints, run_arguments, debug_build_path](int exit_status){ if(exit_status!=EXIT_SUCCESS) debugging=false; else { diff --git a/src/window.cc b/src/window.cc index eab641a..9857b1f 100644 --- a/src/window.cc +++ b/src/window.cc @@ -534,7 +534,7 @@ void Window::set_menu_actions() { if(Project::compiling || Project::debugging) return; - if(Config::get().window.save_on_compile_or_run) + if(Config::get().project.save_on_compile_or_run) notebook.save_project_files(); project_language=Project::get_language(); @@ -544,7 +544,7 @@ void Window::set_menu_actions() { if(Project::compiling || Project::debugging) return; - if(Config::get().window.save_on_compile_or_run) + if(Config::get().project.save_on_compile_or_run) notebook.save_project_files(); project_language=Project::get_language(); @@ -619,7 +619,7 @@ void Window::set_menu_actions() { return; } - if(Config::get().window.save_on_compile_or_run) + if(Config::get().project.save_on_compile_or_run) notebook.save_project_files(); project_language=Project::get_language();