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:
parent
48c42737a6
commit
08f47edd6a
2 changed files with 17 additions and 13 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -1274,13 +1274,6 @@ 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 {
|
||||||
if (self.screen_cursor(cursor)) |pos| {
|
|
||||||
set_cell_map_cursor(cell_map, pos.row, pos.col);
|
|
||||||
if (!focused or !tui.is_mainview_focused() or !self.enable_terminal_cursor) {
|
|
||||||
self.plane.cursor_move_yx(@intCast(pos.row), @intCast(pos.col));
|
|
||||||
const style = if (focused and tui.is_mainview_focused()) theme.editor_cursor else theme.editor_cursor_secondary;
|
|
||||||
self.render_cursor_cell(style);
|
|
||||||
} else {
|
|
||||||
const configured_shape = tui.get_cursor_shape();
|
const configured_shape = tui.get_cursor_shape();
|
||||||
const cursor_shape = if (tui.rdr().vx.caps.multi_cursor)
|
const cursor_shape = if (tui.rdr().vx.caps.multi_cursor)
|
||||||
configured_shape
|
configured_shape
|
||||||
|
|
@ -1291,11 +1284,22 @@ pub const Editor = struct {
|
||||||
.underline_blink => .block_blink,
|
.underline_blink => .block_blink,
|
||||||
else => configured_shape,
|
else => configured_shape,
|
||||||
} else configured_shape;
|
} else configured_shape;
|
||||||
|
if (self.screen_cursor(cursor)) |pos| {
|
||||||
|
set_cell_map_cursor(cell_map, pos.row, pos.col);
|
||||||
|
if (!focused or !tui.is_mainview_focused() or !self.enable_terminal_cursor) {
|
||||||
|
self.plane.cursor_move_yx(@intCast(pos.row), @intCast(pos.col));
|
||||||
|
const style = if (focused and tui.is_mainview_focused()) theme.editor_cursor else theme.editor_cursor_secondary;
|
||||||
|
self.render_cursor_cell(style);
|
||||||
|
} else {
|
||||||
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 {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue