Repository: wezterm/wezterm (language: rust)

Issue:
Text overlapping bar cursor
**Is your feature request related to a problem? Please describe.**
When using the bar cursor option the text for that cell overlaps with the rendering of the cursor

**Describe the solution you'd like**
A config option to render the bar cursor as solid, not showing the color of the text underneath 

**Describe alternatives you've considered**
Thought the cursor_border color option might have helped but it didn't

**Additional context**
![Screenshot from 2023-02-02 16-59-43](https://user-images.githubusercontent.com/3851030/216244970-8b28e8c5-2c0b-4a08-bf2e-94c697bee4c6.png)
You'll see the leftmost part of the "w" under the cursor is overlapping with the cursor itself. Ideally I would like an option to always render the bar cursor over the top for consistency. Apologies if there is already a way to do this that I couldn't figure out.




Discussion / hints:
I fixed this by rendering the cursor on the topmost layer:

```diff
diff --git a/wezterm-gui/src/termwindow/render/screen_line.rs b/wezterm-gui/src/termwindow/render/screen_line.rs
index b7d4daa4f..8f5b3a637 100644
--- a/wezterm-gui/src/termwindow/render/screen_line.rs
+++ b/wezterm-gui/src/termwindow/render/screen_line.rs
@@ -350,7 +350,7 @@ impl crate::TermWindow {
                 + (phys(params.cursor.x, num_cols, direction) as f32 * cell_width);
 
             if cursor_shape.is_some() {
-                let mut quad = layers.allocate(0).context("layers.allocate(0)")?;
+                let mut quad = layers.allocate(2).context("layers.allocate(2)")?;
                 quad.set_hsv(hsv);
                 quad.set_has_color(false);
 
```

But I believe this will hide characters when using the block cursor.

Fix patch:
diff --git a/wezterm-gui/src/termwindow/render/screen_line.rs b/wezterm-gui/src/termwindow/render/screen_line.rs
index b7d4daa4f2c..7b44f18a083 100644
--- a/wezterm-gui/src/termwindow/render/screen_line.rs
+++ b/wezterm-gui/src/termwindow/render/screen_line.rs
@@ -13,6 +13,7 @@ use std::rc::Rc;
 use std::time::Instant;
 use termwiz::cell::{unicode_column_width, Blink};
 use termwiz::color::LinearRgba;
+use termwiz::surface::CursorShape;
 use wezterm_bidi::Direction;
 use wezterm_term::color::ColorAttribute;
 use wezterm_term::CellAttributes;
@@ -349,8 +350,14 @@ impl crate::TermWindow {
                 + params.left_pixel_x
                 + (phys(params.cursor.x, num_cols, direction) as f32 * cell_width);
 
-            if cursor_shape.is_some() {
-                let mut quad = layers.allocate(0).context("layers.allocate(0)")?;
+            if let Some(shape) = cursor_shape {
+                let cursor_layer = match shape {
+                    CursorShape::BlinkingBar | CursorShape::SteadyBar => 2,
+                    _ => 0,
+                };
+                let mut quad = layers
+                    .allocate(cursor_layer)
+                    .with_context(||format!("layers.allocate({cursor_layer})"))?;
                 quad.set_hsv(hsv);
                 quad.set_has_color(false);
 
@@ -402,7 +409,7 @@ impl crate::TermWindow {
                             .glyph_cache
                             .borrow_mut()
                             .cursor_sprite(
-                                cursor_shape,
+                                Some(shape),
                                 &params.render_metrics,
                                 (cursor_range.end - cursor_range.start) as u8,
                             )?


Test patch: