summaryrefslogtreecommitdiffstats
path: root/cmd-new-window.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2012-07-11 07:10:15 +0000
committerNicholas Marriott <nicm@openbsd.org>2012-07-11 07:10:15 +0000
commitede8312d59c5d08990f83f38682c26434823525b (patch)
treebdf66e80ca1d71548a554804f4ab6656a828a821 /cmd-new-window.c
parentdf912e3540968a2a0b266e523ecc08bb2dc0ca20 (diff)
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.
Diffstat (limited to 'cmd-new-window.c')
-rw-r--r--cmd-new-window.c12
1 files changed, 6 insertions, 6 deletions
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);
}