Repository: wezterm/wezterm (language: rust)

Issue:
Turn off hiding the mouse cursor when typing
**Is your feature request related to a problem? Please describe.**
Wezterm automatically hides the mouse cursor if you hover over the terminal while typing. While this is a convenient feature for some, I feel like I always lose track of my cursor whenever it's hidden.

**Describe the solution you'd like**
I'd like a simple config option like `hide_cursor_when_typing` that could enable and disable this behavior.

**Additional context**
I'm willing to try making a PR for this feature.



Discussion / hints:
I think that's a reasonable request, and it should be a pretty straight forward PR if you'd like to roll your sleeves up!

There are a couple of `context.set_cursor(None)` calls in https://github.com/wez/wezterm/blob/main/wezterm-gui/src/termwindow/keyevent.rs#L649 that are responsible for hiding the cursor.

I'd suggest naming the option `hide_mouse_cursor_when_typing` to make it more obviously distinct from the textual cursor.

You can add that config option somewhere around here, just like `detect_password_input`:
https://github.com/wez/wezterm/blob/main/config/src/config.rs#L184-L185

In the termwindow code, you can then use `self.config.hide_mouse_cursor_when_typing` to access that config value.


Fix patch:
diff --git a/config/src/config.rs b/config/src/config.rs
index 9a2be00f729..d99190706d5 100644
--- a/config/src/config.rs
+++ b/config/src/config.rs
@@ -581,6 +581,11 @@ pub struct Config {
     #[dynamic(default = "linear_ease")]
     pub text_blink_rapid_ease_out: EasingFunction,
 
+    /// If true, the mouse cursor will be hidden while typing.
+    /// This option is true by default.
+    #[dynamic(default = "default_true")]
+    pub hide_mouse_cursor_when_typing: bool,
+
     /// If non-zero, specifies the period (in seconds) at which various
     /// statistics are logged.  Note that there is a minimum period of
     /// 10 seconds.
diff --git a/docs/config/lua/config/hide_mouse_cursor_when_typing.md b/docs/config/lua/config/hide_mouse_cursor_when_typing.md
new file mode 100644
index 00000000000..016e05e831e
--- /dev/null
+++ b/docs/config/lua/config/hide_mouse_cursor_when_typing.md
@@ -0,0 +1,14 @@
+# `hide_mouse_cursor_when_typing`
+
+*Since: nightly builds only*
+
+If `true`, the mouse cursor will be hidden when typing, if your mouse cursor is
+hovering over the window.
+
+The default is `true`. Set to `false` to disable this behavior.
+
+```lua
+return {
+  hide_mouse_cursor_when_typing = true,
+}
+```
diff --git a/wezterm-gui/src/termwindow/keyevent.rs b/wezterm-gui/src/termwindow/keyevent.rs
index c17f3e9d403..334fb35acf2 100644
--- a/wezterm-gui/src/termwindow/keyevent.rs
+++ b/wezterm-gui/src/termwindow/keyevent.rs
@@ -391,7 +391,9 @@ impl super::TermWindow {
                         {
                             self.maybe_scroll_to_bottom_for_input(&pane);
                         }
-                        context.set_cursor(None);
+                        if self.config.hide_mouse_cursor_when_typing {
+                            context.set_cursor(None);
+                        }
                         if !keycode.is_modifier() {
                             context.invalidate();
                         }
@@ -646,7 +648,9 @@ impl super::TermWindow {
                     {
                         self.maybe_scroll_to_bottom_for_input(&pane);
                     }
-                    context.set_cursor(None);
+                    if self.config.hide_mouse_cursor_when_typing {
+                        context.set_cursor(None);
+                    }
                     if !key.is_modifier() {
                         context.invalidate();
                     }


Test patch: