]> granicus.if.org Git - nethack/commitdiff
number_pad menu hack
authorPatR <rankin@nethack.org>
Thu, 10 Feb 2022 22:18:44 +0000 (14:18 -0800)
committerPatR <rankin@nethack.org>
Thu, 10 Feb 2022 22:18:44 +0000 (14:18 -0800)
I don't try to toggle 'number_pad' very often, but when I do I almost
always type '0' instead of 'a' for Off or '1' instead of 'b' for On
on the first attempt.  The menu shows
| a -  0 (off)
| b -  1 (on)
| c -  2 (on, MSDOS compatible)
| d -  3 (on, phone-style digit layout)
| e -  4 (on, phone-style layout, MSDOS compatible)
| f - -1 (off, 'z' to move upper-left, 'y' to zap wands)

This change makes '0' through '4' be undocumented group accelerators
for 'a' through 'e' (and '5' for 'f') in the sub-menu put up by 'O'.
tty and X11 worked as-is for '0' and required what amounts to a pair
of one-line changes to handle the other digits.

It doesn't work for curses and Qt (no idea about Windows GUI) because
they insist on treating any typed digit as the start of a count even
if one or more menu entries include that digit as a group accelerator.
(They also fail to support '0' as the group accelerator for iron-ball
class in the menu for multiple-drop.)

src/options.c
win/X11/winmenu.c
win/tty/wintty.c

index a826ff481a32df312d6ad4051c664e4e3170bca5..6b73b64a1779d56cdc01720e6e5ec84b7f68b0a2 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 options.c       $NHDT-Date: 1643491546 2022/01/29 21:25:46 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.535 $ */
+/* NetHack 3.7 options.c       $NHDT-Date: 1644531493 2022/02/10 22:18:13 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.538 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Michael Allison, 2008. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -4528,8 +4528,8 @@ handler_number_pad(void)
     any = cg.zeroany;
     for (i = 0; i < SIZE(npchoices); i++) {
         any.a_int = i + 1;
-        add_menu(tmpwin, &nul_glyphinfo, &any, 'a' + i,
-                 0, ATR_NONE, npchoices[i], MENU_ITEMFLAGS_NONE);
+        add_menu(tmpwin, &nul_glyphinfo, &any, 'a' + i, '0' + i,
+                 ATR_NONE, npchoices[i], MENU_ITEMFLAGS_NONE);
     }
     end_menu(tmpwin, "Select number_pad mode:");
     if (select_menu(tmpwin, PICK_ONE, &mode_pick) > 0) {
index 890dc33aea8392b1754e48e99d0a268d8349919b..d31b95a35a4f0df415ef605cc5854bb5b5ec1216 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 winmenu.c       $NHDT-Date: 1615911117 2021/03/16 16:11:57 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.48 $ */
+/* NetHack 3.7 winmenu.c       $NHDT-Date: 1644531504 2022/02/10 22:18:24 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.50 $ */
 /* Copyright (c) Dean Luick, 1992                                */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -271,8 +271,10 @@ menu_key(Widget w, XEvent *event, String *params, Cardinal *num_params)
             }
             ; /* accept */
         } else if (digit(ch)) {
-            /* special case: '0' is also the default ball class */
-            if (ch == '0' && !menu_info->counting
+            /* special case: '0' is also the default ball class;
+               some menus use digits as potential group accelerators
+               but their entries don't rely on counts */
+            if (!menu_info->counting
                 && index(menu_info->curr_menu.gacc, ch))
                 goto group_accel;
             menu_info->menu_count *= 10L;
index 8d1a77495bcd422993384984844c5151f6385eb1..4f9b484524deea6e666e37287a736e5ffa4fa977 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 wintty.c        $NHDT-Date: 1643491577 2022/01/29 21:26:17 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.282 $ */
+/* NetHack 3.7 wintty.c        $NHDT-Date: 1644531502 2022/02/10 22:18:22 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.283 $ */
 /* Copyright (c) David Cohrs, 1991                                */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2055,11 +2055,6 @@ process_menu_window(winid window, struct WinDesc *cw)
 
         switch (morc) {
         case '0':
-            /* special case: '0' is also the default ball class */
-            if (!counting && index(gacc, morc))
-                goto group_accel;
-            /* fall through to count the zero */
-            /*FALLTHRU*/
         case '1':
         case '2':
         case '3':
@@ -2069,6 +2064,12 @@ process_menu_window(winid window, struct WinDesc *cw)
         case '7':
         case '8':
         case '9':
+            /* special case: '0' is also the default ball class;
+               some menus use digits as potential group accelerators
+               but their entries don't rely on counts */
+            if (!counting && index(gacc, morc))
+                goto group_accel;
+
             count = (count * 10L) + (long) (morc - '0');
             /*
              * It is debatable whether we should allow 0 to