diff options
author | James Booth <boothj5@gmail.com> | 2014-11-09 00:36:25 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-11-09 00:36:25 +0000 |
commit | fbda2b41701ec61a9b72dbde91000ad95d597b9f (patch) | |
tree | 1111bb8ae702f70d87d1860998484e2d45ea603d | |
parent | bcfbc9f7b33a9d2b4a1c454ea89d2d409c80cda0 (diff) | |
download | profani-tty-fbda2b41701ec61a9b72dbde91000ad95d597b9f.tar.gz |
Fixed history messages to work with wrapping
-rw-r--r-- | src/ui/core.c | 25 | ||||
-rw-r--r-- | src/ui/window.c | 8 | ||||
-rw-r--r-- | src/ui/window.h | 7 |
3 files changed, 26 insertions, 14 deletions
diff --git a/src/ui/core.c b/src/ui/core.c index 07434e2f..4f88c294 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -1706,13 +1706,6 @@ _ui_room_history(const char * const room_jid, const char * const nick, } else { GString *line = g_string_new(""); - GDateTime *time = g_date_time_new_from_timeval_utc(&tv_stamp); - gchar *date_fmt = g_date_time_format(time, "%H:%M:%S"); - g_string_append(line, date_fmt); - g_string_append(line, " - "); - g_date_time_unref(time); - g_free(date_fmt); - if (strncmp(message, "/me ", 4) == 0) { g_string_append(line, "*"); g_string_append(line, nick); @@ -1723,7 +1716,7 @@ _ui_room_history(const char * const room_jid, const char * const nick, g_string_append(line, message); } - win_save_print(window, '-', NULL, NO_DATE, 0, "", line->str); + win_save_print(window, '-', &tv_stamp, NO_COLOUR_DATE, 0, "", line->str); g_string_free(line, TRUE); } } @@ -3060,7 +3053,21 @@ _win_show_history(WINDOW *win, int win_index, const char * const contact) jid_destroy(jid); GSList *curr = history; while (curr != NULL) { - win_save_print(window, '-', NULL, NO_DATE, 0, "", curr->data); + char *line = curr->data; + // entry + if (line[2] == ':') { + char hh[3]; memcpy(hh, &line[0], 2); hh[2] = '\0'; int ihh = atoi(hh); + char mm[3]; memcpy(mm, &line[3], 2); mm[2] = '\0'; int imm = atoi(mm); + char ss[3]; memcpy(ss, &line[6], 2); ss[2] = '\0'; int iss = atoi(ss); + GDateTime *time = g_date_time_new_local(2000, 1, 1, ihh, imm, iss); + GTimeVal tv; + g_date_time_to_timeval(time, &tv); + win_save_print(window, '-', &tv, NO_COLOUR_DATE, 0, "", curr->data+11); + g_date_time_unref(time); + // header + } else { + win_save_print(window, '-', NULL, 0, 0, "", curr->data); + } curr = g_slist_next(curr); } window->history_shown = 1; diff --git a/src/ui/window.c b/src/ui/window.c index a9dac466..94c4cf2a 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -552,9 +552,13 @@ _win_print(ProfWin *window, const char show_char, const char * const date_fmt, int colour = COLOUR_ME; if ((flags & NO_DATE) == 0) { - wattron(window->win, COLOUR_TIME); + if ((flags & NO_COLOUR_DATE) == 0) { + wattron(window->win, COLOUR_TIME); + } wprintw(window->win, "%s %c ", date_fmt, show_char); - wattroff(window->win, COLOUR_TIME); + if ((flags & NO_COLOUR_DATE) == 0) { + wattroff(window->win, COLOUR_TIME); + } } if (strlen(from) > 0) { diff --git a/src/ui/window.h b/src/ui/window.h index 185bdd6e..4d864232 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -48,10 +48,11 @@ #include "ui/buffer.h" #include "xmpp/xmpp.h" -#define NO_ME 1 -#define NO_DATE 2 -#define NO_EOL 4 +#define NO_ME 1 +#define NO_DATE 2 +#define NO_EOL 4 #define NO_COLOUR_FROM 8 +#define NO_COLOUR_DATE 16 #define PAD_SIZE 1000 |