From 901279a044ee390900c53dd833f32e330a3aec62 Mon Sep 17 00:00:00 2001 From: Robert Clover Date: Fri, 9 Feb 2024 23:42:30 +1100 Subject: [PATCH] Implement terminal text dimming (#7600) Dims text by a certain factor - this respects theme opacity. The amount is documented in the code. As far as I can tell, all other terminals also dim text using this same method. Dim only affects the foreground. SCR-20240209-mfls Release Notes: - Added terminal text dimming (fixes #7497) --- crates/terminal_view/src/terminal_element.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/terminal_view/src/terminal_element.rs b/crates/terminal_view/src/terminal_element.rs index 2696a6058c07f0bc513d91438f5073483001cb83..4b80e3001a62d7bd77f422a1473e1d7dff25180e 100644 --- a/crates/terminal_view/src/terminal_element.rs +++ b/crates/terminal_view/src/terminal_element.rs @@ -329,8 +329,13 @@ impl TerminalElement { hyperlink: Option<(HighlightStyle, &RangeInclusive)>, ) -> TextRun { let flags = indexed.cell.flags; - let fg = convert_color(&fg, &colors); - // let bg = convert_color(&bg, &colors); + let mut fg = convert_color(&fg, &colors); + + // Ghostty uses (175/255) as the multiplier (~0.69), Alacritty uses 0.66, Kitty + // uses 0.75. We're using 0.7 because it's pretty well in the middle of that. + if flags.intersects(Flags::DIM) { + fg.a *= 0.7; + } let underline = (flags.intersects(Flags::ALL_UNDERLINES) || indexed.cell.hyperlink().is_some())