From 2476329b2cdf5eda3eb75e94c0d8ed844b88cf6e Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 14 Oct 2023 17:24:39 -0700 Subject: [PATCH] fix ^ as choice in / menu for tty and X11 It turned out that using '^' as a group accelerator (new behavior for the 'whatis' command to view traps) already worked for curses and Qt. Fix that for tty and X11. I don't know the situation for WinGUI. Offering any of the menu paging keystrokes as group accelerators should be avoided if there's any chance that the menu will need more that one page. The menu for '/' is short though so losing "^ to go back to first page" for it isn't an issue. --- doc/fixes3-7-0.txt | 4 ++++ win/X11/winmenu.c | 9 ++++++--- win/tty/wintty.c | 8 ++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index f37232824..1d511ff35 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1777,6 +1777,8 @@ tty: changes to support TTY_PERM_INVENT resulted in blank inventory menu when tty: for the !DEF_PAGER configuration, redraw screen properly if attempting to display a file fails and tty_display_file()'s caller requests feedback for that situation +tty: if a group accelerator matched a menu command ('^' in menu for '/') + it wouldn't work to select, just to manipulate the menu Unix: after lua changes to Makefiles, 'make spotless' for dat subdirectory left some generated data files which should have been deleted Windows: new tile additions in win/share did not trigger the creation of a new @@ -1802,6 +1804,8 @@ X11: use visctrl(response) when X11_yn_function() echoes prompt+response in X11: when trying to lookup scrollbars in order to handle scrolling via keys, menu handling always ended up finding the top window X11: enable horizontal scrollbar for persistent inventory window +X11: if a group accelerator matched a menu command ('^' in menu for '/') + it wouldn't work to select, just to manipulate the menu X11+macOS: after the "bad Atom" fix (below), the persistent inventory window crept downward every time it got updated diff --git a/win/X11/winmenu.c b/win/X11/winmenu.c index 550b81fe6..067de1a42 100644 --- a/win/X11/winmenu.c +++ b/win/X11/winmenu.c @@ -254,9 +254,11 @@ menu_key(Widget w, XEvent *event, String *params, Cardinal *num_params) if (menu_info->is_active || perminv_scrolling) { /* handle the input */ /* first check for an explicit selector match, so that it won't be overridden if it happens to duplicate a mapped menu command (':' - to look inside a container vs ':' to select via search string) */ + to look inside a container vs ':' to select via search string); + check for group accelerator match too */ for (curr = menu_info->curr_menu.base; curr; curr = curr->next) - if (curr->identifier.a_void != 0 && curr->selector == ch) + if (curr->identifier.a_void != 0 + && (curr->selector == ch || curr->gselector == ch)) goto make_selection; ch = map_menu_cmd(ch); @@ -366,7 +368,8 @@ menu_key(Widget w, XEvent *event, String *params, Cardinal *num_params) selected_something = FALSE; for (count = 0, curr = menu_info->curr_menu.base; curr; curr = curr->next, count++) - if (curr->identifier.a_void != 0 && curr->selector == ch) + if (curr->identifier.a_void != 0 + && (curr->selector == ch || curr->gselector == ch)) break; if (curr) { diff --git a/win/tty/wintty.c b/win/tty/wintty.c index e8ed9d934..3bcefbdd5 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -1493,11 +1493,15 @@ process_menu_window(winid window, struct WinDesc *cw) } } /* set extra chars.. */ - Strcat(resp, default_menu_cmds); + if (*gacc) { + Strcat(resp, gacc); /* group accelerators */ + if (cw->how == PICK_ONE) + resp_len = (int) strlen(resp); + } Strcat(resp, " "); /* next page or end */ Strcat(resp, "0123456789\033\n\r"); /* counts, quit */ - Strcat(resp, gacc); /* group accelerators */ Strcat(resp, gm.mapped_menu_cmds); + Strcat(resp, default_menu_cmds); if (cw->npages > 1) Sprintf(cw->morestr, "(%d of %d)", curr_page + 1,