X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=muttlib.c;h=0340d20d67a4ad9987de509e74056abd0c50238f;hb=f1ca09e359410e2b578a24a647fc383edd5ab4b5;hp=6e95088c64c9597a37c9e15e888c4ab12261db53;hpb=f404a0ca916be07049af51a3022baaaaab94def6;p=apps%2Fmadmutt.git diff --git a/muttlib.c b/muttlib.c index 6e95088..0340d20 100644 --- a/muttlib.c +++ b/muttlib.c @@ -929,6 +929,23 @@ void mutt_safe_path (char *s, size_t l, ADDRESS *a) *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 */ @@ -1026,10 +1043,10 @@ void mutt_FormatString (char *dest, /* output buffer */ 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 */ @@ -1042,8 +1059,10 @@ void mutt_FormatString (char *dest, /* output buffer */ 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; @@ -1134,9 +1153,15 @@ void mutt_FormatString (char *dest, /* output buffer */ } 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; @@ -1469,7 +1494,7 @@ time_t mutt_decrease_mtime (const char *f, struct stat *st) const char *mutt_make_version (void) { static char vstring[STRING]; - snprintf (vstring, sizeof (vstring), "Mutt %s (%s)", + snprintf (vstring, sizeof (vstring), "Mutt-ng %s (%s)", MUTT_VERSION, ReleaseDate); return vstring; }