]> granicus.if.org Git - neomutt/commitdiff
Make mutt_curses_(error|message) format message to COLS chars. Closes #3278.
authorRocco Rutte <pdmef@gmx.net>
Mon, 22 Jun 2009 15:36:21 +0000 (17:36 +0200)
committerRocco Rutte <pdmef@gmx.net>
Mon, 22 Jun 2009 15:36:21 +0000 (17:36 +0200)
While I'm at it, fold both functions into one.

curs_lib.c

index 2427e609f235b9a544e7407e5ea03d54d0bbf752..47ccb08cba3cd5783831b69df2c81be5260c3660 100644 (file)
@@ -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,