aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-04-18 17:14:33 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-04-18 17:14:33 +0000
commita3d86fb1290961feace9a7bf6d992499eb75bf44 (patch)
treeecdda8913f213e26381b644550ac6e152a35f1bb /render.c
parentMerge branch 'terminal-stop-reading-on-eof' (diff)
parentconfig: bold-text-in-bright: add ‘palette-based’ as a special value (diff)
Merge branch 'brighten-bold-uses-palette-colors'
Closes #449
Diffstat (limited to 'render.c')
-rw-r--r--render.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/render.c b/render.c
index 495c12a6..5efc7c67 100644
--- a/render.c
+++ b/render.c
@@ -252,8 +252,19 @@ 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.
+ */
+ if (term->conf->bold_in_bright.palette_based) {
+ 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));
@@ -434,8 +445,8 @@ 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);
+ if (term->conf->bold_in_bright.enabled && cell->attrs.bold)
+ _fg = color_brighten(term, _fg);
if (cell->attrs.blink && term->blink.state == BLINK_OFF)
_fg = color_dim(_fg);