X-Git-Url: https://git.llucax.com/software/mutt-debian.git/blobdiff_plain/647ac5444d022537a1f0854dd309494c511dfe07..90ca98902668310adea2bd544a61a3d6c9c12f1c:/pager.c?ds=sidebyside diff --git a/pager.c b/pager.c index 61fe096..e19174c 100644 --- a/pager.c +++ b/pager.c @@ -110,6 +110,7 @@ struct line_t struct syntax_t *syntax; struct syntax_t *search; struct q_class_t *quote; + unsigned int is_cont_hdr; /* this line is a continuation of the previous header line */ }; #define ANSI_OFF (1<<0) @@ -712,27 +713,51 @@ resolve_types (char *buf, char *raw, struct line_t *lineInfo, int n, int last, if (n == 0 || ISHEADER (lineInfo[n-1].type)) { - if (buf[0] == '\n') { + if (buf[0] == '\n') /* end of header */ + { lineInfo[n].type = MT_COLOR_NORMAL; getyx(stdscr, brailleLine, brailleCol); - } else if (n > 0 && (buf[0] == ' ' || buf[0] == '\t')) - { - lineInfo[n].type = lineInfo[n-1].type; /* wrapped line */ - (lineInfo[n].syntax)[0].color = (lineInfo[n-1].syntax)[0].color; } else { - lineInfo[n].type = MT_COLOR_HDEFAULT; - color_line = ColorHdrList; - while (color_line) + /* if this is a continuation of the previous line, use the previous + * line's color as default. */ + if (n > 0 && (buf[0] == ' ' || buf[0] == '\t')) + { + lineInfo[n].type = lineInfo[n-1].type; /* wrapped line */ + (lineInfo[n].syntax)[0].color = (lineInfo[n-1].syntax)[0].color; + lineInfo[n].is_cont_hdr = 1; + } + else + { + lineInfo[n].type = MT_COLOR_HDEFAULT; + } + + for (color_line = ColorHdrList; color_line; color_line = color_line->next) { if (REGEXEC (color_line->rx, buf) == 0) { lineInfo[n].type = MT_COLOR_HEADER; lineInfo[n].syntax[0].color = color_line->pair; + if (lineInfo[n].is_cont_hdr) + { + /* adjust the previous continuation lines to reflect the color of this continuation line */ + int j; + for (j = n - 1; j >= 0 && lineInfo[j].is_cont_hdr; --j) + { + lineInfo[j].type = lineInfo[n].type; + lineInfo[j].syntax[0].color = lineInfo[n].syntax[0].color; + } + /* now adjust the first line of this header field */ + if (j >= 0) + { + lineInfo[j].type = lineInfo[n].type; + lineInfo[j].syntax[0].color = lineInfo[n].syntax[0].color; + } + *force_redraw = 1; /* the previous lines have already been drawn on the screen */ + } break; } - color_line = color_line->next; } } } @@ -1032,7 +1057,7 @@ fill_buffer (FILE *f, LOFF_T *last_pos, LOFF_T offset, unsigned char **buf, { if (*(p+1) == '_') /* underline */ p += 2; - else if (*(p+1)) /* bold or overstrike */ + else if (*(p+1) && q > *fmt) /* bold or overstrike */ { *(q-1) = *(p+1); p += 2; @@ -1069,9 +1094,11 @@ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf, int ch, vch, k, last_special = -1, special = 0, t; wchar_t wc; mbstate_t mbstate; - int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap); - + + if (check_attachment_marker ((char *)buf) == 0) + wrap_cols = COLS; + /* FIXME: this should come from lineInfo */ memset(&mbstate, 0, sizeof(mbstate)); @@ -1381,7 +1408,8 @@ display_line (FILE *f, LOFF_T *last_pos, struct line_t **lineInfo, int n, { if (cnt < b_read) { - if (ch != -1 && buf[cnt] != ' ' && buf[cnt] != '\t' && buf[cnt] != '\n' && buf[cnt] != '\r') + if (ch != -1 && buf[0] != ' ' && buf[0] != '\t' && + buf[cnt] != ' ' && buf[cnt] != '\t' && buf[cnt] != '\n' && buf[cnt] != '\r') { buf_ptr = buf + ch; /* skip trailing blanks */ @@ -2101,7 +2129,6 @@ search_next: { regerror (err, &SearchRE, buffer, sizeof (buffer)); mutt_error ("%s", buffer); - regfree (&SearchRE); for (i = 0; i < maxLine ; i++) { /* cleanup */