Add j and k for navigation in menus, GitHub issue 1828.

This commit is contained in:
nicm 2019-07-09 12:44:47 +00:00
parent a4be028b76
commit b74b8be680

20
menu.c
View File

@ -206,8 +206,18 @@ menu_key_cb(struct client *c, struct key_event *event)
c->flags |= CLIENT_REDRAWOVERLAY;
return (0);
}
for (i = 0; i < (u_int)count; i++) {
name = menu->items[i].name;
if (name == NULL || *name == '-')
continue;
if (event->key == menu->items[i].key) {
md->choice = i;
goto chosen;
}
}
switch (event->key) {
case KEYC_UP:
case 'k':
if (old == -1)
old = 0;
do {
@ -220,6 +230,7 @@ menu_key_cb(struct client *c, struct key_event *event)
c->flags |= CLIENT_REDRAWOVERLAY;
return (0);
case KEYC_DOWN:
case 'j':
if (old == -1)
old = 0;
do {
@ -239,15 +250,6 @@ menu_key_cb(struct client *c, struct key_event *event)
case 'q':
return (1);
}
for (i = 0; i < (u_int)count; i++) {
name = menu->items[i].name;
if (name == NULL || *name == '-')
continue;
if (event->key == menu->items[i].key) {
md->choice = i;
goto chosen;
}
}
return (0);
chosen: