From: PatR Date: Sat, 28 Mar 2015 01:24:53 +0000 (-0700) Subject: tty menu hack for ':' X-Git-Tag: NetHack-3.6.0_RC01~535^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=45c5a796818fc064473146548a002f3292b73956;p=nethack tty menu hack for ':' Looting a container generates a menu which contains ': - look inside' but the recent change to make ':' be a menu command for selecting items which match a search string made it impossible to pick that item. (Well, I suppose you could enter a search string which matched it, but that's a nuisance compared to just directly picking a choice.) This makes menu selection for tty give precedence to menu choice characters over mapped menu commands when some character happens to be both. I'm not sure whether it ought to be expended to group accelerators too, so didn't do that. There's bound to be a better way to do this, but it works. --- diff --git a/win/tty/wintty.c b/win/tty/wintty.c index f3cc97eb5..afe0e204e 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 wintty.c $NHDT-Date: 1426465444 2015/03/16 00:24:04 $ $NHDT-Branch: debug $:$NHDT-Revision: 1.71 $ */ +/* NetHack 3.5 wintty.c $NHDT-Date: 1427505884 2015/03/28 01:24:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.73 $ */ /* NetHack 3.5 wintty.c $Date: 2012/01/22 06:27:09 $ $Revision: 1.66 $ */ /* Copyright (c) David Cohrs, 1991 */ /* NetHack may be freely redistributed. See license for details. */ @@ -1391,10 +1391,11 @@ struct WinDesc *cw; { tty_menu_item *page_start, *page_end, *curr; long count; - int n, curr_page, page_lines; + int n, curr_page, page_lines, resp_len; boolean finished, counting, reset_count; char *cp, *rp, resp[QBUFSZ], gacc[QBUFSZ], - *msave, *morestr; + *msave, *morestr, really_morc; +#define MENU_EXPLICIT_CHOICE 0x7f /* pseudo menu manipulation char */ curr_page = page_lines = 0; page_start = page_end = 0; @@ -1501,6 +1502,8 @@ struct WinDesc *cw; page_lines = 0; } *rp = 0; + /* remember how many explicit menu choices there are */ + resp_len = (int)strlen(resp); /* corner window - clear extra lines from last page */ if (cw->offx) { @@ -1533,7 +1536,15 @@ struct WinDesc *cw; xwaitforspace(resp); } - morc = map_menu_cmd(morc); + really_morc = morc; /* (only used with MENU_EXPLICIT_CHOICE */ + if ((rp = index(resp, morc)) != 0 && rp < resp + resp_len) + /* explicit menu selection; don't override it if it also + happens to match a mapped menu command (such as ':' to + look inside a container vs ':' to search) */ + morc = MENU_EXPLICIT_CHOICE; + else + morc = map_menu_cmd(morc); + switch (morc) { case '0': /* special case: '0' is also the default ball class */ @@ -1664,6 +1675,9 @@ struct WinDesc *cw; } } break; + case MENU_EXPLICIT_CHOICE: + morc = really_morc; + /*FALLTHRU*/ default: if (cw->how == PICK_NONE || !index(resp, morc)) { /* unacceptable input received */