From 787f0a135679e64301090968385eaea1fd9c62e4 Mon Sep 17 00:00:00 2001 From: Michael Elkins Date: Thu, 10 Oct 2002 09:40:04 +0000 Subject: [PATCH] Fix header coloring, so there is no difference between ncurses and slang. --- pager.c | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/pager.c b/pager.c index 54f1341cc..8cdf39063 100644 --- a/pager.c +++ b/pager.c @@ -1370,26 +1370,6 @@ display_line (FILE *f, long *last_pos, struct line_t **lineInfo, int n, if (!(flags & M_SHOW)) return 0; - if (flags & M_SHOWCOLOR) - { - m = ((*lineInfo)[n].continuation) ? ((*lineInfo)[n].syntax)[0].first : n; - if ((*lineInfo)[m].type == MT_COLOR_HEADER) - def_color = ((*lineInfo)[m].syntax)[0].color; - else - def_color = (*lineInfo)[m].type; - - attrset (def_color); -#ifdef HAVE_BKGDSET - bkgdset (def_color | ' '); -#endif - clrtoeol (); - SETCOLOR (MT_COLOR_NORMAL); - BKGDSET (MT_COLOR_NORMAL); - - } - else - clrtoeol (); - /* display the line */ format_line (lineInfo, n, buf, flags, &a, cnt, &ch, &vch, &col, &special); @@ -1406,6 +1386,25 @@ display_line (FILE *f, long *last_pos, struct line_t **lineInfo, int n, if (special || (col != COLS && (flags & (M_SHOWCOLOR | M_SEARCH)))) resolve_color (*lineInfo, n, vch, flags, 0, &a); + /* + * Fill the blank space at the end of the line with the prevailing color. + * ncurses does an implicit clrtoeol() when you do addch('\n') so we have + * to make sure to reset the color *after* that + */ + if (flags & M_SHOWCOLOR) + { + m = ((*lineInfo)[n].continuation) ? ((*lineInfo)[n].syntax)[0].first : n; + if ((*lineInfo)[m].type == MT_COLOR_HEADER) + def_color = ((*lineInfo)[m].syntax)[0].color; + else + def_color = ColorDefs[ (*lineInfo)[m].type ]; + + attrset (def_color); +#ifdef HAVE_BKGDSET + bkgdset (def_color | ' '); +#endif + } + /* ncurses always wraps lines when you get to the right side of the * screen, but S-Lang seems to only wrap if the next character is *not* * a newline (grr!). @@ -1415,6 +1414,17 @@ display_line (FILE *f, long *last_pos, struct line_t **lineInfo, int n, #endif addch ('\n'); + /* + * reset the color back to normal. This *must* come after the + * addch('\n'), otherwise the color for this line will not be + * filled to the right margin. + */ + if (flags & M_SHOWCOLOR) + { + SETCOLOR(MT_COLOR_NORMAL); + BKGDSET(MT_COLOR_NORMAL); + } + /* build a return code */ if (!(flags & M_SHOW)) flags = 0; -- 2.40.0