]> granicus.if.org Git - nethack/commitdiff
X11 menu hack for ':'
authorPatR <rankin@nethack.org>
Wed, 1 Apr 2015 09:47:04 +0000 (02:47 -0700)
committerPatR <rankin@nethack.org>
Wed, 1 Apr 2015 09:47:04 +0000 (02:47 -0700)
Same functionality as was recently implemented for tty.  If a
character like ':' is an explicit menu selector and the player
types it, select that menu entry rather than treating it as a
search request.  (Same for other menu commands like '>', but
offhand I can't think of anything besides container looting's
': - look inside' that uses any non-letter selectors other
than '$', which isn't used as a menu meta command.)

win/X11/winmenu.c

index b28dc3361e1decbf7bfdaae66c9ce4619899c0bc..6ab51fae9da647b7af0bf4e1c3846f9b29935f86 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.5 winmenu.c       $NHDT-Date$  $NHDT-Branch$:$NHDT-Revision$ */
+/* NetHack 3.5 winmenu.c       $NHDT-Date: 1427881480 2015/04/01 09:44:40 $  $NHDT-Branch: master $:$NHDT-Revision: 1.5 $ */
 /* NetHack 3.5 winmenu.c       $Date: 2009/05/06 10:55:53 $  $Revision: 1.5 $ */
 /*     SCCS Id: @(#)winmenu.c  3.5     1996/08/15      */
 /* Copyright (c) Dean Luick, 1992                                */
@@ -206,6 +206,7 @@ menu_key(w, event, params, num_params)
     struct xwindow *wp;
     char ch;
     int count;
+    boolean selected_something;
 
     wp = find_widget(w);
     menu_info = wp->menu_information;
@@ -218,6 +219,13 @@ menu_key(w, event, params, num_params)
     }
 
     if (menu_info->is_active) {                /* waiting for 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) */
+       for (curr = menu_info->curr_menu.base; curr; curr = curr->next)
+           if (curr->identifier.a_void != 0 && curr->selector == ch)
+               goto make_selection;
+
        ch = map_menu_cmd(ch);
        if (ch == '\033') {             /* quit */
            if (menu_info->counting) {
@@ -294,7 +302,8 @@ menu_key(w, event, params, num_params)
                X11_nhbell();
            return;
        } else {
-           boolean selected_something = FALSE;
+ make_selection:
+           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) break;