summaryrefslogtreecommitdiffstats
path: root/menu.c
diff options
context:
space:
mode:
authornicm <nicm>2020-04-16 17:20:23 +0000
committernicm <nicm>2020-04-16 17:20:23 +0000
commit9311ed049b2dba24d562e34ae17af0f5e316784e (patch)
tree441ccb6ae7e412fdfc0c55c11507013cb0bb96f1 /menu.c
parent2e347d6a384a5cfa9e18058393043e623a10c584 (diff)
Start menu with top item selected if no mouse, GitHub issue 2169.
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/menu.c b/menu.c
index 941d4123..39cb50c7 100644
--- a/menu.c
+++ b/menu.c
@@ -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;