From d356b72ca97c31411cb632b85f98f81fcd3a0965 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Thu, 7 Apr 2022 21:55:28 -0700 Subject: [PATCH] cursor_fg, cursor_bg, cursor_border now accept alpha values refs: https://github.com/wez/wezterm/issues/1835 --- docs/changelog.md | 1 + term/src/color.rs | 12 ++++++------ term/src/terminalstate/performer.rs | 2 +- wezterm-gui/src/termwindow/render.rs | 6 +++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index d07b68d15..a8b71e34a 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -27,6 +27,7 @@ As features stabilize some brief notes about them will accumulate here. * Wayland: touchpad scroll is now more responsive/precise. Thanks to [@davidrios](https://github.com/davidrios)! [#1800](https://github.com/wez/wezterm/pull/1800) * Kitty image protocol: now also supports shared memory data transmission. Thanks to [@tantei3](https://github.com/tantei3)! [#1810](https://github.com/wez/wezterm/pull/1810) * Secondary DA response bumped up to persuade vim to set `ttymouse=sgr` by default. [#1825](https://github.com/wez/wezterm/issues/1825) +* `cursor_bg`, `cursor_fg` and `cursor_border` may now specify alpha values. [#1835](https://github.com/wez/wezterm/issues/1835) #### Fixed * Incorrect csi-u encoding with non-ascii characters. [#1746](https://github.com/wez/wezterm/issues/1746) diff --git a/term/src/color.rs b/term/src/color.rs index a33df9ecb..0ff800704 100644 --- a/term/src/color.rs +++ b/term/src/color.rs @@ -49,9 +49,9 @@ pub struct ColorPalette { pub colors: Palette256, pub foreground: RgbColor, pub background: RgbColor, - pub cursor_fg: RgbColor, - pub cursor_bg: RgbColor, - pub cursor_border: RgbColor, + pub cursor_fg: SrgbaTuple, + pub cursor_bg: SrgbaTuple, + pub cursor_border: SrgbaTuple, pub selection_fg: SrgbaTuple, pub selection_bg: SrgbaTuple, pub scrollbar_thumb: RgbColor, @@ -167,9 +167,9 @@ impl ColorPalette { let foreground = colors[249]; // Grey70 let background = colors[AnsiColor::Black as usize]; - let cursor_bg = RgbColor::new_8bpc(0x52, 0xad, 0x70); - let cursor_border = RgbColor::new_8bpc(0x52, 0xad, 0x70); - let cursor_fg = colors[AnsiColor::Black as usize]; + let cursor_bg = RgbColor::new_8bpc(0x52, 0xad, 0x70).into(); + let cursor_border = RgbColor::new_8bpc(0x52, 0xad, 0x70).into(); + let cursor_fg = colors[AnsiColor::Black as usize].into(); let selection_fg = SrgbaTuple(0., 0., 0., 0.); let selection_bg = SrgbaTuple(0.5, 0.4, 0.6, 0.5); diff --git a/term/src/terminalstate/performer.rs b/term/src/terminalstate/performer.rs index 67e6cbd09..f71ce990a 100644 --- a/term/src/terminalstate/performer.rs +++ b/term/src/terminalstate/performer.rs @@ -818,7 +818,7 @@ impl<'a> Performer<'a> { // We set the border to the background color; we don't // have an escape that sets that independently, and this // way just looks better. - self.palette_mut().cursor_border = c; + self.palette_mut().cursor_border = c.into(); } set_or_query!(cursor_bg) } diff --git a/wezterm-gui/src/termwindow/render.rs b/wezterm-gui/src/termwindow/render.rs index 6698e07ed..9b22f9f78 100644 --- a/wezterm-gui/src/termwindow/render.rs +++ b/wezterm-gui/src/termwindow/render.rs @@ -1075,7 +1075,7 @@ impl super::TermWindow { log::trace!("quad map elapsed {:?}", start.elapsed()); metrics::histogram!("quad.map", start.elapsed()); - let cursor_border_color = rgbcolor_to_window_color(palette.cursor_border); + let cursor_border_color = palette.cursor_border.to_linear(); let foreground = rgbcolor_to_window_color(palette.foreground); let white_space = gl_state.util_sprites.white_space.texture_coords(); let filled_box = gl_state.util_sprites.filled_box.texture_coords(); @@ -1350,8 +1350,8 @@ impl super::TermWindow { let start = Instant::now(); let selection_fg = palette.selection_fg.to_linear(); let selection_bg = palette.selection_bg.to_linear(); - let cursor_fg = rgbcolor_to_window_color(palette.cursor_fg); - let cursor_bg = rgbcolor_to_window_color(palette.cursor_bg); + let cursor_fg = palette.cursor_fg.to_linear(); + let cursor_bg = palette.cursor_bg.to_linear(); let cursor_is_default_color = palette.cursor_fg == global_cursor_fg && palette.cursor_bg == global_cursor_bg;