Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fluid: save shell commands in per-file preferences #328

Closed
Albrecht-S opened this issue Dec 14, 2021 · 9 comments
Closed

Fluid: save shell commands in per-file preferences #328

Albrecht-S opened this issue Dec 14, 2021 · 9 comments
Assignees
Labels
enhancement New feature or request fluid Fast Light User Interface Designer (fluid)

Comments

@Albrecht-S
Copy link
Member

Albrecht-S commented Dec 14, 2021

I noticed that there's a new feature to save the shell command to the .fl file but I found a case where this is done when it should not.

Running `fluid -u xxx.fl' (which "updates" the .fl file to the current FLTK version) now unconditionally adds the last saved shell command to xxx.fl.

Thus it is possible to write a saved shell command of one project to another unrelated project. For a quick workaround I can probably remove the shell command from the preferences, but this is at least unexpected and should be fixed.

Background: once upon a time ... I used a special shell command in fluid which is still stored in my fluid.prefs file:

+linux_shell_cmd {ls -l *.fl;sleep 1; ../build/debug/fltk-config --compile tabs.cxx && ./tabs}
+linux_shell_flags 3

When running fluid -u as described above this shell command is added to every .fl file. This is particularly annoying because I use to run fluid -u -c on all .fl files in the FLTK source tree from time to time for maintenance.

@Albrecht-S Albrecht-S added bug Something isn't working fluid Fast Light User Interface Designer (fluid) labels Dec 14, 2021
@Albrecht-S
Copy link
Member Author

Note: after clearing the shell command and re-running fluid -u an empty shell command is added to the .fl file which is acceptable. But why add an empty shell command?

@Albrecht-S
Copy link
Member Author

Another observation: if I use the "old" 1.4.0 fluid version to read a file written by the current version I see these console messages:

print_panel.fl:5: Unknown word "linux_shell_cmd"
print_panel.fl:5: Unknown word ""
print_panel.fl:6: Unknown word "linux_shell_flags"
print_panel.fl:6: Unknown word "3"
print_panel.fl:7: Unknown word "mac_shell_cmd"
print_panel.fl:7: Unknown word "echo "Fluid is nice""
print_panel.fl:8: Unknown word "mac_shell_flags"
print_panel.fl:8: Unknown word "3"

but this is probably something we can't avoid, right? Top 10 lines of the file:

-----   print_panel.fl   -----

     1	# data file for the Fltk User Interface Designer (fluid)
     2	version 1.0400
     3	header_name {.h}
     4	code_name {.cxx}
     5	linux_shell_cmd {}
     6	linux_shell_flags 3
     7	mac_shell_cmd {echo "Fluid is nice"}
     8	mac_shell_flags 3
     9	comment {//
    10	// FLUID print panel for the Fast Light Tool Kit (FLTK).

MatthiasWM pushed a commit to MatthiasWM/fltk that referenced this issue Dec 15, 2021
MatthiasWM pushed a commit to MatthiasWM/fltk that referenced this issue Dec 15, 2021
Project wide settings require a redesign.
Temporarily disabled until I find a satisfying solution.
MatthiasWM pushed a commit that referenced this issue Dec 15, 2021
Project wide settings require a redesign.
Temporarily disabled until I find a satisfying solution.
@MatthiasWM
Copy link
Contributor

Changing project settings will always cause error messages in previous Fluid versions. Also, reading is quite inefficient. I'll try to find a solution here.

To correctly write the shell commands as a project setting, I need to differentiate better between inherited settings, personal settings, and project related settings.

@MatthiasWM MatthiasWM added the active Somebody is working on it label Dec 15, 2021
@Albrecht-S
Copy link
Member Author

Thanks for the update. I'll try this tomorrow. (?)

@Albrecht-S
Copy link
Member Author

I checked the current fluid output as promised and removed some remaining mac_shell_* items from .fl files (commit e8961f1). This is OK now. Almost.

The only remaining issue I found is a regression that one trailing semicolon is generated. Sorry, this is OT here but I didn't want to open yet another issue.

diff --git a/FL/Fl_File_Chooser.H b/FL/Fl_File_Chooser.H
index 57e0a97f9..5935edc28 100644
--- a/FL/Fl_File_Chooser.H
+++ b/FL/Fl_File_Chooser.H
@@ -142,7 +142,7 @@ public:
   void ok_label(const char *l);
   const char * ok_label();
   void preview(int e);
-  int preview() const { return previewButton->value(); }
+  int preview() const { return previewButton->value(); };     <<--- HERE
 private:
   void showHidden(int e);
   void remove_hidden_files();

The obvious reproducer is to write files from fluid Fl_File_Chooser.fl, or

cd src
fluid -c Fl_File_Chooser.fl

I couldn't create a compiler warning but ISTR that we recently removed such trailing semicolons after {...} because of a report about warnings.

MatthiasWM pushed a commit to MatthiasWM/fltk that referenced this issue Dec 20, 2021
@MatthiasWM
Copy link
Contributor

Ok, I fixed the code generator (waiting for CI to finish before PR), but it must have been like this for quite a while, judging by past commits. I guess nobody ever bothered rebuilding the File Chooser.

@Albrecht-S
Copy link
Member Author

I guess nobody ever bothered rebuilding the File Chooser.

I did it routinely every now and then - but not since you started working on fluid these weeks (thank you!). I'm executing fluid -u -c <file> for all fluid files in the distro! However, if nothing changed there was no reason to check it in.

FTR: I found commit 6ac305a where I removed trailing semicolons. I found them using -Wextra-semi -Werror=extra-semi because a user reported this.

@MatthiasWM MatthiasWM added enhancement New feature or request and removed bug Something isn't working labels Jan 8, 2022
@MatthiasWM
Copy link
Contributor

Implementation hints:

  • shell commands must never be written into a .fl design file! The shell commands would get distributed to end users, and I really don't want to be responsible for rm -r * or similar stupid commands.
  • shell commands are different for every user, and possibly for some design files.
    ** implement default shell commands on App level
    ** implement the ability to change them per design file
    ** save the custom commands in a Preferences file under the design file name, so they are local for this user only
    ** limit the number of design file user prefs, so we don't now indefinitely
  • allow multiple commands (edit, build, run, close, debug, ...?) that can be renamed and have custom shortcuts

@MatthiasWM MatthiasWM changed the title fluid writes saved shell command unconditionally to .fl file Fluid: save shell commands inf per-file preferences Jan 12, 2022
@MatthiasWM MatthiasWM removed the active Somebody is working on it label Feb 12, 2022
@MatthiasWM MatthiasWM changed the title Fluid: save shell commands inf per-file preferences Fluid: save shell commands in per-file preferences Feb 20, 2022
@MatthiasWM
Copy link
Contributor

Mostly implemented, continued in #674

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fluid Fast Light User Interface Designer (fluid)
Projects
None yet
Development

No branches or pull requests

2 participants