small software-rendered rust tty
Diffstat (limited to 'src/render.rs')
| -rw-r--r-- | src/render.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/render.rs b/src/render.rs index 6ab9dc5..845f2d2 100644 --- a/src/render.rs +++ b/src/render.rs @@ -10,19 +10,15 @@ use crate::colors; #[implicit_fn::implicit_fn] pub fn render( - x: &super::Terminal, + x: &mut super::Terminal, (w, h): (usize, usize), ppem: f32, ) -> Image<Box<[u8]>, 3> { let m = FONT.metrics(&[]); let sz = ppem * (m.max_width / m.units_per_em as f32); let mut i = Image::build(w as _, h as _).fill(colors::BACKGROUND); - for (col, k) in x.cells[x.size.0 as usize * x.row..] - .chunks_exact(x.size.0 as _) - .zip(0..) - .skip(1) - { - for (&(mut cell), j) in col.iter().skip(2).zip(0..) { + for (col, k) in x.cells.rows().zip(1..) { + for (&(mut cell), j) in col.iter().zip(1..) { if cell.style.flags & crate::term::INVERT != 0 { std::mem::swap(&mut cell.style.bg, &mut cell.style.color); } @@ -123,7 +119,7 @@ pub fn render( unsafe { i.as_mut().overlay_at( &cell, - 4 + ((x.cursor.0 - 1) as f32 * sz) as u32, + 4 + ((x.cursor.0 + 1) as f32 * sz) as u32, (x.cursor.1 as f32 * (ppem * 1.25)) as u32 - 20, ) }; |