1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-23 02:13:01 +01:00

sort names in groupchat sidepanel

This commit is contained in:
Jfreegman 2013-11-24 02:33:03 -05:00
parent 1064e8d144
commit 4aa68c8251
3 changed files with 25 additions and 1 deletions

View File

@ -121,7 +121,7 @@ static void groupchat_onGroupNamelistChange(ToxWindow *self, Tox *m, int groupnu
groupchats[groupnum].num_peers = MIN(tox_group_number_peers(m, groupnum), MAX_GROUP_PEERS); groupchats[groupnum].num_peers = MIN(tox_group_number_peers(m, groupnum), MAX_GROUP_PEERS);
tox_group_copy_names(m, groupnum, groupchats[groupnum].peer_names, groupchats[groupnum].num_peers); tox_group_copy_names(m, groupnum, groupchats[groupnum].peer_names, groupchats[groupnum].num_peers);
//qsort(groupchats[groupnum].peer_names, qsort(groupchats[groupnum].peer_names, groupchats[groupnum].num_peers, TOX_MAX_NAME_LENGTH, name_compare);
} }
static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key) static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key)

View File

@ -113,3 +113,24 @@ void alert_window(ToxWindow *self)
self->blink = true; self->blink = true;
beep(); beep();
} }
/* case-insensitive string compare function for use with qsort - same return logic as strcmp */
int name_compare(const void *nick1, const void *nick2)
{
char s[strlen(nick1)];
char t[strlen(nick2)];
strcpy(s, (const char*) nick1);
strcpy(t, (const char*) nick2);
int i;
for (i = 0; s[i] != '\0' && t[i] != '\0'; ++i) {
s[i] = tolower(s[i]);
t[i] = tolower(t[i]);
if (s[i] != t[i])
break;
}
return s[i] - t[i];
}

View File

@ -27,3 +27,6 @@ bool timed_out(uint64_t timestamp, uint64_t timeout, uint64_t curtime);
/* Beeps and makes window tab blink */ /* Beeps and makes window tab blink */
void alert_window(ToxWindow *self); void alert_window(ToxWindow *self);
/* case-insensitive string compare function for use with qsort - same return logic as strcmp */
int name_compare(const void *nick1, const void *nick2);