summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2017-04-20 10:13:28 -0700
committerJoe Wilm <joe@jwilm.com>2017-04-20 10:13:28 -0700
commit346ec09af5a274735833c207ddc40cf49c30bc8b (patch)
tree2b814dcc93ca699036233ed882583c59c4e99f4f
parent7df35a30eaaa9e2fab3b7dd3e8490de0105458cf (diff)
Fix some bugs with resize
-rw-r--r--src/grid.rs1
-rw-r--r--src/term/mod.rs26
2 files changed, 18 insertions, 9 deletions
diff --git a/src/grid.rs b/src/grid.rs
index 8d1d051b..cdb93c96 100644
--- a/src/grid.rs
+++ b/src/grid.rs
@@ -159,7 +159,6 @@ impl<T> Grid<T> {
#[inline]
pub fn scroll_up(&mut self, region: Range<index::Line>, positions: index::Line) {
-
for line in IndexRange(region.start..(region.end - positions)) {
self.swap_lines(line, line + positions);
}
diff --git a/src/term/mod.rs b/src/term/mod.rs
index 4a02944b..68f6a5ac 100644
--- a/src/term/mod.rs
+++ b/src/term/mod.rs
@@ -898,8 +898,13 @@ impl Term {
// Scroll up to keep cursor in terminal
if self.cursor.point.line >= num_lines {
let lines = self.cursor.point.line - num_lines + 1;
- self.scroll_up(lines);
- self.cursor.point.line -= lines;
+ self.grid.scroll_up(Line(0)..old_lines, lines);
+ }
+
+ // Scroll up alt grid as well
+ if self.cursor_save_alt.point.line >= num_lines {
+ let lines = self.cursor_save_alt.point.line - num_lines + 1;
+ self.alt_grid.scroll_up(Line(0)..old_lines, lines);
}
println!("num_cols, num_lines = {}, {}", num_cols, num_lines);
@@ -909,9 +914,16 @@ impl Term {
self.grid.resize(num_lines, num_cols, &template);
self.alt_grid.resize(num_lines, num_cols, &template);
- // Ensure cursor is in-bounds
- self.cursor.point.line = limit(self.cursor.point.line, Line(0), num_lines - 1);
- self.cursor.point.col = limit(self.cursor.point.col, Column(0), num_cols - 1);
+ // Reset scrolling region to new size
+ self.scroll_region = Line(0)..self.grid.num_lines();
+
+ // Ensure cursors are in-bounds.
+ self.cursor.point.col = min(self.cursor.point.col, num_cols - 1);
+ self.cursor.point.line = min(self.cursor.point.line, num_lines - 1);
+ self.cursor_save.point.col = min(self.cursor_save.point.col, num_cols - 1);
+ self.cursor_save.point.line = min(self.cursor_save.point.line, num_lines - 1);
+ self.cursor_save_alt.point.col = min(self.cursor_save_alt.point.col, num_cols - 1);
+ self.cursor_save_alt.point.line = min(self.cursor_save_alt.point.line, num_lines - 1);
// Recreate tabs list
self.tabs = IndexRange::from(Column(0)..self.grid.num_cols())
@@ -924,11 +936,9 @@ impl Term {
// Make sure bottom of terminal is clear
let template = self.empty_cell;
self.grid.clear_region((self.cursor.point.line + 1).., |c| c.reset(&template));
- self.alt_grid.clear_region((self.cursor.point.line + 1).., |c| c.reset(&template));
+ self.alt_grid.clear_region((self.cursor_save_alt.point.line + 1).., |c| c.reset(&template));
}
- // Reset scrolling region to new size
- self.scroll_region = Line(0)..self.grid.num_lines();
}
#[inline]