diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-03-23 13:41:23 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-03-23 13:41:23 +0100 |
commit | a0f442a84e63a1969f89a0d3c05137f6403a8c74 (patch) | |
tree | 24ff435837ad3cdca95ab9b5e5b5246f5eb9de6c /src | |
parent | 03d01f423436cee0de51f75f4011e265b6639e62 (diff) | |
download | weechat-a0f442a84e63a1969f89a0d3c05137f6403a8c74.zip |
Fix alignment of keys in output of /key when some keys contain wide chars
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-command.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 0be428f74..b37f359a1 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -1906,13 +1906,28 @@ void command_key_display (struct t_gui_key *key) { char *expanded_name; + char str_spaces[20 + 1]; + int length_screen, num_spaces; expanded_name = gui_keyboard_get_expanded_name (key->key); - gui_chat_printf (NULL, " %20s%s => %s%s", + + str_spaces[0] = '\0'; + length_screen = utf8_strlen_screen ((expanded_name) ? + expanded_name : key->key); + num_spaces = 20 - length_screen; + if (num_spaces > 0) + { + memset (str_spaces, ' ', num_spaces); + str_spaces[num_spaces] = '\0'; + } + + gui_chat_printf (NULL, " %s%s%s => %s%s", + str_spaces, (expanded_name) ? expanded_name : key->key, GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), GUI_COLOR(GUI_COLOR_CHAT), key->command); + if (expanded_name) free (expanded_name); } |