From: Richard Russon Date: Mon, 21 Oct 2019 11:34:04 +0000 (+0100) Subject: eliminate MuttIndexWindow from mutt_make_string_flags() X-Git-Tag: 2019-10-25~1^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=370b619db32cabe7e9705294c5bdd5d9c037045c;p=neomutt eliminate MuttIndexWindow from mutt_make_string_flags() `mutt_make_string_flags()`, and its macro wrapper `mutt_make_string()`, use `mutt_expando_format()` and `index_format_str()` to expand strings. Some of the callers expect the string to be truncated at the screen width. These functions now have an extra paramter to avoid using `MuttIndexWindow` directly. --- diff --git a/copy.c b/copy.c index c707e6782..ccb25e8ac 100644 --- a/copy.c +++ b/copy.c @@ -609,8 +609,8 @@ int mutt_copy_message_fp(FILE *fp_out, FILE *fp_in, struct Email *e, if (C_TextFlowed) mutt_str_strfcpy(prefix, ">", sizeof(prefix)); else - mutt_make_string(prefix, sizeof(prefix), NONULL(C_IndentString), Context, - Context->mailbox, e); + mutt_make_string(prefix, sizeof(prefix), wraplen, NONULL(C_IndentString), + Context, Context->mailbox, e); } if ((cmflags & MUTT_CM_NOHEADER) == 0) diff --git a/edit.c b/edit.c index 29f7d44ad..f84408210 100644 --- a/edit.c +++ b/edit.c @@ -228,7 +228,7 @@ static char **be_include_messages(char *msg, char **buf, int *bufmax, if (C_Attribution) { setlocale(LC_TIME, NONULL(C_AttributionLocale)); - mutt_make_string(tmp, sizeof(tmp) - 1, C_Attribution, Context, + mutt_make_string(tmp, sizeof(tmp) - 1, 0, C_Attribution, Context, Context->mailbox, Context->mailbox->emails[n]); setlocale(LC_TIME, ""); strcat(tmp, "\n"); diff --git a/hdrline.c b/hdrline.c index 6d901efc8..815033af3 100644 --- a/hdrline.c +++ b/hdrline.c @@ -1488,14 +1488,16 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co * mutt_make_string_flags - Create formatted strings using mailbox expandos * @param buf Buffer for the result * @param buflen Buffer length + * @param cols Number of screen columns (OPTIONAL) * @param s printf-line format string * @param ctx Mailbox Context * @param m Mailbox * @param e Email * @param flags Flags, see #MuttFormatFlags */ -void mutt_make_string_flags(char *buf, size_t buflen, const char *s, struct Context *ctx, - struct Mailbox *m, struct Email *e, MuttFormatFlags flags) +void mutt_make_string_flags(char *buf, size_t buflen, int cols, const char *s, + struct Context *ctx, struct Mailbox *m, + struct Email *e, MuttFormatFlags flags) { struct HdrFormatInfo hfi; @@ -1504,8 +1506,7 @@ void mutt_make_string_flags(char *buf, size_t buflen, const char *s, struct Cont hfi.mailbox = m; hfi.pager_progress = 0; - mutt_expando_format(buf, buflen, 0, MuttIndexWindow->cols, s, - index_format_str, (unsigned long) &hfi, flags); + mutt_expando_format(buf, buflen, 0, cols, s, index_format_str, (unsigned long) &hfi, flags); } /** diff --git a/hdrline.h b/hdrline.h index 3110badbb..1e52ceec3 100644 --- a/hdrline.h +++ b/hdrline.h @@ -52,13 +52,13 @@ struct HdrFormatInfo bool mutt_is_mail_list(const struct Address *addr); bool mutt_is_subscribed_list(const struct Address *addr); -void mutt_make_string_flags(char *buf, size_t buflen, const char *s, +void mutt_make_string_flags(char *buf, size_t buflen, int cols, const char *s, struct Context *ctx, struct Mailbox *m, struct Email *e, MuttFormatFlags flags); void mutt_make_string_info(char *buf, size_t buflen, int cols, const char *s, struct HdrFormatInfo *hfi, MuttFormatFlags flags); -#define mutt_make_string(BUF, BUFLEN, S, CTX, M, E) \ - mutt_make_string_flags(BUF, BUFLEN, S, CTX, M, E, 0) +#define mutt_make_string(BUF, BUFLEN, COLS, S, CTX, M, E) \ + mutt_make_string_flags(BUF, BUFLEN, COLS, S, CTX, M, E, MUTT_FORMAT_NO_FLAGS) #endif /* MUTT_HDRLINE_H */ diff --git a/hook.c b/hook.c index 3cfcb6611..272de0bd9 100644 --- a/hook.c +++ b/hook.c @@ -644,7 +644,7 @@ static int addr_hook(char *path, size_t pathlen, HookFlags type, if ((mutt_pattern_exec(SLIST_FIRST(hook->pattern), 0, m, e, &cache) > 0) ^ hook->regex.pat_not) { - mutt_make_string_flags(path, pathlen, hook->command, ctx, m, e, MUTT_FORMAT_PLAIN); + mutt_make_string_flags(path, pathlen, 0, hook->command, ctx, m, e, MUTT_FORMAT_PLAIN); return 0; } } diff --git a/index.c b/index.c index e93992680..e4f72d312 100644 --- a/index.c +++ b/index.c @@ -813,8 +813,8 @@ void index_make_entry(char *buf, size_t buflen, struct Menu *menu, int line) } } - mutt_make_string_flags(buf, buflen, NONULL(C_IndexFormat), Context, - Context->mailbox, e, flags); + mutt_make_string_flags(buf, buflen, menu->indexwin->cols, NONULL(C_IndexFormat), + Context, Context->mailbox, e, flags); } /** diff --git a/postpone.c b/postpone.c index 96e14ef13..e1bda7a07 100644 --- a/postpone.c +++ b/postpone.c @@ -49,6 +49,7 @@ #include "mutt_logging.h" #include "mutt_menu.h" #include "mutt_thread.h" +#include "mutt_window.h" #include "muttlib.h" #include "mx.h" #include "ncrypt/ncrypt.h" @@ -205,7 +206,8 @@ static void post_make_entry(char *buf, size_t buflen, struct Menu *menu, int lin { struct Context *ctx = menu->data; - mutt_make_string_flags(buf, buflen, NONULL(C_IndexFormat), ctx, ctx->mailbox, + mutt_make_string_flags(buf, buflen, menu->indexwin->cols, + NONULL(C_IndexFormat), ctx, ctx->mailbox, ctx->mailbox->emails[line], MUTT_FORMAT_ARROWCURSOR); } diff --git a/recvattach.c b/recvattach.c index 7ac0a3dcd..4fc394dad 100644 --- a/recvattach.c +++ b/recvattach.c @@ -258,8 +258,8 @@ const char *attach_format_str(char *buf, size_t buflen, size_t col, int cols, C_MessageFormat && aptr->content->email) { char s[128]; - mutt_make_string_flags(s, sizeof(s), C_MessageFormat, NULL, NULL, - aptr->content->email, + mutt_make_string_flags(s, sizeof(s), cols, C_MessageFormat, NULL, + NULL, aptr->content->email, MUTT_FORMAT_FORCESUBJ | MUTT_FORMAT_ARROWCURSOR); if (*s) { diff --git a/recvcmd.c b/recvcmd.c index 1d450a647..87e5e6648 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -410,7 +410,7 @@ static void include_header(bool quote, FILE *fp_in, struct Email *e, FILE *fp_ou mutt_str_strfcpy(prefix2, prefix, sizeof(prefix2)); else if (!C_TextFlowed) { - mutt_make_string(prefix2, sizeof(prefix2), NONULL(C_IndentString), + mutt_make_string(prefix2, sizeof(prefix2), 0, NONULL(C_IndentString), Context, Context->mailbox, e); } else @@ -505,8 +505,8 @@ static void attach_forward_bodies(FILE *fp, struct Email *e, struct AttachCtx *a mutt_str_strfcpy(prefix, ">", sizeof(prefix)); else { - mutt_make_string(prefix, sizeof(prefix), NONULL(C_IndentString), Context, - Context->mailbox, e_parent); + mutt_make_string(prefix, sizeof(prefix), 0, NONULL(C_IndentString), + Context, Context->mailbox, e_parent); } } @@ -988,8 +988,8 @@ void mutt_attach_reply(FILE *fp, struct Email *e, struct AttachCtx *actx, if (!C_TextFlowed) { - mutt_make_string(prefix, sizeof(prefix), NONULL(C_IndentString), Context, - Context->mailbox, e_parent); + mutt_make_string(prefix, sizeof(prefix), 0, NONULL(C_IndentString), + Context, Context->mailbox, e_parent); } else mutt_str_strfcpy(prefix, ">", sizeof(prefix)); diff --git a/send.c b/send.c index c23eee02d..ede7563ff 100644 --- a/send.c +++ b/send.c @@ -435,7 +435,7 @@ void mutt_forward_intro(struct Mailbox *m, struct Email *e, FILE *fp) char buf[1024]; setlocale(LC_TIME, NONULL(C_AttributionLocale)); - mutt_make_string(buf, sizeof(buf), C_ForwardAttributionIntro, NULL, m, e); + mutt_make_string(buf, sizeof(buf), 0, C_ForwardAttributionIntro, NULL, m, e); setlocale(LC_TIME, ""); fputs(buf, fp); fputs("\n\n", fp); @@ -454,7 +454,7 @@ void mutt_forward_trailer(struct Mailbox *m, struct Email *e, FILE *fp) char buf[1024]; setlocale(LC_TIME, NONULL(C_AttributionLocale)); - mutt_make_string(buf, sizeof(buf), C_ForwardAttributionTrailer, NULL, m, e); + mutt_make_string(buf, sizeof(buf), 0, C_ForwardAttributionTrailer, NULL, m, e); setlocale(LC_TIME, ""); fputc('\n', fp); fputs(buf, fp); @@ -640,7 +640,7 @@ void mutt_make_attribution(struct Mailbox *m, struct Email *e, FILE *fp_out) char buf[1024]; setlocale(LC_TIME, NONULL(C_AttributionLocale)); - mutt_make_string(buf, sizeof(buf), C_Attribution, NULL, m, e); + mutt_make_string(buf, sizeof(buf), 0, C_Attribution, NULL, m, e); setlocale(LC_TIME, ""); fputs(buf, fp_out); fputc('\n', fp_out); @@ -658,7 +658,7 @@ void mutt_make_post_indent(struct Mailbox *m, struct Email *e, FILE *fp_out) return; char buf[256]; - mutt_make_string(buf, sizeof(buf), C_PostIndentString, NULL, m, e); + mutt_make_string(buf, sizeof(buf), 0, C_PostIndentString, NULL, m, e); fputs(buf, fp_out); fputc('\n', fp_out); } @@ -927,7 +927,7 @@ void mutt_make_forward_subject(struct Envelope *env, struct Mailbox *m, struct E char buf[256]; /* set the default subject for the message. */ - mutt_make_string(buf, sizeof(buf), NONULL(C_ForwardFormat), NULL, m, e); + mutt_make_string(buf, sizeof(buf), 0, NONULL(C_ForwardFormat), NULL, m, e); mutt_str_replace(&env->subject, buf); }