Hi, I've attached a new version of Rocco's colored progress bar patch[*] for the default branch.
[*] http://marc.info/?l=mutt-dev&m=123730077818672 -- Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
diff -r 4ba366bc7c45 PATCHES --- a/PATCHES Tue Aug 12 14:04:55 2014 -0700 +++ b/PATCHES Thu Jan 15 11:21:28 2015 +0100 @@ -0,0 +1,1 @@ +patch-1.5.23hg.pdmef.progress.vl.1 diff -r 4ba366bc7c45 color.c --- a/color.c Tue Aug 12 14:04:55 2014 -0700 +++ b/color.c Thu Jan 15 11:21:28 2015 +0100 @@ -94,6 +94,7 @@ static const struct mapping_t Fields[] = { "underline", MT_COLOR_UNDERLINE }, { "index", MT_COLOR_INDEX }, { "prompt", MT_COLOR_PROMPT }, + { "progress", MT_COLOR_PROGRESS }, { NULL, 0 } }; diff -r 4ba366bc7c45 curs_lib.c --- a/curs_lib.c Tue Aug 12 14:04:55 2014 -0700 +++ b/curs_lib.c Thu Jan 15 11:21:28 2015 +0100 @@ -397,6 +397,52 @@ void mutt_progress_init (progress_t* pro 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); + clrtoeol (); + mutt_refresh(); + } + 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]; @@ -447,14 +493,14 @@ void mutt_progress_update (progress_t* p if (progress->size > 0) { - mutt_message ("%s %s/%s (%d%%)", progress->msg, posstr, progress->sizestr, - percent > 0 ? percent : - (int) (100.0 * (double) progress->pos / progress->size)); + message_bar (percent > 0 ? percent : (int) (100.0 * (double) progress->pos / progress->size), + "%s %s/%s (%d%%)", progress->msg, posstr, progress->sizestr, + percent > 0 ? percent : (int) (100.0 * (double) progress->pos / progress->size)); } else { if (percent > 0) - mutt_message ("%s %s (%d%%)", progress->msg, posstr, percent); + message_bar (percent, "%s %s (%d%%)", progress->msg, posstr, percent); else mutt_message ("%s %s", progress->msg, posstr); } diff -r 4ba366bc7c45 doc/manual.xml.head --- a/doc/manual.xml.head Tue Aug 12 14:04:55 2014 -0700 +++ b/doc/manual.xml.head Thu Jan 15 11:21:28 2015 +0100 @@ -2645,6 +2645,7 @@ specify one or the other). <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 -r 4ba366bc7c45 mutt_curses.h --- a/mutt_curses.h Tue Aug 12 14:04:55 2014 -0700 +++ b/mutt_curses.h Thu Jan 15 11:21:28 2015 +0100 @@ -121,6 +121,7 @@ enum MT_COLOR_UNDERLINE, MT_COLOR_INDEX, MT_COLOR_PROMPT, + MT_COLOR_PROGRESS, MT_COLOR_MAX };