*p = '_';
}
+/* counts how many characters in s can be skipped while none of the
+ * characters of c appears */
+int mutt_skipchars (const char* s, const char* c) {
+ int ret = 0;
+ const char* p = s;
+ while (s && *s) {
+ register const char* t = c;
+ while (t && *t) {
+ if (*t == *s)
+ return (ret);
+ t++;
+ }
+ ret++;
+ s++;
+ }
+ return (mutt_strlen (p));
+}
void mutt_FormatString (char *dest, /* output buffer */
size_t destlen, /* output buffer len */
ch = *src++; /* pad char */
/* calculate space left on line. if we've already written more data
than will fit on the line, ignore the rest of the line */
- if ( DrawFullLine )
+ if ( DrawFullLine || option(OPTSTATUSONTOP))
count = (COLS < destlen ? COLS : destlen);
else
- count = ((COLS-SidebarWidth) < destlen ? COLS - SidebarWidth : destlen);
+ count = ((COLS-SidebarWidth) < destlen ? (COLS - SidebarWidth) : destlen);
if (count > col)
{
count -= col; /* how many columns left on this line */
wptr += count;
col += count;
}
- if (len + wlen > destlen)
+ if (wid + wlen > destlen)
len = destlen - wlen;
+ else
+ len = wid;
memcpy (wptr, buf, len);
wptr += len;
wlen += len;
}
else
{
- *wptr++ = *src++;
- wlen++;
- col++;
+ unsigned int bar = mutt_skipchars (src, "%\\");
+ char* bar2 = safe_malloc (bar+1);
+ strfcpy (bar2, src, bar+1);
+ while (bar--) {
+ *wptr++ = *src++;
+ wlen++;
+ }
+ col += mutt_strwidth (bar2);
+ FREE(&bar2);
}
}
*wptr = 0;