X-Git-Url: https://git.subgeniuskitty.com/xmenu/.git/blobdiff_plain/2b0484b11ccb71b9bed2593706938928a32a4e11..112e23c3e8bd279b4ee5464f39fb2b8df48b7f6d:/xmenu.c diff --git a/xmenu.c b/xmenu.c index e74c3c7..c5290c9 100644 --- a/xmenu.c +++ b/xmenu.c @@ -233,7 +233,7 @@ error: errx(1, "improper position: %s", optarg); } -/* parse color string */ +/* parse font string */ 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 Item *lastitem; KeySym ksym; XEvent ev; @@ -1281,14 +1282,14 @@ selectitem: } 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); - currmenu->selected = item; - for(int i = ksym-XK_1; i > 0; i-=1){ - item = itemcycle(currmenu, ITEMNEXT); - currmenu->selected = item; - } - } else if ((ksym == XK_Return || ksym == XK_Right || ksym == KSYMRIGHT) && - currmenu->selected != NULL) { + 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) && + currmenu->selected != NULL) { item = currmenu->selected; goto selectitem; } else if ((ksym == XK_Escape || ksym == XK_Left || ksym == KSYMLEFT) &&