Continuing with the conversion to using windows for screen drawing, mutt_FormatString() was directly using COLS for right justification and similar formatting. Instead pass in a parameter, cols.
This change involved seeding the parameter through callback functions too, as many of them call mutt_FormatString() back. -- Kevin J. McCarthy GPG Fingerprint: 8975 A9B3 3AA3 7910 385C 5308 ADEF 7684 8031 6BDA http://www.8t8.us/configs/gpg-key-transition-statement.txt
# HG changeset patch # User Kevin McCarthy <ke...@8t8.us> # Date 1461444992 25200 # Sat Apr 23 13:56:32 2016 -0700 # Node ID 537254fe0773deabddf831ac7b3ceeaaaafdf18e # Parent 550d805f7b6457567db295ceede777f9c133abe7 Add cols parameter to mutt_FormatString() Continuing with the conversion to using windows for screen drawing, mutt_FormatString() was directly using COLS for right justification and similar formatting. Instead pass in a parameter, cols. This change involved seeding the parameter through callback functions too, as many of them call mutt_FormatString() back. diff --git a/addrbook.c b/addrbook.c --- a/addrbook.c +++ b/addrbook.c @@ -38,17 +38,17 @@ { N_("Del"), OP_DELETE }, { N_("Undel"), OP_UNDELETE }, { N_("Select"), OP_GENERIC_SELECT_ENTRY }, { N_("Help"), OP_HELP }, { NULL, 0 } }; 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) { char tmp[SHORT_STRING], adr[SHORT_STRING]; ALIAS *alias = (ALIAS *) data; switch (op) { @@ -75,17 +75,17 @@ break; } return (src); } 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) { ALIAS *cur = ((ALIAS **) menu->data)[n]; int ot = cur->tagged; cur->tagged = (m >= 0 ? m : !cur->tagged); diff --git a/browser.c b/browser.c --- a/browser.c +++ b/browser.c @@ -137,17 +137,17 @@ if (stat (fullpath, &st) == 0) return (S_ISDIR (st.st_mode)); else return 0; } 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) { char fn[SHORT_STRING], tmp[SHORT_STRING], permission[11]; char date[16], *t_fmt; time_t tnow; FOLDER *folder = (FOLDER *) data; struct passwd *pw; @@ -312,19 +312,19 @@ default: snprintf (tmp, sizeof (tmp), "%%%sc", fmt); snprintf (dest, destlen, tmp, op); break; } 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); } static void add_folder (MUTTMENU *m, struct browser_state *state, const char *name, const struct stat *s, unsigned int new) { if (state->entrylen == state->entrymax) @@ -510,17 +510,17 @@ static void folder_entry (char *s, size_t slen, MUTTMENU *menu, int num) { FOLDER folder; 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 init_menu (struct browser_state *state, MUTTMENU *menu, char *title, size_t titlelen, int buffy) { char path[_POSIX_PATH_MAX]; diff --git a/compose.c b/compose.c --- a/compose.c +++ b/compose.c @@ -94,17 +94,17 @@ { N_("Attach file"), OP_COMPOSE_ATTACH_FILE }, { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION }, { N_("Help"), OP_HELP }, { NULL, 0 } }; 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); } #include "mutt_crypt.h" @@ -397,33 +397,33 @@ } } } return s; } /* 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); /* * compose_format_str() * * %a = total number of attachments * %h = hostname [option] * %l = approx. length of current message (in bytes) * %v = Mutt version * * This function is similar to status_format_str(). Look at that function for * help when modifying this function. */ 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) { char fmt[SHORT_STRING], tmp[SHORT_STRING]; int optional = (flags & M_FORMAT_OPTIONAL); MUTTMENU *menu = (MUTTMENU *) data; @@ -456,27 +456,27 @@ return (src); default: snprintf (buf, buflen, "%%%s%c", prefix, op); break; } 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); } /* return values: * * 1 message should be postponed * 0 normal exit @@ -1308,17 +1308,17 @@ break; #endif } /* 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); NORMAL_COLOR; menu->redraw &= ~REDRAW_STATUS; } } diff --git a/crypt-gpgme.c b/crypt-gpgme.c --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -2739,16 +2739,17 @@ * %t trust/validity of the key-uid association * %p protocol * %[...] date of key using strftime(3) */ static const char *crypt_entry_fmt (char *dest, size_t destlen, 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) { @@ -2936,32 +2937,32 @@ gpgme_get_protocol_name (key->kobj->protocol)); break; default: *dest = '\0'; } 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); } /* Used by the display function to format a line. */ static void crypt_entry (char *s, size_t l, MUTTMENU * menu, int num) { crypt_key_t **key_table = (crypt_key_t **) menu->data; crypt_entry_t entry; 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); } /* Compare two addresses and the keyid to be used for sorting. */ static int _crypt_compare_address (const void *a, const void *b) { crypt_key_t **s = (crypt_key_t **) a; crypt_key_t **t = (crypt_key_t **) b; diff --git a/hdrline.c b/hdrline.c --- a/hdrline.c +++ b/hdrline.c @@ -231,16 +231,17 @@ * %y = `x-label:' field (if present) * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label) * %Z = status flags */ static const char * hdr_format_str (char *dest, size_t destlen, 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) { @@ -730,34 +731,34 @@ break; default: snprintf (dest, destlen, "%%%s%c", prefix, op); break; } 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 #undef THREAD_OLD } void _mutt_make_string (char *dest, size_t destlen, const char *s, CONTEXT *ctx, HEADER *hdr, format_flag flags) { struct hdr_format_info hfi; hfi.hdr = hdr; 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); } diff --git a/muttlib.c b/muttlib.c --- a/muttlib.c +++ b/muttlib.c @@ -1048,16 +1048,17 @@ if (*p == '/' || ISSPACE (*p) || !IsPrint ((unsigned char) *p)) *p = '_'; } 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 */ format_flag flags) /* callback flags */ { char prefix[SHORT_STRING], buf[LONG_STRING], *cp, *wptr = dest, ch; char ifstring[SHORT_STRING], elsestring[SHORT_STRING]; size_t wlen, count, len, wid; @@ -1112,17 +1113,17 @@ /* Extract the command name and copy to command line */ dprint(3, (debugfile, "fmtpipe +++: %s\n", srcbuf->dptr)); if (word->data) *word->data = '\0'; 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++) { if (*p == '\'') /* shell quoting doesn't permit escaping a single quote within * single-quoted material. double-quoting instead will lead * shell variable expansions, so break out of the single-quoted * span, insert a double-quoted single quote, and resume. */ @@ -1167,17 +1168,17 @@ recycler = safe_strdup(dest); if (recycler) { /* destlen is decremented at the start of this function * to save space for the terminal nul char. We can add * 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); } } } } else { /* read error */ @@ -1277,37 +1278,37 @@ /* %>X: right justify to EOL, left takes precedence * %*X: right justify to EOL, right takes precedence */ int soft = ch == '*'; int pl, pw; if ((pl = mutt_charlen (src, &pw)) <= 0) 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 * memory for that, use as much memory as possible */ if (wlen + (pad * pl) + len > destlen) pad = (destlen > wlen + len) ? ((destlen - wlen - len) / pl) : 0; else { /* 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++ = ' '; wlen++; col++; } } while (pad-- > 0) @@ -1316,17 +1317,17 @@ wptr += pl; wlen += pl; col += pw; } } 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 */ len = mutt_wstr_trunc (buf, destlen, avail_cols, &wid); /* truncate left so that right part fits completely in */ wlen = mutt_wstr_trunc (dest, destlen - len, avail_cols - wid, &col); wptr = dest + wlen; /* Multi-column characters may be truncated in the middle. @@ -1334,36 +1335,36 @@ while ((col + wid < avail_cols) && (wlen + len < destlen)) { *wptr++ = ' '; wlen++; col++; } } 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; col += wid; src += pl; } break; /* skip rest of input */ } else if (ch == '|') { /* pad to EOL */ int pl, pw, c; if ((pl = mutt_charlen (src, &pw)) <= 0) 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) { memcpy (wptr, src, pl); wptr += pl; wlen += pl; col += pw; @@ -1384,30 +1385,30 @@ tolower = 1; else if (ch == ':') nodots = 1; ch = *src++; } /* 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 (nodots) { char *p = buf; for (; *p; p++) if (*p == '.') *p = '_'; } 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; wlen += len; col += mutt_strwidth (buf); } } else if (*src == '\\') diff --git a/pgpinvoke.c b/pgpinvoke.c --- a/pgpinvoke.c +++ b/pgpinvoke.c @@ -54,16 +54,17 @@ const char *signas; /* %a */ const char *ids; /* %r */ }; const char *_mutt_fmt_pgp_command (char *dest, size_t destlen, 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) { @@ -135,26 +136,26 @@ default: { *dest = '\0'; break; } } 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)); } /* * Glue. */ diff --git a/pgpkey.c b/pgpkey.c --- a/pgpkey.c +++ b/pgpkey.c @@ -117,16 +117,17 @@ { size_t num; pgp_uid_t *uid; } pgp_entry_t; static const char *pgp_entry_fmt (char *dest, size_t destlen, 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) { @@ -273,31 +274,31 @@ /* undefined trust */ optional = 0; break; default: *dest = '\0'; } 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 pgp_entry (char *s, size_t l, MUTTMENU * menu, int num) { pgp_uid_t **KeyTable = (pgp_uid_t **) menu->data; pgp_entry_t entry; 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); } static int _pgp_compare_address (const void *a, const void *b) { int r; pgp_uid_t **s = (pgp_uid_t **) a; diff --git a/protos.h b/protos.h --- a/protos.h +++ b/protos.h @@ -66,19 +66,19 @@ int _mutt_traverse_thread (CONTEXT *ctx, HEADER *hdr, int flag); #define mutt_new_parameter() safe_calloc (1, sizeof (PARAMETER)) #define mutt_new_header() safe_calloc (1, sizeof (HEADER)) #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); void mutt_set_parameter (const char *, const char *, PARAMETER **); FILE *mutt_open_read (const char *, pid_t *); @@ -122,16 +122,17 @@ time_t mutt_mktime (struct tm *, int); time_t mutt_parse_date (const char *, HEADER *); int is_from (const char *, char *, size_t, time_t *); const char *mutt_attach_fmt ( char *dest, size_t destlen, 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); diff --git a/query.c b/query.c --- a/query.c +++ b/query.c @@ -178,17 +178,17 @@ !regexec (re, table[n].data->addr->val, 0, NULL, 0)) return 0; #endif } 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, unsigned long data, format_flag flags) { ENTRY *entry = (ENTRY *)data; QUERY *query = entry->data; char tmp[SHORT_STRING]; @@ -225,29 +225,29 @@ break; default: snprintf (tmp, sizeof (tmp), "%%%sc", fmt); snprintf (dest, destlen, tmp, op); break; } 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; } static void query_entry (char *s, size_t slen, MUTTMENU *m, int num) { 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); } static int query_tag (MUTTMENU *menu, int n, int m) { ENTRY *cur = &((ENTRY *) menu->data)[n]; int ot = cur->tagged; diff --git a/recvattach.c b/recvattach.c --- a/recvattach.c +++ b/recvattach.c @@ -168,16 +168,17 @@ * %M = MIME subtype * %n = attachment number * %s = size * %u = unlink */ const char *mutt_attach_fmt (char *dest, size_t destlen, 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) { @@ -360,25 +361,25 @@ snprintf (dest, destlen, fmt, aptr->content->attach_count + aptr->content->attach_qualifies); } break; default: *dest = 0; } 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) { BODY *cur = ((ATTACHPTR **) menu->data)[n]->content; int ot = cur->tagged; cur->tagged = (m >= 0 ? m : !cur->tagged); diff --git a/remailer.c b/remailer.c --- a/remailer.c +++ b/remailer.c @@ -372,16 +372,17 @@ * %s short name * %a address * */ static const char *mix_entry_fmt (char *dest, size_t destlen, 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) { @@ -424,28 +425,28 @@ optional = 0; break; default: *dest = '\0'; } 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 int mix_chain_add (MIXCHAIN *chain, const char *s, REMAILER **type2_list) { int i; diff --git a/smime.c b/smime.c --- a/smime.c +++ b/smime.c @@ -154,16 +154,17 @@ * The OpenSSL interface */ /* This is almost identical to ppgp's invoking interface. */ 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, const char *ifstring, const char *elsestring, unsigned long data, format_flag flags) { @@ -279,31 +280,31 @@ } default: *dest = '\0'; break; } 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)); } static pid_t smime_invoke (FILE **smimein, FILE **smimeout, FILE **smimeerr, diff --git a/status.c b/status.c --- a/status.c +++ b/status.c @@ -35,17 +35,17 @@ { snprintf (buf, buflen, "%s%s%s", (method & SORT_REVERSE) ? "reverse-" : "", (method & SORT_LAST) ? "last-" : "", mutt_getnamebyvalue (method & SORT_MASK, SortMethods)); 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] * %f = full mailbox path * %F = number of flagged messages [option] * %h = hostname * %l = length of mailbox (in bytes) [option] * %m = total number of messages [option] @@ -57,17 +57,17 @@ * %r = readonly/wontwrite/changed flag * %s = current sorting method ($sort) * %S = current aux sorting method ($sort_aux) * %t = # of tagged messages [option] * %u = number of unread 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) { char fmt[SHORT_STRING], tmp[SHORT_STRING], *cp; int count, optional = (flags & M_FORMAT_OPTIONAL); MUTTMENU *menu = (MUTTMENU *) data; @@ -285,24 +285,24 @@ return (src); default: snprintf (buf, buflen, "%%%s%c", prefix, op); break; } 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); }
signature.asc
Description: PGP signature