=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-list-keys.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- src/usr.bin/tmux/cmd-list-keys.c 2015/10/26 22:03:04 1.27 +++ src/usr.bin/tmux/cmd-list-keys.c 2015/11/12 11:05:34 1.28 @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-list-keys.c,v 1.27 2015/10/26 22:03:04 nicm Exp $ */ +/* $OpenBSD: cmd-list-keys.c,v 1.28 2015/11/12 11:05:34 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -57,6 +57,7 @@ char tmp[BUFSIZ]; size_t used; int repeat, width, tablewidth, keywidth; + u_int i; if (self->entry == &cmd_list_commands_entry) return (cmd_list_keys_commands(self, cmdq)); @@ -83,8 +84,8 @@ width = strlen(table->name); if (width > tablewidth) - tablewidth =width; - width = strlen(key); + tablewidth = width; + width = utf8_cstrwidth(key); if (width > keywidth) keywidth = width; } @@ -102,8 +103,12 @@ r = "-r "; else r = " "; - used = xsnprintf(tmp, sizeof tmp, "%s-T %-*s %-*s ", r, - (int)tablewidth, table->name, (int)keywidth, key); + used = xsnprintf(tmp, sizeof tmp, "%s-T %-*s %s", r, + (int)tablewidth, table->name, key); + for (i = 0; i < keywidth - utf8_cstrwidth(key); i++) { + if (strlcat(tmp, " ", sizeof tmp) < sizeof tmp) + used++; + } if (used < sizeof tmp) { cmd_list_print(bd->cmdlist, tmp + used, (sizeof tmp) - used);