diff options
| author | Matthias Melcher <github@matthiasm.com> | 2024-02-10 14:28:27 +0100 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2024-02-10 14:28:33 +0100 |
| commit | 1ed14867e62811ca4b2f6f968b3376ce0a148182 (patch) | |
| tree | 4f1a6912475d7d4ce52bd58325164c2d538b71e9 | |
| parent | f4af40fe5539269b92701f3adb94fb2775f1f457 (diff) | |
Fixes FLUID shortcut generation
and makes the C++ code human readable
| -rw-r--r-- | fluid/Fl_Menu_Type.cxx | 18 | ||||
| -rw-r--r-- | fluid/Fl_Widget_Type.cxx | 19 |
2 files changed, 25 insertions, 12 deletions
diff --git a/fluid/Fl_Menu_Type.cxx b/fluid/Fl_Menu_Type.cxx index c1d99257e..ab8c2cca8 100644 --- a/fluid/Fl_Menu_Type.cxx +++ b/fluid/Fl_Menu_Type.cxx @@ -396,14 +396,20 @@ void Fl_Menu_Item_Type::write_item(Fd_Code_Writer& f) { f.write_c("\"\""); if (((Fl_Button*)o)->shortcut()) { int s = ((Fl_Button*)o)->shortcut(); - if (g_project.use_FL_COMMAND && (s & (FL_CTRL|FL_META))) { - f.write_c(", "); - if (s & FL_COMMAND) f.write_c("FL_COMMAND|"); - if (s & FL_CONTROL) f.write_c("FL_CONTROL|"); - f.write_c("0x%x, ", s & ~(FL_CTRL|FL_META)); + f.write_c(", "); + if (g_project.use_FL_COMMAND) { + if (s & FL_COMMAND) { f.write_c("FL_COMMAND|"); s &= ~FL_COMMAND; } + if (s & FL_CONTROL) { f.write_c("FL_CONTROL|"); s &= ~FL_CONTROL; } } else { - f.write_c(", 0x%x, ", s); + if (s & FL_CTRL) { f.write_c("FL_CTRL|"); s &= ~FL_CTRL; } + if (s & FL_META) { f.write_c("FL_META|"); s &= ~FL_META; } } + if (s & FL_SHIFT) { f.write_c("FL_SHIFT|"); s &= ~FL_SHIFT; } + if (s & FL_ALT) { f.write_c("FL_ALT|"); s &= ~FL_ALT; } + if ((s < 127) && isprint(s)) + f.write_c("'%c', ", s); + else + f.write_c("0x%x, ", s); } else { f.write_c(", 0, "); } diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx index 7b4e79ec9..2b087f743 100644 --- a/fluid/Fl_Widget_Type.cxx +++ b/fluid/Fl_Widget_Type.cxx @@ -3102,14 +3102,21 @@ void Fl_Widget_Type::write_widget_code(Fd_Code_Writer& f) { else if (is_a(ID_Value_Input)) shortcut = ((Fl_Value_Input*)o)->shortcut(); else if (is_a(ID_Text_Display)) shortcut = ((Fl_Text_Display*)o)->shortcut(); if (shortcut) { - if (g_project.use_FL_COMMAND && (shortcut & (FL_CTRL|FL_META))) { - f.write_c("%s%s->shortcut(", f.indent(), var); - if (shortcut & FL_COMMAND) f.write_c("FL_COMMAND|"); - if (shortcut & FL_CONTROL) f.write_c("FL_CONTROL|"); - f.write_c("0x%x);\n", shortcut & ~(FL_CTRL|FL_META)); + int s = shortcut; + f.write_c("%s%s->shortcut(", f.indent(), var); + if (g_project.use_FL_COMMAND) { + if (s & FL_COMMAND) { f.write_c("FL_COMMAND|"); s &= ~FL_COMMAND; } + if (s & FL_CONTROL) { f.write_c("FL_CONTROL|"); s &= ~FL_CONTROL; } } else { - f.write_c("%s%s->shortcut(0x%x);\n", f.indent(), var, shortcut); + if (s & FL_CTRL) { f.write_c("FL_CTRL|"); s &= ~FL_CTRL; } + if (s & FL_META) { f.write_c("FL_META|"); s &= ~FL_META; } } + if (s & FL_SHIFT) { f.write_c("FL_SHIFT|"); s &= ~FL_SHIFT; } + if (s & FL_ALT) { f.write_c("FL_ALT|"); s &= ~FL_ALT; } + if ((s < 127) && isprint(s)) + f.write_c("'%c');\n", s); + else + f.write_c("0x%x);\n", s); } if (is_a(ID_Button)) { |
