version 1.28, 2016/10/14 22:14:22 |
version 1.29, 2016/10/16 19:04:05 |
|
|
* Unbind key from command. |
* Unbind key from command. |
*/ |
*/ |
|
|
static enum cmd_retval cmd_unbind_key_exec(struct cmd *, struct cmd_q *); |
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 cmd_q *, |
|
key_code); |
|
|
|
|
static enum cmd_retval cmd_unbind_key_mode_table(struct cmd *, |
|
struct cmdq_item *, key_code); |
|
|
const struct cmd_entry cmd_unbind_key_entry = { |
const struct cmd_entry cmd_unbind_key_entry = { |
.name = "unbind-key", |
.name = "unbind-key", |
.alias = "unbind", |
.alias = "unbind", |
|
|
}; |
}; |
|
|
static enum cmd_retval |
static enum cmd_retval |
cmd_unbind_key_exec(struct cmd *self, struct cmd_q *cmdq) |
cmd_unbind_key_exec(struct cmd *self, struct cmdq_item *item) |
{ |
{ |
struct args *args = self->args; |
struct args *args = self->args; |
key_code key; |
key_code key; |
|
|
|
|
if (!args_has(args, 'a')) { |
if (!args_has(args, 'a')) { |
if (args->argc != 1) { |
if (args->argc != 1) { |
cmdq_error(cmdq, "missing key"); |
cmdq_error(item, "missing key"); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |
key = key_string_lookup_string(args->argv[0]); |
key = key_string_lookup_string(args->argv[0]); |
if (key == KEYC_NONE || key == KEYC_UNKNOWN) { |
if (key == KEYC_NONE || key == KEYC_UNKNOWN) { |
cmdq_error(cmdq, "unknown key: %s", args->argv[0]); |
cmdq_error(item, "unknown key: %s", args->argv[0]); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |
} else { |
} else { |
if (args->argc != 0) { |
if (args->argc != 0) { |
cmdq_error(cmdq, "key given with -a"); |
cmdq_error(item, "key given with -a"); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |
key = KEYC_UNKNOWN; |
key = KEYC_UNKNOWN; |
} |
} |
|
|
if (args_has(args, 't')) |
if (args_has(args, 't')) |
return (cmd_unbind_key_mode_table(self, cmdq, key)); |
return (cmd_unbind_key_mode_table(self, item, key)); |
|
|
if (key == KEYC_UNKNOWN) { |
if (key == KEYC_UNKNOWN) { |
tablename = args_get(args, 'T'); |
tablename = args_get(args, 'T'); |
|
|
return (CMD_RETURN_NORMAL); |
return (CMD_RETURN_NORMAL); |
} |
} |
if (key_bindings_get_table(tablename, 0) == NULL) { |
if (key_bindings_get_table(tablename, 0) == NULL) { |
cmdq_error(cmdq, "table %s doesn't exist", tablename); |
cmdq_error(item, "table %s doesn't exist", tablename); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |
key_bindings_remove_table(tablename); |
key_bindings_remove_table(tablename); |
|
|
if (args_has(args, 'T')) { |
if (args_has(args, 'T')) { |
tablename = args_get(args, 'T'); |
tablename = args_get(args, 'T'); |
if (key_bindings_get_table(tablename, 0) == NULL) { |
if (key_bindings_get_table(tablename, 0) == NULL) { |
cmdq_error(cmdq, "table %s doesn't exist", tablename); |
cmdq_error(item, "table %s doesn't exist", tablename); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |
} else if (args_has(args, 'n')) |
} else if (args_has(args, 'n')) |
|
|
} |
} |
|
|
static enum cmd_retval |
static enum cmd_retval |
cmd_unbind_key_mode_table(struct cmd *self, struct cmd_q *cmdq, key_code key) |
cmd_unbind_key_mode_table(struct cmd *self, struct cmdq_item *item, |
|
key_code key) |
{ |
{ |
struct args *args = self->args; |
struct args *args = self->args; |
const char *tablename; |
const char *tablename; |
|
|
|
|
tablename = args_get(args, 't'); |
tablename = args_get(args, 't'); |
if ((mtab = mode_key_findtable(tablename)) == NULL) { |
if ((mtab = mode_key_findtable(tablename)) == NULL) { |
cmdq_error(cmdq, "unknown key table: %s", tablename); |
cmdq_error(item, "unknown key table: %s", tablename); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |
|
|