render: draw the grid with rasterized glyphs

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I6350824abb506c2af98884a7374228116a6a6964
This commit is contained in:
raf 2026-06-23 16:57:49 +03:00
commit 5690e0e883
No known key found for this signature in database
GPG key ID: 29D95B64378DB4BF
9 changed files with 768 additions and 24 deletions

View file

@ -124,10 +124,32 @@ impl Grid {
}
}
pub fn cols(&self) -> usize {
self.cols
}
pub fn rows(&self) -> usize {
self.rows
}
/// Resize the screen, clipping content (reflow comes later).
pub fn resize(&mut self, cols: usize, rows: usize) {
let cols = cols.max(1);
let rows = rows.max(1);
for line in &mut self.lines {
line.resize(cols, Cell::default());
}
self.lines.resize(rows, vec![Cell::default(); cols]);
self.cols = cols;
self.rows = rows;
self.top = 0;
self.bottom = rows - 1;
self.tabs = default_tabs(cols);
self.cursor.x = self.cursor.x.min(cols - 1);
self.cursor.y = self.cursor.y.min(rows - 1);
self.wrap_pending = false;
}
pub fn cursor(&self) -> (usize, usize) {
(self.cursor.x, self.cursor.y)
}
@ -526,6 +548,7 @@ impl Grid {
// --- inspection (logging + tests) ---
/// The visible text of one row, trailing blanks trimmed.
#[cfg(test)]
pub fn row_text(&self, y: usize) -> String {
self.lines[y]
.iter()
@ -536,7 +559,6 @@ impl Grid {
.to_string()
}
#[cfg(test)]
pub fn cell(&self, x: usize, y: usize) -> &Cell {
&self.lines[y][x]
}