diff --git a/src/InternalScreen.zig b/src/InternalScreen.zig index 1a57dc0..6001306 100644 --- a/src/InternalScreen.zig +++ b/src/InternalScreen.zig @@ -95,3 +95,20 @@ pub fn writeCell( }; self.buf[i].style = cell.style; } + +pub fn readCell(self: *InternalScreen, col: usize, row: usize) ?Cell { + if (self.width < col) { + // column out of bounds + return null; + } + if (self.height < row) { + // height out of bounds + return null; + } + const i = (row * self.width) + col; + assert(i < self.buf.len); + return .{ + .char = .{ .grapheme = self.buf[i].char.items }, + .style = self.buf[i].style, + }; +} diff --git a/src/main.zig b/src/main.zig index e6c43ed..9644603 100644 --- a/src/main.zig +++ b/src/main.zig @@ -13,6 +13,7 @@ pub const Color = Cell.Color; pub const Image = @import("Image.zig"); pub const Mouse = @import("Mouse.zig"); pub const Screen = @import("Screen.zig"); +pub const AllocatingScreen = @import("InternalScreen.zig"); pub const Winsize = @import("Tty.zig").Winsize; pub const Window = @import("Window.zig");