diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-04-18 17:14:33 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-04-18 17:14:33 +0000 |
| commit | a3d86fb1290961feace9a7bf6d992499eb75bf44 (patch) | |
| tree | ecdda8913f213e26381b644550ac6e152a35f1bb | |
| parent | Merge branch 'terminal-stop-reading-on-eof' (diff) | |
| parent | config: bold-text-in-bright: add ‘palette-based’ as a special value (diff) | |
Merge branch 'brighten-bold-uses-palette-colors'
Closes #449
| -rw-r--r-- | CHANGELOG.md | 5 | ||||
| -rw-r--r-- | config.c | 16 | ||||
| -rw-r--r-- | config.h | 6 | ||||
| -rw-r--r-- | doc/foot.ini.5.scd | 12 | ||||
| -rw-r--r-- | render.c | 17 |
5 files changed, 47 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index b1244531..e9beff07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,11 @@ (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` may now be set to `palette-based`, in which + case it will use the corresponding bright palette color when the + color to brighten matches one of the base 8 colors, instead of + increasing the luminance + (https://codeberg.org/dnkl/foot/issues/449). ### Deprecated @@ -583,8 +583,15 @@ parse_section_main(const char *key, const char *value, struct config *conf, conf->resize_delay_ms = ms; } - else if (strcmp(key, "bold-text-in-bright") == 0) - conf->bold_in_bright = str_to_bool(value); + else if (strcmp(key, "bold-text-in-bright") == 0) { + if (strcmp(value, "palette-based") == 0) { + conf->bold_in_bright.enabled = true; + conf->bold_in_bright.palette_based = true; + } else { + conf->bold_in_bright.enabled = str_to_bool(value); + conf->bold_in_bright.palette_based = false; + } + } else if (strcmp(key, "bell") == 0) { if (strcmp(value, "set-urgency") == 0) @@ -2193,7 +2200,10 @@ config_load(struct config *conf, const char *conf_path, .pad_x = 2, .pad_y = 2, .resize_delay_ms = 100, - .bold_in_bright = false, + .bold_in_bright = { + .enabled = false, + .palette_based = false, + }, .bell_action = BELL_ACTION_NONE, .startup_mode = STARTUP_WINDOWED, .fonts = {tll_init(), tll_init(), tll_init(), tll_init()}, @@ -79,7 +79,11 @@ struct config { bool center; uint16_t resize_delay_ms; - bool bold_in_bright; + struct { + bool enabled; + bool palette_based; + } bold_in_bright; + enum { BELL_ACTION_NONE, BELL_ACTION_URGENT, diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index 675f9bf8..4af48307 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -200,8 +200,16 @@ in this order: apply window management rules. Default: _foot_. *bold-text-in-bright* - Boolean. When enabled, bold text is rendered in a brighter color - (in addition to using a bold font). Default: _no_. + Semi-boolean. When enabled, bold text is rendered in a brighter + color (in addition to using a bold font). The color is brightened + by increasing its luminance. + + If set to *palette-based*, rather than a simple *yes|true*, colors + matching one of the 8 regular palette colors will be brightened + using the corresponding bright palette color. Other colors will be + brightened by increasing the luminance. + + Default: _no_. *bell* Action to perform when receiving a *BEL* character. Can be set to @@ -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); |
