statusbar: show only the first error message, with dots to indicate more

The old default behavior of showing the first three messages with a
long pause after each of them was annoying, and the final "Further
messages were suppressed" hid the relevant information.  So, when
there is more than one error message, just pause very briefly and
then add trailing dots to the first message.

This makes the 'nopauses' option a no-op.

This addresses https://savannah.gnu.org/bugs/?57048.
master
Benno Schulenberg 2019-10-12 14:17:30 +02:00
parent bfdc31fbb4
commit 7f8851caa8
1 changed files with 16 additions and 14 deletions

View File

@ -2184,10 +2184,9 @@ void warn_and_shortly_pause(const char *msg)
void statusline(message_type importance, const char *msg, ...) void statusline(message_type importance, const char *msg, ...)
{ {
va_list ap; va_list ap;
static int alerts = 0;
int colorpair; int colorpair;
char *compound, *message; char *compound, *message;
size_t start_col; static size_t start_col = 0;
bool bracketed; bool bracketed;
#ifndef NANO_TINY #ifndef NANO_TINY
bool old_whitespace = ISSET(WHITESPACE_DISPLAY); bool old_whitespace = ISSET(WHITESPACE_DISPLAY);
@ -2210,20 +2209,23 @@ void statusline(message_type importance, const char *msg, ...)
} }
#endif #endif
/* If the ALERT status has been reset, reset the counter. */ /* If there are multiple alert messages, add trailing dots to the first. */
if (lastmessage == HUSH) if (lastmessage == ALERT) {
alerts = 0; if (start_col > 4) {
wmove(bottomwin, 0, COLS + 2 - start_col);
/* Shortly pause after each of the first three alert messages, wattron(bottomwin, interface_color_pair[ERROR_MESSAGE]);
* to give the user time to read them. */ waddstr(bottomwin, "...");
if (lastmessage == ALERT && alerts < 4 && !ISSET(NO_PAUSES)) wattroff(bottomwin, interface_color_pair[ERROR_MESSAGE]);
napms(1200); wnoutrefresh(bottomwin);
start_col = 0;
napms(100);
beep();
}
return;
}
if (importance == ALERT) { if (importance == ALERT) {
if (++alerts > 3 && !ISSET(NO_PAUSES)) beep();
msg = _("Further warnings were suppressed");
else if (alerts < 4)
beep();
colorpair = interface_color_pair[ERROR_MESSAGE]; colorpair = interface_color_pair[ERROR_MESSAGE];
} else if (importance == NOTICE) } else if (importance == NOTICE)
colorpair = interface_color_pair[SELECTED_TEXT]; colorpair = interface_color_pair[SELECTED_TEXT];