>From 50081a7422ce30d81ea6ccdaed0e9b91299eb59e Mon Sep 17 00:00:00 2001 From: Brand Huntsman Date: Wed, 28 Feb 2018 21:03:48 -0700 Subject: [PATCH 1/5] remove bright field from colortype struct Signed-off-by: Brand Huntsman --- src/color.c | 8 ++++---- src/nano.h | 2 -- src/proto.h | 2 +- src/rcfile.c | 22 ++++++++++++++-------- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/color.c b/src/color.c index 131f23d8..1847bd6e 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; @@ -91,7 +91,8 @@ void set_colorpairs(void) while (beforenow != ink && (beforenow->fg != ink->fg || beforenow->bg != ink->bg || - beforenow->bright != ink->bright)) + (beforenow->attributes & 0xFFFF0000) != + ink->attributes)) beforenow = beforenow->next; if (beforenow != ink) @@ -99,8 +100,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 c092d3e1..ca9950ad 100644 --- a/src/nano.h +++ b/src/nano.h @@ -182,8 +182,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/proto.h b/src/proto.h index a19c5148..d98a491a 100644 --- a/src/proto.h +++ b/src/proto.h @@ -471,7 +471,7 @@ int do_yesno_prompt(bool all, const char *msg); /* Most functions in rcfile.c. */ #ifdef ENABLE_NANORC #ifdef ENABLE_COLOR -bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright); +bool parse_color_names(char *combostr, short *fg, short *bg, int *attributes); void grab_and_store(const char *kind, char *ptr, regexlisttype **storage); #endif void parse_rcfile(FILE *rcstream, bool syntax_only); diff --git a/src/rcfile.c b/src/rcfile.c index 362f3c8e..a99865f9 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -620,7 +620,7 @@ short color_to_short(const char *colorname, bool *bright) void parse_colors(char *ptr, int rex_flags) { short fg, bg; - bool bright; + int attributes; char *item; if (!opensyntax) { @@ -636,7 +636,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') { @@ -683,7 +683,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); @@ -742,13 +742,16 @@ void parse_colors(char *ptr, int rex_flags) } /* Parse the color name, or pair of color names, in combostr. */ -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; } @@ -757,11 +760,14 @@ bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright) *bg = -1; if (comma != combostr) { - *fg = color_to_short(combostr, bright); + *fg = color_to_short(combostr, &bright); /* If the specified foreground color is bad, ignore the regexes. */ if (*fg == -1) return FALSE; + + if (bright) + *attributes |= A_BOLD; } else *fg = -1; @@ -773,7 +779,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.1