Commit 4c566c79 authored by Rishabh Dave's avatar Rishabh Dave Committed by Benno Schulenberg
Browse files

tweaks: reduce the number of wattron/wattrof calls


Also, compose the coloring attributes during initialization
instead of every time when painting something.
Signed-off-by: default avatarRishabh Dave <rishabhddave@gmail.com>
Signed-off-by: default avatarBenno Schulenberg <bensberg@justemail.net>
No related merge requests found
Showing with 7 additions and 5 deletions
+7 -5
...@@ -97,6 +97,9 @@ void set_colorpairs(void) ...@@ -97,6 +97,9 @@ void set_colorpairs(void)
this_color->pairnum = clr_pair; this_color->pairnum = clr_pair;
clr_pair++; clr_pair++;
} }
this_color->attributes = COLOR_PAIR(this_color->pairnum) |
(this_color->bright ? A_BOLD : A_NORMAL);
} }
} }
} }
......
...@@ -210,6 +210,8 @@ typedef struct colortype { ...@@ -210,6 +210,8 @@ typedef struct colortype {
int pairnum; int pairnum;
/* The color pair number used for this foreground color and /* The color pair number used for this foreground color and
* background color. */ * background color. */
int attributes;
/* Pair number and brightness composed into ready-to-use attributes. */
int rex_flags; int rex_flags;
/* The regex compilation flags (with or without REG_ICASE). */ /* The regex compilation flags (with or without REG_ICASE). */
char *start_regex; char *start_regex;
......
...@@ -2265,9 +2265,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int ...@@ -2265,9 +2265,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
regmatch_t endmatch; regmatch_t endmatch;
/* Match position for end_regex. */ /* Match position for end_regex. */
if (varnish->bright) wattron(edit, varnish->attributes);
wattron(edit, A_BOLD);
wattron(edit, COLOR_PAIR(varnish->pairnum));
/* Two notes about regexec(). A return value of zero means /* Two notes about regexec(). A return value of zero means
* that there is a match. Also, rm_eo is the first * that there is a match. Also, rm_eo is the first
* non-matching character after the match. */ * non-matching character after the match. */
...@@ -2524,8 +2522,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int ...@@ -2524,8 +2522,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
} }
} }
tail_of_loop: tail_of_loop:
wattroff(edit, A_BOLD); wattroff(edit, varnish->attributes);
wattroff(edit, COLOR_PAIR(varnish->pairnum));
} }
} }
#endif /* !DISABLE_COLOR */ #endif /* !DISABLE_COLOR */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment