From fe4fc509e9e7a7e8f91dfa9c0b44a809ecf4f213 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 27 Apr 2024 21:42:09 -0700 Subject: [PATCH] renderer/metal: use index() for all cell settings --- src/renderer/metal/cell.zig | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/renderer/metal/cell.zig b/src/renderer/metal/cell.zig index e6974ae34..29f101534 100644 --- a/src/renderer/metal/cell.zig +++ b/src/renderer/metal/cell.zig @@ -79,8 +79,7 @@ pub const Contents = struct { comptime key: Key, coord: terminal.Coordinate, ) ?key.CellType() { - const idx = coord.y * self.cols + coord.x; - const mapping = self.map[idx].array.get(key); + const mapping = self.map[self.index(coord)].array.get(key); if (!mapping.set) return null; return switch (key) { .bg => self.bgs.items[mapping.index], @@ -136,11 +135,8 @@ pub const Contents = struct { /// then we would have to update the mapping for every element in /// the list. If we clear from the bottom up, then we only have to /// update the mapping for the last element in the list. - pub fn clear( - self: *Contents, - y: usize, - ) void { - const start_idx = y * self.cols; + pub fn clear(self: *Contents, y: terminal.size.CellCountInt) void { + const start_idx = self.index(.{ .x = 0, .y = y }); const end_idx = start_idx + self.cols; const maps = self.map[start_idx..end_idx]; for (0..self.cols) |x| {