mirror of
https://github.com/Tha14/toxic.git
synced 2024-12-23 15:43:24 +01:00
remove superfluous prompt alerts and some visual changes
This commit is contained in:
parent
f7d96b0779
commit
369233ba04
59
src/chat.c
59
src/chat.c
@ -136,32 +136,27 @@ static void chat_onStatusChange(ToxWindow *self, Tox *m, int num, TOX_USERSTATUS
|
||||
if (ctx->friendnum != num)
|
||||
return;
|
||||
|
||||
wattron(ctx->history, COLOR_PAIR(CYAN));
|
||||
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
||||
wattroff(ctx->history, COLOR_PAIR(CYAN));
|
||||
char *status_msg = NULL;
|
||||
int colour = 0;
|
||||
|
||||
switch(status) {
|
||||
if (status == TOX_USERSTATUS_BUSY) {
|
||||
status_msg = "[Busy]";
|
||||
colour = RED;
|
||||
}
|
||||
else if (status == TOX_USERSTATUS_AWAY) {
|
||||
status_msg = "[Away]";
|
||||
colour = YELLOW;
|
||||
}
|
||||
|
||||
case TOX_USERSTATUS_NONE:
|
||||
wprintw(ctx->history, "* Chat partner set status to ");
|
||||
wattron(ctx->history, COLOR_PAIR(GREEN));
|
||||
wprintw(ctx->history, "[Online]\n");
|
||||
wattroff(ctx->history, COLOR_PAIR(GREEN));
|
||||
break;
|
||||
if (status_msg != NULL) {
|
||||
wattron(ctx->history, COLOR_PAIR(CYAN));
|
||||
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
||||
wattroff(ctx->history, COLOR_PAIR(CYAN));
|
||||
|
||||
case TOX_USERSTATUS_BUSY:
|
||||
wprintw(ctx->history, "* Chat partner set status to ");
|
||||
wattron(ctx->history, COLOR_PAIR(RED));
|
||||
wprintw(ctx->history, "[Busy]\n");
|
||||
wattroff(ctx->history, COLOR_PAIR(RED));
|
||||
break;
|
||||
|
||||
case TOX_USERSTATUS_AWAY:
|
||||
wprintw(ctx->history, "* Chat partner set status to ");
|
||||
wattron(ctx->history, COLOR_PAIR(YELLOW));
|
||||
wprintw(ctx->history, "[Away]\n");
|
||||
wattroff(ctx->history, COLOR_PAIR(YELLOW));
|
||||
break;
|
||||
wprintw(ctx->history, "* Chat partner set status to: ");
|
||||
wattron(ctx->history, COLOR_PAIR(colour) | A_BOLD);
|
||||
wprintw(ctx->history, "%s\n", status_msg);
|
||||
wattroff(ctx->history, COLOR_PAIR(colour) | A_BOLD);
|
||||
}
|
||||
}
|
||||
|
||||
@ -378,26 +373,26 @@ void execute(ToxWindow *self, ChatContext *ctx, Tox *m, char *cmd)
|
||||
|
||||
if (!strncmp(status, "online", strlen("online"))) {
|
||||
status_kind = TOX_USERSTATUS_NONE;
|
||||
wprintw(ctx->history, "Status set to ");
|
||||
wattron(ctx->history, COLOR_PAIR(GREEN));
|
||||
wprintw(ctx->history, "Status set to: ");
|
||||
wattron(ctx->history, COLOR_PAIR(GREEN) | A_BOLD);
|
||||
wprintw(ctx->history, "[Online]\n");
|
||||
wattroff(ctx->history, COLOR_PAIR(GREEN));
|
||||
wattroff(ctx->history, COLOR_PAIR(GREEN) | A_BOLD);
|
||||
}
|
||||
|
||||
else if (!strncmp(status, "away", strlen("away"))) {
|
||||
status_kind = TOX_USERSTATUS_AWAY;
|
||||
wprintw(ctx->history, "Status set to ");
|
||||
wattron(ctx->history, COLOR_PAIR(YELLOW));
|
||||
wprintw(ctx->history, "Status set to: ");
|
||||
wattron(ctx->history, COLOR_PAIR(YELLOW) | A_BOLD);
|
||||
wprintw(ctx->history, "[Away]\n");
|
||||
wattroff(ctx->history, COLOR_PAIR(YELLOW));
|
||||
wattroff(ctx->history, COLOR_PAIR(YELLOW) | A_BOLD);
|
||||
}
|
||||
|
||||
else if (!strncmp(status, "busy", strlen("busy"))) {
|
||||
status_kind = TOX_USERSTATUS_BUSY;
|
||||
wprintw(ctx->history, "Status set to ");
|
||||
wattron(ctx->history, COLOR_PAIR(RED));
|
||||
wprintw(ctx->history, "Status set to: ");
|
||||
wattron(ctx->history, COLOR_PAIR(RED) | A_BOLD);
|
||||
wprintw(ctx->history, "[Busy]\n");
|
||||
wattroff(ctx->history, COLOR_PAIR(RED));
|
||||
wattroff(ctx->history, COLOR_PAIR(RED) | A_BOLD);
|
||||
}
|
||||
|
||||
else {
|
||||
|
@ -93,7 +93,7 @@ int friendlist_onFriendAdded(Tox *m, int num)
|
||||
friends[i].active = true;
|
||||
friends[i].chatwin = -1;
|
||||
friends[i].online = false;
|
||||
friends[i].status = TOX_USERSTATUS_INVALID;
|
||||
friends[i].status = TOX_USERSTATUS_NONE;
|
||||
|
||||
if (tox_getname(m, num, friends[i].name) != 0 || friends[i].name[0] == '\0')
|
||||
strcpy((char *) friends[i].name, "unknown");
|
||||
@ -150,10 +150,9 @@ static void delete_friend(Tox *m, ToxWindow *self, int f_num, wint_t key)
|
||||
break;
|
||||
}
|
||||
|
||||
if (store_data(m, DATA_FILE))
|
||||
wprintw(self->window, "\nFailed to store messenger data\n");
|
||||
|
||||
num_friends = i;
|
||||
|
||||
store_data(m, DATA_FILE);
|
||||
select_friend(m, KEY_DOWN);
|
||||
}
|
||||
|
||||
@ -212,9 +211,9 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
|
||||
}
|
||||
|
||||
wprintw(self->window, "[");
|
||||
wattron(self->window, COLOR_PAIR(colour));
|
||||
wattron(self->window, COLOR_PAIR(colour) | A_BOLD);
|
||||
wprintw(self->window, "O");
|
||||
wattroff(self->window, COLOR_PAIR(colour));
|
||||
wattroff(self->window, COLOR_PAIR(colour) | A_BOLD);
|
||||
wprintw(self->window, "] %s", friends[i].name);
|
||||
|
||||
if (friends[i].statusmsg[0])
|
||||
|
37
src/prompt.c
37
src/prompt.c
@ -314,7 +314,8 @@ void cmd_nick(ToxWindow *self, Tox *m, int argc, char **argv)
|
||||
}
|
||||
|
||||
nick = argv[1];
|
||||
nick[strlen(++nick)-1] = L'\0';
|
||||
if (nick[0] == '\"')
|
||||
nick[strlen(++nick)-1] = L'\0';
|
||||
|
||||
tox_setname(m, (uint8_t *) nick, strlen(nick) + 1);
|
||||
wprintw(self->window, "Nickname set to: %s\n", nick);
|
||||
@ -358,19 +359,31 @@ void cmd_status(ToxWindow *self, Tox *m, int argc, char **argv)
|
||||
|
||||
if (!strncmp(status, "online", strlen("online"))) {
|
||||
status_kind = TOX_USERSTATUS_NONE;
|
||||
status_text = "Online";
|
||||
} else if (!strncmp(status, "away", strlen("away"))) {
|
||||
status_kind = TOX_USERSTATUS_AWAY;
|
||||
status_text = "Away";
|
||||
} else if (!strncmp(status, "busy", strlen("busy"))) {
|
||||
status_kind = TOX_USERSTATUS_BUSY;
|
||||
status_text = "Busy";
|
||||
} else {
|
||||
wprintw(self->window, "Invalid status.\n");
|
||||
return;
|
||||
wprintw(self->window, "Status set to: ");
|
||||
wattron(self->window, COLOR_PAIR(GREEN) | A_BOLD);
|
||||
wprintw(self->window, "[Online]\n");
|
||||
wattroff(self->window, COLOR_PAIR(GREEN) | A_BOLD);
|
||||
}
|
||||
|
||||
wprintw(self->window, "Status set to: %s\n", status_text);
|
||||
else if (!strncmp(status, "away", strlen("away"))) {
|
||||
status_kind = TOX_USERSTATUS_AWAY;
|
||||
wprintw(self->window, "Status set to: ");
|
||||
wattron(self->window, COLOR_PAIR(YELLOW) | A_BOLD);
|
||||
wprintw(self->window, "[Away]\n");
|
||||
wattroff(self->window, COLOR_PAIR(YELLOW) | A_BOLD);
|
||||
}
|
||||
|
||||
else if (!strncmp(status, "busy", strlen("busy"))) {
|
||||
status_kind = TOX_USERSTATUS_BUSY;
|
||||
wprintw(self->window, "Status set to: ");
|
||||
wattron(self->window, COLOR_PAIR(RED) | A_BOLD);
|
||||
wprintw(self->window, "[Busy]\n");
|
||||
wattroff(self->window, COLOR_PAIR(RED) | A_BOLD);
|
||||
}
|
||||
|
||||
else
|
||||
wprintw(self->window, "Invalid status.\n");
|
||||
|
||||
tox_set_userstatus(m, status_kind);
|
||||
|
||||
if (msg != NULL) {
|
||||
|
@ -32,7 +32,7 @@ void on_request(uint8_t *public_key, uint8_t *data, uint16_t length, void *userd
|
||||
}
|
||||
|
||||
wprintw(prompt->window, "\nWith the message: %s\n", data);
|
||||
wprintw(prompt->window, "\nUse \"accept %d\" to accept it.\n", n);
|
||||
wprintw(prompt->window, "Type \"accept %d\" to accept it.\n", n);
|
||||
|
||||
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
|
||||
if (windows[i].onFriendRequest != NULL)
|
||||
@ -48,10 +48,18 @@ void on_connectionchange(Tox *m, int friendnumber, uint8_t status, void *userdat
|
||||
if (!nick[0])
|
||||
snprintf(nick, sizeof(nick), "%s", UNKNOWN_NAME);
|
||||
|
||||
if (status == 1)
|
||||
wprintw(prompt->window, "\n%s has come online\n", nick, friendnumber);
|
||||
else
|
||||
wprintw(prompt->window, "\n%s went offline\n", nick, friendnumber);
|
||||
if (status == 1) {
|
||||
wattron(prompt->window, A_BOLD);
|
||||
wprintw(prompt->window, "\n%s ", nick);
|
||||
wattroff(prompt->window, A_BOLD);
|
||||
wprintw(prompt->window, "has come online\n");
|
||||
} else {
|
||||
wattron(prompt->window, A_BOLD);
|
||||
wprintw(prompt->window, "\n%s ", nick);
|
||||
wattroff(prompt->window, A_BOLD);
|
||||
wprintw(prompt->window, "has gone offline\n");
|
||||
|
||||
}
|
||||
|
||||
int i;
|
||||
|
||||
@ -93,17 +101,6 @@ void on_nickchange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, v
|
||||
|
||||
void on_statusmessagechange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata)
|
||||
{
|
||||
/* Don't show default "Online" status message */
|
||||
if (strncmp(string, "Online", strlen(string))) {
|
||||
uint8_t nick[TOX_MAX_NAME_LENGTH] = {0};
|
||||
tox_getname(m, friendnumber, (uint8_t *) &nick);
|
||||
|
||||
if (!nick[0])
|
||||
snprintf(nick, sizeof(nick), "%s", UNKNOWN_NAME);
|
||||
|
||||
wprintw(prompt->window, "\n%s set note to: %s\n", nick, string);
|
||||
}
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
|
||||
@ -114,32 +111,6 @@ void on_statusmessagechange(Tox *m, int friendnumber, uint8_t *string, uint16_t
|
||||
|
||||
void on_statuschange(Tox *m, int friendnumber, TOX_USERSTATUS status, void *userdata)
|
||||
{
|
||||
uint8_t nick[TOX_MAX_NAME_LENGTH] = {0};
|
||||
tox_getname(m, friendnumber, (uint8_t *) &nick);
|
||||
|
||||
if (!nick[0])
|
||||
snprintf(nick, sizeof(nick), "%s", UNKNOWN_NAME);
|
||||
|
||||
switch(status) {
|
||||
case TOX_USERSTATUS_NONE:
|
||||
/* Disabled because it spams a second messages when user comes online */
|
||||
break;
|
||||
|
||||
case TOX_USERSTATUS_BUSY:
|
||||
wprintw(prompt->window, "\n%s set status to ", nick);
|
||||
wattron(prompt->window, COLOR_PAIR(RED));
|
||||
wprintw(prompt->window, "[Busy]\n");
|
||||
wattroff(prompt->window, COLOR_PAIR(RED));
|
||||
break;
|
||||
|
||||
case TOX_USERSTATUS_AWAY:
|
||||
wprintw(prompt->window, "\n%s set status to ", nick);
|
||||
wattron(prompt->window, COLOR_PAIR(YELLOW));
|
||||
wprintw(prompt->window, "[Away]\n");
|
||||
wattroff(prompt->window, COLOR_PAIR(YELLOW));
|
||||
break;
|
||||
}
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
|
||||
|
Loading…
Reference in New Issue
Block a user