diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2020-04-16 17:20:24 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2020-04-16 17:20:24 +0000 |
commit | 9b01e727fd251c64cad0fc4b79ef2af8f0bdfaa8 (patch) | |
tree | c933c7b98107f783c56df582872040c3369bd827 /usr.bin/tmux/menu.c | |
parent | 902d48251893525f444777186a6d12c741d7cca9 (diff) |
Start menu with top item selected if no mouse, GitHub issue 2169.
Diffstat (limited to 'usr.bin/tmux/menu.c')
-rw-r--r-- | usr.bin/tmux/menu.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/usr.bin/tmux/menu.c b/usr.bin/tmux/menu.c index c6794509f83..1242550cd36 100644 --- a/usr.bin/tmux/menu.c +++ b/usr.bin/tmux/menu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: menu.c,v 1.22 2020/04/15 16:11:23 nicm Exp $ */ +/* $OpenBSD: menu.c,v 1.23 2020/04/16 17:20:23 nicm Exp $ */ /* * Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -298,6 +298,8 @@ menu_display(struct menu *menu, int flags, struct cmdq_item *item, u_int px, void *data) { struct menu_data *md; + u_int i; + const char *name; if (c->tty.sx < menu->width + 4 || c->tty.sy < menu->count + 2) return (-1); @@ -318,7 +320,18 @@ menu_display(struct menu *menu, int flags, struct cmdq_item *item, u_int px, md->py = py; md->menu = menu; - md->choice = -1; + if (md->flags & MENU_NOMOUSE) { + for (i = 0; i < menu->count; i++) { + name = menu->items[i].name; + if (name != NULL && *name != '-') + break; + } + if (i != menu->count) + md->choice = i; + else + md->choice = -1; + } else + md->choice = -1; md->cb = cb; md->data = data; |