Browse Source

add lastitem and adapt code to general code style

master
phillbush 4 years ago
parent
commit
c2959cf439
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      xmenu.c

+ 3
- 3
xmenu.c View File

@@ -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;

@@ -1282,11 +1283,10 @@ selectitem:
item = itemcycle(currmenu, ITEMNEXT);
} else if (ksym >= XK_1 && ksym <= XK_9){
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;
item = itemcycle(currmenu, ITEMNEXT);
if (item == itemcycle(currmenu, ITEMLAST))
break;
}
} else if ((ksym == XK_Return || ksym == XK_Right || ksym == KSYMRIGHT) &&
currmenu->selected != NULL) {


Loading…
Cancel
Save