summaryrefslogtreecommitdiff
path: root/fluid/shell_command.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2023-03-19 20:04:01 +0100
committerGitHub <noreply@github.com>2023-03-19 20:04:01 +0100
commitf37347dd6ed73f180116e100de46cbe33ce19598 (patch)
tree5f98b4914544ad065243a81a4e481e3c4e598fa8 /fluid/shell_command.cxx
parentf9004352b42b3b039c391d5a8c83930c9b49b53a (diff)
Fix and consolidate settings dialogs (#346, #703)
Diffstat (limited to 'fluid/shell_command.cxx')
-rw-r--r--fluid/shell_command.cxx54
1 files changed, 12 insertions, 42 deletions
diff --git a/fluid/shell_command.cxx b/fluid/shell_command.cxx
index 630b84b1f..46d8b8f46 100644
--- a/fluid/shell_command.cxx
+++ b/fluid/shell_command.cxx
@@ -33,7 +33,7 @@ Shell_Settings shell_settings_linux = { };
Shell_Settings shell_settings_macos = { };
/// Current shell command, stored in .fl file for each platform, and in app prefs
-char *g_shell_command = NULL;
+Fl_String g_shell_command;
/// Save .fl file before running, stored in .fl file for each platform, and in app prefs
int g_shell_save_fl = 1;
@@ -85,11 +85,7 @@ void shell_settings_read()
#else
Shell_Settings &shell_settings = shell_settings_linux;
#endif
- if (g_shell_command)
- free((void*)g_shell_command);
- g_shell_command = NULL;
- if (shell_settings.command)
- g_shell_command = fl_strdup(shell_settings.command);
+ g_shell_command = shell_settings.command;
g_shell_save_fl = ((shell_settings.flags&1)==1);
g_shell_save_code = ((shell_settings.flags&2)==2);
g_shell_save_strings = ((shell_settings.flags&4)==4);
@@ -112,8 +108,8 @@ void shell_settings_write()
if (shell_settings.command)
free((void*)shell_settings.command);
shell_settings.command = NULL;
- if (g_shell_command)
- shell_settings.command = fl_strdup(g_shell_command);
+ if (!g_shell_command.empty())
+ shell_settings.command = fl_strdup(g_shell_command.c_str());
shell_settings.flags = 0;
if (g_shell_save_fl)
shell_settings.flags |= 1;
@@ -244,13 +240,13 @@ void Fl_Process::clean_close(HANDLE& h) {
// Shell command support...
-static bool prepare_shell_command(const char * &command) { // common pre-shell command code all platforms
- shell_window->hide();
+static bool prepare_shell_command() {
+// settings_window->hide();
if (s_proc.desc()) {
fl_alert("Previous shell command still running!");
return false;
}
- if ((command = g_shell_command) == NULL || !*command) {
+ if (g_shell_command.empty()) {
fl_alert("No shell command entered!");
return false;
}
@@ -282,17 +278,15 @@ void shell_pipe_cb(FL_SOCKET, void*) {
}
void do_shell_command(Fl_Return_Button*, void*) {
- const char *command=NULL; // Command to run
-
- if (!prepare_shell_command(command)) return;
+ if (!prepare_shell_command()) return;
// Show the output window and clear things...
shell_run_terminal->text("");
- shell_run_terminal->append(command);
+ shell_run_terminal->append(g_shell_command.c_str());
shell_run_terminal->append("\n");
shell_run_window->label("Shell Command Running...");
- if (s_proc.popen((char *)command) == NULL) {
+ if (s_proc.popen((char *)g_shell_command.c_str()) == NULL) {
fl_alert("Unable to run shell command: %s", strerror(errno));
return;
}
@@ -343,31 +337,7 @@ void do_shell_command(Fl_Return_Button*, void*) {
Fluid app settings are saved per user and per machine.
*/
void show_shell_window() {
- update_shell_window();
- shell_window->hotspot(shell_command_input);
- shell_window->show();
-}
-
-/**
- Update the shell properties dialog box.
- */
-void update_shell_window() {
- shell_command_input->value(g_shell_command);
- shell_savefl_button->value(g_shell_save_fl);
- shell_writecode_button->value(g_shell_save_code);
- shell_writemsgs_button->value(g_shell_save_strings);
- shell_use_fl_button->value(g_shell_use_fl_settings);
-}
-
-/**
- Copy the sshe;l settings from the dialog box into the variables.
- */
-void apply_shell_window() {
- if (g_shell_command)
- free((void*)g_shell_command);
- g_shell_command = fl_strdup(shell_command_input->value());
- g_shell_save_fl = shell_savefl_button->value();
- g_shell_save_code = shell_writecode_button->value();
- g_shell_save_strings = shell_writemsgs_button->value();
+ settings_window->show();
+ w_settings_tabs->value(w_settings_shell_tab);
}