diff options
Diffstat (limited to 'src/main.zig')
-rw-r--r-- | src/main.zig | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/main.zig b/src/main.zig index d26cefa..2a4c39d 100644 --- a/src/main.zig +++ b/src/main.zig @@ -14,16 +14,18 @@ const ns_per_s = std.time.ns_per_s; const smp_allocator = std.heap.smp_allocator; const std = @import("std"); +const CursorShape = vaxis.Cell.CursorShape; const Graphemes = vaxis.Graphemes; const Key = vaxis.Key; const Loop = vaxis.Loop; const Style = vaxis.Cell.Style; const Tty = vaxis.Tty; const Unicode = vaxis.Unicode; +const Vaxis = vaxis.Vaxis; const Window = vaxis.Window; const Winsize = vaxis.Winsize; const gwidth = vaxis.gwidth.gwidth; -const Vaxis = vaxis.Vaxis; +const ctlseqs = vaxis.ctlseqs; const vaxis = @import("vaxis"); pub const panic = vaxis.panic_handler; @@ -61,10 +63,16 @@ const Environment = struct { pub fn render(self: Environment, buffer: Buffer) !void { const window = self.vaxis.window(); window.clear(); + const sel_start = buffer.selection.startByte(); + window.screen.cursor_vis = sel_start == buffer.selection.endByte(); var col: u16 = 0; var row: u16 = 0; var graphemes_iter = buffer.iterate(); while (graphemes_iter.next()) |grapheme| { + if (window.screen.cursor_vis and grapheme.offset == sel_start) { + window.setCursorShape(.beam); + window.showCursor(col, row); + } const in_head = buffer.selection.inHead(grapheme); const in_body = buffer.selection.inBody(grapheme); const style = Style { @@ -135,6 +143,9 @@ pub fn main() !void { var tty = try Tty.init(); defer tty.deinit(); + defer tty.anyWriter().print(ctlseqs.cursor_shape, .{ + @intFromEnum(CursorShape.block), // FIXME: make configurable + }) catch {}; var vx = try vaxis.init(allocator, .{ .system_clipboard_allocator = allocator, }); |