diff options
author | Tiago Cunha <tcunha@gmx.com> | 2011-07-08 08:42:03 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2011-07-08 08:42:03 +0000 |
commit | bba822105bb45ab998ebb7e8299ddc2b8989e672 (patch) | |
tree | 3901738866dabad26bc71ae16c2fceb4255ee16a /cmd-command-prompt.c | |
parent | dc2c174496532a915120c6fd12b26df742a3ee8e (diff) | |
download | rtmux-bba822105bb45ab998ebb7e8299ddc2b8989e672.tar.gz rtmux-bba822105bb45ab998ebb7e8299ddc2b8989e672.tar.bz2 rtmux-bba822105bb45ab998ebb7e8299ddc2b8989e672.zip |
Sync OpenBSD patchset 934:
Make confirm-before prompt customizable with -p option like
command-prompt. Also move responsibility for calling status_replace into
status_prompt_{set,update} and add #W and #P to the default kill-window
and kill-pane prompts. By Tiago Cunha.
Diffstat (limited to 'cmd-command-prompt.c')
-rw-r--r-- | cmd-command-prompt.c | 39 |
1 files changed, 8 insertions, 31 deletions
diff --git a/cmd-command-prompt.c b/cmd-command-prompt.c index ba18cbc5..55e69b3b 100644 --- a/cmd-command-prompt.c +++ b/cmd-command-prompt.c @@ -90,8 +90,7 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx) const char *inputs, *prompts; struct cmd_command_prompt_cdata *cdata; struct client *c; - char *input = NULL; - char *prompt, *prompt_replaced, *ptr; + char *prompt, *ptr, *input = NULL; size_t n; if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL) @@ -127,28 +126,18 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx) ptr = strsep(&cdata->next_prompt, ","); if (prompts == NULL) prompt = xstrdup(ptr); - else { - prompt_replaced = status_replace(c, NULL, NULL, NULL, ptr, - time(NULL), 0); - xasprintf(&prompt, "%s ", prompt_replaced); - xfree(prompt_replaced); - } + else + xasprintf(&prompt, "%s ", ptr); /* Get initial prompt input. */ if ((inputs = args_get(args, 'I')) != NULL) { cdata->inputs = xstrdup(inputs); cdata->next_input = cdata->inputs; - ptr = strsep(&cdata->next_input, ","); - - input = status_replace(c, NULL, NULL, NULL, ptr, time(NULL), - 0); + input = strsep(&cdata->next_input, ","); } status_prompt_set(c, prompt, input, cmd_command_prompt_callback, cmd_command_prompt_free, cdata, 0); - - if (input != NULL) - xfree(input); xfree(prompt); return (0); @@ -161,8 +150,8 @@ cmd_command_prompt_callback(void *data, const char *s) struct client *c = cdata->c; struct cmd_list *cmdlist; struct cmd_ctx ctx; - char *cause, *new_template, *prompt; - char *prompt_replaced, *ptr, *input = NULL; + char *cause, *new_template, *prompt, *ptr; + char *input = NULL; if (s == NULL) return (0); @@ -176,23 +165,11 @@ cmd_command_prompt_callback(void *data, const char *s) * and update the prompt data. */ if ((ptr = strsep(&cdata->next_prompt, ",")) != NULL) { - prompt_replaced = status_replace(c, NULL, NULL, NULL, ptr, - time(NULL), 0); - xasprintf(&prompt, "%s ", prompt_replaced); - - /* Find next input and expand special sequences. */ - if ((ptr = strsep(&cdata->next_input, ",")) != NULL) { - input = status_replace(c, NULL, NULL, NULL, ptr, - time(NULL), 0); - } - + xasprintf(&prompt, "%s ", ptr); + input = strsep(&cdata->next_input, ","); status_prompt_update(c, prompt, input); - if (input != NULL) - xfree(input); - xfree(prompt_replaced); xfree(prompt); - cdata->idx++; return (1); } |