nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 23c3fd9bcd17c6843d1f513334815e2bdee99157
parent c118397a14763c538403ca8bd77649eab6ee7f9e
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Tue, 21 Feb 2017 12:57:11 +0100

statusbar: display at most three consecutive alert messages

Cap the number of pauses when displaying ALERT messages, to avoid
making the user wait for ages when tens or hundreds of files were
specified on the command line.

This fixes https://savannah.gnu.org/bugs/?50362.
Reported-by: Mike Frysinger <vapier@gentoo.org>

Diffstat:
Msrc/winio.c | 15++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/winio.c b/src/winio.c @@ -2088,6 +2088,7 @@ void warn_and_shortly_pause(const char *msg) void statusline(message_type importance, const char *msg, ...) { va_list ap; + static int alerts = 0; char *compound, *message; size_t start_col; bool bracketed; @@ -2112,12 +2113,20 @@ void statusline(message_type importance, const char *msg, ...) (lastmessage == MILD && importance == HUSH)) return; - /* Delay another alert message, to allow an earlier one to be noticed. */ - if (lastmessage == ALERT) + /* If the ALERT status has been reset, reset the counter. */ + if (lastmessage == HUSH) + alerts = 0; + + /* Shortly pause after each of the first three alert messages, + * to give the user time to read them. */ + if (lastmessage == ALERT && alerts < 4) napms(1200); - if (importance == ALERT) + if (importance == ALERT) { + if (++alerts > 3) + msg = "Some warnings were suppressed"; beep(); + } lastmessage = importance;