mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-26 14:53:26 +01:00
Show offline friends names and some cosmetic changes
This commit is contained in:
parent
577f42c075
commit
aa6e205ee8
@ -102,7 +102,7 @@ static void chat_onNickChange(ToxWindow *self, int num, uint8_t *nick, uint16_t
|
|||||||
wattroff(ctx->history, COLOR_PAIR(2));
|
wattroff(ctx->history, COLOR_PAIR(2));
|
||||||
|
|
||||||
nick[len - 1] = '\0';
|
nick[len - 1] = '\0';
|
||||||
snprintf(self->title, sizeof(self->title), "[%s (%d)]", nick, num);
|
snprintf(self->title, sizeof(self->title), "[%s]", nick);
|
||||||
|
|
||||||
wprintw(ctx->history, "* Chat partner changed nick to '%s'\n", nick);
|
wprintw(ctx->history, "* Chat partner changed nick to '%s'\n", nick);
|
||||||
}
|
}
|
||||||
@ -444,7 +444,7 @@ ToxWindow new_chat(Tox *m, int friendnum)
|
|||||||
uint8_t nick[TOX_MAX_NAME_LENGTH] = {0};
|
uint8_t nick[TOX_MAX_NAME_LENGTH] = {0};
|
||||||
tox_getname(m, friendnum, (uint8_t *) &nick);
|
tox_getname(m, friendnum, (uint8_t *) &nick);
|
||||||
|
|
||||||
snprintf(ret.title, sizeof(ret.title), "[%s (%d)]", nick, friendnum);
|
snprintf(ret.title, sizeof(ret.title), "[%s]", nick);
|
||||||
|
|
||||||
ChatContext *x = calloc(1, sizeof(ChatContext));
|
ChatContext *x = calloc(1, sizeof(ChatContext));
|
||||||
ret.x = x;
|
ret.x = x;
|
||||||
|
@ -72,8 +72,10 @@ int friendlist_onFriendAdded(Tox *m, int num)
|
|||||||
friends[i].num = num;
|
friends[i].num = num;
|
||||||
friends[i].active = true;
|
friends[i].active = true;
|
||||||
friends[i].chatwin = -1;
|
friends[i].chatwin = -1;
|
||||||
//tox_getname(m, num, friends[i].name);
|
|
||||||
strcpy((char *) friends[i].name, "unknown");
|
if (tox_getname(m, num, friends[i].name) != 0 || friends[i].name[0] == '\0')
|
||||||
|
strcpy((char *) friends[i].name, "unknown");
|
||||||
|
|
||||||
strcpy((char *) friends[i].statusmsg, NOSTATUSMSG);
|
strcpy((char *) friends[i].statusmsg, NOSTATUSMSG);
|
||||||
|
|
||||||
if (i == num_friends)
|
if (i == num_friends)
|
||||||
@ -164,8 +166,8 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
|
|||||||
wprintw(self->window, "Empty. Add some friends! :-)\n");
|
wprintw(self->window, "Empty. Add some friends! :-)\n");
|
||||||
} else {
|
} else {
|
||||||
wattron(self->window, COLOR_PAIR(2) | A_BOLD);
|
wattron(self->window, COLOR_PAIR(2) | A_BOLD);
|
||||||
wprintw(self->window, " * Open chat with up/down keys and enter.\n");
|
wprintw(self->window, " Open chat with up/down keys and enter.\n");
|
||||||
wprintw(self->window, " * Delete friends with the backspace key.\n\n");
|
wprintw(self->window, " Delete friends with the backspace key.\n\n");
|
||||||
wattroff(self->window, COLOR_PAIR(2) | A_BOLD);
|
wattroff(self->window, COLOR_PAIR(2) | A_BOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,33 +184,31 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
|
|||||||
|
|
||||||
if (is_online) {
|
if (is_online) {
|
||||||
TOX_USERSTATUS status = tox_get_userstatus(m, friends[i].num);
|
TOX_USERSTATUS status = tox_get_userstatus(m, friends[i].num);
|
||||||
int colour;
|
int colour = 7; /* Invalid or other errors default to black */
|
||||||
|
|
||||||
switch(status) {
|
switch(status) {
|
||||||
case TOX_USERSTATUS_NONE:
|
case TOX_USERSTATUS_NONE:
|
||||||
colour = 1;
|
colour = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOX_USERSTATUS_AWAY:
|
case TOX_USERSTATUS_AWAY:
|
||||||
colour = 5;
|
colour = 5;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOX_USERSTATUS_BUSY:
|
case TOX_USERSTATUS_BUSY:
|
||||||
case TOX_USERSTATUS_INVALID:
|
|
||||||
default:
|
|
||||||
colour = 3;
|
colour = 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wprintw(self->window, "[");
|
||||||
wattron(self->window, COLOR_PAIR(colour));
|
wattron(self->window, COLOR_PAIR(colour));
|
||||||
wprintw(self->window, "%s ", friends[i].name);
|
wprintw(self->window, "O");
|
||||||
wattroff(self->window, COLOR_PAIR(colour));
|
wattroff(self->window, COLOR_PAIR(colour));
|
||||||
|
wprintw(self->window, "] %s ", friends[i].name);
|
||||||
|
|
||||||
if (strncmp(friends[i].statusmsg, NOSTATUSMSG, strlen(NOSTATUSMSG)))
|
if (strncmp(friends[i].statusmsg, NOSTATUSMSG, strlen(NOSTATUSMSG)))
|
||||||
wprintw(self->window, "(%s)\n", friends[i].statusmsg);
|
wprintw(self->window, "(%s)\n", friends[i].statusmsg);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
wprintw(self->window, "%s (Offline)\n", friends[i].name);
|
wprintw(self->window, "[O] %s (Offline)\n", friends[i].name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user