fix comment on parsefonts()
[xmenu] / xmenu.c
diff --git a/xmenu.c b/xmenu.c
index 0cc56ac..c5290c9 100644 (file)
--- a/xmenu.c
+++ b/xmenu.c
@@ -233,7 +233,7 @@ error:
        errx(1, "improper position: %s", optarg);
 }
 
        errx(1, "improper position: %s", optarg);
 }
 
-/* parse color string */
+/* parse font string */
 static void
 parsefonts(const char *s)
 {
 static void
 parsefonts(const char *s)
 {
@@ -1209,6 +1209,7 @@ run(struct Menu *currmenu)
        struct Menu *menu;
        struct Item *item;
        struct Item *previtem = NULL;
        struct Menu *menu;
        struct Item *item;
        struct Item *previtem = NULL;
+       struct Item *lastitem;
        KeySym ksym;
        XEvent ev;
 
        KeySym ksym;
        XEvent ev;
 
@@ -1280,8 +1281,15 @@ selectitem:
                                item = itemcycle(currmenu, ITEMPREV);
                        } else if (ksym == XK_Tab || ksym == XK_Down || ksym == KSYMDOWN) {
                                item = itemcycle(currmenu, ITEMNEXT);
                                item = itemcycle(currmenu, ITEMPREV);
                        } else if (ksym == XK_Tab || ksym == XK_Down || ksym == KSYMDOWN) {
                                item = itemcycle(currmenu, ITEMNEXT);
+                       } else if (ksym >= XK_1 && ksym <= XK_9){
+                               item = itemcycle(currmenu, ITEMFIRST);
+                               lastitem = itemcycle(currmenu, ITEMLAST);
+                               for (int i = ksym - XK_1; i > 0 && item != lastitem; i--) {
+                                       currmenu->selected = item;
+                                       item = itemcycle(currmenu, ITEMNEXT);
+                               }
                        } else if ((ksym == XK_Return || ksym == XK_Right || ksym == KSYMRIGHT) &&
                        } else if ((ksym == XK_Return || ksym == XK_Right || ksym == KSYMRIGHT) &&
-                                  currmenu->selected != NULL) {
+                                   currmenu->selected != NULL) {
                                item = currmenu->selected;
                                goto selectitem;
                        } else if ((ksym == XK_Escape || ksym == XK_Left || ksym == KSYMLEFT) &&
                                item = currmenu->selected;
                                goto selectitem;
                        } else if ((ksym == XK_Escape || ksym == XK_Left || ksym == KSYMLEFT) &&