mirror of
https://github.com/tmux/tmux.git
synced 2024-12-04 19:58:48 +00:00
Start menu with top item selected if no mouse, GitHub issue 2169.
This commit is contained in:
parent
2e347d6a38
commit
9311ed049b
15
menu.c
15
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;
|
||||
|
Loading…
Reference in New Issue
Block a user