=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-list-keys.c,v retrieving revision 1.35 retrieving revision 1.36 diff -c -r1.35 -r1.36 *** src/usr.bin/tmux/cmd-list-keys.c 2016/06/15 08:54:11 1.35 --- src/usr.bin/tmux/cmd-list-keys.c 2016/09/12 15:40:58 1.36 *************** *** 1,4 **** ! /* $OpenBSD: cmd-list-keys.c,v 1.35 2016/06/15 08:54:11 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: cmd-list-keys.c,v 1.36 2016/09/12 15:40:58 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 135,145 **** cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq) { struct args *args = self->args; ! const char *tablename; const struct mode_key_table *mtab; struct mode_key_binding *mbind; ! const char *key, *cmdstr, *mode; ! int width, keywidth, any_mode; tablename = args_get(args, 't'); if ((mtab = mode_key_findtable(tablename)) == NULL) { --- 135,145 ---- cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq) { struct args *args = self->args; ! const char *tablename, *key, *cmdstr, *mode; const struct mode_key_table *mtab; struct mode_key_binding *mbind; ! char repeat[16]; ! int width, keywidth, repeatwidth, any_mode; tablename = args_get(args, 't'); if ((mtab = mode_key_findtable(tablename)) == NULL) { *************** *** 147,153 **** return (CMD_RETURN_ERROR); } ! width = 0; any_mode = 0; RB_FOREACH(mbind, mode_key_tree, mtab->tree) { key = key_string_lookup_key(mbind->key); --- 147,153 ---- return (CMD_RETURN_ERROR); } ! keywidth = repeatwidth = 0; any_mode = 0; RB_FOREACH(mbind, mode_key_tree, mtab->tree) { key = key_string_lookup_key(mbind->key); *************** *** 155,163 **** if (mbind->mode != 0) any_mode = 1; ! keywidth = strlen(key); ! if (keywidth > width) ! width = keywidth; } RB_FOREACH(mbind, mode_key_tree, mtab->tree) { --- 155,170 ---- if (mbind->mode != 0) any_mode = 1; ! width = strlen(key); ! if (width > keywidth) ! keywidth = width; ! ! if (mbind->repeat != 1) { ! snprintf(repeat, sizeof repeat, "%u", mbind->repeat); ! width = strlen(repeat); ! if (width > repeatwidth) ! repeatwidth = width; ! } } RB_FOREACH(mbind, mode_key_tree, mtab->tree) { *************** *** 166,176 **** mode = ""; if (mbind->mode != 0) mode = "c"; cmdstr = mode_key_tostring(mtab->cmdstr, mbind->cmd); if (cmdstr != NULL) { ! cmdq_print(cmdq, "bind-key -%st %s%s %*s %s%s%s%s", mode, any_mode && *mode == '\0' ? " " : "", ! mtab->name, (int) width, key, cmdstr, mbind->arg != NULL ? " \"" : "", mbind->arg != NULL ? mbind->arg : "", mbind->arg != NULL ? "\"": ""); --- 173,189 ---- mode = ""; if (mbind->mode != 0) mode = "c"; + snprintf(repeat, sizeof repeat, "%u", mbind->repeat); cmdstr = mode_key_tostring(mtab->cmdstr, mbind->cmd); if (cmdstr != NULL) { ! cmdq_print(cmdq, ! "bind-key -%st %s%s%s%*s %*s %s%s%s%s", mode, any_mode && *mode == '\0' ? " " : "", ! mtab->name, ! mbind->repeat != 1 ? " -R " : ! (repeatwidth == 0 ? "" : " "), ! repeatwidth, mbind->repeat != 1 ? repeat : "", ! (int)keywidth, key, cmdstr, mbind->arg != NULL ? " \"" : "", mbind->arg != NULL ? mbind->arg : "", mbind->arg != NULL ? "\"": "");