degesch: write date change messages earlier
This commit is contained in:
parent
ccc167d120
commit
8ed93ae03e
26
degesch.c
26
degesch.c
@ -1309,6 +1309,7 @@ struct app_context
|
||||
struct poller_fd signal_event; ///< Signal FD event
|
||||
|
||||
struct poller_timer flush_timer; ///< Flush all open files (e.g. logs)
|
||||
struct poller_timer date_chg_tmr; ///< Print a date change
|
||||
|
||||
struct poller poller; ///< Manages polled descriptors
|
||||
bool quitting; ///< User requested quitting
|
||||
@ -1326,7 +1327,6 @@ struct app_context
|
||||
// TODO: make buffer names fully unique like weechat does
|
||||
struct str_map buffers_by_name; ///< Buffers by name
|
||||
|
||||
// TODO: So that we always output proper date change messages
|
||||
time_t last_displayed_msg_time; ///< Time of last displayed message
|
||||
|
||||
// Terminal:
|
||||
@ -2967,6 +2967,9 @@ buffer_print_backlog (struct app_context *ctx, struct buffer *buffer)
|
||||
buffer->unseen_messages_count = 0;
|
||||
buffer->highlighted = false;
|
||||
|
||||
// So that it is obvious if the last line in the buffer is not from today
|
||||
buffer_update_time (ctx, time (NULL));
|
||||
|
||||
refresh_prompt (ctx);
|
||||
input_show (&ctx->input);
|
||||
}
|
||||
@ -9014,6 +9017,22 @@ on_flush_timer (struct app_context *ctx)
|
||||
rearm_flush_timer (ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
rearm_date_change_timer (struct app_context *ctx)
|
||||
{
|
||||
const time_t seconds_per_day = 60 * 60 * 12;
|
||||
poller_timer_set (&ctx->date_chg_tmr,
|
||||
(time (NULL) + seconds_per_day - 1)
|
||||
/ seconds_per_day * seconds_per_day * 1000);
|
||||
}
|
||||
|
||||
static void
|
||||
on_date_change_timer (struct app_context *ctx)
|
||||
{
|
||||
buffer_update_time (ctx, time (NULL));
|
||||
rearm_date_change_timer (ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
init_poller_events (struct app_context *ctx)
|
||||
{
|
||||
@ -9031,6 +9050,11 @@ init_poller_events (struct app_context *ctx)
|
||||
ctx->flush_timer.dispatcher = (poller_timer_fn) on_flush_timer;
|
||||
ctx->flush_timer.user_data = ctx;
|
||||
rearm_flush_timer (ctx);
|
||||
|
||||
poller_timer_init (&ctx->date_chg_tmr, &ctx->poller);
|
||||
ctx->flush_timer.dispatcher = (poller_timer_fn) on_date_change_timer;
|
||||
ctx->flush_timer.user_data = ctx;
|
||||
rearm_date_change_timer (ctx);
|
||||
}
|
||||
|
||||
// --- Main program ------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user