aboutsummaryrefslogtreecommitdiff
path: root/cmd-list-keys.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd-list-keys.c')
-rw-r--r--cmd-list-keys.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/cmd-list-keys.c b/cmd-list-keys.c
index d26486bd..c76f9f47 100644
--- a/cmd-list-keys.c
+++ b/cmd-list-keys.c
@@ -57,6 +57,7 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq)
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 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq)
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 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq)
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);