aboutsummaryrefslogtreecommitdiff
path: root/cmd-command-prompt.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2016-10-16 20:01:10 +0100
committerThomas Adam <thomas@xteddy.org>2016-10-16 20:01:10 +0100
commitc67b7025882ee6bc2b3d5112dbc630c191f1fa2a (patch)
tree4c36124e376eac0235accd523be6545ccdccf6af /cmd-command-prompt.c
parent3d8efdf310f475a6b9ed83814182c966de2bdab3 (diff)
parentddc4512d2e0eda6c705e002cb5dbf80719d709e1 (diff)
downloadrtmux-c67b7025882ee6bc2b3d5112dbc630c191f1fa2a.tar.gz
rtmux-c67b7025882ee6bc2b3d5112dbc630c191f1fa2a.tar.bz2
rtmux-c67b7025882ee6bc2b3d5112dbc630c191f1fa2a.zip
Merge branch 'obsd-master'
Diffstat (limited to 'cmd-command-prompt.c')
-rw-r--r--cmd-command-prompt.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/cmd-command-prompt.c b/cmd-command-prompt.c
index 12ecb493..5e21b2bc 100644
--- a/cmd-command-prompt.c
+++ b/cmd-command-prompt.c
@@ -121,12 +121,24 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_NORMAL);
}
+static enum cmd_retval
+cmd_command_prompt_error(struct cmd_q *cmdq, void *data)
+{
+ char *error = data;
+
+ cmdq_error(cmdq, "%s", error);
+ free(error);
+
+ return (CMD_RETURN_NORMAL);
+}
+
static int
cmd_command_prompt_callback(void *data, const char *s)
{
struct cmd_command_prompt_cdata *cdata = data;
struct client *c = cdata->c;
struct cmd_list *cmdlist;
+ struct cmd_q *new_cmdq;
char *cause, *new_template, *prompt, *ptr;
char *input = NULL;
@@ -153,17 +165,19 @@ cmd_command_prompt_callback(void *data, const char *s)
if (cmd_string_parse(new_template, &cmdlist, NULL, 0, &cause) != 0) {
if (cause != NULL) {
- *cause = toupper((u_char) *cause);
- status_message_set(c, "%s", cause);
- free(cause);
- }
- return (0);
+ new_cmdq = cmdq_get_callback(cmd_command_prompt_error,
+ cause);
+ } else
+ new_cmdq = NULL;
+ } else {
+ new_cmdq = cmdq_get_command(cmdlist, NULL, NULL, 0);
+ cmd_list_free(cmdlist);
}
- cmdq_run(c->cmdq, cmdlist, NULL);
- cmd_list_free(cmdlist);
+ if (new_cmdq != NULL)
+ cmdq_append(c, new_cmdq);
- if (c->prompt_callbackfn != (void *) &cmd_command_prompt_callback)
+ if (c->prompt_callbackfn != (void *)&cmd_command_prompt_callback)
return (1);
return (0);
}