version 1.37, 2021/10/25 09:38:36 |
version 1.38, 2023/01/20 21:36:00 |
|
|
.name = "display-menu", |
.name = "display-menu", |
.alias = "menu", |
.alias = "menu", |
|
|
.args = { "c:t:OT:x:y:", 1, -1, cmd_display_menu_args_parse }, |
.args = { "c:t:S:OT:x:y:", 1, -1, cmd_display_menu_args_parse }, |
.usage = "[-O] [-c target-client] " CMD_TARGET_PANE_USAGE " [-T title] " |
.usage = "[-O] [-c target-client] [-S starting-choice] " |
"[-x position] [-y position] name key command ...", |
CMD_TARGET_PANE_USAGE " [-T title] [-x position] " |
|
"[-y position] name key command ...", |
|
|
.target = { 't', CMD_FIND_PANE, 0 }, |
.target = { 't', CMD_FIND_PANE, 0 }, |
|
|
|
|
struct menu *menu = NULL; |
struct menu *menu = NULL; |
struct menu_item menu_item; |
struct menu_item menu_item; |
const char *key, *name; |
const char *key, *name; |
char *title; |
char *title, *cause; |
int flags = 0; |
int flags = 0, starting_choice = 0; |
u_int px, py, i, count = args_count(args); |
u_int px, py, i, count = args_count(args); |
|
|
if (tc->overlay_draw != NULL) |
if (tc->overlay_draw != NULL) |
return (CMD_RETURN_NORMAL); |
return (CMD_RETURN_NORMAL); |
|
|
|
if (args_has(args, 'S')) { |
|
if (strcmp(args_get(args, 'S'), "-") == 0) |
|
starting_choice = -1; |
|
else { |
|
starting_choice = args_strtonum(args, 'S', 0, UINT_MAX, |
|
&cause); |
|
if (cause != NULL) { |
|
cmdq_error(item, "starting choice %s", cause); |
|
free(cause); |
|
return (CMD_RETURN_ERROR); |
|
} |
|
} |
|
} |
|
|
if (args_has(args, 'T')) |
if (args_has(args, 'T')) |
title = format_single_from_target(item, args_get(args, 'T')); |
title = format_single_from_target(item, args_get(args, 'T')); |
else |
else |
|
|
flags |= MENU_STAYOPEN; |
flags |= MENU_STAYOPEN; |
if (!event->m.valid) |
if (!event->m.valid) |
flags |= MENU_NOMOUSE; |
flags |= MENU_NOMOUSE; |
if (menu_display(menu, flags, item, px, py, tc, target, NULL, |
if (menu_display(menu, flags, starting_choice, item, px, py, tc, target, |
NULL) != 0) |
NULL, NULL) != 0) |
return (CMD_RETURN_NORMAL); |
return (CMD_RETURN_NORMAL); |
return (CMD_RETURN_WAIT); |
return (CMD_RETURN_WAIT); |
} |
} |