Browse Source

Added preference item terminal.clear_on_run_command, and change preference item project.clear_terminal_on_compile to terminal.clear_on_compile

pipelines/235045657
eidheim 5 years ago
parent
commit
ffd9679740
  1. 2
      CMakeLists.txt
  2. 3
      src/config.cpp
  3. 3
      src/config.hpp
  4. 77
      src/files.hpp
  5. 16
      src/project.cpp
  6. 7
      src/window.cpp

2
CMakeLists.txt

@ -1,7 +1,7 @@
cmake_minimum_required (VERSION 2.8.8) cmake_minimum_required (VERSION 2.8.8)
project(juci) project(juci)
set(JUCI_VERSION "1.6.0.6") set(JUCI_VERSION "1.6.0.7")
set(CPACK_PACKAGE_NAME "jucipp") set(CPACK_PACKAGE_NAME "jucipp")
set(CPACK_PACKAGE_CONTACT "Ole Christian Eidheim <eidheim@gmail.com>") set(CPACK_PACKAGE_CONTACT "Ole Christian Eidheim <eidheim@gmail.com>")

3
src/config.cpp

@ -198,7 +198,6 @@ void Config::read(const boost::property_tree::ptree &cfg) {
project.meson.compile_command = cfg.get<std::string>("project.meson.compile_command"); project.meson.compile_command = cfg.get<std::string>("project.meson.compile_command");
project.default_build_management_system = cfg.get<std::string>("project.default_build_management_system"); project.default_build_management_system = cfg.get<std::string>("project.default_build_management_system");
project.save_on_compile_or_run = cfg.get<bool>("project.save_on_compile_or_run"); project.save_on_compile_or_run = cfg.get<bool>("project.save_on_compile_or_run");
project.clear_terminal_on_compile = cfg.get<bool>("project.clear_terminal_on_compile");
project.ctags_command = cfg.get<std::string>("project.ctags_command"); project.ctags_command = cfg.get<std::string>("project.ctags_command");
project.grep_command = cfg.get<std::string>("project.grep_command"); project.grep_command = cfg.get<std::string>("project.grep_command");
project.cargo_command = cfg.get<std::string>("project.cargo_command"); project.cargo_command = cfg.get<std::string>("project.cargo_command");
@ -207,6 +206,8 @@ void Config::read(const boost::property_tree::ptree &cfg) {
terminal.history_size = cfg.get<int>("terminal.history_size"); terminal.history_size = cfg.get<int>("terminal.history_size");
terminal.font = cfg.get<std::string>("terminal.font"); terminal.font = cfg.get<std::string>("terminal.font");
terminal.clear_on_compile = cfg.get<bool>("terminal.clear_on_compile");
terminal.clear_on_run_command = cfg.get<bool>("terminal.clear_on_run_command");
log.libclang = cfg.get<bool>("log.libclang"); log.libclang = cfg.get<bool>("log.libclang");
log.language_server = cfg.get<bool>("log.language_server"); log.language_server = cfg.get<bool>("log.language_server");

3
src/config.hpp

@ -25,6 +25,8 @@ public:
public: public:
int history_size; int history_size;
std::string font; std::string font;
bool clear_on_compile;
bool clear_on_run_command;
}; };
class Project { class Project {
@ -46,7 +48,6 @@ public:
Meson meson; Meson meson;
std::string default_build_management_system; std::string default_build_management_system;
bool save_on_compile_or_run; bool save_on_compile_or_run;
bool clear_terminal_on_compile;
std::string ctags_command; std::string ctags_command;
std::string grep_command; std::string grep_command;
std::string cargo_command; std::string cargo_command;

77
src/files.hpp

@ -77,7 +77,45 @@ const std::string default_config_file = R"RAW({
"terminal": { "terminal": {
"history_size": 10000, "history_size": 10000,
"font_comment": "Use \"\" to use source.font with slightly smaller size", "font_comment": "Use \"\" to use source.font with slightly smaller size",
"font": "" "font": "",
"clear_on_compile": true,
"clear_on_run_command": false
},
"project": {
"default_build_path_comment": "Use <project_directory_name> to insert the project top level directory name",
"default_build_path": "./build",
"debug_build_path_comment": "Use <project_directory_name> to insert the project top level directory name, and <default_build_path> to insert your default_build_path setting.",
"debug_build_path": "<default_build_path>/debug",
"cmake": {)RAW"
#ifdef _WIN32
R"RAW(
"command": "cmake -G\"MSYS Makefiles\"",)RAW"
#else
R"RAW(
"command": "cmake",)RAW"
#endif
R"RAW(
"compile_command": "cmake --build ."
},
"meson": {
"command": "meson",
"compile_command": "ninja"
},
"default_build_management_system_comment": "Select which build management system to use when creating a new C or C++ project, for instance \"cmake\" or \"meson\"",
"default_build_management_system": "cmake",
"save_on_compile_or_run": true,)RAW"
#ifdef JUCI_USE_UCTAGS
R"RAW(
"ctags_command": "uctags",)RAW"
#else
R"RAW(
"ctags_command": "ctags",)RAW"
#endif
R"RAW(
"grep_command": "grep",
"cargo_command": "cargo",
"python_command": "PYTHONUNBUFFERED=1 python",
"markdown_command": "grip -b"
}, },
"keybindings": { "keybindings": {
"preferences": "<primary>comma", "preferences": "<primary>comma",
@ -177,43 +215,6 @@ const std::string default_config_file = R"RAW({
"window_toggle_zen_mode": "", "window_toggle_zen_mode": "",
"window_clear_terminal": "" "window_clear_terminal": ""
}, },
"project": {
"default_build_path_comment": "Use <project_directory_name> to insert the project top level directory name",
"default_build_path": "./build",
"debug_build_path_comment": "Use <project_directory_name> to insert the project top level directory name, and <default_build_path> to insert your default_build_path setting.",
"debug_build_path": "<default_build_path>/debug",
"cmake": {)RAW"
#ifdef _WIN32
R"RAW(
"command": "cmake -G\"MSYS Makefiles\"",)RAW"
#else
R"RAW(
"command": "cmake",)RAW"
#endif
R"RAW(
"compile_command": "cmake --build ."
},
"meson": {
"command": "meson",
"compile_command": "ninja"
},
"default_build_management_system_comment": "Select which build management system to use when creating a new C or C++ project, for instance \"cmake\" or \"meson\"",
"default_build_management_system": "cmake",
"save_on_compile_or_run": true,
"clear_terminal_on_compile": true,)RAW"
#ifdef JUCI_USE_UCTAGS
R"RAW(
"ctags_command": "uctags",)RAW"
#else
R"RAW(
"ctags_command": "ctags",)RAW"
#endif
R"RAW(
"grep_command": "grep",
"cargo_command": "cargo",
"python_command": "PYTHONUNBUFFERED=1 python",
"markdown_command": "grip -b"
},
"documentation_searches": { "documentation_searches": {
"clang": { "clang": {
"separator": "::", "separator": "::",

16
src/project.cpp

@ -372,7 +372,7 @@ void Project::LLDB::debug_start() {
debugging = true; debugging = true;
if(Config::get().project.clear_terminal_on_compile) if(Config::get().terminal.clear_on_compile)
Terminal::get().clear(); Terminal::get().clear();
Terminal::get().print("Compiling and debugging " + *run_arguments + "\n"); Terminal::get().print("Compiling and debugging " + *run_arguments + "\n");
@ -843,7 +843,7 @@ void Project::Clang::compile() {
compiling = true; compiling = true;
if(Config::get().project.clear_terminal_on_compile) if(Config::get().terminal.clear_on_compile)
Terminal::get().clear(); Terminal::get().clear();
Terminal::get().print("Compiling project " + filesystem::get_short_path(build->project_path).string() + "\n"); Terminal::get().print("Compiling project " + filesystem::get_short_path(build->project_path).string() + "\n");
@ -877,7 +877,7 @@ void Project::Clang::compile_and_run() {
compiling = true; compiling = true;
if(Config::get().project.clear_terminal_on_compile) if(Config::get().terminal.clear_on_compile)
Terminal::get().clear(); Terminal::get().clear();
Terminal::get().print("Compiling and running " + arguments + "\n"); Terminal::get().print("Compiling and running " + arguments + "\n");
@ -986,7 +986,7 @@ void Project::Python::compile_and_run() {
path = view->file_path.parent_path(); path = view->file_path.parent_path();
} }
if(Config::get().project.clear_terminal_on_compile) if(Config::get().terminal.clear_on_compile)
Terminal::get().clear(); Terminal::get().clear();
Terminal::get().print("Running " + command + "\n"); Terminal::get().print("Running " + command + "\n");
@ -1012,7 +1012,7 @@ void Project::JavaScript::compile_and_run() {
path = view->file_path.parent_path(); path = view->file_path.parent_path();
} }
if(Config::get().project.clear_terminal_on_compile) if(Config::get().terminal.clear_on_compile)
Terminal::get().clear(); Terminal::get().clear();
Terminal::get().print("Running " + command + "\n"); Terminal::get().print("Running " + command + "\n");
@ -1025,7 +1025,7 @@ void Project::HTML::compile_and_run() {
if(dynamic_cast<NpmBuild *>(build.get())) { if(dynamic_cast<NpmBuild *>(build.get())) {
std::string command = "npm start"; std::string command = "npm start";
if(Config::get().project.clear_terminal_on_compile) if(Config::get().terminal.clear_on_compile)
Terminal::get().clear(); Terminal::get().clear();
Terminal::get().print("Running " + command + "\n"); Terminal::get().print("Running " + command + "\n");
@ -1053,7 +1053,7 @@ std::pair<std::string, std::string> Project::Rust::get_run_arguments() {
void Project::Rust::compile() { void Project::Rust::compile() {
compiling = true; compiling = true;
if(Config::get().project.clear_terminal_on_compile) if(Config::get().terminal.clear_on_compile)
Terminal::get().clear(); Terminal::get().clear();
Terminal::get().print("Compiling project " + filesystem::get_short_path(build->project_path).string() + "\n"); Terminal::get().print("Compiling project " + filesystem::get_short_path(build->project_path).string() + "\n");
@ -1067,7 +1067,7 @@ void Project::Rust::compile() {
void Project::Rust::compile_and_run() { void Project::Rust::compile_and_run() {
compiling = true; compiling = true;
if(Config::get().project.clear_terminal_on_compile) if(Config::get().terminal.clear_on_compile)
Terminal::get().clear(); Terminal::get().clear();
auto arguments = get_run_arguments().second; auto arguments = get_run_arguments().second;

7
src/window.cpp

@ -1381,6 +1381,8 @@ void Window::set_menu_actions() {
if(!content.empty()) { if(!content.empty()) {
last_run_command = content; last_run_command = content;
auto directory_folder = Project::get_preferably_directory_folder(); auto directory_folder = Project::get_preferably_directory_folder();
if(Config::get().terminal.clear_on_run_command)
Terminal::get().clear();
Terminal::get().async_print("Running: " + content + '\n'); Terminal::get().async_print("Running: " + content + '\n');
Terminal::get().async_process(content, directory_folder, [content](int exit_status) { Terminal::get().async_process(content, directory_folder, [content](int exit_status) {
@ -1489,8 +1491,11 @@ void Window::set_menu_actions() {
EntryBox::get().clear(); EntryBox::get().clear();
EntryBox::get().entries.emplace_back(last_run_debug_command, [this](const std::string &content) { EntryBox::get().entries.emplace_back(last_run_debug_command, [this](const std::string &content) {
if(!content.empty()) { if(!content.empty()) {
if(Project::current) if(Project::current) {
if(Config::get().terminal.clear_on_run_command)
Terminal::get().clear();
Project::current->debug_run_command(content); Project::current->debug_run_command(content);
}
last_run_debug_command = content; last_run_debug_command = content;
} }
EntryBox::get().hide(); EntryBox::get().hide();

Loading…
Cancel
Save