core: add option weechat.look.nick_color_hash_salt to allow for reshuffling of colors (issue #635)
parent
c634d6c56e
commit
1a00368888
|
@ -153,6 +153,7 @@ struct t_config_option *config_look_mouse;
|
|||
struct t_config_option *config_look_mouse_timer_delay;
|
||||
struct t_config_option *config_look_nick_color_force;
|
||||
struct t_config_option *config_look_nick_color_hash;
|
||||
struct t_config_option *config_look_nick_color_hash_salt;
|
||||
struct t_config_option *config_look_nick_color_stop_chars;
|
||||
struct t_config_option *config_look_nick_prefix;
|
||||
struct t_config_option *config_look_nick_suffix;
|
||||
|
@ -3246,6 +3247,13 @@ config_weechat_init_options ()
|
|||
"using 32-bit instead of 64-bit integer"),
|
||||
"djb2|sum|djb2_32|sum_32", 0, 0, "djb2", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
config_look_nick_color_hash_salt = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
"nick_color_hash_salt", "string",
|
||||
N_("salt to be used with the hash algorithm used for nick colors; "
|
||||
"modifying this shuffles nick colors"),
|
||||
NULL, 0, 0, "", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
config_look_nick_color_stop_chars = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
"nick_color_stop_chars", "string",
|
||||
|
|
|
@ -206,6 +206,7 @@ extern struct t_config_option *config_look_mouse;
|
|||
extern struct t_config_option *config_look_mouse_timer_delay;
|
||||
extern struct t_config_option *config_look_nick_color_force;
|
||||
extern struct t_config_option *config_look_nick_color_hash;
|
||||
extern struct t_config_option *config_look_nick_color_hash_salt;
|
||||
extern struct t_config_option *config_look_nick_color_stop_chars;
|
||||
extern struct t_config_option *config_look_nick_prefix;
|
||||
extern struct t_config_option *config_look_nick_suffix;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue