diff options
author | Rocco Rutte <pdmef@gmx.net> | 2009-06-22 17:36:21 +0200 |
---|---|---|
committer | Rocco Rutte <pdmef@gmx.net> | 2009-06-22 17:36:21 +0200 |
commit | 3813c6a0aa6a43f5f33a2272eea2f88fbbbc6e5b (patch) | |
tree | fc1b412a9dcaf828c66a6fdfef66ebb1e5971ac1 /curs_lib.c | |
parent | bfddfb411272a9f5da7139a50b23ea939aac9d34 (diff) |
Make mutt_curses_(error|message) format message to COLS chars. Closes #3278.
While I'm at it, fold both functions into one.
Diffstat (limited to 'curs_lib.c')
-rw-r--r-- | curs_lib.c | 40 |
1 files changed, 17 insertions, 23 deletions
@@ -295,54 +295,48 @@ void mutt_query_exit (void) SigInt = 0; } -void mutt_curses_error (const char *fmt, ...) +static void curses_message (int error, const char *fmt, va_list ap) { - va_list ap; char scratch[LONG_STRING]; - va_start (ap, fmt); vsnprintf (scratch, sizeof (scratch), fmt, ap); - va_end (ap); - + dprint (1, (debugfile, "%s\n", scratch)); mutt_format_string (Errorbuf, sizeof (Errorbuf), - 0, COLS-2, FMT_LEFT, 0, scratch, sizeof (scratch), 0); + 0, COLS, FMT_LEFT, 0, scratch, sizeof (scratch), 0); if (!option (OPTKEEPQUIET)) { BEEP (); - SETCOLOR (MT_COLOR_ERROR); + SETCOLOR (error ? MT_COLOR_ERROR : MT_COLOR_MESSAGE); mvaddstr (LINES-1, 0, Errorbuf); clrtoeol (); SETCOLOR (MT_COLOR_NORMAL); mutt_refresh (); } - set_option (OPTMSGERR); + if (error) + set_option (OPTMSGERR); + else + unset_option (OPTMSGERR); } -void mutt_curses_message (const char *fmt, ...) +void mutt_curses_error (const char *fmt, ...) { va_list ap; - char scratch[LONG_STRING]; va_start (ap, fmt); - vsnprintf (scratch, sizeof (scratch), fmt, ap); + curses_message (1, fmt, ap); va_end (ap); +} - mutt_format_string (Errorbuf, sizeof (Errorbuf), - 0, COLS-2, FMT_LEFT, 0, scratch, sizeof (scratch), 0); - - if (!option (OPTKEEPQUIET)) - { - SETCOLOR (MT_COLOR_MESSAGE); - mvaddstr (LINES - 1, 0, Errorbuf); - clrtoeol (); - SETCOLOR (MT_COLOR_NORMAL); - mutt_refresh (); - } +void mutt_curses_message (const char *fmt, ...) +{ + va_list ap; - unset_option (OPTMSGERR); + va_start (ap, fmt); + curses_message (0, fmt, ap); + va_end (ap); } void mutt_progress_init (progress_t* progress, const char *msg, |