mirror of
https://github.com/Tha14/toxic.git
synced 2024-12-23 15:53:26 +01:00
sort names in groupchat sidepanel
This commit is contained in:
parent
1064e8d144
commit
4aa68c8251
@ -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);
|
||||
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)
|
||||
|
@ -113,3 +113,24 @@ void alert_window(ToxWindow *self)
|
||||
self->blink = true;
|
||||
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];
|
||||
}
|
@ -27,3 +27,6 @@ bool timed_out(uint64_t timestamp, uint64_t timeout, uint64_t curtime);
|
||||
|
||||
/* Beeps and makes window tab blink */
|
||||
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);
|
Loading…
Reference in New Issue
Block a user