From 866cafbf1b96426334d7658fb4b7f142a9ff1a9f Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Wed, 22 Jan 2014 23:29:28 -0500 Subject: [PATCH] timestamp for prompt connection and friend request alerts --- src/misc_tools.c | 2 +- src/prompt.c | 11 ++++++++--- src/toxic_strings.c | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/misc_tools.c b/src/misc_tools.c index 2a42932..a94087b 100644 --- a/src/misc_tools.c +++ b/src/misc_tools.c @@ -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; diff --git a/src/prompt.c b/src/prompt.c index 1aa804f..ea29692 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -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); diff --git a/src/toxic_strings.c b/src/toxic_strings.c index 5813edf..15cff71 100644 --- a/src/toxic_strings.c +++ b/src/toxic_strings.c @@ -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);