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

timestamp for prompt connection and friend request alerts

This commit is contained in:
Jfreegman 2014-01-22 23:29:28 -05:00
parent 06b09cd981
commit 866cafbf1b
3 changed files with 11 additions and 5 deletions

View File

@ -59,7 +59,7 @@ int string_is_empty(char *string)
}
/* convert a multibyte string to a wide character string (must provide buffer) */
int char_to_wcs_buf(wchar_t *buf, const uint8_t *string, size_t n)
int mbs_to_wcs_buf(wchar_t *buf, const uint8_t *string, size_t n)
{
size_t len = mbstowcs(NULL, string, 0) + 1;

View File

@ -360,17 +360,20 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, int friendnum , u
if (!nick[0])
snprintf(nick, sizeof(nick), "%s", UNKNOWN_NAME);
wprintw(self->window, "\n");
print_time(self->window);
if (status == 1) {
wattron(self->window, COLOR_PAIR(GREEN));
wattron(self->window, A_BOLD);
wprintw(self->window, "\n%s ", nick);
wprintw(self->window, "* %s ", nick);
wattroff(self->window, A_BOLD);
wprintw(self->window, "has come online\n");
wattroff(self->window, COLOR_PAIR(GREEN));
} else {
wattron(self->window, COLOR_PAIR(RED));
wattron(self->window, A_BOLD);
wprintw(self->window, "\n%s ", nick);
wprintw(self->window, "* %s ", nick);
wattroff(self->window, A_BOLD);
wprintw(self->window, "has gone offline\n");
wattroff(self->window, COLOR_PAIR(RED));
@ -383,7 +386,9 @@ static void prompt_onFriendRequest(ToxWindow *self, uint8_t *key, uint8_t *data,
data[length - 1] = 0;
prep_prompt_win();
wprintw(self->window, "\nFriend request with the message: '%s'\n", data);
wprintw(self->window, "\n");
print_time(self->window);
wprintw(self->window, "Friend request with the message: '%s'\n", data);
int n = add_friend_request(key);

View File

@ -132,6 +132,7 @@ void fetch_hist_item(wchar_t *buf, size_t *pos, size_t *len, wchar_t (*hst)[MAX_
} else {
if (++(*hst_pos) >= hst_tot) {
--(*hst_pos);
beep();
return;
}
}
@ -214,7 +215,7 @@ int complete_line(wchar_t *buf, size_t *pos, size_t *len, const void *list, int
/* convert to widechar and copy back to original buf */
wchar_t newbuf[MAX_STR_SIZE];
if (char_to_wcs_buf(newbuf, ubuf, MAX_STR_SIZE) == -1)
if (mbs_to_wcs_buf(newbuf, ubuf, MAX_STR_SIZE) == -1)
return -1;
wcscpy(buf, newbuf);