diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2022-02-02 07:09:46 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2022-02-02 07:09:46 +0200 |
commit | a7163a05daad0ae4b04624eb954d361a75cd33cb (patch) | |
tree | 0cf1b35d2c54bda4fce4b61ab17f3822e06b05d6 /src/ui/text.c | |
parent | 242fce55cf9af42ce044a329dc3c29a5b79f801c (diff) |
Improved legibility of ANSI FG colors
Brighten dark colors on a (nearly) black background.
On light backgrounds, reduce the darkening as it was a bit too strong; more of the color is now shown.
Diffstat (limited to 'src/ui/text.c')
-rw-r--r-- | src/ui/text.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/ui/text.c b/src/ui/text.c index 3fe56b59..b610d3b8 100644 --- a/src/ui/text.c +++ b/src/ui/text.c | |||
@@ -702,11 +702,20 @@ static iColor fgColor_AttributedRun_(const iAttributedRun *d) { | |||
702 | iColor fg = d->fgColor_; | 702 | iColor fg = d->fgColor_; |
703 | const iHSLColor themeBg = get_HSLColor(tmBackground_ColorId); | 703 | const iHSLColor themeBg = get_HSLColor(tmBackground_ColorId); |
704 | const float bgLuminance = luma_Color(get_Color(tmBackground_ColorId)); | 704 | const float bgLuminance = luma_Color(get_Color(tmBackground_ColorId)); |
705 | /* TODO: Actually this should check if the FG is too close to the BG, and | ||
706 | either darken or brighten the FG. Now it only accounts for nearly black/white | ||
707 | backgrounds. */ | ||
708 | if (bgLuminance < 0.1f) { | ||
709 | /* Background is dark. Lighten the foreground. */ | ||
710 | iHSLColor fgHsl = hsl_Color(fg); | ||
711 | fgHsl.lum = iMax(0.2f, fgHsl.lum); | ||
712 | return rgb_HSLColor(fgHsl); | ||
713 | } | ||
705 | if (bgLuminance > 0.4f) { | 714 | if (bgLuminance > 0.4f) { |
706 | float dim = (bgLuminance - 0.4f); | 715 | float dim = (bgLuminance - 0.4f); |
707 | fg.r *= 0.5f * dim; | 716 | fg.r *= 1.0f * dim; |
708 | fg.g *= 0.5f * dim; | 717 | fg.g *= 1.0f * dim; |
709 | fg.b *= 0.5f * dim; | 718 | fg.b *= 1.0f * dim; |
710 | } | 719 | } |
711 | if (themeBg.sat > 0.15f && themeBg.lum >= 0.5f) { | 720 | if (themeBg.sat > 0.15f && themeBg.lum >= 0.5f) { |
712 | iHSLColor fgHsl = hsl_Color(fg); | 721 | iHSLColor fgHsl = hsl_Color(fg); |