version 1.37, 2016/10/11 07:23:34 |
version 1.38, 2016/10/12 14:50:14 |
|
|
cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq) |
cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq) |
{ |
{ |
struct args *args = self->args; |
struct args *args = self->args; |
const char *tablename, *key, *cmdstr, *mode; |
const char *tablename, *cmdstr; |
const struct mode_key_table *mtab; |
const struct mode_key_table *mtab; |
struct mode_key_binding *mbind; |
struct mode_key_binding *mbind; |
int width, keywidth, any_mode; |
int width, keywidth; |
|
|
tablename = args_get(args, 't'); |
tablename = args_get(args, 't'); |
if ((mtab = mode_key_findtable(tablename)) == NULL) { |
if ((mtab = mode_key_findtable(tablename)) == NULL) { |
|
|
} |
} |
|
|
keywidth = 0; |
keywidth = 0; |
any_mode = 0; |
|
RB_FOREACH(mbind, mode_key_tree, mtab->tree) { |
RB_FOREACH(mbind, mode_key_tree, mtab->tree) { |
key = key_string_lookup_key(mbind->key); |
width = strlen(key_string_lookup_key(mbind->key)); |
|
|
if (mbind->mode != 0) |
|
any_mode = 1; |
|
|
|
width = strlen(key); |
|
if (width > keywidth) |
if (width > keywidth) |
keywidth = width; |
keywidth = width; |
} |
} |
|
|
RB_FOREACH(mbind, mode_key_tree, mtab->tree) { |
RB_FOREACH(mbind, mode_key_tree, mtab->tree) { |
key = key_string_lookup_key(mbind->key); |
|
|
|
mode = ""; |
|
if (mbind->mode != 0) |
|
mode = "c"; |
|
cmdstr = mode_key_tostring(mtab->cmdstr, mbind->cmd); |
cmdstr = mode_key_tostring(mtab->cmdstr, mbind->cmd); |
if (cmdstr != NULL) { |
if (cmdstr != NULL) { |
cmdq_print(cmdq, "bind-key -%st %s%s %*s %s", |
cmdq_print(cmdq, "bind-key -t %s %*s %s", |
mode, any_mode && *mode == '\0' ? " " : "", |
mtab->name, (int)keywidth, |
mtab->name, |
key_string_lookup_key(mbind->key), cmdstr); |
(int)keywidth, key, cmdstr); |
|
} |
} |
} |
} |
|
|