From dee72ed41f54d9ba12b1ce20c18476d9276a876d Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 8 Aug 2023 08:08:47 +0000 Subject: Add options and flags for menu styles similar to those existing for popups, from Alexis Hildebrandt. GitHub issue 3650. --- cmd-display-menu.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'cmd-display-menu.c') diff --git a/cmd-display-menu.c b/cmd-display-menu.c index 5f9dc459..a0a86b1f 100644 --- a/cmd-display-menu.c +++ b/cmd-display-menu.c @@ -39,10 +39,11 @@ const struct cmd_entry cmd_display_menu_entry = { .name = "display-menu", .alias = "menu", - .args = { "c:t:S:OT:x:y:", 1, -1, cmd_display_menu_args_parse }, - .usage = "[-O] [-c target-client] [-S starting-choice] " - CMD_TARGET_PANE_USAGE " [-T title] [-x position] " - "[-y position] name key command ...", + .args = { "b:c:C:t:s:S:OT:x:y:", 1, -1, cmd_display_menu_args_parse }, + .usage = "[-O] [-b border-lines] [-c target-client] " + "[-C starting-choice] [-s style] [-S border-style] " + CMD_TARGET_PANE_USAGE "[-T title] [-x position] [-y position] " + "name key command ...", .target = { 't', CMD_FIND_PANE, 0 }, @@ -289,19 +290,25 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item) struct client *tc = cmdq_get_target_client(item); struct menu *menu = NULL; 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; int flags = 0, starting_choice = 0; 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) return (CMD_RETURN_NORMAL); - if (args_has(args, 'S')) { - if (strcmp(args_get(args, 'S'), "-") == 0) + if (args_has(args, 'C')) { + if (strcmp(args_get(args, 'C'), "-") == 0) starting_choice = -1; else { - starting_choice = args_strtonum(args, 'S', 0, UINT_MAX, + starting_choice = args_strtonum(args, 'C', 0, UINT_MAX, &cause); if (cause != NULL) { cmdq_error(item, "starting choice %s", cause); @@ -352,12 +359,24 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item) 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')) flags |= MENU_STAYOPEN; if (!event->m.valid) flags |= MENU_NOMOUSE; - if (menu_display(menu, flags, starting_choice, item, px, py, tc, target, - NULL, NULL) != 0) + if (menu_display(menu, flags, starting_choice, item, px, py, tc, lines, + style, border_style, target, NULL, NULL) != 0) return (CMD_RETURN_NORMAL); return (CMD_RETURN_WAIT); } -- cgit v1.2.3