]> granicus.if.org Git - neomutt/commitdiff
eliminate MuttIndexWindow from mutt_make_string_flags()
authorRichard Russon <rich@flatcap.org>
Mon, 21 Oct 2019 11:34:04 +0000 (12:34 +0100)
committerRichard Russon <rich@flatcap.org>
Wed, 23 Oct 2019 10:37:44 +0000 (11:37 +0100)
`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.

copy.c
edit.c
hdrline.c
hdrline.h
hook.c
index.c
postpone.c
recvattach.c
recvcmd.c
send.c

diff --git a/copy.c b/copy.c
index c707e678207b9683f5ed7f8788cdec9ab612df12..ccb25e8ac8bcfe9380cdabfaeaa6b6f627343f7b 100644 (file)
--- 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 29f7d44ad4da4649c52990fe8a71801f0bb8bc9b..f84408210a2f2781465da7e7f6e7774c1e921e6a 100644 (file)
--- 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");
index 6d901efc83b8c3cdbc5317e273f6402e1ceb4507..815033af37d73097697827d491531c463a359c98 100644 (file)
--- 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);
 }
 
 /**
index 3110badbb2f6ac6ac316ed4fb8e3e9b93306b556..1e52ceec3920ba0dc8c20798176aaba920ed011f 100644 (file)
--- 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 3cfcb6611fcaf65ccf9c346a12cdd360750f9d85..272de0bd92cbad56c6b1196069f481c7a7895dba 100644 (file)
--- 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 e9399268040e027a3bdff088870b71ef2391f81e..e4f72d312d65b412fa5025fd426da6f58f85a9cf 100644 (file)
--- 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);
 }
 
 /**
index 96e14ef13744ad2050ae0f553979af52fb493bf4..e1bda7a07908148be824b5d994125aa7a87aa55e 100644 (file)
@@ -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);
 }
 
index 7ac0a3dcd5ae2645d611e6543328ebb4ab57af30..4fc394dad8dd0404faf355effd1989b57d50b94b 100644 (file)
@@ -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)
           {
index 1d450a64734692d95d6838ef79955e7376180443..87e5e6648f39fb21b0bccee0882052dde9e13657 100644 (file)
--- 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 c23eee02d98a5303efe250df372ff5bc38629cce..ede7563ff8280ed763910305d74b7f05a0ffc9db 100644 (file)
--- 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);
 }