aboutsummaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/degesch.c b/degesch.c
index adc2c3e..4eabdeb 100644
--- a/degesch.c
+++ b/degesch.c
@@ -1977,6 +1977,7 @@ struct app_context
struct input *input; ///< User interface
+ struct poller_idle prompt_event; ///< Deferred prompt refresh
struct poller_idle input_event; ///< Pending input event
struct str_vector pending_input; ///< Pending input lines
@@ -2107,7 +2108,14 @@ app_context_free (struct app_context *self)
free (self->editor_filename);
}
-static void refresh_prompt (struct app_context *ctx);
+static void
+refresh_prompt (struct app_context *ctx)
+{
+ // XXX: the need for this conditional could probably be resolved
+ // by some clever reordering
+ if (ctx->prompt_event.poller)
+ poller_idle_set (&ctx->prompt_event);
+}
// --- Configuration -----------------------------------------------------------
@@ -5860,10 +5868,10 @@ input_maybe_set_prompt (struct input *self, char *new_prompt)
CALL_ (self, set_prompt, new_prompt);
}
-// TODO: do this in an idle task so as to not call this unnecessarily
static void
-refresh_prompt (struct app_context *ctx)
+on_refresh_prompt (struct app_context *ctx)
{
+ poller_idle_reset (&ctx->prompt_event);
bool have_attributes = !!get_attribute_printer (stdout);
struct str prompt;
@@ -13290,6 +13298,10 @@ init_poller_events (struct app_context *ctx)
ctx->autoaway_tmr.dispatcher = (poller_timer_fn) on_autoaway_timer;
ctx->autoaway_tmr.user_data = ctx;
+ poller_idle_init (&ctx->prompt_event, &ctx->poller);
+ ctx->prompt_event.dispatcher = (poller_idle_fn) on_refresh_prompt;
+ ctx->prompt_event.user_data = ctx;
+
poller_idle_init (&ctx->input_event, &ctx->poller);
ctx->input_event.dispatcher = (poller_idle_fn) on_pending_input;
ctx->input_event.user_data = ctx;
@@ -13528,7 +13540,7 @@ main (int argc, char *argv[])
config_schema_call_changed (ctx.config.root);
// Initialize input so that we can switch to new buffers
- refresh_prompt (&ctx);
+ on_refresh_prompt (&ctx);
ctx.input->add_functions = input_add_functions;
CALL_ (ctx.input, start, argv[0]);
toggle_bracketed_paste (true);