version 1.28, 2015/11/12 11:05:34 |
version 1.29, 2015/11/12 12:43:36 |
|
|
|
|
#include <sys/types.h> |
#include <sys/types.h> |
|
|
|
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
|
#include "tmux.h" |
#include "tmux.h" |
|
|
struct key_table *table; |
struct key_table *table; |
struct key_binding *bd; |
struct key_binding *bd; |
const char *key, *tablename, *r; |
const char *key, *tablename, *r; |
char tmp[BUFSIZ]; |
char *cp, tmp[BUFSIZ]; |
size_t used; |
size_t used; |
int repeat, width, tablewidth, keywidth; |
int repeat, width, tablewidth, keywidth; |
u_int i; |
|
|
|
if (self->entry == &cmd_list_commands_entry) |
if (self->entry == &cmd_list_commands_entry) |
return (cmd_list_keys_commands(self, cmdq)); |
return (cmd_list_keys_commands(self, cmdq)); |
|
|
if (bd->can_repeat) |
if (bd->can_repeat) |
repeat = 1; |
repeat = 1; |
|
|
width = strlen(table->name); |
width = utf8_cstrwidth(table->name); |
if (width > tablewidth) |
if (width > tablewidth) |
tablewidth = width; |
tablewidth = width; |
width = utf8_cstrwidth(key); |
width = utf8_cstrwidth(key); |
|
|
r = "-r "; |
r = "-r "; |
else |
else |
r = " "; |
r = " "; |
used = xsnprintf(tmp, sizeof tmp, "%s-T %-*s %s", r, |
xsnprintf(tmp, sizeof tmp, "%s-T ", r); |
(int)tablewidth, table->name, key); |
|
for (i = 0; i < keywidth - utf8_cstrwidth(key); i++) { |
cp = utf8_padcstr(table->name, tablewidth); |
if (strlcat(tmp, " ", sizeof tmp) < sizeof tmp) |
strlcat(tmp, cp, sizeof tmp); |
used++; |
strlcat(tmp, " ", sizeof tmp); |
} |
free(cp); |
if (used < sizeof tmp) { |
|
|
cp = utf8_padcstr(key, keywidth); |
|
strlcat(tmp, cp, sizeof tmp); |
|
strlcat(tmp, " ", sizeof tmp); |
|
free(cp); |
|
|
|
used = strlen(tmp); |
|
if (used < (sizeof tmp) - 1) { |
cmd_list_print(bd->cmdlist, tmp + used, |
cmd_list_print(bd->cmdlist, tmp + used, |
(sizeof tmp) - used); |
(sizeof tmp) - used); |
} |
} |