aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-11-13 16:40:34 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-11-13 16:40:34 +0000
commitd1a76a67c0c8c4ad3341cf9baa95f48e0e6d8fb1 (patch)
treefc6a5d6c1284bd7a7f035ae66998fa16f2c27a15 /render.c
parentdoc: foot.ini: try to clear up the meaning of (AA)RRGGBB (diff)
parentconfig: add [colors].dim0-7 (diff)
Merge branch 'configurable-dim-colors'
Closes #776
Diffstat (limited to 'render.c')
-rw-r--r--render.c41
1 files changed, 34 insertions, 7 deletions
diff --git a/render.c b/render.c
index 39957de8..46cc0f75 100644
--- a/render.c
+++ b/render.c
@@ -244,7 +244,7 @@ color_hex_to_pixman(uint32_t color)
}
static inline uint32_t
-color_dim(uint32_t color)
+color_decrease_luminance(uint32_t color)
{
uint32_t alpha = color & 0xff000000;
int hue, sat, lum;
@@ -253,6 +253,33 @@ color_dim(uint32_t color)
}
static inline uint32_t
+color_dim(const struct terminal *term, uint32_t color)
+{
+ const struct config *conf = term->conf;
+ const uint8_t custom_dim = conf->colors.use_custom.dim;
+
+ if (likely(custom_dim == 0))
+ return color_decrease_luminance(color);
+
+ for (size_t i = 0; i < 8; i++) {
+ if (((custom_dim >> i) & 1) == 0)
+ continue;
+
+ if (term->colors.table[0 + i] == color) {
+ /* “Regular” color, return the corresponding “dim” */
+ return conf->colors.dim[i];
+ }
+
+ else if (term->colors.table[8 + i] == color) {
+ /* “Bright” color, return the corresponding “regular” */
+ return term->colors.table[i];
+ }
+ }
+
+ return color_decrease_luminance(color);
+}
+
+static inline uint32_t
color_brighten(const struct terminal *term, uint32_t color)
{
/*
@@ -485,12 +512,12 @@ render_cell(struct terminal *term, pixman_image_t *pix,
}
if (cell->attrs.dim)
- _fg = color_dim(_fg);
+ _fg = color_dim(term, _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);
+ _fg = color_decrease_luminance(_fg);
pixman_color_t fg = color_hex_to_pixman(_fg);
pixman_color_t bg = color_hex_to_pixman_with_alpha(_bg, alpha);
@@ -779,7 +806,7 @@ render_urgency(struct terminal *term, struct buffer *buf)
{
uint32_t red = term->colors.table[1];
if (term->is_searching)
- red = color_dim(red);
+ red = color_decrease_luminance(red);
pixman_color_t bg = color_hex_to_pixman(red);
@@ -1685,8 +1712,8 @@ render_csd_title(struct terminal *term, const struct csd_data *info,
: term->conf->colors.bg;
if (!term->visual_focus) {
- bg = color_dim(bg);
- fg = color_dim(fg);
+ bg = color_dim(term, bg);
+ fg = color_dim(term, fg);
}
const wchar_t *title_text = L"";
@@ -2001,7 +2028,7 @@ render_csd_button(struct terminal *term, enum csd_surface surf_idx,
}
if (!term->visual_focus)
- _color = color_dim(_color);
+ _color = color_dim(term, _color);
pixman_color_t color = color_hex_to_pixman_with_alpha(_color, alpha);
render_csd_part(term, surf, buf, info->width, info->height, &color);