[misc] [PATCH] Default (white) as foreground colour

White could only with great difficulty be used as customized
foreground colour, because the colour pair COLR_CUSTOM then
was identical to COLR_DEFAULT (default on default). This made
it impossible to distinguish the selected element in lists.

The patch turns on A_BOLD when default (or white) is chosen
as foreground colour.
---
 src/config.c | 1 +
 src/custom.c | 9 ++++++++-
 src/utils.c  | 7 +++++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/config.c b/src/config.c
index c46d718..3221f23 100644
--- a/src/config.c
+++ b/src/config.c
@@ -263,6 +263,7 @@ static int config_parse_color_theme(void *dummy, const char *val)
 	if (!config_parse_color_pair(&color1, &color2, val))
 		return 0;
 	init_pair(COLR_CUSTOM, color1, color2);
+	custom_init_attr();
 	return 1;
 }
 
diff --git a/src/custom.c b/src/custom.c
index f528d32..1e5884f 100644
--- a/src/custom.c
+++ b/src/custom.c
@@ -58,7 +58,13 @@ static struct attribute attr;
  */
 void custom_init_attr(void)
 {
-	attr.color[ATTR_HIGHEST] = COLOR_PAIR(COLR_CUSTOM);
+	short col_fg;
+	pair_content(COLR_CUSTOM, &col_fg, NULL);
+
+	attr.color[ATTR_HIGHEST] =
+		(col_fg == COLOR_WHITE || col_fg == -1 || col_fg == 255) ?
+		COLOR_PAIR(COLR_CUSTOM) | A_BOLD :
+		COLOR_PAIR(COLR_CUSTOM);
 	attr.color[ATTR_HIGH] = COLOR_PAIR(COLR_HIGH);
 	attr.color[ATTR_MIDDLE] = COLOR_PAIR(COLR_RED) | A_BOLD;
 	attr.color[ATTR_LOW] = COLOR_PAIR(COLR_CYAN);
@@ -371,6 +377,7 @@ display_color_config(struct window *cwin, int *mark_fore, int *mark_back,
 			if (colr_back == 255)
 				colr_back = -1;
 			init_pair(COLR_CUSTOM, colr_fore, colr_back);
+			custom_init_attr();
 		} else {
 			/* Retrieve the actual color theme. */
 			pair_content(COLR_CUSTOM, &colr_fore, &colr_back);
diff --git a/src/utils.c b/src/utils.c
index c046ad5..d156faf 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -669,6 +669,12 @@ print_bool_option_incolor(WINDOW * win, unsigned option, int pos_y,
 		EXIT(_("option not defined"));
 	}
 
+	/*
+	 * At entry, custom_apply_attr(ATTR_HIGHEST) is in effect.
+	 * Turn it off explicitly, while it may have other attributes
+	 * besides the colour (A_BOLD, if foreground colour is default).
+	 */
+	custom_remove_attr(win, ATTR_HIGHEST);
 	custom_apply_attr(win, color);
 	mvwaddstr(win, pos_y, pos_x, option_value);
 	custom_remove_attr(win, color);
-- 
2.14.2.666.gea220ee40

Links