=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-list-keys.c,v retrieving revision 1.39 retrieving revision 1.40 diff -c -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 **** ! /* $OpenBSD: cmd-list-keys.c,v 1.39 2016/10/14 22:14:22 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: cmd-list-keys.c,v 1.40 2016/10/16 19:04:05 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 27,36 **** * List key bindings. */ ! static enum cmd_retval cmd_list_keys_exec(struct cmd *, struct cmd_q *); ! 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 *); const struct cmd_entry cmd_list_keys_entry = { .name = "list-keys", --- 27,37 ---- * List key bindings. */ ! static enum cmd_retval cmd_list_keys_exec(struct cmd *, struct cmdq_item *); ! 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,61 **** }; static enum cmd_retval ! cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq) { struct args *args = self->args; struct key_table *table; --- 56,62 ---- }; static enum cmd_retval ! cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = self->args; struct key_table *table; *************** *** 65,78 **** int repeat, width, tablewidth, keywidth; if (self->entry == &cmd_list_commands_entry) ! return (cmd_list_keys_commands(self, cmdq)); if (args_has(args, 't')) ! return (cmd_list_keys_table(self, cmdq)); tablename = args_get(args, 'T'); if (tablename != NULL && key_bindings_get_table(tablename, 0) == NULL) { ! cmdq_error(cmdq, "table %s doesn't exist", tablename); return (CMD_RETURN_ERROR); } --- 66,79 ---- int repeat, width, tablewidth, keywidth; if (self->entry == &cmd_list_commands_entry) ! return (cmd_list_keys_commands(self, item)); if (args_has(args, 't')) ! return (cmd_list_keys_table(self, item)); tablename = args_get(args, 'T'); if (tablename != NULL && key_bindings_get_table(tablename, 0) == NULL) { ! cmdq_error(item, "table %s doesn't exist", tablename); return (CMD_RETURN_ERROR); } *************** *** 124,130 **** strlcat(tmp, cp, sizeof tmp); free(cp); ! cmdq_print(cmdq, "bind-key %s", tmp); } } --- 125,131 ---- strlcat(tmp, cp, sizeof tmp); free(cp); ! cmdq_print(item, "bind-key %s", tmp); } } *************** *** 132,138 **** } static enum cmd_retval ! cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq) { struct args *args = self->args; const char *tablename, *cmdstr; --- 133,139 ---- } static enum cmd_retval ! cmd_list_keys_table(struct cmd *self, struct cmdq_item *item) { struct args *args = self->args; const char *tablename, *cmdstr; *************** *** 142,148 **** tablename = args_get(args, 't'); if ((mtab = mode_key_findtable(tablename)) == NULL) { ! cmdq_error(cmdq, "unknown key table: %s", tablename); return (CMD_RETURN_ERROR); } --- 143,149 ---- tablename = args_get(args, 't'); if ((mtab = mode_key_findtable(tablename)) == NULL) { ! cmdq_error(item, "unknown key table: %s", tablename); return (CMD_RETURN_ERROR); } *************** *** 156,162 **** 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", mtab->name, (int)keywidth, key_string_lookup_key(mbind->key), cmdstr); } --- 157,163 ---- RB_FOREACH(mbind, mode_key_tree, mtab->tree) { cmdstr = mode_key_tostring(mtab->cmdstr, mbind->cmd); if (cmdstr != NULL) { ! cmdq_print(item, "bind-key -t %s %*s %s", mtab->name, (int)keywidth, key_string_lookup_key(mbind->key), cmdstr); } *************** *** 166,178 **** } static enum cmd_retval ! cmd_list_keys_commands(struct cmd *self, struct cmd_q *cmdq) { struct args *args = self->args; const struct cmd_entry **entryp; const struct cmd_entry *entry; struct format_tree *ft; ! const char *template; char *line; if ((template = args_get(args, 'F')) == NULL) { --- 167,179 ---- } static enum cmd_retval ! 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, *s; char *line; if ((template = args_get(args, 'F')) == NULL) { *************** *** 181,205 **** "#{command_list_usage}"; } ! ft = format_create(cmdq, 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); ! } line = format_expand(ft, template); if (*line != '\0') ! cmdq_print(cmdq, "%s", line); free(line); } --- 182,208 ---- "#{command_list_usage}"; } ! 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) ! 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(item, "%s", line); free(line); }