tags 358337 confirmed thanks On Wed, Mar 22, 2006 at 09:50:16AM +0000, Silas S. Brown wrote: > Package: flwm > Version: 1.00-7 > Severity: minor > > > If there is a window with an ampersand (&) in its title, > then on the window-list menu the & will not be displayed but > the following letter will be underlined instead. This is > probably because the window-list is displayed by some > function that is normally used to display menus with > shortcut keys. (Pressing the letter has no effect however.)
Hello Silas, I confirm this problem. FLTK 1.1 documentation say: const char* Fl_Menu_Item::label() const void Fl_Menu_Item::label(const char*) void Fl_Menu_Item::label(Fl_Labeltype, const char*) This is the title of the item. A NULL here indicates the end of the menu (or of a submenu). A '&' in the item will print an underscore under the next letter, and if the menu is popped up that letter will be a "shortcut" to pick that item. To get a real '&' put two in a row. I hope the attached patch fix this problem, I will see with upstream. Thanks for reporting this problem! -- Bill. <[EMAIL PROTECTED]> Imagine a large red swirl here.
--- ./Menu.C 2000-09-22 18:53:05.000000000 +0200 +++ ../flwm-1.00/./Menu.C 2006-03-23 22:55:04.000000000 +0100 @@ -20,6 +20,24 @@ #include <dirent.h> #include <sys/stat.h> +static char *double_ampersand(const char *s) +{ + long i,l; + for(i=0,l=0;s[i];i++) + if (s[i]=='&') + l++; + char *c = new (char [l+i+1]); + for(i=0,l=0;s[i];i++) + { + c[l++]=s[i]; + if (s[i]=='&') + c[l++]=s[i]; + } + c[l]=0; + return c; +} + + // it is possible for the window to be deleted or withdrawn while // the menu is up. This will detect that case (with reasonable // reliability): @@ -90,8 +108,11 @@ } fl_font(o->font, o->size); fl_color((Fl_Color)o->color); - const char* l = f->label(); if (!l) l = "unnamed"; + const char* l = f->label(); + if (!l) l = "unnamed"; + else l = double_ampersand(f->label()); fl_draw(l, X+MENU_ICON_W+3, Y, W-MENU_ICON_W-3, H, align); + delete l; } static void