From 85e32f9a1598a49a032ba3ea2d13d517eaa9c91b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 6 Aug 2023 09:55:13 -0700 Subject: [PATCH] renderer: hide cursor is state explicit asks for invisible cursor This was a regression. The previous logic would always show the cursor if we were using a non-blinking cursor. But, if the terminal state is explicitly requesting an invisible cursor (mode 25) then we need to hide the cursor. --- src/renderer/Metal.zig | 6 +++++- src/renderer/OpenGL.zig | 6 +++++- src/termio/Exec.zig | 4 ++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index 6a7561ecb..0d1a1fb29 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -531,11 +531,15 @@ pub fn render( // Setup our cursor state if (self.focused) { self.cursor_visible = visible: { + // If the cursor is explicitly not visible in the state, + // then it is not visible. + if (!state.cursor.visible) break :visible false; + // If the cursor isn't a blinking style, then never blink. if (!state.cursor.style.blinking()) break :visible true; // Otherwise, adhere to our current state. - break :visible self.cursor_visible and state.cursor.visible; + break :visible self.cursor_visible; }; self.cursor_style = renderer.CursorStyle.fromTerminal(state.cursor.style) orelse .box; } else { diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index fc4cbbee2..7ec797876 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -731,11 +731,15 @@ pub fn render( // Setup our cursor state if (self.focused) { self.cursor_visible = visible: { + // If the cursor is explicitly not visible in the state, + // then it is not visible. + if (!state.cursor.visible) break :visible false; + // If the cursor isn't a blinking style, then never blink. if (!state.cursor.style.blinking()) break :visible true; // Otherwise, adhere to our current state. - break :visible self.cursor_visible and state.cursor.visible; + break :visible self.cursor_visible; }; self.cursor_style = renderer.CursorStyle.fromTerminal(state.cursor.style) orelse .box; } else { diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index 79f368282..9d135c74b 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -1173,6 +1173,10 @@ const StreamHandler = struct { } pub fn setMode(self: *StreamHandler, mode: terminal.Mode, enabled: bool) !void { + // Note: this function doesn't need to grab the render state or + // terminal locks because it is only called from process() which + // grabs the lock. + switch (mode) { .cursor_keys => { self.terminal.modes.cursor_keys = enabled;