summaryrefslogtreecommitdiffstats
path: root/cmd-unbind-key.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-unbind-key.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-unbind-key.c')
-rw-r--r--cmd-unbind-key.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/cmd-unbind-key.c b/cmd-unbind-key.c
index ac6c0c0f..4a39f51b 100644
--- a/cmd-unbind-key.c
+++ b/cmd-unbind-key.c
@@ -26,10 +26,9 @@
* Unbind key from command.
*/
-int cmd_unbind_key_check(struct args *);
-int cmd_unbind_key_exec(struct cmd *, struct cmd_ctx *);
-
-int cmd_unbind_key_table(struct cmd *, struct cmd_ctx *, int);
+enum cmd_retval cmd_unbind_key_check(struct args *);
+enum cmd_retval cmd_unbind_key_exec(struct cmd *, struct cmd_ctx *);
+enum cmd_retval cmd_unbind_key_table(struct cmd *, struct cmd_ctx *, int);
const struct cmd_entry cmd_unbind_key_entry = {
"unbind-key", "unbind",
@@ -41,17 +40,17 @@ const struct cmd_entry cmd_unbind_key_entry = {
cmd_unbind_key_exec
};
-int
+enum cmd_retval
cmd_unbind_key_check(struct args *args)
{
if (args_has(args, 'a') && args->argc != 0)
- return (-1);
+ return (CMD_RETURN_ERROR);
if (!args_has(args, 'a') && args->argc != 1)
- return (-1);
- return (0);
+ return (CMD_RETURN_ERROR);
+ return (CMD_RETURN_NORMAL);
}
-int
+enum cmd_retval
cmd_unbind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx)
{
struct args *args = self->args;
@@ -62,7 +61,7 @@ cmd_unbind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx)
key = key_string_lookup_string(args->argv[0]);
if (key == KEYC_NONE) {
ctx->error(ctx, "unknown key: %s", args->argv[0]);
- return (-1);
+ return (CMD_RETURN_ERROR);
}
} else
key = KEYC_NONE;
@@ -75,16 +74,16 @@ cmd_unbind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx)
bd = RB_ROOT(&key_bindings);
key_bindings_remove(bd->key);
}
- return (0);
+ return (CMD_RETURN_NORMAL);
}
if (!args_has(args, 'n'))
key |= KEYC_PREFIX;
key_bindings_remove(key);
- return (0);
+ return (CMD_RETURN_NORMAL);
}
-int
+enum cmd_retval
cmd_unbind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key)
{
struct args *args = self->args;
@@ -95,7 +94,7 @@ cmd_unbind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key)
tablename = args_get(args, 't');
if ((mtab = mode_key_findtable(tablename)) == NULL) {
ctx->error(ctx, "unknown key table: %s", tablename);
- return (-1);
+ return (CMD_RETURN_ERROR);
}
if (key == KEYC_NONE) {
@@ -104,7 +103,7 @@ cmd_unbind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key)
RB_REMOVE(mode_key_tree, mtab->tree, mbind);
free(mbind);
}
- return (0);
+ return (CMD_RETURN_NORMAL);
}
mtmp.key = key;
@@ -113,5 +112,5 @@ cmd_unbind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key)
RB_REMOVE(mode_key_tree, mtab->tree, mbind);
free(mbind);
}
- return (0);
+ return (CMD_RETURN_NORMAL);
}