From b74b8be680bb7ca0a6952adafd29d97e85da5c67 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 9 Jul 2019 12:44:47 +0000 Subject: [PATCH] Add j and k for navigation in menus, GitHub issue 1828. --- menu.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/menu.c b/menu.c index cc21c796..da8d89c4 100644 --- a/menu.c +++ b/menu.c @@ -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: