version 1.32, 2017/01/24 21:50:22 |
version 1.33, 2019/05/25 07:18:20 |
|
|
static enum cmd_retval |
static enum cmd_retval |
cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item) |
cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item) |
{ |
{ |
struct args *args = self->args; |
struct args *args = self->args; |
char *cause; |
key_code key; |
struct cmd_list *cmdlist; |
const char *tablename; |
key_code key; |
struct cmd_parse_result *pr; |
const char *tablename; |
|
|
|
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) { |
|
|
else |
else |
tablename = "prefix"; |
tablename = "prefix"; |
|
|
cmdlist = cmd_list_parse(args->argc - 1, args->argv + 1, NULL, 0, |
pr = cmd_parse_from_arguments(args->argc - 1, args->argv + 1, NULL); |
&cause); |
switch (pr->status) { |
if (cmdlist == NULL) { |
case CMD_PARSE_EMPTY: |
cmdq_error(item, "%s", cause); |
cmdq_error(item, "empty command"); |
free(cause); |
|
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
|
case CMD_PARSE_ERROR: |
|
cmdq_error(item, "%s", pr->error); |
|
free(pr->error); |
|
return (CMD_RETURN_ERROR); |
|
case CMD_PARSE_SUCCESS: |
|
break; |
} |
} |
|
key_bindings_add(tablename, key, args_has(args, 'r'), pr->cmdlist); |
key_bindings_add(tablename, key, args_has(args, 'r'), cmdlist); |
|
return (CMD_RETURN_NORMAL); |
return (CMD_RETURN_NORMAL); |
} |
} |