mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Fixed history messages to work with wrapping
This commit is contained in:
parent
bcfbc9f7b3
commit
fbda2b4170
@ -1706,13 +1706,6 @@ _ui_room_history(const char * const room_jid, const char * const nick,
|
|||||||
} else {
|
} else {
|
||||||
GString *line = g_string_new("");
|
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) {
|
if (strncmp(message, "/me ", 4) == 0) {
|
||||||
g_string_append(line, "*");
|
g_string_append(line, "*");
|
||||||
g_string_append(line, nick);
|
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);
|
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);
|
g_string_free(line, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3060,7 +3053,21 @@ _win_show_history(WINDOW *win, int win_index, const char * const contact)
|
|||||||
jid_destroy(jid);
|
jid_destroy(jid);
|
||||||
GSList *curr = history;
|
GSList *curr = history;
|
||||||
while (curr != NULL) {
|
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);
|
curr = g_slist_next(curr);
|
||||||
}
|
}
|
||||||
window->history_shown = 1;
|
window->history_shown = 1;
|
||||||
|
@ -552,9 +552,13 @@ _win_print(ProfWin *window, const char show_char, const char * const date_fmt,
|
|||||||
int colour = COLOUR_ME;
|
int colour = COLOUR_ME;
|
||||||
|
|
||||||
if ((flags & NO_DATE) == 0) {
|
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);
|
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) {
|
if (strlen(from) > 0) {
|
||||||
|
@ -48,10 +48,11 @@
|
|||||||
#include "ui/buffer.h"
|
#include "ui/buffer.h"
|
||||||
#include "xmpp/xmpp.h"
|
#include "xmpp/xmpp.h"
|
||||||
|
|
||||||
#define NO_ME 1
|
#define NO_ME 1
|
||||||
#define NO_DATE 2
|
#define NO_DATE 2
|
||||||
#define NO_EOL 4
|
#define NO_EOL 4
|
||||||
#define NO_COLOUR_FROM 8
|
#define NO_COLOUR_FROM 8
|
||||||
|
#define NO_COLOUR_DATE 16
|
||||||
|
|
||||||
#define PAD_SIZE 1000
|
#define PAD_SIZE 1000
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user