>From c5cfa41cbdf36ac24916b6f40aac33369700695a Mon Sep 17 00:00:00 2001 From: Brand Huntsman Date: Thu, 23 Aug 2018 18:50:16 -0600 Subject: [PATCH] remove bright field from colortype struct Signed-off-by: Brand Huntsman --- src/color.c | 5 ++--- src/nano.h | 2 -- src/rcfile.c | 22 ++++++++++++++-------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/color.c b/src/color.c index 036b4d45..6605a713 100644 --- 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 index c0779801..e1042759 100644 --- 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 index 08de4d67..42accfc5 100644 --- 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 { -- 2.16.4