Description: Colored progress bar.
 Patch written by Rocco Rutte on 2009-03-17
 <https://marc.info/?l=mutt-dev&m=123730077818672&w=2>,
 with a correction by Vincent Lefèvre on 2010-08-02
 <https://marc.info/?l=mutt-dev&m=128074817801186&w=2>, and
 other minor changes due to the evolution of the Mutt code.
Author: Rocco Rutte, Vincent Lefevre <vincent@vinc17.net>
Last-Update: 2026-05-10

diff --git a/PATCHES b/PATCHES
index e69de29b..ef39e779 100644
--- a/PATCHES
+++ b/PATCHES
@@ -0,0 +1 @@
+patch-20260510.pdmef.progress.vl.1
diff --git a/color.c b/color.c
index 41a75a30..cc39b6fc 100644
--- a/color.c
+++ b/color.c
@@ -110,6 +110,7 @@ static const struct mapping_t Fields[] =
   { "underline",        MT_COLOR_UNDERLINE },
   { "index",            MT_COLOR_INDEX },
   { "prompt",           MT_COLOR_PROMPT },
+  { "progress",         MT_COLOR_PROGRESS },
 #ifdef USE_SIDEBAR
   { "sidebar_divider",  MT_COLOR_DIVIDER },
   { "sidebar_flagged",  MT_COLOR_FLAGGED },
diff --git a/curs_lib.c b/curs_lib.c
index e9795558..c825f88c 100644
--- a/curs_lib.c
+++ b/curs_lib.c
@@ -718,6 +718,51 @@ void mutt_progress_init(progress_t *progress, const char *msg,
   mutt_progress_update(progress, 0, 0);
 }
 
+static void message_bar(int percent, const char *fmt, ...)
+{
+  va_list ap;
+  char buf[STRING], buf2[STRING];
+  int w = percent * COLS / 100;
+  size_t l;
+
+  va_start(ap, fmt);
+  vsnprintf(buf, sizeof(buf), fmt, ap);
+  l = mutt_strwidth(buf);
+  va_end(ap);
+
+  mutt_format_string(buf2, sizeof(buf2),
+                     0, COLS-2, FMT_LEFT, 0, buf, sizeof(buf), 0);
+
+  move(LINES - 1, 0);
+
+  if (l < w)
+  {
+    SETCOLOR(MT_COLOR_PROGRESS);
+    addstr(buf2);
+    w -= l;
+    while (w--)
+      addch(' ');
+    SETCOLOR(MT_COLOR_NORMAL);
+  }
+  else
+  {
+    size_t bw;
+    char ch;
+    int off = mutt_wstr_trunc(buf2, sizeof(buf2), w, &bw);
+
+    ch = buf2[off];
+    buf2[off] = 0;
+    SETCOLOR(MT_COLOR_PROGRESS);
+    addstr(buf2);
+    buf2[off] = ch;
+    SETCOLOR(MT_COLOR_NORMAL);
+    addstr(&buf2[off]);
+  }
+
+  clrtoeol();
+  mutt_refresh();
+}
+
 void mutt_progress_update(progress_t *progress, long pos, int percent)
 {
   char posstr[SHORT_STRING];
@@ -770,6 +815,9 @@ void mutt_progress_update(progress_t *progress, long pos, int percent)
 
     if (progress->size > 0)
     {
+      int percent2 = percent > 0 ? percent :
+        (int) (100.0 * (double) progress->pos / progress->size);
+
       /* L10N:
        * This is a progress status message, printed as longer-running actions
        * take place to give an update to the user.
@@ -785,10 +833,8 @@ void mutt_progress_update(progress_t *progress, long pos, int percent)
        * Note that the various punctuation and the format of the percentage
        * can be adjusted, including the order the parts are displayed in.
        */
-      mutt_message(_("%1$s %2$s/%3$s (%4$d%%)"),
-                   progress->msg, posstr, progress->sizestr,
-                   percent > 0 ? percent :
-                   (int) (100.0 * (double) progress->pos / progress->size));
+      message_bar(percent2, _("%1$s %2$s/%3$s (%4$d%%)"),
+                  progress->msg, posstr, progress->sizestr, percent2);
     }
     else
     {
@@ -808,7 +854,8 @@ void mutt_progress_update(progress_t *progress, long pos, int percent)
          * Note that the various punctuation and the format of the percentage
          * can be adjusted, including the order the parts are displayed in.
          */
-        mutt_message(_("%1$s %2$s (%3$d%%)"), progress->msg, posstr, percent);
+        message_bar(percent, _("%1$s %2$s (%3$d%%)"),
+                    progress->msg, posstr, percent);
       }
       else
         mutt_message("%s %s", progress->msg, posstr);
diff --git a/doc/manual.xml.head b/doc/manual.xml.head
index f37b81c2..761cf46c 100644
--- a/doc/manual.xml.head
+++ b/doc/manual.xml.head
@@ -3288,6 +3288,7 @@ When set, color is applied only to the exact text matched by
 <listitem><para>message (informational messages)</para></listitem>
 <listitem><para>normal</para></listitem>
 <listitem><para>prompt</para></listitem>
+<listitem><para>progress (visual progress bar)</para></listitem>
 <listitem><para>quoted (text matching <link linkend="quote-regexp">$quote_regexp</link> in the body of a message)</para></listitem>
 <listitem><para>quoted1, quoted2, ..., quoted<emphasis>N</emphasis> (higher levels of quoting)</para></listitem>
 <listitem><para>search (highlighting of words in the pager)</para></listitem>
diff --git a/mutt_curses.h b/mutt_curses.h
index cdd63c72..4d2758b7 100644
--- a/mutt_curses.h
+++ b/mutt_curses.h
@@ -122,6 +122,7 @@ enum
   MT_COLOR_UNDERLINE,
   MT_COLOR_INDEX,
   MT_COLOR_PROMPT,
+  MT_COLOR_PROGRESS,
 #ifdef USE_SIDEBAR
   MT_COLOR_DIVIDER,
   MT_COLOR_FLAGGED,
