From: Daniel Carl Date: Thu, 11 Dec 2014 20:59:53 +0000 (+0100) Subject: Remove input timeout if inputbox was changed meanwhile. X-Git-Url: https://git.owens.tech/assets/favicon.png/assets/favicon.png/git?a=commitdiff_plain;h=4ca33a2ed057a8732621abfb0f8746e46abccaf3;p=vimb.git Remove input timeout if inputbox was changed meanwhile. If the user started a command that failed with error state, the input timeout was started. In case this was followed by a good command that prints output to inputbox, the output was cleared by the previous set timeout function. To fix this behaviour, the timeout is removed if the timer was started and the inputbox is changed. --- diff --git a/src/main.c b/src/main.c index 5f4cc4d..509d214 100644 --- a/src/main.c +++ b/src/main.c @@ -145,6 +145,8 @@ void vb_echo(const MessageType type, gboolean hide, const char *error, ...) static void input_print(gboolean force, const MessageType type, gboolean hide, const char *message) { + static guint timer = 0; + /* don't print message if the input is focussed */ if (!force && gtk_widget_is_focus(GTK_WIDGET(vb.gui.input))) { return; @@ -157,7 +159,14 @@ static void input_print(gboolean force, const MessageType type, gboolean hide, } vb_set_input_text(message); if (hide) { - g_timeout_add_seconds(MESSAGE_TIMEOUT, (GSourceFunc)hide_message, NULL); + /* add timeout function */ + timer = g_timeout_add_seconds(MESSAGE_TIMEOUT, (GSourceFunc)hide_message, NULL); + } else if (timer > 0) { + /* If there is already a timeout function but the input box content is + * changed - remove the timeout. Seems the user started another + * command or typed into inputbox. */ + g_source_remove(timer); + timer = 0; } }