summaryrefslogtreecommitdiff
path: root/fluid/shell_command.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2023-12-14 19:40:29 +0100
committerMatthias Melcher <github@matthiasm.com>2023-12-14 19:40:34 +0100
commit33d071875623dc90e8da00d0491f97bc2558c861 (patch)
tree742cf9b611ac89f4bbb234edbaf9a9e7834a5f5a /fluid/shell_command.cxx
parent673fa2e09c178b6c49fddba53ca3d49ceb9bcd73 (diff)
FLUID: option to show terminal, clear terminal, and clear history
Diffstat (limited to 'fluid/shell_command.cxx')
-rw-r--r--fluid/shell_command.cxx35
1 files changed, 24 insertions, 11 deletions
diff --git a/fluid/shell_command.cxx b/fluid/shell_command.cxx
index 79b1609e8..28382636b 100644
--- a/fluid/shell_command.cxx
+++ b/fluid/shell_command.cxx
@@ -384,6 +384,22 @@ static void expand_macros(Fl_String &cmd) {
}
/**
+ Show the terminal window where it was last positioned.
+ */
+void show_terminal_window() {
+ Fl_Preferences pos(fluid_prefs, "shell_run_Window_pos");
+ int x, y, w, h;
+ pos.get("x", x, -1);
+ pos.get("y", y, 0);
+ pos.get("w", w, 640);
+ pos.get("h", h, 480);
+ if (x!=-1) {
+ shell_run_window->resize(x, y, w, h);
+ }
+ shell_run_window->show();
+}
+
+/**
Prepare for and run a shell command.
\param[in] cmd the command that is sent to `/bin/sh -c ...` or `cmd.exe` on Windows machines
@@ -400,20 +416,17 @@ void run_shell_command(const Fl_String &cmd, int flags) {
Fl_String expanded_cmd = cmd;
expand_macros(expanded_cmd);
- if (!shell_run_window->visible()) {
- Fl_Preferences pos(fluid_prefs, "shell_run_Window_pos");
- int x, y, w, h;
- pos.get("x", x, -1);
- pos.get("y", y, 0);
- pos.get("w", w, 640);
- pos.get("h", h, 480);
- if (x!=-1) {
- shell_run_window->resize(x, y, w, h);
- }
- shell_run_window->show();
+ if ( ((flags & Fd_Shell_Command::DONT_SHOW_TERMINAL) == 0)
+ && (!shell_run_window->visible()))
+ {
+ show_terminal_window();
}
// Show the output window and clear things...
+ if (flags & Fd_Shell_Command::CLEAR_TERMINAL)
+ shell_run_terminal->printf("\033[2J\033[H");
+ if (flags & Fd_Shell_Command::CLEAR_HISTORY)
+ shell_run_terminal->printf("\033[3J");
shell_run_terminal->printf("\033[0;32m%s\033[0m\n", expanded_cmd.c_str());
shell_run_window->label(expanded_cmd.c_str());