fix: cursor hiding when primary terminal cursor is offscreen

We now change it's color and hide it in the bottom right corner
to avoid hiding secondary cursors.
This commit is contained in:
CJ van den Berg 2026-01-15 22:43:16 +01:00
parent 48c42737a6
commit 08f47edd6a
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 17 additions and 13 deletions

View file

@ -562,8 +562,8 @@ pub fn request_mouse_cursor_default(self: *Self, push_or_pop: bool) void {
} }
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 y: u16 = if (y_ < 0) 9999 else @intCast(y_);
const x: u16 = if (x_ < 0) self.vx.screen.width + 1 else @intCast(x_); const x: u16 = if (x_ < 0) 9999 else @intCast(x_);
self.vx.screen.cursor_vis = true; self.vx.screen.cursor_vis = true;
self.vx.screen.cursor_row = y; self.vx.screen.cursor_row = y;
self.vx.screen.cursor_col = x; self.vx.screen.cursor_col = x;

View file

@ -1274,6 +1274,16 @@ pub const Editor = struct {
} }
fn render_cursor_primary(self: *Self, cursor: *const Cursor, theme: *const Widget.Theme, cell_map: CellMap, focused: bool) !void { fn render_cursor_primary(self: *Self, cursor: *const Cursor, theme: *const Widget.Theme, cell_map: CellMap, focused: bool) !void {
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| { if (self.screen_cursor(cursor)) |pos| {
set_cell_map_cursor(cell_map, pos.row, pos.col); set_cell_map_cursor(cell_map, pos.row, pos.col);
if (!focused or !tui.is_mainview_focused() or !self.enable_terminal_cursor) { if (!focused or !tui.is_mainview_focused() or !self.enable_terminal_cursor) {
@ -1281,21 +1291,15 @@ pub const Editor = struct {
const style = if (focused and tui.is_mainview_focused()) theme.editor_cursor else theme.editor_cursor_secondary; const style = if (focused and tui.is_mainview_focused()) theme.editor_cursor else theme.editor_cursor_secondary;
self.render_cursor_cell(style); self.render_cursor_cell(style);
} else { } 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;
const y, const x = self.plane.rel_yx_to_abs(@intCast(pos.row), @intCast(pos.col)); const y, const x = self.plane.rel_yx_to_abs(@intCast(pos.row), @intCast(pos.col));
tui.rdr().set_terminal_cursor_color(theme.editor_cursor.bg.?);
tui.rdr().cursor_enable(y, x, cursor_shape) catch {}; tui.rdr().cursor_enable(y, x, cursor_shape) catch {};
} }
} else { } else {
tui.rdr().cursor_enable(-1, -1, .default) catch {}; if (self.enable_terminal_cursor) {
tui.rdr().set_terminal_cursor_color(theme.statusbar.bg.?);
tui.rdr().cursor_enable(-1, -1, cursor_shape) catch {};
}
} }
} }