diff --git a/CHANGELOG.md b/CHANGELOG.md index 0da8880d..e9beff07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,8 +42,10 @@ (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 +* `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). diff --git a/config.c b/config.c index 653c3f8a..3aed1e7d 100644 --- a/config.c +++ b/config.c @@ -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()}, diff --git a/config.h b/config.h index d64c5e98..06184658 100644 --- a/config.h +++ b/config.h @@ -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 diff --git a/render.c b/render.c index 3ca0deeb..5efc7c67 100644 --- a/render.c +++ b/render.c @@ -258,9 +258,11 @@ 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]; + 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; @@ -443,7 +445,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) + if (term->conf->bold_in_bright.enabled && cell->attrs.bold) _fg = color_brighten(term, _fg); if (cell->attrs.blink && term->blink.state == BLINK_OFF)