add lastitem and adapt code to general code style
This commit is contained in:
parent
736d20be06
commit
c2959cf439
6
xmenu.c
6
xmenu.c
|
@ -1209,6 +1209,7 @@ run(struct Menu *currmenu)
|
||||||
struct Menu *menu;
|
struct Menu *menu;
|
||||||
struct Item *item;
|
struct Item *item;
|
||||||
struct Item *previtem = NULL;
|
struct Item *previtem = NULL;
|
||||||
|
struct Item *lastitem;
|
||||||
KeySym ksym;
|
KeySym ksym;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
|
@ -1282,11 +1283,10 @@ selectitem:
|
||||||
item = itemcycle(currmenu, ITEMNEXT);
|
item = itemcycle(currmenu, ITEMNEXT);
|
||||||
} else if (ksym >= XK_1 && ksym <= XK_9){
|
} else if (ksym >= XK_1 && ksym <= XK_9){
|
||||||
item = itemcycle(currmenu, ITEMFIRST);
|
item = itemcycle(currmenu, ITEMFIRST);
|
||||||
for(int i = ksym-XK_1; i > 0; i-=1){
|
lastitem = itemcycle(currmenu, ITEMLAST);
|
||||||
|
for (int i = ksym - XK_1; i > 0 && item != lastitem; i--) {
|
||||||
currmenu->selected = item;
|
currmenu->selected = item;
|
||||||
item = itemcycle(currmenu, ITEMNEXT);
|
item = itemcycle(currmenu, ITEMNEXT);
|
||||||
if (item == itemcycle(currmenu, ITEMLAST))
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} 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) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user