Use Vi for Code View / Editing Code in Fluid

15 views
Skip to first unread message

Christian

unread,
Feb 12, 2025, 12:48:39 PMFeb 12
to fltk.coredev
Hello,

Issue is I tend to open the .cxx source file in order to search and examine my code but any changes I make here will not get written to the .fl file and I need to go in to the individual functions in fluid and make the edits there. It works it is just a bit annoying.

I am looking for a way to make quick edits to my entire .cxx source file or header files and when I save the file, make the same changes to the fluid file.

This is because my project is getting more complex and at times I want to use fluid to make the edits, and other times it is much quicker to go in to the actual source and perform the edits there. Just wish they would write into the .fl file automatically.

1. Is this something that fluid could be modified to support or,
2. Is it reasonable to write a script that can push any changes I make to the .cxx source also to the .fl file. Sounds like this might be tricky since the .fl file handles the entire project.

Kind regards,

-Christian

Greg Ercolano

unread,
Feb 12, 2025, 1:16:51 PMFeb 12
to fltkc...@googlegroups.com
-Christian --


    I'm familiar with this as I often run into it myself.

    The problem with adding a global way to edit the c++ code is that it'd be hard for fluid to, in a cross platform way, detect where you made your changes in the generated c++ file, and then fold that back into the .fl file. I suppose a "special" generated .cxx file could include special comment markers that could help fluid re-fold your changes back into fluid's "in memory" representation of your code, but I could see that being very tricky to do.

    The workarounds I've found over the years is to either (a) carefully edit the .fl file itself, or (b) not get carried away with using a single .fl file to make the entire application, and implement only the GUI aspects in one or more .fl files, and make calls to a separate module (that I maintain in VI) to do all the actual application's work. This way all the code I might commonly want to change globally will be in my separately VI maintained code.

    If you edit the .fl file, keep in mind the .fl file's escaping of special characters, like the escape character itself (\) has to be doubly escaped inside the .fl file. So if you add a printf() statement, be sure your \n becomes \\n inside the .fl file. As long as you carefully maintain .fl's formatting, editing the .fl is pretty safe to do.



Albrecht Schlosser

unread,
Feb 12, 2025, 5:01:21 PMFeb 12
to fltkc...@googlegroups.com
On 2/12/25 18:45 Christian wrote:
> Issue is I tend to open the .cxx source file in order to search and
> examine my code but any changes I make here will not get written to
> the .fl file and I need to go in to the individual functions in fluid
> and make the edits there. It works it is just a bit annoying.
>
> I am looking for a way to make quick edits to my entire .cxx source
> file or header files and when I save the file, make the same changes
> to the fluid file.
> ...
> 1. Is this something that fluid could be modified to support

Probably yes. Matthias, the main author of fluid wrote a "MergeBack"
feature and published it for testing some time ago. However, this was a
proof of concept, not yet complete and not yet ready for release.

AFAICT Matt is planning to add support for this "MergeBack" feature in
the next minor release which will likely be 1.5.0. Note that this is all
from my own memory, I'm not sure what he will or can do in the near
future but ISTR that I tested it with some success...

You can take a look at PR #1182 ("Reinstating Fluid MergeBack feature")
with meanwhile somewhat aged code that could be merged after some
adjustments and more testing etc..
https://github.com/fltk/fltk/pull/1182

I'm pretty sure Matthias can tell us more and he will likely chime in
soon...

imacarthur

unread,
Feb 13, 2025, 8:48:24 AMFeb 13
to fltk.coredev
Seems to me this might be "non-trivial" though...
The "forward conversion" from fluid to C++ is "deterministic" but reversing that from C++ to fluid seems like it would be less so. You might have to put "a lot" of "decoration" into the generated C++ to help guide the reverse processing I suspect (not having tried it...)

It just seems to me a bit "cryptographic" - easy to go one way, hard to go back the other way!

Reply all
Reply to author
Forward
0 new messages