};
static const char *
-alias_format_str (char *dest, size_t destlen, size_t col, char op, const char *src,
+alias_format_str (char *dest, size_t destlen, size_t col, int cols, char op, const char *src,
const char *fmt, const char *ifstring, const char *elsestring,
unsigned long data, format_flag flags)
{
static void alias_entry (char *s, size_t slen, MUTTMENU *m, int num)
{
- mutt_FormatString (s, slen, 0, NONULL (AliasFmt), alias_format_str, (unsigned long) ((ALIAS **) m->data)[num], M_FORMAT_ARROWCURSOR);
+ mutt_FormatString (s, slen, 0, MuttIndexWindow->cols, NONULL (AliasFmt), alias_format_str, (unsigned long) ((ALIAS **) m->data)[num], M_FORMAT_ARROWCURSOR);
}
static int alias_tag (MUTTMENU *menu, int n, int m)
}
static const char *
-folder_format_str (char *dest, size_t destlen, size_t col, char op, const char *src,
+folder_format_str (char *dest, size_t destlen, size_t col, int cols, char op, const char *src,
const char *fmt, const char *ifstring, const char *elsestring,
unsigned long data, format_flag flags)
{
}
if (optional)
- mutt_FormatString (dest, destlen, col, ifstring, folder_format_str, data, 0);
+ mutt_FormatString (dest, destlen, col, cols, ifstring, folder_format_str, data, 0);
else if (flags & M_FORMAT_OPTIONAL)
- mutt_FormatString (dest, destlen, col, elsestring, folder_format_str, data, 0);
+ mutt_FormatString (dest, destlen, col, cols, elsestring, folder_format_str, data, 0);
return (src);
}
folder.ff = &((struct folder_file *) menu->data)[num];
folder.num = num;
- mutt_FormatString (s, slen, 0, NONULL(FolderFormat), folder_format_str,
+ mutt_FormatString (s, slen, 0, MuttIndexWindow->cols, NONULL(FolderFormat), folder_format_str,
(unsigned long) &folder, M_FORMAT_ARROWCURSOR);
}
static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
{
- mutt_FormatString (b, blen, 0, NONULL (AttachFormat), mutt_attach_fmt,
+ mutt_FormatString (b, blen, 0, MuttIndexWindow->cols, NONULL (AttachFormat), mutt_attach_fmt,
(unsigned long)(((ATTACHPTR **) menu->data)[num]),
M_FORMAT_STAT_FILE | M_FORMAT_ARROWCURSOR);
}
}
/* prototype for use below */
-static void compose_status_line (char *buf, size_t buflen, size_t col, MUTTMENU *menu,
+static void compose_status_line (char *buf, size_t buflen, size_t col, int cols, MUTTMENU *menu,
const char *p);
/*
*/
static const char *
-compose_format_str (char *buf, size_t buflen, size_t col, char op, const char *src,
+compose_format_str (char *buf, size_t buflen, size_t col, int cols, char op, const char *src,
const char *prefix, const char *ifstring,
const char *elsestring,
unsigned long data, format_flag flags)
}
if (optional)
- compose_status_line (buf, buflen, col, menu, ifstring);
+ compose_status_line (buf, buflen, col, cols, menu, ifstring);
else if (flags & M_FORMAT_OPTIONAL)
- compose_status_line (buf, buflen, col, menu, elsestring);
+ compose_status_line (buf, buflen, col, cols, menu, elsestring);
return (src);
}
-static void compose_status_line (char *buf, size_t buflen, size_t col, MUTTMENU *menu,
- const char *p)
+static void compose_status_line (char *buf, size_t buflen, size_t col, int cols,
+ MUTTMENU *menu, const char *p)
{
- mutt_FormatString (buf, buflen, col, p, compose_format_str,
+ mutt_FormatString (buf, buflen, col, cols, p, compose_format_str,
(unsigned long) menu, 0);
}
/* Draw formatted compose status line */
if (menu->redraw & REDRAW_STATUS)
{
- compose_status_line (buf, sizeof (buf), 0, menu, NONULL(ComposeFormat));
+ compose_status_line (buf, sizeof (buf), 0, MuttStatusWindow->cols, menu, NONULL(ComposeFormat));
mutt_window_move (MuttStatusWindow, 0, 0);
SETCOLOR (MT_COLOR_STATUS);
mutt_paddstr (MuttStatusWindow->cols, buf);
static const char *crypt_entry_fmt (char *dest,
size_t destlen,
size_t col,
+ int cols,
char op,
const char *src,
const char *prefix,
}
if (optional)
- mutt_FormatString (dest, destlen, col, ifstring, mutt_attach_fmt, data, 0);
+ mutt_FormatString (dest, destlen, col, cols, ifstring, mutt_attach_fmt, data, 0);
else if (flags & M_FORMAT_OPTIONAL)
- mutt_FormatString (dest, destlen, col, elsestring, mutt_attach_fmt, data, 0);
+ mutt_FormatString (dest, destlen, col, cols, elsestring, mutt_attach_fmt, data, 0);
return (src);
}
entry.key = key_table[num];
entry.num = num + 1;
- mutt_FormatString (s, l, 0, NONULL (PgpEntryFormat), crypt_entry_fmt,
+ mutt_FormatString (s, l, 0, MuttIndexWindow->cols, NONULL (PgpEntryFormat), crypt_entry_fmt,
(unsigned long) &entry, M_FORMAT_ARROWCURSOR);
}
hdr_format_str (char *dest,
size_t destlen,
size_t col,
+ int cols,
char op,
const char *src,
const char *prefix,
}
if (optional)
- mutt_FormatString (dest, destlen, col, ifstring, hdr_format_str, (unsigned long) hfi, flags);
+ mutt_FormatString (dest, destlen, col, cols, ifstring, hdr_format_str, (unsigned long) hfi, flags);
else if (flags & M_FORMAT_OPTIONAL)
- mutt_FormatString (dest, destlen, col, elsestring, hdr_format_str, (unsigned long) hfi, flags);
+ mutt_FormatString (dest, destlen, col, cols, elsestring, hdr_format_str, (unsigned long) hfi, flags);
return (src);
#undef THREAD_NEW
hfi.ctx = ctx;
hfi.pager_progress = 0;
- mutt_FormatString (dest, destlen, 0, s, hdr_format_str, (unsigned long) &hfi, flags);
+ mutt_FormatString (dest, destlen, 0, MuttIndexWindow->cols, s, hdr_format_str, (unsigned long) &hfi, flags);
}
void
mutt_make_string_info (char *dst, size_t dstlen, const char *s, struct hdr_format_info *hfi, format_flag flags)
{
- mutt_FormatString (dst, dstlen, 0, s, hdr_format_str, (unsigned long) hfi, flags);
+ mutt_FormatString (dst, dstlen, 0, MuttIndexWindow->cols, s, hdr_format_str, (unsigned long) hfi, flags);
}
void mutt_FormatString (char *dest, /* output buffer */
size_t destlen, /* output buffer len */
size_t col, /* starting column (nonzero when called recursively) */
+ int cols, /* maximum columns */
const char *src, /* template string */
format_t *callback, /* callback for processing */
unsigned long data, /* callback data */
mutt_extract_token(word, srcbuf, 0);
dprint(3, (debugfile, "fmtpipe %2d: %s\n", i++, word->data));
mutt_buffer_addch(command, '\'');
- mutt_FormatString(buf, sizeof(buf), 0, word->data, callback, data,
+ mutt_FormatString(buf, sizeof(buf), 0, cols, word->data, callback, data,
flags | M_FORMAT_NOFILTER);
for (p = buf; p && *p; p++)
{
* it back for the recursive call since the expansion of
* format pipes does not try to append a nul itself.
*/
- mutt_FormatString(dest, destlen+1, col, recycler, callback, data, flags);
+ mutt_FormatString(dest, destlen+1, col, cols, recycler, callback, data, flags);
FREE(&recycler);
}
}
pl = pw = 1;
/* see if there's room to add content, else ignore */
- if ((col < COLS && wlen < destlen) || soft)
+ if ((col < cols && wlen < destlen) || soft)
{
int pad;
/* get contents after padding */
- mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags);
+ mutt_FormatString (buf, sizeof (buf), 0, cols, src + pl, callback, data, flags);
len = mutt_strlen (buf);
wid = mutt_strwidth (buf);
- pad = (COLS - col - wid) / pw;
+ pad = (cols - col - wid) / pw;
if (pad >= 0)
{
/* try to consume as many columns as we can, if we don't have
{
/* Add pre-spacing to make multi-column pad characters and
* the contents after padding line up */
- while ((col + (pad * pw) + wid < COLS) &&
+ while ((col + (pad * pw) + wid < cols) &&
(wlen + (pad * pl) + len < destlen))
{
*wptr++ = ' ';
else if (soft && pad < 0)
{
int offset = ((flags & M_FORMAT_ARROWCURSOR) && option (OPTARROWCURSOR)) ? 3 : 0;
- int avail_cols = (COLS > offset) ? (COLS - offset) : 0;
+ int avail_cols = (cols > offset) ? (cols - offset) : 0;
/* \0-terminate dest for length computation in mutt_wstr_trunc() */
*wptr = 0;
/* make sure right part is at most as wide as display */
}
}
if (len + wlen > destlen)
- len = mutt_wstr_trunc (buf, destlen - wlen, COLS - col, NULL);
+ len = mutt_wstr_trunc (buf, destlen - wlen, cols - col, NULL);
memcpy (wptr, buf, len);
wptr += len;
wlen += len;
pl = pw = 1;
/* see if there's room to add content, else ignore */
- if (col < COLS && wlen < destlen)
+ if (col < cols && wlen < destlen)
{
- c = (COLS - col) / pw;
+ c = (cols - col) / pw;
if (c > 0 && wlen + (c * pl) > destlen)
c = ((signed)(destlen - wlen)) / pl;
while (c > 0)
}
/* use callback function to handle this case */
- src = callback (buf, sizeof (buf), col, ch, src, prefix, ifstring, elsestring, data, flags);
+ src = callback (buf, sizeof (buf), col, cols, ch, src, prefix, ifstring, elsestring, data, flags);
if (tolower)
mutt_strlower (buf);
}
if ((len = mutt_strlen (buf)) + wlen > destlen)
- len = mutt_wstr_trunc (buf, destlen - wlen, COLS - col, NULL);
+ len = mutt_wstr_trunc (buf, destlen - wlen, cols - col, NULL);
memcpy (wptr, buf, len);
wptr += len;
const char *_mutt_fmt_pgp_command (char *dest,
size_t destlen,
size_t col,
+ int cols,
char op,
const char *src,
const char *prefix,
}
if (optional)
- mutt_FormatString (dest, destlen, col, ifstring, _mutt_fmt_pgp_command, data, 0);
+ mutt_FormatString (dest, destlen, col, cols, ifstring, _mutt_fmt_pgp_command, data, 0);
else if (flags & M_FORMAT_OPTIONAL)
- mutt_FormatString (dest, destlen, col, elsestring, _mutt_fmt_pgp_command, data, 0);
+ mutt_FormatString (dest, destlen, col, cols, elsestring, _mutt_fmt_pgp_command, data, 0);
return (src);
}
void mutt_pgp_command (char *d, size_t dlen, struct pgp_command_context *cctx, const char *fmt)
{
- mutt_FormatString (d, dlen, 0, NONULL (fmt), _mutt_fmt_pgp_command, (unsigned long) cctx, 0);
+ mutt_FormatString (d, dlen, 0, MuttIndexWindow->cols, NONULL (fmt), _mutt_fmt_pgp_command, (unsigned long) cctx, 0);
dprint (2, (debugfile, "mutt_pgp_command: %s\n", d));
}
static const char *pgp_entry_fmt (char *dest,
size_t destlen,
size_t col,
+ int cols,
char op,
const char *src,
const char *prefix,
}
if (optional)
- mutt_FormatString (dest, destlen, col, ifstring, mutt_attach_fmt, data, 0);
+ mutt_FormatString (dest, destlen, col, cols, ifstring, mutt_attach_fmt, data, 0);
else if (flags & M_FORMAT_OPTIONAL)
- mutt_FormatString (dest, destlen, col, elsestring, mutt_attach_fmt, data, 0);
+ mutt_FormatString (dest, destlen, col, cols, elsestring, mutt_attach_fmt, data, 0);
return (src);
}
entry.uid = KeyTable[num];
entry.num = num + 1;
- mutt_FormatString (s, l, 0, NONULL (PgpEntryFormat), pgp_entry_fmt,
+ mutt_FormatString (s, l, 0, MuttIndexWindow->cols, NONULL (PgpEntryFormat), pgp_entry_fmt,
(unsigned long) &entry, M_FORMAT_ARROWCURSOR);
}
#define mutt_new_envelope() safe_calloc (1, sizeof (ENVELOPE))
#define mutt_new_enter_state() safe_calloc (1, sizeof (ENTER_STATE))
-typedef const char * format_t (char *, size_t, size_t, char, const char *, const char *, const char *, const char *, unsigned long, format_flag);
+typedef const char * format_t (char *, size_t, size_t, int, char, const char *, const char *, const char *, const char *, unsigned long, format_flag);
-void mutt_FormatString (char *, size_t, size_t, const char *, format_t *, unsigned long, format_flag);
+void mutt_FormatString (char *, size_t, size_t, int, const char *, format_t *, unsigned long, format_flag);
void mutt_parse_content_type (char *, BODY *);
void mutt_generate_boundary (PARAMETER **);
void mutt_delete_parameter (const char *attribute, PARAMETER **p);
char *dest,
size_t destlen,
size_t col,
+ int cols,
char op,
const char *src,
const char *prefix,
return REG_NOMATCH;
}
-static const char * query_format_str (char *dest, size_t destlen, size_t col,
+static const char * query_format_str (char *dest, size_t destlen, size_t col, int cols,
char op, const char *src,
const char *fmt, const char *ifstring,
const char *elsestring,
}
if (optional)
- mutt_FormatString (dest, destlen, col, ifstring, query_format_str, data, 0);
+ mutt_FormatString (dest, destlen, col, cols, ifstring, query_format_str, data, 0);
else if (flags & M_FORMAT_OPTIONAL)
- mutt_FormatString (dest, destlen, col, elsestring, query_format_str, data, 0);
+ mutt_FormatString (dest, destlen, col, cols, elsestring, query_format_str, data, 0);
return src;
}
ENTRY *entry = &((ENTRY *) m->data)[num];
entry->data->num = num;
- mutt_FormatString (s, slen, 0, NONULL (QueryFormat), query_format_str,
+ mutt_FormatString (s, slen, 0, MuttIndexWindow->cols, NONULL (QueryFormat), query_format_str,
(unsigned long) entry, M_FORMAT_ARROWCURSOR);
}
const char *mutt_attach_fmt (char *dest,
size_t destlen,
size_t col,
+ int cols,
char op,
const char *src,
const char *prefix,
}
if (optional)
- mutt_FormatString (dest, destlen, col, ifstring, mutt_attach_fmt, data, 0);
+ mutt_FormatString (dest, destlen, col, cols, ifstring, mutt_attach_fmt, data, 0);
else if (flags & M_FORMAT_OPTIONAL)
- mutt_FormatString (dest, destlen, col, elsestring, mutt_attach_fmt, data, 0);
+ mutt_FormatString (dest, destlen, col, cols, elsestring, mutt_attach_fmt, data, 0);
return (src);
}
static void attach_entry (char *b, size_t blen, MUTTMENU *menu, int num)
{
- mutt_FormatString (b, blen, 0, NONULL (AttachFormat), mutt_attach_fmt, (unsigned long) (((ATTACHPTR **)menu->data)[num]), M_FORMAT_ARROWCURSOR);
+ mutt_FormatString (b, blen, 0, MuttIndexWindow->cols, NONULL (AttachFormat), mutt_attach_fmt, (unsigned long) (((ATTACHPTR **)menu->data)[num]), M_FORMAT_ARROWCURSOR);
}
int mutt_tag_attach (MUTTMENU *menu, int n, int m)
static const char *mix_entry_fmt (char *dest,
size_t destlen,
size_t col,
+ int cols,
char op,
const char *src,
const char *prefix,
}
if (optional)
- mutt_FormatString (dest, destlen, col, ifstring, mutt_attach_fmt, data, 0);
+ mutt_FormatString (dest, destlen, col, cols, ifstring, mutt_attach_fmt, data, 0);
else if (flags & M_FORMAT_OPTIONAL)
- mutt_FormatString (dest, destlen, col, elsestring, mutt_attach_fmt, data, 0);
+ mutt_FormatString (dest, destlen, col, cols, elsestring, mutt_attach_fmt, data, 0);
return (src);
}
static void mix_entry (char *b, size_t blen, MUTTMENU *menu, int num)
{
REMAILER **type2_list = (REMAILER **) menu->data;
- mutt_FormatString (b, blen, 0, NONULL (MixEntryFormat), mix_entry_fmt,
+ mutt_FormatString (b, blen, 0, MuttIndexWindow->cols, NONULL (MixEntryFormat), mix_entry_fmt,
(unsigned long) type2_list[num], M_FORMAT_ARROWCURSOR);
}
static const char *_mutt_fmt_smime_command (char *dest,
size_t destlen,
size_t col,
+ int cols,
char op,
const char *src,
const char *prefix,
}
if (optional)
- mutt_FormatString (dest, destlen, col, ifstring, _mutt_fmt_smime_command,
+ mutt_FormatString (dest, destlen, col, cols, ifstring, _mutt_fmt_smime_command,
data, 0);
else if (flags & M_FORMAT_OPTIONAL)
- mutt_FormatString (dest, destlen, col, elsestring, _mutt_fmt_smime_command,
+ mutt_FormatString (dest, destlen, col, cols, elsestring, _mutt_fmt_smime_command,
data, 0);
return (src);
static void mutt_smime_command (char *d, size_t dlen,
struct smime_command_context *cctx, const char *fmt)
{
- mutt_FormatString (d, dlen, 0, NONULL(fmt), _mutt_fmt_smime_command,
+ mutt_FormatString (d, dlen, 0, MuttIndexWindow->cols, NONULL(fmt), _mutt_fmt_smime_command,
(unsigned long) cctx, 0);
dprint (2,(debugfile, "mutt_smime_command: %s\n", d));
}
return buf;
}
-static void _menu_status_line (char *buf, size_t buflen, size_t col, MUTTMENU *menu, const char *p);
+static void _menu_status_line (char *buf, size_t buflen, size_t col, int cols, MUTTMENU *menu, const char *p);
/* %b = number of incoming folders with unread messages [option]
* %d = number of deleted messages [option]
* %v = Mutt version
* %V = currently active limit pattern [option] */
static const char *
-status_format_str (char *buf, size_t buflen, size_t col, char op, const char *src,
+status_format_str (char *buf, size_t buflen, size_t col, int cols, char op, const char *src,
const char *prefix, const char *ifstring,
const char *elsestring,
unsigned long data, format_flag flags)
}
if (optional)
- _menu_status_line (buf, buflen, col, menu, ifstring);
+ _menu_status_line (buf, buflen, col, cols, menu, ifstring);
else if (flags & M_FORMAT_OPTIONAL)
- _menu_status_line (buf, buflen, col, menu, elsestring);
+ _menu_status_line (buf, buflen, col, cols, menu, elsestring);
return (src);
}
-static void _menu_status_line (char *buf, size_t buflen, size_t col, MUTTMENU *menu, const char *p)
+static void _menu_status_line (char *buf, size_t buflen, size_t col, int cols, MUTTMENU *menu, const char *p)
{
- mutt_FormatString (buf, buflen, col, p, status_format_str, (unsigned long) menu, 0);
+ mutt_FormatString (buf, buflen, col, cols, p, status_format_str, (unsigned long) menu, 0);
}
void menu_status_line (char *buf, size_t buflen, MUTTMENU *menu, const char *p)
{
- mutt_FormatString (buf, buflen, 0, p, status_format_str, (unsigned long) menu, 0);
+ mutt_FormatString (buf, buflen, 0, MuttStatusWindow->cols, p, status_format_str, (unsigned long) menu, 0);
}