diff options
author | Thomas Adam <thomas@xteddy.org> | 2019-05-28 13:02:27 +0100 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2019-05-28 13:02:27 +0100 |
commit | eba6cf61c94b534d356439eab7ed883e2f7ca47d (patch) | |
tree | 931f5ad61c3abb2166721b65d0e5b102262e6165 /menu.c | |
parent | c0116b2c5ba7d52509a8ce01dd27c2e3a3d4e2af (diff) | |
parent | e0fd2950548def0124733b43fb347e82878f47b3 (diff) | |
download | rtmux-eba6cf61c94b534d356439eab7ed883e2f7ca47d.tar.gz rtmux-eba6cf61c94b534d356439eab7ed883e2f7ca47d.tar.bz2 rtmux-eba6cf61c94b534d356439eab7ed883e2f7ca47d.zip |
Merge branch 'obsd-master'
Diffstat (limited to 'menu.c')
-rw-r--r-- | menu.c | 22 |
1 files changed, 16 insertions, 6 deletions
@@ -80,7 +80,7 @@ menu_add_item(struct menu *menu, const struct menu_item *item, menu->count--; return; } - if (item->key != KEYC_UNKNOWN && item->key != KEYC_NONE) { + if (*s != '-' && item->key != KEYC_UNKNOWN && item->key != KEYC_NONE) { key = key_string_lookup_key(item->key); xasprintf(&name, "%s#[default] #[align=right](%s)", s, key); } else @@ -182,6 +182,7 @@ menu_key_cb(struct client *c, struct key_event *event) const struct menu_item *item; struct cmdq_item *new_item; struct cmd_parse_result *pr; + const char *name; if (KEYC_IS_MOUSE(event->key)) { if (md->flags & MENU_NOMOUSE) @@ -207,21 +208,27 @@ menu_key_cb(struct client *c, struct key_event *event) } switch (event->key) { case KEYC_UP: + if (old == -1) + old = 0; do { if (md->choice == -1 || md->choice == 0) md->choice = count - 1; else md->choice--; - } while (menu->items[md->choice].name == NULL); + name = menu->items[md->choice].name; + } while ((name == NULL || *name == '-') && md->choice != old); c->flags |= CLIENT_REDRAWOVERLAY; return (0); case KEYC_DOWN: + if (old == -1) + old = 0; do { if (md->choice == -1 || md->choice == count - 1) md->choice = 0; - else - md->choice++; - } while (menu->items[md->choice].name == NULL); + else + md->choice++; + name = menu->items[md->choice].name; + } while ((name == NULL || *name == '-') && md->choice != old); c->flags |= CLIENT_REDRAWOVERLAY; return (0); case '\r': @@ -233,6 +240,9 @@ menu_key_cb(struct client *c, struct key_event *event) 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; @@ -244,7 +254,7 @@ chosen: if (md->choice == -1) return (1); item = &menu->items[md->choice]; - if (item->name == NULL) + if (item->name == NULL || *item->name == '-') return (1); if (md->cb != NULL) { md->cb(md->menu, md->choice, item->key, md->data); |