From 1209cde2b10706301c0d2ad71b2cffd48c5dbebb Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 18 Jul 2020 09:02:56 -0700 Subject: [PATCH] Add bold_brightens_ansi_colors configuration option refs: https://github.com/wez/wezterm/issues/244 --- docs/changelog.markdown | 2 ++ docs/config/fonts.markdown | 14 ++++++++++++++ src/config/mod.rs | 6 ++++++ src/frontend/gui/termwindow.rs | 8 ++++++-- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/docs/changelog.markdown b/docs/changelog.markdown index 2e1b18900..f2f9f4919 100644 --- a/docs/changelog.markdown +++ b/docs/changelog.markdown @@ -14,6 +14,8 @@ brief notes about them may accumulate here. (not multiplexer) terminal sessions. * Added support for SGR 53/55 which enable/disable Overline style. `printf "\x1b[53moverline\x1b[0m\n"` +* Added `bold_brightens_ansi_colors` option to allow disabling the automatic + brightening of bold text. ### 20200620-160318-e00b076c diff --git a/docs/config/fonts.markdown b/docs/config/fonts.markdown index dac7913d2..2160c73ac 100644 --- a/docs/config/fonts.markdown +++ b/docs/config/fonts.markdown @@ -27,6 +27,20 @@ return { -- or notice slight differences when comparing with other terminal -- emulators, you may wish to tune this value! dpi = 96.0, + + -- When true (the default), text that is set to ANSI color + -- indices 0-7 will be shifted to the corresponding brighter + -- color index (8-15) when the intensity is set to Bold. + -- + -- This brightening effect doesn't occur when the text is set + -- to the default foreground color! + -- + -- This defaults to true for better compatibility with a wide + -- range of mature software; for instance, a lot of software + -- assumes that Black+Bold renders as a Dark Grey which is + -- legible on a Black background, but if this option is set to + -- true, it would render as Black on Black. + bold_brightens_ansi_colors = true, } ``` diff --git a/src/config/mod.rs b/src/config/mod.rs index 5383821c7..4d0c5ea77 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -283,6 +283,12 @@ pub struct Config { #[serde(default)] pub font_rules: Vec, + /// When true (the default), PaletteIndex 0-7 are shifted to + /// bright when the font intensity is bold. The brightening + /// doesn't apply to text that is the default color. + #[serde(default = "default_true")] + pub bold_brightens_ansi_colors: bool, + /// The color palette pub colors: Option, diff --git a/src/frontend/gui/termwindow.rs b/src/frontend/gui/termwindow.rs index 001a73891..b68f11449 100644 --- a/src/frontend/gui/termwindow.rs +++ b/src/frontend/gui/termwindow.rs @@ -2312,7 +2312,9 @@ impl TermWindow { params.palette.resolve_fg(attrs.foreground) } } - wezterm_term::color::ColorAttribute::PaletteIndex(idx) if idx < 8 => { + wezterm_term::color::ColorAttribute::PaletteIndex(idx) + if idx < 8 && params.config.bold_brightens_ansi_colors => + { // For compatibility purposes, switch to a brighter version // of one of the standard ANSI colors when Bold is enabled. // This lifts black to dark grey. @@ -2599,7 +2601,9 @@ impl TermWindow { palette.resolve_fg(attrs.foreground) } } - wezterm_term::color::ColorAttribute::PaletteIndex(idx) if idx < 8 => { + wezterm_term::color::ColorAttribute::PaletteIndex(idx) + if idx < 8 && config.bold_brightens_ansi_colors => + { // For compatibility purposes, switch to a brighter version // of one of the standard ANSI colors when Bold is enabled. // This lifts black to dark grey.