diff options
author | nicm <nicm> | 2020-04-13 08:26:27 +0000 |
---|---|---|
committer | nicm <nicm> | 2020-04-13 08:26:27 +0000 |
commit | c20eb0c0ae3347c768894a6355adfd7ebae6f2f3 (patch) | |
tree | 970e82f29bd603d459476d44245ce73aad18666e /cmd-unbind-key.c | |
parent | 9cbe9675ea8a8efb01dcc5f267e6d5853b2cd58f (diff) | |
download | rtmux-c20eb0c0ae3347c768894a6355adfd7ebae6f2f3.tar.gz rtmux-c20eb0c0ae3347c768894a6355adfd7ebae6f2f3.tar.bz2 rtmux-c20eb0c0ae3347c768894a6355adfd7ebae6f2f3.zip |
Make struct cmd local to cmd.c and move it out of tmux.h.
Diffstat (limited to 'cmd-unbind-key.c')
-rw-r--r-- | cmd-unbind-key.c | 44 |
1 files changed, 3 insertions, 41 deletions
diff --git a/cmd-unbind-key.c b/cmd-unbind-key.c index 69141346..4b9f39a6 100644 --- a/cmd-unbind-key.c +++ b/cmd-unbind-key.c @@ -28,15 +28,12 @@ static enum cmd_retval cmd_unbind_key_exec(struct cmd *, struct cmdq_item *); -static enum cmd_retval cmd_unbind_key_mode_table(struct cmd *, - struct cmdq_item *, key_code); - const struct cmd_entry cmd_unbind_key_entry = { .name = "unbind-key", .alias = "unbind", - .args = { "ant:T:", 0, 1 }, - .usage = "[-an] [-t mode-table] [-T key-table] key", + .args = { "anT:", 0, 1 }, + .usage = "[-an] [-T key-table] key", .flags = CMD_AFTERHOOK, .exec = cmd_unbind_key_exec @@ -45,7 +42,7 @@ const struct cmd_entry cmd_unbind_key_entry = { static enum cmd_retval cmd_unbind_key_exec(struct cmd *self, struct cmdq_item *item) { - struct args *args = self->args; + struct args *args = cmd_get_args(self); key_code key; const char *tablename; @@ -67,9 +64,6 @@ cmd_unbind_key_exec(struct cmd *self, struct cmdq_item *item) key = KEYC_UNKNOWN; } - if (args_has(args, 't')) - return (cmd_unbind_key_mode_table(self, item, key)); - if (key == KEYC_UNKNOWN) { tablename = args_get(args, 'T'); if (tablename == NULL) { @@ -98,35 +92,3 @@ cmd_unbind_key_exec(struct cmd *self, struct cmdq_item *item) key_bindings_remove(tablename, key); return (CMD_RETURN_NORMAL); } - -static enum cmd_retval -cmd_unbind_key_mode_table(struct cmd *self, struct cmdq_item *item, - key_code key) -{ - struct args *args = self->args; - const char *tablename; - const struct mode_key_table *mtab; - struct mode_key_binding *mbind, mtmp; - - tablename = args_get(args, 't'); - if ((mtab = mode_key_findtable(tablename)) == NULL) { - cmdq_error(item, "unknown key table: %s", tablename); - return (CMD_RETURN_ERROR); - } - - if (key == KEYC_UNKNOWN) { - while (!RB_EMPTY(mtab->tree)) { - mbind = RB_ROOT(mtab->tree); - RB_REMOVE(mode_key_tree, mtab->tree, mbind); - free(mbind); - } - return (CMD_RETURN_NORMAL); - } - - mtmp.key = key; - if ((mbind = RB_FIND(mode_key_tree, mtab->tree, &mtmp)) != NULL) { - RB_REMOVE(mode_key_tree, mtab->tree, mbind); - free(mbind); - } - return (CMD_RETURN_NORMAL); -} |