refactor: add Editor.get_cursor_abs and Editor.get_primary_abs

This commit is contained in:
CJ van den Berg 2025-12-18 15:24:30 +01:00
parent 8866e27da7
commit c166e0d379
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -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();