Patch for Fl_Valuator

15 views
Skip to first unread message

Andreas Held

unread,
Jan 3, 2026, 3:57:39 PM (7 days ago) Jan 3
to fltkc...@googlegroups.com
Hi

Happy New Year to all of you.

I am one of the maintainers of pyFltk, the Python bindings for fltk. We
have been struggling for some time with the signature of
Fl_Valuator::format(), which does not lend itself very nicely for
wrapping into other languages. Besides, as the comments in
Fl_Valuator.cxx explain, the signature is basically incomplete because
the buffer length is missing.

As it seems that for fltk1.5 some newer C++ concepts are being
supported, I have tried to create a patch for fltk1.5 by adding a new
method with the following signature:
const std::string format_str();
to replace the current:
int format(char*);
The idea being that Fl_Valuator::format() could be deprecated first and
then removed at a later point.

If you want to have a closer look, the patch can be found here:
https://github.com/AndreasHeld62/fltk/tree/format_patch

If this is something that would be acceptable to the core developers, I
would be happy to create a pull request.

Best regards

Andreas

melcher....@googlemail.com

unread,
Jan 4, 2026, 9:55:46 AM (6 days ago) Jan 4
to fltk.coredev
Thank you for the suggested patch. I did take the API, but implemented it slightly different so that overriding either the old or the new API would both work as expected.

`test/adjuster` was also not implemented correctly. It relied on side effects of the old implementation and was really bad example. 

With commit 0e570fb6729ff6b97249256c2c9d5f3aa58c7bb4 , the new API should work well and no magic numbers are needed any longer.

Andreas Held

unread,
Jan 6, 2026, 3:32:25 AM (5 days ago) Jan 6
to fltk.coredev
Hi Matthias
Thank you very much for taking this up and implementing it cleanly.
However, I just wondered a little bit that you implemented format_str by calling format(). Wouldn't it have been better to fully implement format_str() and then deprecate format() so that it could be removed at some later stage? I am not sure what the common consensus is about changes like this.

Best regards
Andreas

melcher....@googlemail.com

unread,
Jan 6, 2026, 6:40:20 AM (5 days ago) Jan 6
to fltk.coredev
Fl_Valuator::format() is a virtual function that can be overridden by the user, and I have to assume that users did that, so deprecating this will take a long time. Some F-Valuator classes use `format()` to output text, and I wanted to make sure that they will use the user overridden version, no matter if the user overrides `format` or `format_str`. Once we decide to abandon one of those versions, we can move the code from `format` to `format_str`. Last but not least, by reusing the old code as a default, I can avoid code duplication. Functionally, your version and my version should give the same results, right?
Reply all
Reply to author
Forward
0 new messages