commit b5ede4ff65f011c6b5ff2ad8d777a5c40717def4
parent 63b15275bde5f06f1f52dfc5fcaf5e848bafddfd
Author: Brand Huntsman <alpha@qzx.com>
Date: Thu, 23 Aug 2018 18:50:16 -0600
tweaks: remove the 'bright' field from the colortype struct
Put the corresponding value into the 'attributes' field sooner.
Signed-off-by: Brand Huntsman <alpha@qzx.com>
Diffstat:
3 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/src/color.c b/src/color.c
@@ -66,7 +66,7 @@ void set_colorpairs(void)
combo->bg = COLOR_BLACK;
init_pair(i + 1, combo->fg, combo->bg);
interface_color_pair[i] = COLOR_PAIR(i + 1) | A_BANDAID |
- (combo->bright ? A_BOLD : A_NORMAL);
+ combo->attributes;
} else {
if (i == FUNCTION_TAG)
interface_color_pair[i] = A_NORMAL;
@@ -98,8 +98,7 @@ void set_colorpairs(void)
else
ink->pairnum = new_number++;
- ink->attributes = COLOR_PAIR(ink->pairnum) | A_BANDAID |
- (ink->bright ? A_BOLD : A_NORMAL);
+ ink->attributes |= COLOR_PAIR(ink->pairnum) | A_BANDAID;
}
}
}
diff --git a/src/nano.h b/src/nano.h
@@ -188,8 +188,6 @@ typedef struct colortype {
/* This syntax's foreground color. */
short bg;
/* This syntax's background color. */
- bool bright;
- /* Is this color A_BOLD? */
int pairnum;
/* The color pair number used for this foreground color and
* background color. */
diff --git a/src/rcfile.c b/src/rcfile.c
@@ -602,13 +602,16 @@ short color_to_short(const char *colorname, bool *bright)
/* Parse the color name (or pair of color names) in the given string.
* Return FALSE when any color name is invalid; otherwise return TRUE. */
-bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright)
+bool parse_color_names(char *combostr, short *fg, short *bg, int *attributes)
{
char *comma = strchr(combostr, ',');
+ bool bright;
+
+ *attributes = A_NORMAL;
if (comma != NULL) {
- *bg = color_to_short(comma + 1, bright);
- if (*bright) {
+ *bg = color_to_short(comma + 1, &bright);
+ if (bright) {
rcfile_error(N_("A background color cannot be bright"));
return FALSE;
}
@@ -619,9 +622,12 @@ bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright)
*bg = USE_THE_DEFAULT;
if (comma != combostr) {
- *fg = color_to_short(combostr, bright);
+ *fg = color_to_short(combostr, &bright);
if (*fg == BAD_COLOR)
return FALSE;
+
+ if (bright)
+ *attributes = A_BOLD;
} else
*fg = USE_THE_DEFAULT;
@@ -634,7 +640,7 @@ bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright)
void parse_colors(char *ptr, int rex_flags)
{
short fg, bg;
- bool bright;
+ int attributes;
char *item;
if (!opensyntax) {
@@ -650,7 +656,7 @@ void parse_colors(char *ptr, int rex_flags)
item = ptr;
ptr = parse_next_word(ptr);
- if (!parse_color_names(item, &fg, &bg, &bright))
+ if (!parse_color_names(item, &fg, &bg, &attributes))
return;
if (*ptr == '\0') {
@@ -697,7 +703,7 @@ void parse_colors(char *ptr, int rex_flags)
newcolor->fg = fg;
newcolor->bg = bg;
- newcolor->bright = bright;
+ newcolor->attributes = attributes;
newcolor->rex_flags = rex_flags;
newcolor->start_regex = mallocstrcpy(NULL, item);
@@ -760,7 +766,7 @@ colortype *parse_interface_color(char *combostr)
{
colortype *trio = nmalloc(sizeof(colortype));
- if (parse_color_names(combostr, &trio->fg, &trio->bg, &trio->bright)) {
+ if (parse_color_names(combostr, &trio->fg, &trio->bg, &trio->attributes)) {
free(combostr);
return trio;
} else {