diff options
author | Simmo Saan <simmo.saan@gmail.com> | 2019-11-25 20:59:56 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2019-11-25 21:38:20 +0100 |
commit | 1a00368888118ed8d5aa620b164cc466fa005045 (patch) | |
tree | ea5e633259ad33b8a535d1c4b0f5d705da0e313c /src/gui/gui-nick.c | |
parent | c634d6c56e8ae10a044db313389e0feaa8211c0d (diff) | |
download | weechat-1a00368888118ed8d5aa620b164cc466fa005045.zip |
core: add option weechat.look.nick_color_hash_salt to allow for reshuffling of colors (issue #635)
Diffstat (limited to 'src/gui/gui-nick.c')
-rw-r--r-- | src/gui/gui-nick.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/gui/gui-nick.c b/src/gui/gui-nick.c index 9a575cb2a..c1ad7622a 100644 --- a/src/gui/gui-nick.c +++ b/src/gui/gui-nick.c @@ -48,6 +48,8 @@ gui_nick_hash_color (const char *nickname) { uint64_t color; uint32_t color_32; + int length; + char *str; const char *ptr_nick; if (!nickname || !nickname[0]) @@ -59,7 +61,24 @@ gui_nick_hash_color (const char *nickname) if (config_num_nick_colors == 0) return 0; + str = NULL; ptr_nick = nickname; + + if (CONFIG_STRING(config_look_nick_color_hash_salt) + && CONFIG_STRING(config_look_nick_color_hash_salt)[0]) + { + length = strlen (CONFIG_STRING(config_look_nick_color_hash_salt)) + + strlen (nickname) + 1; + str = malloc (length); + if (str) + { + snprintf (str, length, "%s%s", + CONFIG_STRING(config_look_nick_color_hash_salt), + nickname); + ptr_nick = str; + } + } + color = 0; switch (CONFIG_INTEGER(config_look_nick_color_hash)) @@ -105,6 +124,9 @@ gui_nick_hash_color (const char *nickname) break; } + if (str) + free (str); + return (color % config_num_nick_colors); } |