From: Kevin McCarthy Date: Thu, 14 Apr 2016 19:35:50 +0000 (-0700) Subject: Pre-space softfill multi-column padding. X-Git-Tag: neomutt-20160822~172 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eebc23bb847d59098bf927622fa33334bb65d948;p=neomutt Pre-space softfill multi-column padding. Similar to the previous patch, this deals with multi-column padding characters and soft-fill. This will add spacing so the padding and content after padding aligns with the right side. You can see the effect by setting set index_format="%s %*我[ooooo]" and resizing the terminal. The right hand side will be jagged without the patch. --- diff --git a/muttlib.c b/muttlib.c index 382be6e4a..309f1bfed 100644 --- a/muttlib.c +++ b/muttlib.c @@ -1291,14 +1291,26 @@ void mutt_FormatString (char *dest, /* output buffer */ len = mutt_strlen (buf); wid = mutt_strwidth (buf); - /* try to consume as many columns as we can, if we don't have - * memory for that, use as much memory as possible */ pad = (COLS - col - wid) / pw; - if (pad > 0 && wlen + (pad * pl) + len > destlen) - pad = ((signed)(destlen - wlen - len)) / pl; - if (pad > 0) + if (pad >= 0) { - while (pad--) + /* try to consume as many columns as we can, if we don't have + * memory for that, use as much memory as possible */ + if (wlen + (pad * pl) + len > destlen) + pad = ((signed)(destlen - wlen - len)) / pl; + else + { + /* Add pre-spacing to make multi-column pad characters and + * the contents after padding line up */ + while ((col + (pad * pw) + wid < COLS) && + (wlen + (pad * pl) + len < destlen)) + { + *wptr++ = ' '; + wlen++; + col++; + } + } + while (pad-- > 0) { memcpy (wptr, src, pl); wptr += pl;