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.
This commit is contained in:
PatR
2023-10-14 17:24:39 -07:00
parent 1d0e4729bd
commit 2476329b2c
3 changed files with 16 additions and 5 deletions

View File

@@ -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) {

View File

@@ -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,