=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-list-keys.c,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- src/usr.bin/tmux/cmd-list-keys.c 2016/10/14 22:14:22 1.39 +++ src/usr.bin/tmux/cmd-list-keys.c 2016/10/16 19:04:05 1.40 @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-list-keys.c,v 1.39 2016/10/14 22:14:22 nicm Exp $ */ +/* $OpenBSD: cmd-list-keys.c,v 1.40 2016/10/16 19:04:05 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -27,10 +27,11 @@ * List key bindings. */ -static enum cmd_retval cmd_list_keys_exec(struct cmd *, struct cmd_q *); +static enum cmd_retval cmd_list_keys_exec(struct cmd *, struct cmdq_item *); -static enum cmd_retval cmd_list_keys_table(struct cmd *, struct cmd_q *); -static enum cmd_retval cmd_list_keys_commands(struct cmd *, struct cmd_q *); +static enum cmd_retval cmd_list_keys_table(struct cmd *, struct cmdq_item *); +static enum cmd_retval cmd_list_keys_commands(struct cmd *, + struct cmdq_item *); const struct cmd_entry cmd_list_keys_entry = { .name = "list-keys", @@ -55,7 +56,7 @@ }; static enum cmd_retval -cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq) +cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = self->args; struct key_table *table; @@ -65,14 +66,14 @@ int repeat, width, tablewidth, keywidth; if (self->entry == &cmd_list_commands_entry) - return (cmd_list_keys_commands(self, cmdq)); + return (cmd_list_keys_commands(self, item)); if (args_has(args, 't')) - return (cmd_list_keys_table(self, cmdq)); + return (cmd_list_keys_table(self, item)); tablename = args_get(args, 'T'); if (tablename != NULL && 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); } @@ -124,7 +125,7 @@ strlcat(tmp, cp, sizeof tmp); free(cp); - cmdq_print(cmdq, "bind-key %s", tmp); + cmdq_print(item, "bind-key %s", tmp); } } @@ -132,7 +133,7 @@ } static enum cmd_retval -cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq) +cmd_list_keys_table(struct cmd *self, struct cmdq_item *item) { struct args *args = self->args; const char *tablename, *cmdstr; @@ -142,7 +143,7 @@ tablename = args_get(args, 't'); 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); } @@ -156,7 +157,7 @@ RB_FOREACH(mbind, mode_key_tree, mtab->tree) { cmdstr = mode_key_tostring(mtab->cmdstr, mbind->cmd); if (cmdstr != NULL) { - cmdq_print(cmdq, "bind-key -t %s %*s %s", + cmdq_print(item, "bind-key -t %s %*s %s", mtab->name, (int)keywidth, key_string_lookup_key(mbind->key), cmdstr); } @@ -166,13 +167,13 @@ } static enum cmd_retval -cmd_list_keys_commands(struct cmd *self, struct cmd_q *cmdq) +cmd_list_keys_commands(struct cmd *self, struct cmdq_item *item) { struct args *args = self->args; const struct cmd_entry **entryp; const struct cmd_entry *entry; struct format_tree *ft; - const char *template; + const char *template, *s; char *line; if ((template = args_get(args, 'F')) == NULL) { @@ -181,25 +182,27 @@ "#{command_list_usage}"; } - ft = format_create(cmdq, 0); + ft = format_create(item, 0); format_defaults(ft, NULL, NULL, NULL, NULL); for (entryp = cmd_table; *entryp != NULL; entryp++) { entry = *entryp; format_add(ft, "command_list_name", "%s", entry->name); - if (entry->alias != NULL) { - format_add(ft, "command_list_alias", "%s", - entry->alias); - } - if (entry->alias != NULL) { - format_add(ft, "command_list_usage", "%s", - entry->usage); - } + if (entry->alias != NULL) + s = entry->alias; + else + s = ""; + format_add(ft, "command_list_alias", "%s", s); + if (entry->usage != NULL) + s = entry->usage; + else + s = ""; + format_add(ft, "command_list_usage", "%s", s); line = format_expand(ft, template); if (*line != '\0') - cmdq_print(cmdq, "%s", line); + cmdq_print(item, "%s", line); free(line); }