From 2cd9fee9c4fc503142b71c9cb7aa935bfd18d247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 17 Apr 2021 21:02:02 +0200 Subject: [PATCH] render: brighten: use corresponding bright palette color for base 8 colors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When brightening one of the 8 base (“regular”) colors, use the corresponding bright palette color, instead of increasing the luminance. Closes #449 --- CHANGELOG.md | 3 +++ render.c | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1244531..0da8880d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,9 @@ (https://codeberg.org/dnkl/foot/issues/415). * Foot now tries much harder to keep URL jump labels inside the window geometry (https://codeberg.org/dnkl/foot/issues/443). +* `bold-text-in-bright` now uses the corresponding bright palette + color when the color to brighten matches one of the base 8 colors + (https://codeberg.org/dnkl/foot/issues/449). ### Deprecated diff --git a/render.c b/render.c index 495c12a6..3ca0deeb 100644 --- a/render.c +++ b/render.c @@ -252,8 +252,17 @@ color_dim(uint32_t color) } static inline uint32_t -color_brighten(uint32_t color) +color_brighten(const struct terminal *term, uint32_t color) { + /* + * First try to match the color against the base 8 colors. If we + * find a match, return the corresponding bright color. + */ + for (size_t i = 0; i < 8; i++) { + if (term->colors.table[i] == color) + return term->colors.table[i + 8]; + } + int hue, sat, lum; rgb_to_hsl(color, &hue, &sat, &lum); return hsl_to_rgb(hue, sat, min(100, lum * 1.3)); @@ -435,7 +444,7 @@ render_cell(struct terminal *term, pixman_image_t *pix, if (cell->attrs.dim) _fg = color_dim(_fg); if (term->conf->bold_in_bright && cell->attrs.bold) - _fg = color_brighten(_fg); + _fg = color_brighten(term, _fg); if (cell->attrs.blink && term->blink.state == BLINK_OFF) _fg = color_dim(_fg);