From c166e0d379b0d8fa2222b10b88747224d3367f22 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Thu, 18 Dec 2025 15:24:30 +0100 Subject: [PATCH] refactor: add Editor.get_cursor_abs and Editor.get_primary_abs --- src/tui/editor.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/tui/editor.zig b/src/tui/editor.zig index df212c7..3188c1f 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -842,6 +842,16 @@ pub const Editor = struct { return self.get_primary(); } + pub fn get_cursor_abs(self: *const Self, cursor: Cursor) ?Cursor { + const pos = self.screen_cursor(&cursor) orelse return null; + const y, const x = self.plane.rel_yx_to_abs(@intCast(pos.row), @intCast(pos.col)); + return .{ .row = @intCast(y), .col = @intCast(x) }; + } + + pub fn get_primary_abs(self: *const Self) ?Cursor { + return self.get_cursor_abs(self.get_primary().cursor); + } + fn store_undo_meta(self: *Self, allocator: Allocator) ![]u8 { var meta: std.Io.Writer.Allocating = .init(allocator); defer meta.deinit();