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

retain last status on load and some changes to statusbars

This commit is contained in:
Jfreegman 2014-03-15 07:40:13 -04:00
parent 65eb185a9f
commit c055af7348
2 changed files with 21 additions and 25 deletions

View File

@ -724,6 +724,10 @@ static void chat_onDraw(ToxWindow *self, Tox *m)
break; break;
} }
wattron(statusbar->topline, COLOR_PAIR(colour) | A_BOLD);
wprintw(statusbar->topline, " [%s]", status_text);
wattroff(statusbar->topline, COLOR_PAIR(colour) | A_BOLD);
if (friends[self->num].is_typing) if (friends[self->num].is_typing)
wattron(statusbar->topline, COLOR_PAIR(YELLOW)); wattron(statusbar->topline, COLOR_PAIR(YELLOW));
@ -733,15 +737,11 @@ static void chat_onDraw(ToxWindow *self, Tox *m)
if (friends[self->num].is_typing) if (friends[self->num].is_typing)
wattroff(statusbar->topline, COLOR_PAIR(YELLOW)); wattroff(statusbar->topline, COLOR_PAIR(YELLOW));
wattron(statusbar->topline, COLOR_PAIR(colour) | A_BOLD);
wprintw(statusbar->topline, "[%s]", status_text);
wattroff(statusbar->topline, COLOR_PAIR(colour) | A_BOLD);
} else { } else {
wprintw(statusbar->topline, " [Offline]");
wattron(statusbar->topline, A_BOLD); wattron(statusbar->topline, A_BOLD);
wprintw(statusbar->topline, " %s ", self->name); wprintw(statusbar->topline, " %s ", self->name);
wattroff(statusbar->topline, A_BOLD); wattroff(statusbar->topline, A_BOLD);
wprintw(statusbar->topline, "[Offline]");
} }
/* Reset statusbar->statusmsg on window resize */ /* Reset statusbar->statusmsg on window resize */
@ -764,11 +764,8 @@ static void chat_onDraw(ToxWindow *self, Tox *m)
statusbar->statusmsg_len = maxlen; statusbar->statusmsg_len = maxlen;
} }
if (statusbar->statusmsg[0]) { if (statusbar->statusmsg[0])
wattron(statusbar->topline, A_BOLD); wprintw(statusbar->topline, "- %s ", statusbar->statusmsg);
wprintw(statusbar->topline, " - %s ", statusbar->statusmsg);
wattroff(statusbar->topline, A_BOLD);
}
wclrtoeol(statusbar->topline); wclrtoeol(statusbar->topline);
wmove(statusbar->topline, 0, x2 - (KEY_IDENT_DIGITS * 2) - 3); wmove(statusbar->topline, 0, x2 - (KEY_IDENT_DIGITS * 2) - 3);

View File

@ -341,23 +341,24 @@ static void prompt_onDraw(ToxWindow *self, Tox *m)
colour = RED; colour = RED;
break; break;
} }
wattron(statusbar->topline, COLOR_PAIR(colour) | A_BOLD);
wprintw(statusbar->topline, " [%s]", status_text);
wattroff(statusbar->topline, COLOR_PAIR(colour) | A_BOLD);
wattron(statusbar->topline, A_BOLD); wattron(statusbar->topline, A_BOLD);
wprintw(statusbar->topline, " %s ", statusbar->nick); wprintw(statusbar->topline, " %s", statusbar->nick);
wattron(statusbar->topline, A_BOLD); wattroff(statusbar->topline, A_BOLD);
wattron(statusbar->topline, COLOR_PAIR(colour) | A_BOLD);
wprintw(statusbar->topline, "[%s]", status_text);
wattroff(statusbar->topline, COLOR_PAIR(colour) | A_BOLD);
} else { } else {
wprintw(statusbar->topline, "[Offline]");
wattron(statusbar->topline, A_BOLD); wattron(statusbar->topline, A_BOLD);
wprintw(statusbar->topline, " %s ", statusbar->nick); wprintw(statusbar->topline, " %s ", statusbar->nick);
wattroff(statusbar->topline, A_BOLD); wattroff(statusbar->topline, A_BOLD);
wprintw(statusbar->topline, "[Offline]");
} }
wattron(statusbar->topline, A_BOLD); if (statusbar->statusmsg[0])
wprintw(statusbar->topline, " - %s", statusbar->statusmsg); wprintw(statusbar->topline, " - %s", statusbar->statusmsg);
wattroff(statusbar->topline, A_BOLD);
wprintw(statusbar->topline, "\n");
/* put cursor back in correct spot */ /* put cursor back in correct spot */
int y_m = prt->orig_y + ((prt->pos + p_ofst) / px2); int y_m = prt->orig_y + ((prt->pos + p_ofst) / px2);
@ -473,6 +474,7 @@ void prompt_init_statusbar(ToxWindow *self, Tox *m)
pthread_mutex_lock(&Winthread.lock); pthread_mutex_lock(&Winthread.lock);
tox_get_self_name(m, nick, TOX_MAX_NAME_LENGTH); tox_get_self_name(m, nick, TOX_MAX_NAME_LENGTH);
tox_get_self_status_message(m, statusmsg, MAX_STR_SIZE); tox_get_self_status_message(m, statusmsg, MAX_STR_SIZE);
TOX_USERSTATUS status = tox_get_self_user_status(m);
pthread_mutex_unlock(&Winthread.lock); pthread_mutex_unlock(&Winthread.lock);
snprintf(statusbar->nick, sizeof(statusbar->nick), "%s", nick); snprintf(statusbar->nick, sizeof(statusbar->nick), "%s", nick);
@ -482,14 +484,11 @@ void prompt_init_statusbar(ToxWindow *self, Tox *m)
strcpy(ver, TOXICVER); strcpy(ver, TOXICVER);
uint8_t *toxic_ver = strtok(ver, "_"); uint8_t *toxic_ver = strtok(ver, "_");
if (!strcmp("Online", statusmsg)) if (!strcmp("Online", statusmsg) && toxic_ver != NULL)
snprintf(statusmsg, MAX_STR_SIZE, "Toxing on Toxic v.%s", toxic_ver); snprintf(statusmsg, MAX_STR_SIZE, "Toxing on Toxic v.%s", toxic_ver);
pthread_mutex_lock(&Winthread.lock); prompt_update_statusmessage(prompt, statusmsg, strlen(statusmsg) + 1);
tox_set_status_message(m, statusmsg, strlen(statusmsg) + 1); prompt_update_status(prompt, status);
pthread_mutex_unlock(&Winthread.lock);
snprintf(statusbar->statusmsg, sizeof(statusbar->statusmsg), "%s", statusmsg);
/* Init statusbar subwindow */ /* Init statusbar subwindow */
statusbar->topline = subwin(self->window, 2, x, 0, 0); statusbar->topline = subwin(self->window, 2, x, 0, 0);