mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-26 21:53:27 +01:00
define curses colours and replace magic numbers
This commit is contained in:
parent
f5695a4b3e
commit
f7d96b0779
80
src/chat.c
80
src/chat.c
@ -55,9 +55,9 @@ static void chat_onMessage(ToxWindow *self, Tox *m, int num, uint8_t *msg, uint1
|
|||||||
msg[len-1] = '\0';
|
msg[len-1] = '\0';
|
||||||
nick[TOX_MAX_NAME_LENGTH-1] = '\0';
|
nick[TOX_MAX_NAME_LENGTH-1] = '\0';
|
||||||
|
|
||||||
wattron(ctx->history, COLOR_PAIR(2));
|
wattron(ctx->history, COLOR_PAIR(CYAN));
|
||||||
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
||||||
wattroff(ctx->history, COLOR_PAIR(2));
|
wattroff(ctx->history, COLOR_PAIR(CYAN));
|
||||||
wattron(ctx->history, COLOR_PAIR(4));
|
wattron(ctx->history, COLOR_PAIR(4));
|
||||||
wprintw(ctx->history, "%s: ", nick);
|
wprintw(ctx->history, "%s: ", nick);
|
||||||
wattroff(ctx->history, COLOR_PAIR(4));
|
wattroff(ctx->history, COLOR_PAIR(4));
|
||||||
@ -75,9 +75,9 @@ void chat_onConnectionChange(ToxWindow *self, Tox *m, int num, uint8_t status)
|
|||||||
if (ctx->friendnum != num)
|
if (ctx->friendnum != num)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wattron(ctx->history, COLOR_PAIR(2));
|
wattron(ctx->history, COLOR_PAIR(CYAN));
|
||||||
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
||||||
wattroff(ctx->history, COLOR_PAIR(2));
|
wattroff(ctx->history, COLOR_PAIR(CYAN));
|
||||||
|
|
||||||
if (status == 1)
|
if (status == 1)
|
||||||
wprintw(ctx->history, "* Chat partner has come online\n");
|
wprintw(ctx->history, "* Chat partner has come online\n");
|
||||||
@ -98,13 +98,13 @@ static void chat_onAction(ToxWindow *self, Tox *m, int num, uint8_t *action, uin
|
|||||||
|
|
||||||
action[len - 1] = '\0';
|
action[len - 1] = '\0';
|
||||||
|
|
||||||
wattron(ctx->history, COLOR_PAIR(2));
|
wattron(ctx->history, COLOR_PAIR(CYAN));
|
||||||
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
||||||
wattroff(ctx->history, COLOR_PAIR(2));
|
wattroff(ctx->history, COLOR_PAIR(CYAN));
|
||||||
|
|
||||||
wattron(ctx->history, COLOR_PAIR(5));
|
wattron(ctx->history, COLOR_PAIR(YELLOW));
|
||||||
wprintw(ctx->history, "* %s %s\n", nick, action);
|
wprintw(ctx->history, "* %s %s\n", nick, action);
|
||||||
wattroff(ctx->history, COLOR_PAIR(5));
|
wattroff(ctx->history, COLOR_PAIR(YELLOW));
|
||||||
|
|
||||||
self->blink = true;
|
self->blink = true;
|
||||||
beep();
|
beep();
|
||||||
@ -118,9 +118,9 @@ static void chat_onNickChange(ToxWindow *self, int num, uint8_t *nick, uint16_t
|
|||||||
if (ctx->friendnum != num)
|
if (ctx->friendnum != num)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wattron(ctx->history, COLOR_PAIR(2));
|
wattron(ctx->history, COLOR_PAIR(CYAN));
|
||||||
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
||||||
wattroff(ctx->history, COLOR_PAIR(2));
|
wattroff(ctx->history, COLOR_PAIR(CYAN));
|
||||||
|
|
||||||
nick[len - 1] = '\0';
|
nick[len - 1] = '\0';
|
||||||
snprintf(self->title, sizeof(self->title), "[%s]", nick);
|
snprintf(self->title, sizeof(self->title), "[%s]", nick);
|
||||||
@ -136,31 +136,31 @@ static void chat_onStatusChange(ToxWindow *self, Tox *m, int num, TOX_USERSTATUS
|
|||||||
if (ctx->friendnum != num)
|
if (ctx->friendnum != num)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wattron(ctx->history, COLOR_PAIR(2));
|
wattron(ctx->history, COLOR_PAIR(CYAN));
|
||||||
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
||||||
wattroff(ctx->history, COLOR_PAIR(2));
|
wattroff(ctx->history, COLOR_PAIR(CYAN));
|
||||||
|
|
||||||
switch(status) {
|
switch(status) {
|
||||||
|
|
||||||
case TOX_USERSTATUS_NONE:
|
case TOX_USERSTATUS_NONE:
|
||||||
wprintw(ctx->history, "* Chat partner set status to ");
|
wprintw(ctx->history, "* Chat partner set status to ");
|
||||||
wattron(ctx->history, COLOR_PAIR(1));
|
wattron(ctx->history, COLOR_PAIR(GREEN));
|
||||||
wprintw(ctx->history, "[Online]\n");
|
wprintw(ctx->history, "[Online]\n");
|
||||||
wattroff(ctx->history, COLOR_PAIR(1));
|
wattroff(ctx->history, COLOR_PAIR(GREEN));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOX_USERSTATUS_BUSY:
|
case TOX_USERSTATUS_BUSY:
|
||||||
wprintw(ctx->history, "* Chat partner set status to ");
|
wprintw(ctx->history, "* Chat partner set status to ");
|
||||||
wattron(ctx->history, COLOR_PAIR(3));
|
wattron(ctx->history, COLOR_PAIR(RED));
|
||||||
wprintw(ctx->history, "[Busy]\n");
|
wprintw(ctx->history, "[Busy]\n");
|
||||||
wattroff(ctx->history, COLOR_PAIR(3));
|
wattroff(ctx->history, COLOR_PAIR(RED));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOX_USERSTATUS_AWAY:
|
case TOX_USERSTATUS_AWAY:
|
||||||
wprintw(ctx->history, "* Chat partner set status to ");
|
wprintw(ctx->history, "* Chat partner set status to ");
|
||||||
wattron(ctx->history, COLOR_PAIR(5));
|
wattron(ctx->history, COLOR_PAIR(YELLOW));
|
||||||
wprintw(ctx->history, "[Away]\n");
|
wprintw(ctx->history, "[Away]\n");
|
||||||
wattroff(ctx->history, COLOR_PAIR(5));
|
wattroff(ctx->history, COLOR_PAIR(YELLOW));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,9 +176,9 @@ static void chat_onStatusMessageChange(ToxWindow *self, int num, uint8_t *status
|
|||||||
status[len - 1] = '\0';
|
status[len - 1] = '\0';
|
||||||
|
|
||||||
if (strncmp(status, "Online", strlen("status"))) { /* Ignore default "Online" message */
|
if (strncmp(status, "Online", strlen("status"))) { /* Ignore default "Online" message */
|
||||||
wattron(ctx->history, COLOR_PAIR(2));
|
wattron(ctx->history, COLOR_PAIR(CYAN));
|
||||||
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
||||||
wattroff(ctx->history, COLOR_PAIR(2));
|
wattroff(ctx->history, COLOR_PAIR(CYAN));
|
||||||
wprintw(ctx->history, "* Chat partner changed personal note to: %s\n", status);
|
wprintw(ctx->history, "* Chat partner changed personal note to: %s\n", status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -286,18 +286,18 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key)
|
|||||||
uint8_t selfname[TOX_MAX_NAME_LENGTH];
|
uint8_t selfname[TOX_MAX_NAME_LENGTH];
|
||||||
tox_getselfname(m, selfname, sizeof(selfname));
|
tox_getselfname(m, selfname, sizeof(selfname));
|
||||||
|
|
||||||
wattron(ctx->history, COLOR_PAIR(2));
|
wattron(ctx->history, COLOR_PAIR(CYAN));
|
||||||
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
||||||
wattroff(ctx->history, COLOR_PAIR(2));
|
wattroff(ctx->history, COLOR_PAIR(CYAN));
|
||||||
wattron(ctx->history, COLOR_PAIR(1));
|
wattron(ctx->history, COLOR_PAIR(GREEN));
|
||||||
wprintw(ctx->history, "%s: ", selfname);
|
wprintw(ctx->history, "%s: ", selfname);
|
||||||
wattroff(ctx->history, COLOR_PAIR(1));
|
wattroff(ctx->history, COLOR_PAIR(GREEN));
|
||||||
wprintw(ctx->history, "%s\n", line);
|
wprintw(ctx->history, "%s\n", line);
|
||||||
|
|
||||||
if (tox_sendmessage(m, ctx->friendnum, (uint8_t *) line, strlen(line) + 1) == 0) {
|
if (tox_sendmessage(m, ctx->friendnum, (uint8_t *) line, strlen(line) + 1) == 0) {
|
||||||
wattron(ctx->history, COLOR_PAIR(3));
|
wattron(ctx->history, COLOR_PAIR(RED));
|
||||||
wprintw(ctx->history, " * Failed to send message.\n");
|
wprintw(ctx->history, " * Failed to send message.\n");
|
||||||
wattroff(ctx->history, COLOR_PAIR(3));
|
wattroff(ctx->history, COLOR_PAIR(RED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,21 +345,21 @@ void execute(ToxWindow *self, ChatContext *ctx, Tox *m, char *cmd)
|
|||||||
|
|
||||||
action++;
|
action++;
|
||||||
|
|
||||||
wattron(ctx->history, COLOR_PAIR(2));
|
wattron(ctx->history, COLOR_PAIR(CYAN));
|
||||||
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
||||||
wattroff(ctx->history, COLOR_PAIR(2));
|
wattroff(ctx->history, COLOR_PAIR(CYAN));
|
||||||
|
|
||||||
uint8_t selfname[TOX_MAX_NAME_LENGTH];
|
uint8_t selfname[TOX_MAX_NAME_LENGTH];
|
||||||
tox_getselfname(m, selfname, sizeof(selfname));
|
tox_getselfname(m, selfname, sizeof(selfname));
|
||||||
|
|
||||||
wattron(ctx->history, COLOR_PAIR(5));
|
wattron(ctx->history, COLOR_PAIR(YELLOW));
|
||||||
wprintw(ctx->history, "* %s %s\n", selfname, action);
|
wprintw(ctx->history, "* %s %s\n", selfname, action);
|
||||||
wattroff(ctx->history, COLOR_PAIR(5));
|
wattroff(ctx->history, COLOR_PAIR(YELLOW));
|
||||||
|
|
||||||
if (tox_sendaction(m, ctx->friendnum, (uint8_t *) action, strlen(action) + 1) == 0) {
|
if (tox_sendaction(m, ctx->friendnum, (uint8_t *) action, strlen(action) + 1) == 0) {
|
||||||
wattron(ctx->history, COLOR_PAIR(3));
|
wattron(ctx->history, COLOR_PAIR(RED));
|
||||||
wprintw(ctx->history, " * Failed to send action\n");
|
wprintw(ctx->history, " * Failed to send action\n");
|
||||||
wattroff(ctx->history, COLOR_PAIR(3));
|
wattroff(ctx->history, COLOR_PAIR(RED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,25 +379,25 @@ void execute(ToxWindow *self, ChatContext *ctx, Tox *m, char *cmd)
|
|||||||
if (!strncmp(status, "online", strlen("online"))) {
|
if (!strncmp(status, "online", strlen("online"))) {
|
||||||
status_kind = TOX_USERSTATUS_NONE;
|
status_kind = TOX_USERSTATUS_NONE;
|
||||||
wprintw(ctx->history, "Status set to ");
|
wprintw(ctx->history, "Status set to ");
|
||||||
wattron(ctx->history, COLOR_PAIR(1));
|
wattron(ctx->history, COLOR_PAIR(GREEN));
|
||||||
wprintw(ctx->history, "[Online]\n");
|
wprintw(ctx->history, "[Online]\n");
|
||||||
wattroff(ctx->history, COLOR_PAIR(1));
|
wattroff(ctx->history, COLOR_PAIR(GREEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!strncmp(status, "away", strlen("away"))) {
|
else if (!strncmp(status, "away", strlen("away"))) {
|
||||||
status_kind = TOX_USERSTATUS_AWAY;
|
status_kind = TOX_USERSTATUS_AWAY;
|
||||||
wprintw(ctx->history, "Status set to ");
|
wprintw(ctx->history, "Status set to ");
|
||||||
wattron(ctx->history, COLOR_PAIR(5));
|
wattron(ctx->history, COLOR_PAIR(YELLOW));
|
||||||
wprintw(ctx->history, "[Away]\n");
|
wprintw(ctx->history, "[Away]\n");
|
||||||
wattroff(ctx->history, COLOR_PAIR(5));
|
wattroff(ctx->history, COLOR_PAIR(YELLOW));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!strncmp(status, "busy", strlen("busy"))) {
|
else if (!strncmp(status, "busy", strlen("busy"))) {
|
||||||
status_kind = TOX_USERSTATUS_BUSY;
|
status_kind = TOX_USERSTATUS_BUSY;
|
||||||
wprintw(ctx->history, "Status set to ");
|
wprintw(ctx->history, "Status set to ");
|
||||||
wattron(ctx->history, COLOR_PAIR(3));
|
wattron(ctx->history, COLOR_PAIR(RED));
|
||||||
wprintw(ctx->history, "[Busy]\n");
|
wprintw(ctx->history, "[Busy]\n");
|
||||||
wattroff(ctx->history, COLOR_PAIR(3));
|
wattroff(ctx->history, COLOR_PAIR(RED));
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
@ -480,7 +480,7 @@ static void chat_onInit(ToxWindow *self, Tox *m)
|
|||||||
|
|
||||||
void print_help(ChatContext *self)
|
void print_help(ChatContext *self)
|
||||||
{
|
{
|
||||||
wattron(self->history, COLOR_PAIR(2) | A_BOLD);
|
wattron(self->history, COLOR_PAIR(CYAN) | A_BOLD);
|
||||||
wprintw(self->history, "Commands:\n");
|
wprintw(self->history, "Commands:\n");
|
||||||
wattroff(self->history, A_BOLD);
|
wattroff(self->history, A_BOLD);
|
||||||
|
|
||||||
@ -494,7 +494,7 @@ void print_help(ChatContext *self)
|
|||||||
wprintw(self->history, " /quit or /exit : Exit Toxic\n");
|
wprintw(self->history, " /quit or /exit : Exit Toxic\n");
|
||||||
wprintw(self->history, " /help : Print this message again\n\n");
|
wprintw(self->history, " /help : Print this message again\n\n");
|
||||||
|
|
||||||
wattroff(self->history, COLOR_PAIR(2));
|
wattroff(self->history, COLOR_PAIR(CYAN));
|
||||||
}
|
}
|
||||||
|
|
||||||
ToxWindow new_chat(Tox *m, int friendnum)
|
ToxWindow new_chat(Tox *m, int friendnum)
|
||||||
|
@ -180,10 +180,10 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
|
|||||||
if (num_friends == 0) {
|
if (num_friends == 0) {
|
||||||
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(CYAN) | 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(CYAN) | A_BOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
@ -197,17 +197,17 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
|
|||||||
|
|
||||||
if (friends[i].online) {
|
if (friends[i].online) {
|
||||||
TOX_USERSTATUS status = friends[i].status;
|
TOX_USERSTATUS status = friends[i].status;
|
||||||
int colour = 7; /* Invalid or other errors default to black */
|
int colour = WHITE;
|
||||||
|
|
||||||
switch(status) {
|
switch(status) {
|
||||||
case TOX_USERSTATUS_NONE:
|
case TOX_USERSTATUS_NONE:
|
||||||
colour = 1;
|
colour = GREEN;
|
||||||
break;
|
break;
|
||||||
case TOX_USERSTATUS_AWAY:
|
case TOX_USERSTATUS_AWAY:
|
||||||
colour = 5;
|
colour = YELLOW;
|
||||||
break;
|
break;
|
||||||
case TOX_USERSTATUS_BUSY:
|
case TOX_USERSTATUS_BUSY:
|
||||||
colour = 3;
|
colour = RED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
src/main.c
10
src/main.c
@ -71,6 +71,7 @@ static void init_term()
|
|||||||
|
|
||||||
if (has_colors()) {
|
if (has_colors()) {
|
||||||
start_color();
|
start_color();
|
||||||
|
init_pair(0, COLOR_WHITE, COLOR_BLACK);
|
||||||
init_pair(1, COLOR_GREEN, COLOR_BLACK);
|
init_pair(1, COLOR_GREEN, COLOR_BLACK);
|
||||||
init_pair(2, COLOR_CYAN, COLOR_BLACK);
|
init_pair(2, COLOR_CYAN, COLOR_BLACK);
|
||||||
init_pair(3, COLOR_RED, COLOR_BLACK);
|
init_pair(3, COLOR_RED, COLOR_BLACK);
|
||||||
@ -79,7 +80,6 @@ static void init_term()
|
|||||||
init_pair(6, COLOR_MAGENTA, COLOR_BLACK);
|
init_pair(6, COLOR_MAGENTA, COLOR_BLACK);
|
||||||
init_pair(7, COLOR_BLACK, COLOR_BLACK);
|
init_pair(7, COLOR_BLACK, COLOR_BLACK);
|
||||||
init_pair(8, COLOR_BLACK, COLOR_WHITE);
|
init_pair(8, COLOR_BLACK, COLOR_WHITE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
@ -398,17 +398,17 @@ int main(int argc, char *argv[])
|
|||||||
load_data(m, DATA_FILE);
|
load_data(m, DATA_FILE);
|
||||||
|
|
||||||
if (f_flag == -1) {
|
if (f_flag == -1) {
|
||||||
attron(COLOR_PAIR(3) | A_BOLD);
|
attron(COLOR_PAIR(RED) | A_BOLD);
|
||||||
wprintw(prompt->window, "You passed '-f' without giving an argument.\n"
|
wprintw(prompt->window, "You passed '-f' without giving an argument.\n"
|
||||||
"defaulting to 'data' for a keyfile...\n");
|
"defaulting to 'data' for a keyfile...\n");
|
||||||
attroff(COLOR_PAIR(3) | A_BOLD);
|
attroff(COLOR_PAIR(RED) | A_BOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config_err) {
|
if (config_err) {
|
||||||
attron(COLOR_PAIR(3) | A_BOLD);
|
attron(COLOR_PAIR(RED) | A_BOLD);
|
||||||
wprintw(prompt->window, "Unable to determine configuration directory.\n"
|
wprintw(prompt->window, "Unable to determine configuration directory.\n"
|
||||||
"defaulting to 'data' for a keyfile...\n");
|
"defaulting to 'data' for a keyfile...\n");
|
||||||
attroff(COLOR_PAIR(3) | A_BOLD);
|
attroff(COLOR_PAIR(RED) | A_BOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -243,7 +243,7 @@ void cmd_quit(ToxWindow *self, Tox *m, int argc, char **argv)
|
|||||||
void cmd_help(ToxWindow *self, Tox *m, int argc, char **argv)
|
void cmd_help(ToxWindow *self, Tox *m, int argc, char **argv)
|
||||||
{
|
{
|
||||||
wclear(self->window);
|
wclear(self->window);
|
||||||
wattron(self->window, COLOR_PAIR(2) | A_BOLD);
|
wattron(self->window, COLOR_PAIR(CYAN) | A_BOLD);
|
||||||
wprintw(self->window, "Commands:\n");
|
wprintw(self->window, "Commands:\n");
|
||||||
wattroff(self->window, A_BOLD);
|
wattroff(self->window, A_BOLD);
|
||||||
|
|
||||||
@ -264,7 +264,7 @@ void cmd_help(ToxWindow *self, Tox *m, int argc, char **argv)
|
|||||||
wprintw(self->window, " * Use the TAB key to navigate through the tabs.\n\n");
|
wprintw(self->window, " * Use the TAB key to navigate through the tabs.\n\n");
|
||||||
wattroff(self->window, A_BOLD);
|
wattroff(self->window, A_BOLD);
|
||||||
|
|
||||||
wattroff(self->window, COLOR_PAIR(2));
|
wattroff(self->window, COLOR_PAIR(CYAN));
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_msg(ToxWindow *self, Tox *m, int argc, char **argv)
|
void cmd_msg(ToxWindow *self, Tox *m, int argc, char **argv)
|
||||||
@ -530,9 +530,9 @@ static void prompt_onDraw(ToxWindow *self, Tox *m)
|
|||||||
--y;
|
--y;
|
||||||
}
|
}
|
||||||
|
|
||||||
wattron(self->window, COLOR_PAIR(1));
|
wattron(self->window, COLOR_PAIR(GREEN));
|
||||||
mvwprintw(self->window, y, 0, "# ");
|
mvwprintw(self->window, y, 0, "# ");
|
||||||
wattroff(self->window, COLOR_PAIR(1));
|
wattroff(self->window, COLOR_PAIR(GREEN));
|
||||||
mvwprintw(self->window, y, 2, "%s", prompt_buf);
|
mvwprintw(self->window, y, 2, "%s", prompt_buf);
|
||||||
wclrtoeol(self->window);
|
wclrtoeol(self->window);
|
||||||
wrefresh(self->window);
|
wrefresh(self->window);
|
||||||
|
@ -24,6 +24,16 @@
|
|||||||
#define TOXICVER "NOVER" //Use the -D flag to set this
|
#define TOXICVER "NOVER" //Use the -D flag to set this
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Curses foreground colours (background is black) */
|
||||||
|
#define WHITE 0
|
||||||
|
#define GREEN 1
|
||||||
|
#define CYAN 2
|
||||||
|
#define RED 3
|
||||||
|
#define BLUE 4
|
||||||
|
#define YELLOW 5
|
||||||
|
#define MAGENTA 6
|
||||||
|
#define BLACK 7
|
||||||
|
|
||||||
typedef struct ToxWindow_ ToxWindow;
|
typedef struct ToxWindow_ ToxWindow;
|
||||||
|
|
||||||
struct ToxWindow_ {
|
struct ToxWindow_ {
|
||||||
|
@ -17,7 +17,7 @@ static ToxWindow *active_window;
|
|||||||
static ToxWindow *prompt;
|
static ToxWindow *prompt;
|
||||||
static Tox *m;
|
static Tox *m;
|
||||||
|
|
||||||
#define unknown_name "Unknown"
|
#define UNKNOWN_NAME "Unknown"
|
||||||
|
|
||||||
/* CALLBACKS START */
|
/* CALLBACKS START */
|
||||||
void on_request(uint8_t *public_key, uint8_t *data, uint16_t length, void *userdata)
|
void on_request(uint8_t *public_key, uint8_t *data, uint16_t length, void *userdata)
|
||||||
@ -46,7 +46,7 @@ void on_connectionchange(Tox *m, int friendnumber, uint8_t status, void *userdat
|
|||||||
tox_getname(m, friendnumber, (uint8_t *) &nick);
|
tox_getname(m, friendnumber, (uint8_t *) &nick);
|
||||||
|
|
||||||
if (!nick[0])
|
if (!nick[0])
|
||||||
snprintf(nick, sizeof(nick), "%s", unknown_name);
|
snprintf(nick, sizeof(nick), "%s", UNKNOWN_NAME);
|
||||||
|
|
||||||
if (status == 1)
|
if (status == 1)
|
||||||
wprintw(prompt->window, "\n%s has come online\n", nick, friendnumber);
|
wprintw(prompt->window, "\n%s has come online\n", nick, friendnumber);
|
||||||
@ -99,7 +99,7 @@ void on_statusmessagechange(Tox *m, int friendnumber, uint8_t *string, uint16_t
|
|||||||
tox_getname(m, friendnumber, (uint8_t *) &nick);
|
tox_getname(m, friendnumber, (uint8_t *) &nick);
|
||||||
|
|
||||||
if (!nick[0])
|
if (!nick[0])
|
||||||
snprintf(nick, sizeof(nick), "%s", unknown_name);
|
snprintf(nick, sizeof(nick), "%s", UNKNOWN_NAME);
|
||||||
|
|
||||||
wprintw(prompt->window, "\n%s set note to: %s\n", nick, string);
|
wprintw(prompt->window, "\n%s set note to: %s\n", nick, string);
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ void on_statuschange(Tox *m, int friendnumber, TOX_USERSTATUS status, void *user
|
|||||||
tox_getname(m, friendnumber, (uint8_t *) &nick);
|
tox_getname(m, friendnumber, (uint8_t *) &nick);
|
||||||
|
|
||||||
if (!nick[0])
|
if (!nick[0])
|
||||||
snprintf(nick, sizeof(nick), "%s", unknown_name);
|
snprintf(nick, sizeof(nick), "%s", UNKNOWN_NAME);
|
||||||
|
|
||||||
switch(status) {
|
switch(status) {
|
||||||
case TOX_USERSTATUS_NONE:
|
case TOX_USERSTATUS_NONE:
|
||||||
@ -127,16 +127,16 @@ void on_statuschange(Tox *m, int friendnumber, TOX_USERSTATUS status, void *user
|
|||||||
|
|
||||||
case TOX_USERSTATUS_BUSY:
|
case TOX_USERSTATUS_BUSY:
|
||||||
wprintw(prompt->window, "\n%s set status to ", nick);
|
wprintw(prompt->window, "\n%s set status to ", nick);
|
||||||
wattron(prompt->window, COLOR_PAIR(3));
|
wattron(prompt->window, COLOR_PAIR(RED));
|
||||||
wprintw(prompt->window, "[Busy]\n");
|
wprintw(prompt->window, "[Busy]\n");
|
||||||
wattroff(prompt->window, COLOR_PAIR(3));
|
wattroff(prompt->window, COLOR_PAIR(RED));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOX_USERSTATUS_AWAY:
|
case TOX_USERSTATUS_AWAY:
|
||||||
wprintw(prompt->window, "\n%s set status to ", nick);
|
wprintw(prompt->window, "\n%s set status to ", nick);
|
||||||
wattron(prompt->window, COLOR_PAIR(5));
|
wattron(prompt->window, COLOR_PAIR(YELLOW));
|
||||||
wprintw(prompt->window, "[Away]\n");
|
wprintw(prompt->window, "[Away]\n");
|
||||||
wattroff(prompt->window, COLOR_PAIR(5));
|
wattroff(prompt->window, COLOR_PAIR(YELLOW));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,15 +247,15 @@ static void draw_bar()
|
|||||||
static int odd = 0;
|
static int odd = 0;
|
||||||
int blinkrate = 30;
|
int blinkrate = 30;
|
||||||
|
|
||||||
attron(COLOR_PAIR(4));
|
attron(COLOR_PAIR(BLUE));
|
||||||
mvhline(LINES - 2, 0, '_', COLS);
|
mvhline(LINES - 2, 0, '_', COLS);
|
||||||
attroff(COLOR_PAIR(4));
|
attroff(COLOR_PAIR(BLUE));
|
||||||
|
|
||||||
move(LINES - 1, 0);
|
move(LINES - 1, 0);
|
||||||
|
|
||||||
attron(COLOR_PAIR(4) | A_BOLD);
|
attron(COLOR_PAIR(BLUE) | A_BOLD);
|
||||||
printw(" TOXIC " TOXICVER " |");
|
printw(" TOXIC " TOXICVER " |");
|
||||||
attroff(COLOR_PAIR(4) | A_BOLD);
|
attroff(COLOR_PAIR(BLUE) | A_BOLD);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -267,13 +267,13 @@ static void draw_bar()
|
|||||||
odd = (odd + 1) % blinkrate;
|
odd = (odd + 1) % blinkrate;
|
||||||
|
|
||||||
if (windows[i].blink && (odd < (blinkrate / 2)))
|
if (windows[i].blink && (odd < (blinkrate / 2)))
|
||||||
attron(COLOR_PAIR(3));
|
attron(COLOR_PAIR(RED));
|
||||||
|
|
||||||
clrtoeol();
|
clrtoeol();
|
||||||
printw(" %s", windows[i].title);
|
printw(" %s", windows[i].title);
|
||||||
|
|
||||||
if (windows[i].blink && (odd < (blinkrate / 2)))
|
if (windows[i].blink && (odd < (blinkrate / 2)))
|
||||||
attroff(COLOR_PAIR(3));
|
attroff(COLOR_PAIR(RED));
|
||||||
|
|
||||||
if (windows + i == active_window) {
|
if (windows + i == active_window) {
|
||||||
attroff(A_BOLD);
|
attroff(A_BOLD);
|
||||||
|
Loading…
Reference in New Issue
Block a user