#include <lib-crypt/crypt.h>
-#define SW (option(OPTMBOXPANE)?SidebarWidth:0)
-
/* Modified by blong to accept a "suggestion" for file name. If
* that file exists, then construct one with unique name but
* keep any extension. This might fail, I guess.
}
}
-ssize_t m_strformat(char *dst, ssize_t dlen, const char *fmt,
+ssize_t m_strformat(char *dst, ssize_t dlen, int width, const char *fmt,
format_t *callback, anytype cdata, format_flag flags)
{
ssize_t pos = flags & M_FORMAT_ARROWCURSOR ? 3 : 0;
m_strpad(dst, dlen, '\0', pos + 1);
if (!fmt)
- return;
+ return pos;
while (*fmt) {
int ch;
}
switch (ch) {
- ssize_t col;
char lower, nodots, buf[LONG_STRING];
case '>': /* right justify to EOL */
- col = mutt_strwidth(dst);
+ width -= mutt_strwidth(dst);
ch = *fmt++; /* pad char */
- if (COLS - SW > col) {
- m_strformat(buf, sizeof(buf), fmt, callback, cdata, flags);
- pos += m_strpad(dst + pos, dlen - pos, ch,
- COLS - SW - col - mutt_strwidth(buf));
+ if (width > 0) {
+ m_strformat(buf, sizeof(buf), 0, fmt, callback, cdata, flags);
+ width -= mutt_strwidth(buf);
+ pos += m_strpad(dst + pos, dlen - pos, ch, width);
pos += m_strcpy(dst + pos, dlen - pos, buf);
}
return pos; /* skip rest of input */
case '|': /* pad to EOL */
- return pos + m_strpad(dst + pos, dlen - pos, *fmt,
- COLS - SW - mutt_strwidth(dst));
+ width -= mutt_strwidth(dst);
+ return pos + m_strpad(dst + pos, dlen - pos, *fmt, width);
default:
lower = nodots = 0;