Fix some bugs with resize
This commit is contained in:
parent
7df35a30ea
commit
346ec09af5
|
@ -159,7 +159,6 @@ impl<T> Grid<T> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn scroll_up(&mut self, region: Range<index::Line>, positions: index::Line) {
|
pub fn scroll_up(&mut self, region: Range<index::Line>, positions: index::Line) {
|
||||||
|
|
||||||
for line in IndexRange(region.start..(region.end - positions)) {
|
for line in IndexRange(region.start..(region.end - positions)) {
|
||||||
self.swap_lines(line, line + positions);
|
self.swap_lines(line, line + positions);
|
||||||
}
|
}
|
||||||
|
|
|
@ -898,8 +898,13 @@ impl Term {
|
||||||
// Scroll up to keep cursor in terminal
|
// Scroll up to keep cursor in terminal
|
||||||
if self.cursor.point.line >= num_lines {
|
if self.cursor.point.line >= num_lines {
|
||||||
let lines = self.cursor.point.line - num_lines + 1;
|
let lines = self.cursor.point.line - num_lines + 1;
|
||||||
self.scroll_up(lines);
|
self.grid.scroll_up(Line(0)..old_lines, lines);
|
||||||
self.cursor.point.line -= 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);
|
println!("num_cols, num_lines = {}, {}", num_cols, num_lines);
|
||||||
|
@ -909,9 +914,16 @@ impl Term {
|
||||||
self.grid.resize(num_lines, num_cols, &template);
|
self.grid.resize(num_lines, num_cols, &template);
|
||||||
self.alt_grid.resize(num_lines, num_cols, &template);
|
self.alt_grid.resize(num_lines, num_cols, &template);
|
||||||
|
|
||||||
// Ensure cursor is in-bounds
|
// Reset scrolling region to new size
|
||||||
self.cursor.point.line = limit(self.cursor.point.line, Line(0), num_lines - 1);
|
self.scroll_region = Line(0)..self.grid.num_lines();
|
||||||
self.cursor.point.col = limit(self.cursor.point.col, Column(0), num_cols - 1);
|
|
||||||
|
// 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
|
// Recreate tabs list
|
||||||
self.tabs = IndexRange::from(Column(0)..self.grid.num_cols())
|
self.tabs = IndexRange::from(Column(0)..self.grid.num_cols())
|
||||||
|
@ -924,11 +936,9 @@ impl Term {
|
||||||
// Make sure bottom of terminal is clear
|
// Make sure bottom of terminal is clear
|
||||||
let template = self.empty_cell;
|
let template = self.empty_cell;
|
||||||
self.grid.clear_region((self.cursor.point.line + 1).., |c| c.reset(&template));
|
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]
|
#[inline]
|
||||||
|
|
Loading…
Reference in New Issue