diff --git a/src/commands.cpp b/src/commands.cpp index aa41a2a..5db439c 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -20,7 +20,9 @@ void Commands::load() { "run": "echo && echo ", "debug_comment": "Whether or not this command should run through debugger", "debug": false, - "debug_remote_host": "" + "debug_remote_host": "", + "label_comment": "Output to the terminal instead of the run command", + "label": "" } ] )"); @@ -43,7 +45,8 @@ void Commands::load() { regex = std::regex(path, std::regex::optimize); commands.emplace_back(Command{key, modifier, std::move(regex), command.string_or("compile", ""), command.string("run"), - command.boolean_or("debug", false), command.string_or("debug_remote_host", "")}); + command.boolean_or("debug", false), command.string_or("debug_remote_host", ""), + command.string_or("label", "")}); } } catch(const std::exception &e) { diff --git a/src/commands.hpp b/src/commands.hpp index 86847b7..bd52b81 100644 --- a/src/commands.hpp +++ b/src/commands.hpp @@ -17,6 +17,7 @@ public: std::string run; bool debug; std::string debug_remote_host; + std::string label; }; static Commands &get() { diff --git a/src/window.cpp b/src/window.cpp index 66c96d1..3bd8f1e 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1942,6 +1942,14 @@ bool Window::on_key_press_event(GdkEventKey *event) { auto run = command.run; boost::replace_all(run, "", filesystem::escape_argument(path.string())); boost::replace_all(run, "", filesystem::escape_argument(run_path.string())); + std::string label; + if(!command.label.empty()) { + label = command.label; + boost::replace_all(label, "", filesystem::escape_argument(path.string())); + boost::replace_all(label, "", filesystem::escape_argument(run_path.string())); + } + else + label = run; if(!compile.empty() || command.debug) { if(Project::debugging && command.debug) // Possibly continue current debugging @@ -1967,19 +1975,19 @@ bool Window::on_key_press_event(GdkEventKey *event) { if(!command.debug) { Project::compiling = true; - Terminal::get().print("\e[2mCompiling and running: " + run + "\e[m\n"); - Terminal::get().async_process(compile, run_path, [run, run_path](int exit_status) { + Terminal::get().print("\e[2mCompiling and running: " + label + "\e[m\n"); + Terminal::get().async_process(compile, run_path, [run, run_path, label](int exit_status) { Project::compiling = false; if(exit_status == 0) { - Terminal::get().async_process(run, run_path, [run](int exit_status) { - Terminal::get().print("\e[2m" + run + " returned: " + (exit_status == 0 ? "\e[32m" : "\e[31m") + std::to_string(exit_status) + "\e[m\n"); + Terminal::get().async_process(run, run_path, [label](int exit_status) { + Terminal::get().print("\e[2m" + label + " returned: " + (exit_status == 0 ? "\e[32m" : "\e[31m") + std::to_string(exit_status) + "\e[m\n"); }); } }); } else { // Debug Project::debugging = true; - Terminal::get().print("\e[2mCompiling and debugging: " + run + "\e[m\n"); + Terminal::get().print("\e[2mCompiling and debugging: " + label + "\e[m\n"); Terminal::get().async_process(compile, run_path, [project = project->shared_from_this(), run, run_path, debug_remote_host = command.debug_remote_host](int exit_status) { if(exit_status != EXIT_SUCCESS) Project::debugging = false; @@ -1989,14 +1997,14 @@ bool Window::on_key_press_event(GdkEventKey *event) { } } else if(!command.debug) { - Terminal::get().async_print("\e[2mRunning: " + run + "\e[m\n"); - Terminal::get().async_process(run, run_path, [run](int exit_status) { - Terminal::get().print("\e[2m" + run + " returned: " + (exit_status == 0 ? "\e[32m" : "\e[31m") + std::to_string(exit_status) + "\e[m\n"); + Terminal::get().async_print("\e[2mRunning: " + label + "\e[m\n"); + Terminal::get().async_process(run, run_path, [label](int exit_status) { + Terminal::get().print("\e[2m" + label + " returned: " + (exit_status == 0 ? "\e[32m" : "\e[31m") + std::to_string(exit_status) + "\e[m\n"); }); } else { // Debug Project::debugging = true; - Terminal::get().async_print("\e[2mDebugging: " + run + "\e[m\n"); + Terminal::get().async_print("\e[2mDebugging: " + label + "\e[m\n"); project->debug_start(run, run_path, command.debug_remote_host); } return true;