diff --git a/src/tui/InputBox.zig b/src/tui/InputBox.zig index 6ded557..20bf405 100644 --- a/src/tui/InputBox.zig +++ b/src/tui/InputBox.zig @@ -36,11 +36,17 @@ pub fn Options(context: type) type { } if (self.cursor) |cursor| { const pos: c_int = @intCast(cursor); - self.plane.cursor_move_yx(0, pos + 1) catch return false; - var cell = self.plane.cell_init(); - _ = self.plane.at_cursor_cell(&cell) catch return false; - cell.set_style(theme.editor_cursor); - _ = self.plane.putc(&cell) catch {}; + const tui_ = tui.current(); + if (tui_.config.enable_terminal_cursor) { + const y, const x = self.plane.rel_yx_to_abs(0, pos + 1); + tui_.rdr.cursor_enable(y, x, .default) catch {}; + } else { + self.plane.cursor_move_yx(0, pos + 1) catch return false; + var cell = self.plane.cell_init(); + _ = self.plane.at_cursor_cell(&cell) catch return false; + cell.set_style(theme.editor_cursor); + _ = self.plane.putc(&cell) catch {}; + } } return false; } diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 8f3dd81..dd4b919 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -843,15 +843,18 @@ pub const Editor = struct { } fn render_terminal_cursor(self: *const Self, cursor_: *const Cursor) !void { + const tui_ = tui.current(); + if (tui_.is_mini_or_overlay_enabled()) + return; if (self.screen_cursor(cursor_)) |cursor| { const y, const x = self.plane.rel_yx_to_abs(@intCast(cursor.row), @intCast(cursor.col)); - const shape = if (tui.current().input_mode) |mode| + const shape = if (tui_.input_mode) |mode| mode.cursor_shape else .block; - tui.current().rdr.cursor_enable(y, x, tui.translate_cursor_shape(shape)) catch {}; + tui_.rdr.cursor_enable(y, x, tui.translate_cursor_shape(shape)) catch {}; } else { - tui.current().rdr.cursor_disable(); + tui_.rdr.cursor_disable(); } } diff --git a/src/tui/status/filestate.zig b/src/tui/status/filestate.zig index 58190c6..f2067d8 100644 --- a/src/tui/status/filestate.zig +++ b/src/tui/status/filestate.zig @@ -101,15 +101,21 @@ pub fn render(self: *Self, btn: *Button.State(Self), theme: *const Widget.Theme) fn render_mini_mode(plane: *Plane, theme: *const Widget.Theme) void { plane.off_styles(style.italic); - const mini_mode = tui.current().mini_mode orelse return; + const tui_ = tui.current(); + const mini_mode = tui_.mini_mode orelse return; _ = plane.print(" {s}", .{mini_mode.text}) catch {}; if (mini_mode.cursor) |cursor| { const pos: c_int = @intCast(cursor); - plane.cursor_move_yx(0, pos + 1) catch return; - var cell = plane.cell_init(); - _ = plane.at_cursor_cell(&cell) catch return; - cell.set_style(theme.editor_cursor); - _ = plane.putc(&cell) catch {}; + if (tui_.config.enable_terminal_cursor) { + const y, const x = plane.rel_yx_to_abs(0, pos + 1); + tui_.rdr.cursor_enable(y, x, .default) catch {}; + } else { + plane.cursor_move_yx(0, pos + 1) catch return; + var cell = plane.cell_init(); + _ = plane.at_cursor_cell(&cell) catch return; + cell.set_style(theme.editor_cursor); + _ = plane.putc(&cell) catch {}; + } } return; } diff --git a/src/tui/tui.zig b/src/tui/tui.zig index 6d219b4..eea4951 100644 --- a/src/tui/tui.zig +++ b/src/tui/tui.zig @@ -585,6 +585,10 @@ pub fn save_config(self: *const Self) !void { try root.write_config(self.config, self.allocator); } +pub fn is_mini_or_overlay_enabled(self: *const Self) bool { + return !(self.mini_mode == null or self.input_mode_outer == null); +} + fn enter_overlay_mode(self: *Self, mode: type) command.Result { command.executeName("disable_fast_scroll", .{}) catch {}; command.executeName("disable_jump_mode", .{}) catch {}; @@ -767,6 +771,7 @@ const cmds = struct { pub const change_file_type_meta = .{ .description = "Change file type" }; pub fn exit_overlay_mode(self: *Self, _: Ctx) Result { + self.rdr.cursor_disable(); if (self.input_mode_outer == null) return; if (self.input_mode) |*mode| mode.deinit(); self.input_mode = self.input_mode_outer; @@ -818,6 +823,7 @@ const cmds = struct { } pub fn exit_mini_mode(self: *Self, _: Ctx) Result { + self.rdr.cursor_disable(); if (self.mini_mode) |_| {} else return; if (self.input_mode) |*mode| mode.deinit(); self.input_mode = self.input_mode_outer;