Mercurial > pidgin.yaz
comparison src/gtkconv.c @ 10099:c49cc5b818cf
[gaim-migrate @ 11122]
Luke got me thinking of a better way to do screename coloring in chats. I
came up with a two-step solution. This is step 1: use a decent hashing
algorithm with much fewer collisions than the simple one I used.
g_str_hash does the trick.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Thu, 14 Oct 2004 18:15:10 +0000 |
parents | 9fdbfe832fac |
children | fad5d3354cc1 |
comparison
equal
deleted
inserted
replaced
10098:fb4216714dac | 10099:c49cc5b818cf |
---|---|
5222 else | 5222 else |
5223 g_snprintf(str, 1024, "%s:", who_escaped); | 5223 g_snprintf(str, 1024, "%s:", who_escaped); |
5224 if (flags & GAIM_MESSAGE_NICK) | 5224 if (flags & GAIM_MESSAGE_NICK) |
5225 strcpy(color, "#AF7F00"); | 5225 strcpy(color, "#AF7F00"); |
5226 else if (flags & GAIM_MESSAGE_RECV) { | 5226 else if (flags & GAIM_MESSAGE_RECV) { |
5227 if (flags & GAIM_MESSAGE_COLORIZE) { | 5227 if (flags & GAIM_MESSAGE_COLORIZE) |
5228 const char *u; | 5228 strcpy(color, g_str_hash(who) % NUM_NICK_COLORS); |
5229 int m = 0; | |
5230 | |
5231 for (u = who; *u != '\0'; u++) | |
5232 m += *u; | |
5233 | |
5234 m = m % NUM_NICK_COLORS; | |
5235 | |
5236 strcpy(color, nick_colors[m]); | |
5237 } | |
5238 else | 5229 else |
5239 strcpy(color, RECV_COLOR); | 5230 strcpy(color, RECV_COLOR); |
5240 } | 5231 } |
5241 else if (flags & GAIM_MESSAGE_SEND) | 5232 else if (flags & GAIM_MESSAGE_SEND) |
5242 strcpy(color, SEND_COLOR); | 5233 strcpy(color, SEND_COLOR); |