screen: allow reading of cells
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
This commit is contained in:
parent
9dae256960
commit
2fab89f2cb
1 changed files with 14 additions and 0 deletions
|
@ -60,3 +60,17 @@ pub fn writeCell(self: *Screen, col: usize, row: usize, cell: Cell) void {
|
|||
assert(i < self.buf.len);
|
||||
self.buf[i] = cell;
|
||||
}
|
||||
|
||||
pub fn readCell(self: *Screen, 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 self.buf[i];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue