From e05ddb17372460a4ff7feeafd8b9c6bce52fb07b Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Mon, 28 Jun 2021 09:18:13 -0700 Subject: [PATCH] fix force_reverse_video_cursor --- docs/changelog.md | 1 + wezterm-gui/src/termwindow/render.rs | 49 ++++++++++++++++------------ 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 5a3c45a5b..559040ae7 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -49,6 +49,7 @@ As features stabilize some brief notes about them will accumulate here. * Fixed: click to focus now focuses the pane under the mouse cursor [#881](https://github.com/wez/wezterm/issues/881) * Removed: `Parasio Dark` color scheme; it was a duplicate of the correctly named `Paraiso Dark` scheme. Thanks to [@adrian5](https://github.com/adrian5)! [#906](https://github.com/wez/wezterm/pull/906) * Fixed: key repeat on Wayland now respects the system specified key repeat rate, and doesn't "stick". [#669](https://github.com/wez/wezterm/issues/669) +* Fixed: `force_reverse_video_cursor` wasn't correctly swapping the cursor colors in all cases. [#706](https://github.com/wez/wezterm/issues/706) ### 20210502-154244-3f7122cb diff --git a/wezterm-gui/src/termwindow/render.rs b/wezterm-gui/src/termwindow/render.rs index 848417767..3852cdff0 100644 --- a/wezterm-gui/src/termwindow/render.rs +++ b/wezterm-gui/src/termwindow/render.rs @@ -191,12 +191,7 @@ impl super::TermWindow { let mut quads = gl_state.quads.map(&mut vb); log::trace!("quad map elapsed {:?}", start.elapsed()); - let cursor_border_color = - rgbcolor_to_window_color(if self.config.force_reverse_video_cursor { - palette.foreground - } else { - palette.cursor_border - }); + let cursor_border_color = rgbcolor_to_window_color(palette.cursor_border); let foreground = rgbcolor_to_window_color(palette.foreground); if self.show_tab_bar && pos.index == 0 { @@ -320,16 +315,8 @@ impl super::TermWindow { let start = Instant::now(); let selection_fg = rgbcolor_to_window_color(palette.selection_fg); let selection_bg = rgbcolor_to_window_color(palette.selection_bg); - let cursor_fg = rgbcolor_to_window_color(if self.config.force_reverse_video_cursor { - palette.background - } else { - palette.cursor_fg - }); - let cursor_bg = rgbcolor_to_window_color(if self.config.force_reverse_video_cursor { - palette.foreground - } else { - palette.cursor_bg - }); + let cursor_fg = rgbcolor_to_window_color(palette.cursor_fg); + let cursor_bg = rgbcolor_to_window_color(palette.cursor_bg); for (line_idx, line) in lines.iter().enumerate() { let stable_row = stable_top + line_idx as StableRowIndex; @@ -949,7 +936,11 @@ impl super::TermWindow { .cursor_sprite(cursor_shape) .texture_coords(), ); - quad.set_cursor_color(params.cursor_border_color); + quad.set_cursor_color(if self.config.force_reverse_video_cursor { + bg_color + } else { + params.cursor_border_color + }); } } } @@ -1013,7 +1004,11 @@ impl super::TermWindow { .cursor_sprite(cursor_shape) .texture_coords(), ); - quad.set_cursor_color(params.cursor_border_color); + quad.set_cursor_color(if self.config.force_reverse_video_cursor { + bg_color + } else { + params.cursor_border_color + }); } } } @@ -1066,7 +1061,11 @@ impl super::TermWindow { .cursor_sprite(cursor_shape) .texture_coords(), ); - quad.set_cursor_color(params.cursor_border_color); + quad.set_cursor_color(if self.config.force_reverse_video_cursor { + bg_color + } else { + params.cursor_border_color + }); Ok(()) } @@ -1147,7 +1146,11 @@ impl super::TermWindow { .cursor_sprite(cursor_shape) .texture_coords(), ); - quad.set_cursor_color(params.cursor_border_color); + quad.set_cursor_color(if self.config.force_reverse_video_cursor { + bg_color + } else { + params.cursor_border_color + }); Ok(()) } @@ -1210,7 +1213,11 @@ impl super::TermWindow { // Cursor cell overrides colors (_, true, CursorShape::BlinkingBlock, CursorVisibility::Visible) | (_, true, CursorShape::SteadyBlock, CursorVisibility::Visible) => { - (params.cursor_fg, params.cursor_bg) + if self.config.force_reverse_video_cursor { + (params.bg_color, params.fg_color) + } else { + (params.cursor_fg, params.cursor_bg) + } } // Normally, render the cell as configured (or if the window is unfocused) _ => (params.fg_color, params.bg_color),