mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Print timestamps correctly with /SB REDRAW
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@926 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
47eda740cc
commit
fab312dde3
@ -390,17 +390,14 @@ char *format_get_level_tag(THEME_REC *theme, TEXT_DEST_REC *dest)
|
|||||||
((level & (MSGLEVEL_NEVER|MSGLEVEL_LASTLOG)) == 0 && \
|
((level & (MSGLEVEL_NEVER|MSGLEVEL_LASTLOG)) == 0 && \
|
||||||
(timestamps || (msgs_timestamps && ((level) & MSGLEVEL_MSGS))))
|
(timestamps || (msgs_timestamps && ((level) & MSGLEVEL_MSGS))))
|
||||||
|
|
||||||
static char *get_timestamp(THEME_REC *theme, TEXT_DEST_REC *dest)
|
static char *get_timestamp(THEME_REC *theme, TEXT_DEST_REC *dest, time_t t)
|
||||||
{
|
{
|
||||||
struct tm *tm;
|
struct tm *tm;
|
||||||
time_t t;
|
|
||||||
int diff;
|
int diff;
|
||||||
|
|
||||||
if (!show_timestamp(dest->level))
|
if (!show_timestamp(dest->level))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
t = time(NULL);
|
|
||||||
|
|
||||||
if (timestamp_timeout > 0) {
|
if (timestamp_timeout > 0) {
|
||||||
diff = t - dest->window->last_timestamp;
|
diff = t - dest->window->last_timestamp;
|
||||||
dest->window->last_timestamp = t;
|
dest->window->last_timestamp = t;
|
||||||
@ -442,12 +439,12 @@ static char *get_server_tag(THEME_REC *theme, TEXT_DEST_REC *dest)
|
|||||||
IRCTXT_SERVERTAG, server->tag);
|
IRCTXT_SERVERTAG, server->tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *format_get_line_start(THEME_REC *theme, TEXT_DEST_REC *dest)
|
char *format_get_line_start(THEME_REC *theme, TEXT_DEST_REC *dest, time_t t)
|
||||||
{
|
{
|
||||||
char *timestamp, *servertag;
|
char *timestamp, *servertag;
|
||||||
char *linestart;
|
char *linestart;
|
||||||
|
|
||||||
timestamp = get_timestamp(theme, dest);
|
timestamp = get_timestamp(theme, dest, t);
|
||||||
servertag = get_server_tag(theme, dest);
|
servertag = get_server_tag(theme, dest);
|
||||||
|
|
||||||
if (timestamp == NULL && servertag == NULL)
|
if (timestamp == NULL && servertag == NULL)
|
||||||
|
@ -65,7 +65,7 @@ char *format_add_linestart(const char *text, const char *linestart);
|
|||||||
char *format_get_level_tag(THEME_REC *theme, TEXT_DEST_REC *dest);
|
char *format_get_level_tag(THEME_REC *theme, TEXT_DEST_REC *dest);
|
||||||
|
|
||||||
/* return timestamp + server tag */
|
/* return timestamp + server tag */
|
||||||
char *format_get_line_start(THEME_REC *theme, TEXT_DEST_REC *dest);
|
char *format_get_line_start(THEME_REC *theme, TEXT_DEST_REC *dest, time_t t);
|
||||||
|
|
||||||
|
|
||||||
/* "private" functions for printtext */
|
/* "private" functions for printtext */
|
||||||
|
@ -287,7 +287,7 @@ static void sig_print_text(TEXT_DEST_REC *dest, const char *text)
|
|||||||
|
|
||||||
/* add timestamp/server tag here - if it's done in print_line()
|
/* add timestamp/server tag here - if it's done in print_line()
|
||||||
it would be written to log files too */
|
it would be written to log files too */
|
||||||
tmp = format_get_line_start(current_theme, dest);
|
tmp = format_get_line_start(current_theme, dest, time(NULL));
|
||||||
str = format_add_linestart(text, tmp);
|
str = format_add_linestart(text, tmp);
|
||||||
g_free_not_null(tmp);
|
g_free_not_null(tmp);
|
||||||
|
|
||||||
|
@ -1021,17 +1021,14 @@ void gui_window_reformat_line(WINDOW_REC *window, LINE_REC *line)
|
|||||||
raw = g_string_new(NULL);
|
raw = g_string_new(NULL);
|
||||||
str = gui_window_line_get_format(window, line, raw);
|
str = gui_window_line_get_format(window, line, raw);
|
||||||
|
|
||||||
if (str == NULL) {
|
if (str == NULL && raw->len == 2 &&
|
||||||
if (raw->len == 2 &&
|
|
||||||
raw->str[1] == (char)LINE_CMD_FORMAT_CONT) {
|
raw->str[1] == (char)LINE_CMD_FORMAT_CONT) {
|
||||||
/* multiline format, format explained in one the
|
/* multiline format, format explained in one the
|
||||||
following lines. remove this line. */
|
following lines. remove this line. */
|
||||||
gui_window_line_remove(window, line);
|
gui_window_line_remove(window, line);
|
||||||
}
|
} else if (str != NULL) {
|
||||||
} else {
|
/* FIXME: ugly ugly .. and this can't handle
|
||||||
/* FIXME: ugly ugly .. at least timestamps should be
|
non-formatted lines.. */
|
||||||
printed by GUI itself.. server tags are also a bit
|
|
||||||
problematic.. */
|
|
||||||
g_string_append_c(raw, '\0');
|
g_string_append_c(raw, '\0');
|
||||||
g_string_append_c(raw, (char)LINE_CMD_EOL);
|
g_string_append_c(raw, (char)LINE_CMD_EOL);
|
||||||
|
|
||||||
@ -1044,7 +1041,7 @@ void gui_window_reformat_line(WINDOW_REC *window, LINE_REC *line)
|
|||||||
|
|
||||||
format_create_dest(&dest, NULL, NULL, line->level, window);
|
format_create_dest(&dest, NULL, NULL, line->level, window);
|
||||||
|
|
||||||
linestart = format_get_line_start(current_theme, &dest);
|
linestart = format_get_line_start(current_theme, &dest, line->time);
|
||||||
leveltag = format_get_level_tag(current_theme, &dest);
|
leveltag = format_get_level_tag(current_theme, &dest);
|
||||||
|
|
||||||
prestr = g_strconcat(linestart == NULL ? "" : linestart,
|
prestr = g_strconcat(linestart == NULL ? "" : linestart,
|
||||||
|
Loading…
Reference in New Issue
Block a user