From: Kevin McCarthy Date: Sat, 29 Dec 2018 21:20:03 +0000 (-0800) Subject: Color protected subject as a header in the pager. X-Git-Tag: mutt-1-12-rel~151 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f3f98bd66cde06d02b943a062142cc268019579a;p=mutt Color protected subject as a header in the pager. --- diff --git a/crypt.c b/crypt.c index e1ab409e..7c39f856 100644 --- 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), diff --git a/globals.h b/globals.h index 54da70cb..b74b4d1c 100644 --- 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 97bb03eb..1ab4ece2 100644 --- 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 91c3b67b..c8a89a54 100644 --- 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 *, ...); diff --git a/muttlib.c b/muttlib.c index 812765f7..61c54d57 100644 --- 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 5fb8629d..e86c93b9 100644 --- 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)