feat: allow cursor shape configuration for mini and overlay modes
This commit is contained in:
parent
d2671259f4
commit
ca784d1712
4 changed files with 6 additions and 9 deletions
|
@ -39,7 +39,7 @@ pub fn Options(context: type) type {
|
||||||
const tui_ = tui.current();
|
const tui_ = tui.current();
|
||||||
if (tui_.config.enable_terminal_cursor) {
|
if (tui_.config.enable_terminal_cursor) {
|
||||||
const y, const x = self.plane.rel_yx_to_abs(0, pos + 1);
|
const y, const x = self.plane.rel_yx_to_abs(0, pos + 1);
|
||||||
tui_.rdr.cursor_enable(y, x, .default) catch {};
|
tui_.rdr.cursor_enable(y, x, tui_.get_cursor_shape()) catch {};
|
||||||
} else {
|
} else {
|
||||||
self.plane.cursor_move_yx(0, pos + 1) catch return false;
|
self.plane.cursor_move_yx(0, pos + 1) catch return false;
|
||||||
var cell = self.plane.cell_init();
|
var cell = self.plane.cell_init();
|
||||||
|
|
|
@ -877,11 +877,7 @@ pub const Editor = struct {
|
||||||
} else {
|
} else {
|
||||||
if (self.screen_cursor(cursor)) |pos| {
|
if (self.screen_cursor(cursor)) |pos| {
|
||||||
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));
|
||||||
const shape = if (tui_.input_mode) |mode|
|
tui_.rdr.cursor_enable(y, x, tui_.get_cursor_shape()) catch {};
|
||||||
mode.cursor_shape
|
|
||||||
else
|
|
||||||
.block;
|
|
||||||
tui_.rdr.cursor_enable(y, x, tui.translate_cursor_shape(shape)) catch {};
|
|
||||||
} else {
|
} else {
|
||||||
tui_.rdr.cursor_disable();
|
tui_.rdr.cursor_disable();
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ fn render_mini_mode(plane: *Plane, theme: *const Widget.Theme) void {
|
||||||
const pos: c_int = @intCast(cursor);
|
const pos: c_int = @intCast(cursor);
|
||||||
if (tui_.config.enable_terminal_cursor) {
|
if (tui_.config.enable_terminal_cursor) {
|
||||||
const y, const x = plane.rel_yx_to_abs(0, pos + 1);
|
const y, const x = plane.rel_yx_to_abs(0, pos + 1);
|
||||||
tui_.rdr.cursor_enable(y, x, .default) catch {};
|
tui_.rdr.cursor_enable(y, x, tui_.get_cursor_shape()) catch {};
|
||||||
} else {
|
} else {
|
||||||
plane.cursor_move_yx(0, pos + 1) catch return;
|
plane.cursor_move_yx(0, pos + 1) catch return;
|
||||||
var cell = plane.cell_init();
|
var cell = plane.cell_init();
|
||||||
|
|
|
@ -1096,8 +1096,9 @@ fn set_terminal_style(self: *Self) void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn translate_cursor_shape(in: keybind.CursorShape) renderer.CursorShape {
|
pub fn get_cursor_shape(self: *Self) renderer.CursorShape {
|
||||||
return switch (in) {
|
const shape = if (self.input_mode) |mode| mode.cursor_shape else .block;
|
||||||
|
return switch (shape) {
|
||||||
.default => .default,
|
.default => .default,
|
||||||
.block_blink => .block_blink,
|
.block_blink => .block_blink,
|
||||||
.block => .block,
|
.block => .block,
|
||||||
|
|
Loading…
Add table
Reference in a new issue