diff --git a/src/ui_model/mod.rs b/src/ui_model/mod.rs index 1ac54f9..5778ffb 100644 --- a/src/ui_model/mod.rs +++ b/src/ui_model/mod.rs @@ -174,6 +174,15 @@ impl UiModel { ModelRect::new(top as usize, bot as usize, left, right) } + /// Move down all lines except first one + pub fn move_down(&mut self) { + let right = self.columns + 1; + + for row in (1..self.rows + 1).rev() { + self.copy_row(row as i64, 1, 0, right); + } + } + pub fn clear(&mut self) { let (rows, columns) = (self.rows, self.columns); self.clear_region(0, rows - 1, 0, columns - 1); diff --git a/src/ui_model/model_layout.rs b/src/ui_model/model_layout.rs index ed23774..9571f06 100644 --- a/src/ui_model/model_layout.rs +++ b/src/ui_model/model_layout.rs @@ -65,6 +65,14 @@ impl ModelLayout { if shift { //TODO: insert special char + if self.cols_filled + 1 >= self.model.columns { + let rows_filled = self.rows_filled + 1; + + self.check_model_size(rows_filled); + self.model.move_down(); + + self.rows_filled = rows_filled; + } } else { self.model.put(c.chars().next().unwrap(), false, None); }