From 1b9e01671a37ded8c2447b82c6f6a656a5ee26e0 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Thu, 15 Jan 2026 11:59:22 +0100 Subject: [PATCH] fix: don't disable primary terminal cursor when offscreen Disabling the primary cursor when offscreen will also disable secondary cursors when kitty's multi-cursor support is enabled. So instead we move the primary cursor offscreen. --- src/renderer/vaxis/renderer.zig | 8 +++++--- src/tui/editor.zig | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/renderer/vaxis/renderer.zig b/src/renderer/vaxis/renderer.zig index d687333..6b446df 100644 --- a/src/renderer/vaxis/renderer.zig +++ b/src/renderer/vaxis/renderer.zig @@ -561,10 +561,12 @@ pub fn request_mouse_cursor_default(self: *Self, push_or_pop: bool) void { if (push_or_pop) self.vx.setMouseShape(.default) else self.vx.setMouseShape(.default); } -pub fn cursor_enable(self: *Self, y: c_int, x: c_int, shape: CursorShape) !void { +pub fn cursor_enable(self: *Self, y_: c_int, x_: c_int, shape: CursorShape) !void { + const y: u16 = if (y_ < 0) self.vx.screen.height + 1 else @intCast(y_); + const x: u16 = if (x_ < 0) self.vx.screen.width + 1 else @intCast(x_); self.vx.screen.cursor_vis = true; - self.vx.screen.cursor_row = @intCast(y); - self.vx.screen.cursor_col = @intCast(x); + self.vx.screen.cursor_row = y; + self.vx.screen.cursor_col = x; self.vx.screen.cursor_shape = shape; } diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 1f5a631..b8fcc6c 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -1283,22 +1283,22 @@ pub const Editor = struct { self.render_cursor_cell(style); } } else { + const configured_shape = tui.get_cursor_shape(); + const cursor_shape = if (tui.rdr().vx.caps.multi_cursor) + configured_shape + else if (self.cursels.items.len > 1) switch (configured_shape) { + .beam => .block, + .beam_blink => .block_blink, + .underline => .block, + .underline_blink => .block_blink, + else => configured_shape, + } else configured_shape; if (self.screen_cursor(cursor)) |pos| { set_cell_map_cursor(cell_map, pos.row, pos.col); const y, const x = self.plane.rel_yx_to_abs(@intCast(pos.row), @intCast(pos.col)); - const configured_shape = tui.get_cursor_shape(); - const cursor_shape = if (tui.rdr().vx.caps.multi_cursor) - configured_shape - else if (self.cursels.items.len > 1) switch (configured_shape) { - .beam => .block, - .beam_blink => .block_blink, - .underline => .block, - .underline_blink => .block_blink, - else => configured_shape, - } else configured_shape; tui.rdr().cursor_enable(y, x, cursor_shape) catch {}; } else { - tui.rdr().cursor_disable(); + tui.rdr().cursor_enable(-1, -1, cursor_shape) catch {}; } } }