From ede8312d59c5d08990f83f38682c26434823525b Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 11 Jul 2012 07:10:15 +0000 Subject: Make command exec functions return an enum rather than -1/0/1 values and add a new value to mean "leave client running but don't attach" to fix problems with using some commands in a command sequence. Most of the work by Thomas Adam, problem reported by "jspenguin" on SF bug 3535531. --- cmd-new-window.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'cmd-new-window.c') diff --git a/cmd-new-window.c b/cmd-new-window.c index 3d9e9320..28dd2358 100644 --- a/cmd-new-window.c +++ b/cmd-new-window.c @@ -39,7 +39,7 @@ const struct cmd_entry cmd_new_window_entry = { cmd_new_window_exec }; -int +enum cmd_retval cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx) { struct args *args = self->args; @@ -56,7 +56,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx) if (args_has(args, 'a')) { wl = cmd_find_window(ctx, args_get(args, 't'), &s); if (wl == NULL) - return (-1); + return (CMD_RETURN_ERROR); idx = wl->idx + 1; /* Find the next free index. */ @@ -66,7 +66,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx) } if (last == INT_MAX) { ctx->error(ctx, "no free window indexes"); - return (-1); + return (CMD_RETURN_ERROR); } /* Move everything from last - 1 to idx up a bit. */ @@ -77,7 +77,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx) } } else { if ((idx = cmd_find_index(ctx, args_get(args, 't'), &s)) == -2) - return (-1); + return (CMD_RETURN_ERROR); } detached = args_has(args, 'd'); @@ -113,7 +113,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx) if (wl == NULL) { ctx->error(ctx, "create window failed: %s", cause); free(cause); - return (-1); + return (CMD_RETURN_ERROR); } if (!detached) { session_select(s, wl->idx); @@ -139,5 +139,5 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx) format_free(ft); } - return (0); + return (CMD_RETURN_NORMAL); } -- cgit v1.2.3