summaryrefslogtreecommitdiff
path: root/fluid/file.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <git@matthiasm.com>2021-12-09 02:43:57 +0100
committerMatthias Melcher <git@matthiasm.com>2021-12-09 02:48:40 +0100
commit4f2febd801eadce214189f119090cbe0bb9c05b1 (patch)
treef34dfcaedd4304c73013e7568e85ab9024ab0c4e /fluid/file.cxx
parent1be158a840922aa03682d39926dc60ecb487063b (diff)
Fluid STR 3460.D: Shell commands are now saved in the .fl file (user option)
The shell properties toolbox is completely redesigned: This dialog box offers a field for a command line and three check buttons to generate and save various files before the command is run. If the fourth checkbox, "use settings in .fl design files" is checked, all shell settings will be store in the current .fl file, and they will be read and restored when the .fl is loaded again. Fluid will save different shell settings for different operating system as it is common that a different OS requires a different shell command. Fluid comes with default shell settings. Pressing the "save as default" button will store the current setting in the Fluid app settings and are used for new designs, or if the "use settings..." box is not checked. Fluid app settings are saved per user and per machine.
Diffstat (limited to 'fluid/file.cxx')
-rw-r--r--fluid/file.cxx216
1 files changed, 136 insertions, 80 deletions
diff --git a/fluid/file.cxx b/fluid/file.cxx
index 1e67ce4c8..063f3e4a0 100644
--- a/fluid/file.cxx
+++ b/fluid/file.cxx
@@ -28,6 +28,7 @@
#include "Fl_Window_Type.h"
#include "alignment_panel.h"
#include "widget_browser.h"
+#include "shell_command.h"
#include "code.h"
#include <FL/Fl.H>
@@ -392,9 +393,23 @@ int write_file(const char *filename, int selected_only) {
break;
}
}
+ shell_settings_write();
if (!selected_only) {
write_string("\nheader_name"); write_word(header_file_name);
write_string("\ncode_name"); write_word(code_file_name);
+
+ if (shell_settings_windows.command) {
+ write_string("\nwin_shell_cmd"); write_word(shell_settings_windows.command);
+ write_string("\nwin_shell_flags"); write_string("%d", shell_settings_windows.flags);
+ }
+ if (shell_settings_linux.command) {
+ write_string("\nlinux_shell_cmd"); write_word(shell_settings_linux.command);
+ write_string("\nlinux_shell_flags"); write_string("%d", shell_settings_linux.flags);
+ }
+ if (shell_settings_macos.command) {
+ write_string("\nmac_shell_cmd"); write_word(shell_settings_macos.command);
+ write_string("\nmac_shell_flags"); write_string("%d", shell_settings_macos.flags);
+ }
}
for (Fl_Type *p = Fl_Type::first; p;) {
if (!selected_only || p->selected) {
@@ -413,9 +428,16 @@ int write_file(const char *filename, int selected_only) {
// read all the objects out of the input file:
/**
- Read child node in the .fl design file.
+ Recursively read child nodes in the .fl design file.
+
+ If this is the first call, also read the global settings for this design.
+
+ \param[in] p parent node or NULL
+ \param[in] paste if set, merge into existing design, else replace design
+ \param[in] options_read this is set if the options were already found in
+ a previous call
*/
-static void read_children(Fl_Type *p, int paste) {
+static void read_children(Fl_Type *p, int paste, char options_read=0) {
Fl_Type::current = p;
for (;;) {
const char *c = read_word();
@@ -430,85 +452,107 @@ static void read_children(Fl_Type *p, int paste) {
break;
}
- // this is the first word in a .fd file:
- if (!strcmp(c,"Magic:")) {
- read_fdesign();
- return;
- }
+ // Make sure that we don;t go through the list of options for child nodes
+ if (!options_read) {
+ // this is the first word in a .fd file:
+ if (!strcmp(c,"Magic:")) {
+ read_fdesign();
+ return;
+ }
- if (!strcmp(c,"version")) {
- c = read_word();
- read_version = strtod(c,0);
- if (read_version<=0 || read_version>double(FL_VERSION+0.00001))
- read_error("unknown version '%s'",c);
- continue;
- }
+ if (!strcmp(c,"version")) {
+ c = read_word();
+ read_version = strtod(c,0);
+ if (read_version<=0 || read_version>double(FL_VERSION+0.00001))
+ read_error("unknown version '%s'",c);
+ continue;
+ }
- // back compatibility with Vincent Penne's original class code:
- if (!p && !strcmp(c,"define_in_struct")) {
- Fl_Type *t = Fl_Type_make("class");
- t->name(read_word());
- Fl_Type::current = p = t;
- paste = 1; // stops "missing }" error
- continue;
- }
+ // back compatibility with Vincent Penne's original class code:
+ if (!p && !strcmp(c,"define_in_struct")) {
+ Fl_Type *t = Fl_Type_make("class");
+ t->name(read_word());
+ Fl_Type::current = p = t;
+ paste = 1; // stops "missing }" error
+ continue;
+ }
- if (!strcmp(c,"do_not_include_H_from_C")) {
- include_H_from_C=0;
- goto CONTINUE;
- }
- if (!strcmp(c,"use_FL_COMMAND")) {
- use_FL_COMMAND=1;
- goto CONTINUE;
- }
- if (!strcmp(c,"i18n_type")) {
- i18n_type = atoi(read_word());
- goto CONTINUE;
- }
- if (!strcmp(c,"i18n_function")) {
- i18n_function = fl_strdup(read_word());
- goto CONTINUE;
- }
- if (!strcmp(c,"i18n_file")) {
- i18n_file = fl_strdup(read_word());
- goto CONTINUE;
- }
- if (!strcmp(c,"i18n_set")) {
- i18n_set = fl_strdup(read_word());
- goto CONTINUE;
- }
- if (!strcmp(c,"i18n_include")) {
- i18n_include = fl_strdup(read_word());
- goto CONTINUE;
- }
- if (!strcmp(c,"i18n_type"))
- {
- i18n_type = atoi(read_word());
- goto CONTINUE;
- }
- if (!strcmp(c,"i18n_type"))
- {
- i18n_type = atoi(read_word());
- goto CONTINUE;
- }
- if (!strcmp(c,"header_name")) {
- if (!header_file_set) header_file_name = fl_strdup(read_word());
- else read_word();
- goto CONTINUE;
- }
+ if (!strcmp(c,"do_not_include_H_from_C")) {
+ include_H_from_C=0;
+ goto CONTINUE;
+ }
+ if (!strcmp(c,"use_FL_COMMAND")) {
+ use_FL_COMMAND=1;
+ goto CONTINUE;
+ }
+ if (!strcmp(c,"i18n_type")) {
+ i18n_type = atoi(read_word());
+ goto CONTINUE;
+ }
+ if (!strcmp(c,"i18n_function")) {
+ i18n_function = fl_strdup(read_word());
+ goto CONTINUE;
+ }
+ if (!strcmp(c,"i18n_file")) {
+ i18n_file = fl_strdup(read_word());
+ goto CONTINUE;
+ }
+ if (!strcmp(c,"i18n_set")) {
+ i18n_set = fl_strdup(read_word());
+ goto CONTINUE;
+ }
+ if (!strcmp(c,"i18n_include")) {
+ i18n_include = fl_strdup(read_word());
+ goto CONTINUE;
+ }
+ if (!strcmp(c,"i18n_type"))
+ {
+ i18n_type = atoi(read_word());
+ goto CONTINUE;
+ }
+ if (!strcmp(c,"i18n_type"))
+ {
+ i18n_type = atoi(read_word());
+ goto CONTINUE;
+ }
+ if (!strcmp(c,"header_name")) {
+ if (!header_file_set) header_file_name = fl_strdup(read_word());
+ else read_word();
+ goto CONTINUE;
+ }
- if (!strcmp(c,"code_name")) {
- if (!code_file_set) code_file_name = fl_strdup(read_word());
- else read_word();
- goto CONTINUE;
- }
+ if (!strcmp(c,"code_name")) {
+ if (!code_file_set) code_file_name = fl_strdup(read_word());
+ else read_word();
+ goto CONTINUE;
+ }
- if (!strcmp(c, "snap") || !strcmp(c, "gridx") || !strcmp(c, "gridy")) {
- // grid settings are now global
- read_word();
- goto CONTINUE;
- }
+ if (!strcmp(c, "snap") || !strcmp(c, "gridx") || !strcmp(c, "gridy")) {
+ // grid settings are now global
+ read_word();
+ goto CONTINUE;
+ }
+ if (strcmp(c, "win_shell_cmd")==0) {
+ if (shell_settings_windows.command)
+ free((void*)shell_settings_windows.command);
+ shell_settings_windows.command = fl_strdup(read_word());
+ } else if (strcmp(c, "win_shell_flags")==0) {
+ shell_settings_windows.flags = atoi(read_word());
+ } else if (strcmp(c, "linux_shell_cmd")==0) {
+ if (shell_settings_linux.command)
+ free((void*)shell_settings_linux.command);
+ shell_settings_linux.command = fl_strdup(read_word());
+ } else if (strcmp(c, "linux_shell_flags")==0) {
+ shell_settings_linux.flags = atoi(read_word());
+ } else if (strcmp(c, "mac_shell_cmd")==0) {
+ if (shell_settings_macos.command)
+ free((void*)shell_settings_macos.command);
+ shell_settings_macos.command = fl_strdup(read_word());
+ } else if (strcmp(c, "mac_shell_flags")==0) {
+ shell_settings_macos.flags = atoi(read_word());
+ }
+ }
{
Fl_Type *t = Fl_Type_make(c);
if (!t) {
@@ -517,6 +561,9 @@ static void read_children(Fl_Type *p, int paste) {
}
t->name(read_word());
+ // After reading the first widget, we no longer need to look for options
+ options_read = 1;
+
c = read_word(1);
if (strcmp(c,"{") && t->is_class()) { // <prefix> <name>
((Fl_Class_Type*)t)->prefix(t->name());
@@ -542,7 +589,7 @@ static void read_children(Fl_Type *p, int paste) {
read_error("Missing child list for %s\n",t->title());
goto REUSE_C;
}
- read_children(t, 0);
+ read_children(t, 0, options_read);
}
Fl_Type::current = p;
@@ -560,16 +607,25 @@ static void read_children(Fl_Type *p, int paste) {
int read_file(const char *filename, int merge) {
Fl_Type *o;
read_version = 0.0;
- if (!open_read(filename)) return 0;
- if (merge) deselect(); else delete_all();
+ if (!open_read(filename))
+ return 0;
+ if (merge)
+ deselect();
+ else
+ delete_all();
read_children(Fl_Type::current, merge);
Fl_Type::current = 0;
// Force menu items to be rebuilt...
for (o = Fl_Type::first; o; o = o->next)
- if (o->is_menu_button()) o->add_child(0,0);
+ if (o->is_menu_button())
+ o->add_child(0,0);
for (o = Fl_Type::first; o; o = o->next)
- if (o->selected) {Fl_Type::current = o; break;}
+ if (o->selected) {
+ Fl_Type::current = o;
+ break;
+ }
selection_changed(Fl_Type::current);
+ shell_settings_read();
return close_read();
}