]> granicus.if.org Git - mutt/commitdiff
Color protected subject as a header in the pager.
authorKevin McCarthy <kevin@8t8.us>
Sat, 29 Dec 2018 21:20:03 +0000 (13:20 -0800)
committerKevin McCarthy <kevin@8t8.us>
Sat, 29 Dec 2018 22:12:07 +0000 (14:12 -0800)
crypt.c
globals.h
init.c
mutt.h
muttlib.c
pager.c

diff --git a/crypt.c b/crypt.c
index e1ab409e81bc0c3228fe10e59d4c2e35d7bf2a19..7c39f856a8df2d4d5786615093da4904d28e4237 100644 (file)
--- a/crypt.c
+++ b/crypt.c
@@ -943,6 +943,7 @@ int mutt_protected_headers_handler (BODY *a, STATE *s)
   {
     if (a->mime_headers->subject)
     {
+      state_mark_protected_header (s);
       mutt_write_one_header (s->fpout, "Subject", a->mime_headers->subject,
                              s->prefix,
                              mutt_window_wrap_cols (MuttIndexWindow, Wrap),
index 54da70cb33d7661453492fd5582aadeeec2b0c9b..b74b4d1c88f8118113d032d74143e97c50d79abb 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -23,6 +23,7 @@ WHERE CONTEXT *Context;
 
 WHERE char Errorbuf[STRING];
 WHERE char AttachmentMarker[STRING];
+WHERE char ProtectedHeaderMarker[STRING];
 
 #if defined(DL_STANDALONE) && defined(USE_DOTLOCK)
 WHERE char *MuttDotlock;
diff --git a/init.c b/init.c
index 97bb03eb7deaa711a4f88da7013cebecad5a3c46..1ab4ece2916db4ee1704bbb5461a0f8fc32cf1d3 100644 (file)
--- a/init.c
+++ b/init.c
@@ -3409,7 +3409,9 @@ void mutt_init (int skip_sys_rc, LIST *commands)
    */
   snprintf (AttachmentMarker, sizeof (AttachmentMarker),
            "\033]9;%ld\a", (long) time (NULL));
-  
+  snprintf (ProtectedHeaderMarker, sizeof (ProtectedHeaderMarker),
+           "\033]8;%ld\a", (long) time (NULL));
+
   /* on one of the systems I use, getcwd() does not return the same prefix
      as is listed in the passwd file */
   if ((p = getenv ("HOME")))
diff --git a/mutt.h b/mutt.h
index 91c3b67b33b7fb6b44bf16b1d241d8e440d64dc1..c8a89a5426bd594aac769adeba9e5a4e849cb60d 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -1088,6 +1088,7 @@ typedef struct
 #define state_putc(x,y) fputc(x,(y)->fpout)
 
 void state_mark_attach (STATE *);
+void state_mark_protected_header (STATE *);
 void state_attach_puts (const char *, STATE *);
 void state_prefix_putc (char, STATE *);
 int  state_printf(STATE *, const char *, ...);
index 812765f7dfcbf6db8b594750d35e9d281587356a..61c54d57e90d202da46bc7d288dce5218371d8b2 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -1783,6 +1783,12 @@ void state_mark_attach (STATE *s)
     state_puts (AttachmentMarker, s);
 }
 
+void state_mark_protected_header (STATE *s)
+{
+  if ((s->flags & MUTT_DISPLAY) && !mutt_strcmp (Pager, "builtin"))
+    state_puts (ProtectedHeaderMarker, s);
+}
+
 void state_attach_puts (const char *t, STATE *s)
 {
   if (*t != '\n') state_mark_attach (s);
diff --git a/pager.c b/pager.c
index 5fb8629dbcb138defa5d1aca6ac5793b31270414..e86c93b988edc7883562da6aec2a0848ff0eca93 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -706,7 +706,8 @@ classify_quote (struct q_class_t **QuoteList, const char *qptr,
 static int brailleLine = -1;
 static int brailleCol = -1;
 
-static int check_attachment_marker (char *);
+static int check_attachment_marker (const char *);
+static int check_protected_header_marker (const char *);
 
 /* Checks if buf matches the QuoteRegexp and doesn't match Smileys.
  * pmatch, if non-null, is populated with the regexec match against
@@ -755,7 +756,8 @@ resolve_types (char *buf, char *raw, struct line_t *lineInfo, int n, int last,
   regmatch_t pmatch[1];
   int found, offset, null_rx, i;
 
-  if (n == 0 || ISHEADER (lineInfo[n-1].type))
+  if (n == 0 || ISHEADER (lineInfo[n-1].type) ||
+      (check_protected_header_marker (raw) == 0))
   {
     if (buf[0] == '\n') /* end of header */
     {
@@ -954,15 +956,23 @@ static int is_ansi (unsigned char *buf)
   return (*buf == 'm');
 }
 
-static int check_attachment_marker (char *p)
+static int check_marker (const char *q, const char *p)
 {
-  char *q = AttachmentMarker;
-  
   for (;*p == *q && *q && *p && *q != '\a' && *p != '\a'; p++, q++)
     ;
   return (int) (*p - *q);
 }
 
+static int check_attachment_marker (const char *p)
+{
+  return check_marker (AttachmentMarker, p);
+}
+
+static int check_protected_header_marker (const char *p)
+{
+  return check_marker (ProtectedHeaderMarker, p);
+}
+
 static int grok_ansi(unsigned char *buf, int pos, ansi_attr *a)
 {
   int x = pos;
@@ -1092,7 +1102,9 @@ fill_buffer (FILE *f, LOFF_T *last_pos, LOFF_T offset, unsigned char **buf,
        while (*p++ != 'm')     /* skip ANSI sequence */
          ;
       }
-      else if (*p == '\033' && *(p+1) == ']' && check_attachment_marker ((char *) p) == 0)
+      else if (*p == '\033' && *(p+1) == ']' &&
+               ((check_attachment_marker ((char *) p) == 0) ||
+                (check_protected_header_marker ((char *) p) == 0)))
       {
        dprint (2, (debugfile, "fill_buffer: Seen attachment marker.\n"));
        while (*p++ != '\a')    /* skip pseudo-ANSI sequence */
@@ -1134,7 +1146,8 @@ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
       ch = grok_ansi (buf, ch+2, pa) + 1;
 
     while (cnt-ch >= 2 && buf[ch] == '\033' && buf[ch+1] == ']' &&
-          check_attachment_marker ((char *) buf+ch) == 0)
+          ((check_attachment_marker ((char *) buf+ch) == 0) ||
+            (check_protected_header_marker ((char *) buf+ch) == 0)))
     {
       while (buf[ch++] != '\a')
        if (ch >= cnt)