Skip to content

Commit

Permalink
Add bold_brightens_ansi_colors configuration option
Browse files Browse the repository at this point in the history
refs: #244
  • Loading branch information
wez committed Jul 18, 2020
1 parent f2327de commit 1209cde
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/changelog.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions docs/config/fonts.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
```

Expand Down
6 changes: 6 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,12 @@ pub struct Config {
#[serde(default)]
pub font_rules: Vec<StyleRule>,

/// 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<Palette>,

Expand Down
8 changes: 6 additions & 2 deletions src/frontend/gui/termwindow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 1209cde

Please sign in to comment.