aboutsummaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2021-02-17 15:55:38 +0100
committerGitHub <noreply@github.com>2021-02-17 15:55:38 +0100
commit831d26156eda9d8de24347d6f0d9751127580533 (patch)
treee979c79c9bd8b9d91cf01b746b183af7116a0f37 /src/client
parentdocs: first documentation step (#185) (diff)
downloadsl0ppij-831d26156eda9d8de24347d6f0d9751127580533.tar.gz
sl0ppij-831d26156eda9d8de24347d6f0d9751127580533.tar.xz
sl0ppij-831d26156eda9d8de24347d6f0d9751127580533.zip
fix(compatibility): get top not to break everything when exiting (#188)
Diffstat (limited to 'src/client')
-rw-r--r--src/client/panes/grid.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/client/panes/grid.rs b/src/client/panes/grid.rs
index 062b5c3a..6dfc3140 100644
--- a/src/client/panes/grid.rs
+++ b/src/client/panes/grid.rs
@@ -164,7 +164,7 @@ impl Grid {
pub fn new(rows: usize, columns: usize) -> Self {
Grid {
lines_above: vec![],
- viewport: vec![],
+ viewport: vec![Row::new().canonical()],
lines_below: vec![],
cursor: Cursor::new(0, 0),
scroll_region: None,
@@ -553,14 +553,14 @@ impl Grid {
}
}
fn pad_lines_until(&mut self, position: usize) {
- for _ in self.viewport.len()..position {
+ for _ in self.viewport.len()..=position {
self.viewport.push(Row::new().canonical());
}
}
pub fn move_cursor_to(&mut self, x: usize, y: usize) {
- self.cursor.x = x;
- self.cursor.y = y;
- self.pad_lines_until(self.cursor.y + 1);
+ self.cursor.x = std::cmp::min(self.width - 1, x);
+ self.cursor.y = std::cmp::min(self.height - 1, y);
+ self.pad_lines_until(self.cursor.y);
self.pad_current_line_until(self.cursor.x);
}
pub fn move_cursor_up(&mut self, count: usize) {
@@ -664,8 +664,8 @@ impl Grid {
self.pad_current_line_until(self.cursor.x);
}
pub fn move_cursor_to_line(&mut self, line: usize) {
- self.cursor.y = line;
- self.pad_lines_until(self.cursor.y + 1);
+ self.cursor.y = std::cmp::min(self.height - 1, line);
+ self.pad_lines_until(self.cursor.y);
self.pad_current_line_until(self.cursor.x);
}
pub fn replace_with_empty_chars(&mut self, count: usize, empty_char_style: CharacterStyles) {