mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
sort nicks with custom prefix by the order defined in isupport in /NAMES
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4247 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
3eedfa4e12
commit
461f653d9b
@ -357,7 +357,7 @@ GSList *nicklist_get_same_unique(SERVER_REC *server, void *id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* nick record comparision for sort functions */
|
/* nick record comparision for sort functions */
|
||||||
int nicklist_compare(NICK_REC *p1, NICK_REC *p2)
|
int nicklist_compare(NICK_REC *p1, NICK_REC *p2, const char *nick_prefix)
|
||||||
{
|
{
|
||||||
int status1, status2;
|
int status1, status2;
|
||||||
|
|
||||||
@ -369,10 +369,10 @@ int nicklist_compare(NICK_REC *p1, NICK_REC *p2)
|
|||||||
* returns :-)
|
* returns :-)
|
||||||
* -- yath */
|
* -- yath */
|
||||||
|
|
||||||
/* Treat others as highest - should really use order in 005 numeric */
|
if (p1->other) {
|
||||||
if (p1->other)
|
const char *other = (nick_prefix == NULL) ? NULL : strchr(nick_prefix, p1->other);
|
||||||
status1 = 5;
|
status1 = (other == NULL) ? 5 : 1000 - (other - nick_prefix);
|
||||||
else if (p1->op)
|
} else if (p1->op)
|
||||||
status1 = 4;
|
status1 = 4;
|
||||||
else if (p1->halfop)
|
else if (p1->halfop)
|
||||||
status1 = 3;
|
status1 = 3;
|
||||||
@ -381,9 +381,10 @@ int nicklist_compare(NICK_REC *p1, NICK_REC *p2)
|
|||||||
else
|
else
|
||||||
status1 = 1;
|
status1 = 1;
|
||||||
|
|
||||||
if (p2->other)
|
if (p2->other) {
|
||||||
status2 = 5;
|
const char *other = (nick_prefix == NULL) ? NULL : strchr(nick_prefix, p2->other);
|
||||||
else if (p2->op)
|
status2 = (other == NULL) ? 5 : 1000 - (other - nick_prefix);
|
||||||
|
} else if (p2->op)
|
||||||
status2 = 4;
|
status2 = 4;
|
||||||
else if (p2->halfop)
|
else if (p2->halfop)
|
||||||
status2 = 3;
|
status2 = 3;
|
||||||
|
@ -49,7 +49,7 @@ void nicklist_update_flags_unique(SERVER_REC *server, void *id,
|
|||||||
void nicklist_set_own(CHANNEL_REC *channel, NICK_REC *nick);
|
void nicklist_set_own(CHANNEL_REC *channel, NICK_REC *nick);
|
||||||
|
|
||||||
/* Nick record comparision for sort functions */
|
/* Nick record comparision for sort functions */
|
||||||
int nicklist_compare(NICK_REC *p1, NICK_REC *p2);
|
int nicklist_compare(NICK_REC *p1, NICK_REC *p2, const char *nick_prefix);
|
||||||
|
|
||||||
/* Check is `msg' is meant for `nick'. */
|
/* Check is `msg' is meant for `nick'. */
|
||||||
int nick_match_msg(CHANNEL_REC *channel, const char *msg, const char *nick);
|
int nick_match_msg(CHANNEL_REC *channel, const char *msg, const char *nick);
|
||||||
|
@ -473,12 +473,14 @@ void fe_channels_nicklist(CHANNEL_REC *channel, int flags)
|
|||||||
NICK_REC *nick;
|
NICK_REC *nick;
|
||||||
GSList *tmp, *nicklist, *sorted;
|
GSList *tmp, *nicklist, *sorted;
|
||||||
int nicks, normal, voices, halfops, ops;
|
int nicks, normal, voices, halfops, ops;
|
||||||
|
const char *nick_flags;
|
||||||
|
|
||||||
nicks = normal = voices = halfops = ops = 0;
|
nicks = normal = voices = halfops = ops = 0;
|
||||||
nicklist = nicklist_getnicks(channel);
|
nicklist = nicklist_getnicks(channel);
|
||||||
sorted = NULL;
|
sorted = NULL;
|
||||||
|
nick_flags = channel->server->get_nick_flags(channel->server);
|
||||||
|
|
||||||
/* sort the nicklist */
|
/* filter (for flags) and count ops, halfops, voices */
|
||||||
for (tmp = nicklist; tmp != NULL; tmp = tmp->next) {
|
for (tmp = nicklist; tmp != NULL; tmp = tmp->next) {
|
||||||
nick = tmp->data;
|
nick = tmp->data;
|
||||||
|
|
||||||
@ -501,11 +503,13 @@ void fe_channels_nicklist(CHANNEL_REC *channel, int flags)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
sorted = g_slist_insert_sorted(sorted, nick, (GCompareFunc)
|
sorted = g_slist_prepend(sorted, nick);
|
||||||
nicklist_compare);
|
|
||||||
}
|
}
|
||||||
g_slist_free(nicklist);
|
g_slist_free(nicklist);
|
||||||
|
|
||||||
|
/* sort the nicklist */
|
||||||
|
sorted = g_slist_sort_with_data(sorted, (GCompareDataFunc) nicklist_compare, (void *)nick_flags);
|
||||||
|
|
||||||
/* display the nicks */
|
/* display the nicks */
|
||||||
if ((flags & CHANNEL_NICKLIST_FLAG_COUNT) == 0) {
|
if ((flags & CHANNEL_NICKLIST_FLAG_COUNT) == 0) {
|
||||||
printformat(channel->server, channel->visible_name,
|
printformat(channel->server, channel->visible_name,
|
||||||
|
Loading…
Reference in New Issue
Block a user