diff options
Diffstat (limited to 'src/grid.rs')
-rw-r--r-- | src/grid.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/grid.rs b/src/grid.rs index 246e9e6..9681638 100644 --- a/src/grid.rs +++ b/src/grid.rs @@ -21,7 +21,7 @@ impl Grid { size, pos: Pos::default(), saved_pos: Pos::default(), - rows: vec![crate::row::Row::new(size.cols); size.rows as usize], + rows: vec![], scroll_top: 0, scroll_bottom: size.rows - 1, origin_mode: false, @@ -32,6 +32,17 @@ impl Grid { } } + pub fn allocate_rows(&mut self) { + if self.rows.is_empty() { + self.rows.extend( + std::iter::repeat_with(|| { + crate::row::Row::new(self.size.cols) + }) + .take(self.size.rows as usize), + ); + } + } + fn new_row(&self) -> crate::row::Row { crate::row::Row::new(self.size.cols) } |