diff options
author | Josh Rahm <rahm@google.com> | 2022-07-21 15:53:59 -0600 |
---|---|---|
committer | Josh Rahm <rahm@google.com> | 2022-07-21 15:53:59 -0600 |
commit | b11548e3db4361cd8312ffbd27472823bdab4d62 (patch) | |
tree | a84b5cf79fb41bb60b6495c1a346bb360b224604 /cmd-display-menu.c | |
parent | 88ebf5544e995d85b2f1416a216ac7f44f719eed (diff) | |
parent | ab1d18d00febe161080b8e81331861481110809f (diff) | |
download | rtmux-b11548e3db4361cd8312ffbd27472823bdab4d62.tar.gz rtmux-b11548e3db4361cd8312ffbd27472823bdab4d62.tar.bz2 rtmux-b11548e3db4361cd8312ffbd27472823bdab4d62.zip |
Merge remote-tracking branch 'origin/master' into rahm
Diffstat (limited to 'cmd-display-menu.c')
-rw-r--r-- | cmd-display-menu.c | 58 |
1 files changed, 49 insertions, 9 deletions
diff --git a/cmd-display-menu.c b/cmd-display-menu.c index 1a11bd01..e6a503b1 100644 --- a/cmd-display-menu.c +++ b/cmd-display-menu.c @@ -52,10 +52,12 @@ const struct cmd_entry cmd_display_popup_entry = { .name = "display-popup", .alias = "popup", - .args = { "BCc:d:Eh:t:w:x:y:", 0, -1, NULL }, - .usage = "[-BCE] [-c target-client] [-d start-directory] [-h height] " - CMD_TARGET_PANE_USAGE " [-w width] " - "[-x position] [-y position] [shell-command]", + .args = { "Bb:Cc:d:e:Eh:s:S:t:T:w:x:y:", 0, -1, NULL }, + .usage = "[-BCE] [-b border-lines] [-c target-client] " + "[-d start-directory] [-e environment] [-h height] " + "[-s style] [-S border-style] " CMD_TARGET_PANE_USAGE + "[-T title] [-w width] [-x position] [-y position] " + "[shell-command]", .target = { 't', CMD_FIND_PANE, 0 }, @@ -353,9 +355,16 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item) struct client *tc = cmdq_get_target_client(item); struct tty *tty = &tc->tty; const char *value, *shell, *shellcmd = NULL; - char *cwd, *cause, **argv = NULL; + const char *style = args_get(args, 's'); + const char *border_style = args_get(args, 'S'); + char *cwd, *cause = NULL, **argv = NULL, *title; int flags = 0, argc = 0; + enum box_lines lines = BOX_LINES_DEFAULT; u_int px, py, w, h, count = args_count(args); + struct args_value *av; + struct environ *env = NULL; + struct options *o = s->curw->window->options; + struct options_entry *oe; if (args_has(args, 'C')) { server_client_clear_overlay(tc); @@ -391,6 +400,20 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item) if (!cmd_display_menu_get_position(tc, item, args, &px, &py, w, h)) return (CMD_RETURN_NORMAL); + value = args_get(args, 'b'); + if (args_has(args, 'B')) + lines = BOX_LINES_NONE; + else if (value != NULL) { + oe = options_get(o, "popup-border-lines"); + lines = options_find_choice(options_table_entry(oe), value, + &cause); + if (cause != NULL) { + cmdq_error(item, "popup-border-lines %s", cause); + free(cause); + return (CMD_RETURN_ERROR); + } + } + value = args_get(args, 'd'); if (value != NULL) cwd = format_single_from_target(item, value); @@ -409,17 +432,34 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item) } else args_to_vector(args, &argc, &argv); + if (args_has(args, 'e') >= 1) { + env = environ_create(); + av = args_first_value(args, 'e'); + while (av != NULL) { + environ_put(env, av->string, 0); + av = args_next_value(av); + } + } + + if (args_has(args, 'T')) + title = format_single_from_target(item, args_get(args, 'T')); + else + title = xstrdup(""); if (args_has(args, 'E') > 1) flags |= POPUP_CLOSEEXITZERO; else if (args_has(args, 'E')) flags |= POPUP_CLOSEEXIT; - if (args_has(args, 'B')) - flags |= POPUP_NOBORDER; - if (popup_display(flags, item, px, py, w, h, shellcmd, argc, argv, cwd, - tc, s, NULL, NULL) != 0) { + if (popup_display(flags, lines, item, px, py, w, h, env, shellcmd, argc, + argv, cwd, title, tc, s, style, border_style, NULL, NULL) != 0) { cmd_free_argv(argc, argv); + if (env != NULL) + environ_free(env); + free(title); return (CMD_RETURN_NORMAL); } + if (env != NULL) + environ_free(env); + free(title); cmd_free_argv(argc, argv); return (CMD_RETURN_WAIT); } |