version 1.40, 2023/08/07 10:52:00 |
version 1.41, 2023/08/08 08:08:47 |
|
|
.name = "display-menu", |
.name = "display-menu", |
.alias = "menu", |
.alias = "menu", |
|
|
.args = { "c:t:S:OT:x:y:", 1, -1, cmd_display_menu_args_parse }, |
.args = { "b:c:C:t:s:S:OT:x:y:", 1, -1, cmd_display_menu_args_parse }, |
.usage = "[-O] [-c target-client] [-S starting-choice] " |
.usage = "[-O] [-b border-lines] [-c target-client] " |
CMD_TARGET_PANE_USAGE " [-T title] [-x position] " |
"[-C starting-choice] [-s style] [-S border-style] " |
"[-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 client *tc = cmdq_get_target_client(item); |
struct client *tc = cmdq_get_target_client(item); |
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, *value; |
|
const char *style = args_get(args, 's'); |
|
const char *border_style = args_get(args, 'S'); |
|
enum box_lines lines = BOX_LINES_DEFAULT; |
char *title, *cause; |
char *title, *cause; |
int flags = 0, starting_choice = 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); |
|
struct options *o = target->s->curw->window->options; |
|
struct options_entry *oe; |
|
|
|
|
if (tc->overlay_draw != NULL) |
if (tc->overlay_draw != NULL) |
return (CMD_RETURN_NORMAL); |
return (CMD_RETURN_NORMAL); |
|
|
if (args_has(args, 'S')) { |
if (args_has(args, 'C')) { |
if (strcmp(args_get(args, 'S'), "-") == 0) |
if (strcmp(args_get(args, 'C'), "-") == 0) |
starting_choice = -1; |
starting_choice = -1; |
else { |
else { |
starting_choice = args_strtonum(args, 'S', 0, UINT_MAX, |
starting_choice = args_strtonum(args, 'C', 0, UINT_MAX, |
&cause); |
&cause); |
if (cause != NULL) { |
if (cause != NULL) { |
cmdq_error(item, "starting choice %s", cause); |
cmdq_error(item, "starting choice %s", cause); |
|
|
return (CMD_RETURN_NORMAL); |
return (CMD_RETURN_NORMAL); |
} |
} |
|
|
|
value = args_get(args, 'b'); |
|
if (value != NULL) { |
|
oe = options_get(o, "menu-border-lines"); |
|
lines = options_find_choice(options_table_entry(oe), value, |
|
&cause); |
|
if (lines == -1) { |
|
cmdq_error(item, "menu-border-lines %s", cause); |
|
free(cause); |
|
return (CMD_RETURN_ERROR); |
|
} |
|
} |
|
|
if (args_has(args, 'O')) |
if (args_has(args, 'O')) |
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, starting_choice, item, px, py, tc, target, |
if (menu_display(menu, flags, starting_choice, item, px, py, tc, lines, |
NULL, NULL) != 0) |
style, border_style, target, NULL, NULL) != 0) |
return (CMD_RETURN_NORMAL); |
return (CMD_RETURN_NORMAL); |
return (CMD_RETURN_WAIT); |
return (CMD_RETURN_WAIT); |
} |
} |