summaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/term/mod.rs
diff options
context:
space:
mode:
authorNathan Lilienthal <nathan@nixpulvis.com>2019-11-18 16:15:25 -0500
committerChristian Duerr <contact@christianduerr.com>2019-11-18 22:15:25 +0100
commit182a9d5c2e01ec9b155fc7edf547e8e6de2f2bd5 (patch)
tree56889a5b18e40c7f4b30ea53b8eb152fbeb82a2d /alacritty_terminal/src/term/mod.rs
parentbcdc605436ebe137173c531844a739eda6ee41ae (diff)
downloadalacritty-182a9d5c2e01ec9b155fc7edf547e8e6de2f2bd5.tar.gz
alacritty-182a9d5c2e01ec9b155fc7edf547e8e6de2f2bd5.zip
Fix deletion of lines when clearing the screen
Previously Alacritty would delete lines when clearing the screen, leading to a loss of data in the scrollback buffer. Instead of deleting these lines, they are now rotated outside of the visible region. This also fixes some issues with Alacritty only resetting lines partially when the background color of the template cell changed. Fixes #2199.
Diffstat (limited to 'alacritty_terminal/src/term/mod.rs')
-rw-r--r--alacritty_terminal/src/term/mod.rs32
1 files changed, 20 insertions, 12 deletions
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs
index 8d69fb3b..6a51ba35 100644
--- a/alacritty_terminal/src/term/mod.rs
+++ b/alacritty_terminal/src/term/mod.rs
@@ -701,7 +701,9 @@ pub struct Term<T> {
/// Mode flags
mode: TermMode,
- /// Scroll region
+ /// Scroll region.
+ ///
+ /// Range going from top to bottom of the terminal, indexed from the top of the viewport.
scroll_region: Range<Line>,
pub dirty: bool,
@@ -1749,17 +1751,6 @@ impl<T: EventListener> ansi::Handler for Term<T> {
self.grid.selection = None;
match mode {
- ansi::ClearMode::Below => {
- for cell in &mut self.grid[self.cursor.point.line][self.cursor.point.col..] {
- cell.reset(&template);
- }
- if self.cursor.point.line < self.grid.num_lines() - 1 {
- self.grid
- .region_mut((self.cursor.point.line + 1)..)
- .each(|cell| cell.reset(&template));
- }
- },
- ansi::ClearMode::All => self.grid.region_mut(..).each(|c| c.reset(&template)),
ansi::ClearMode::Above => {
// If clearing more than one line
if self.cursor.point.line > Line(1) {
@@ -1774,6 +1765,23 @@ impl<T: EventListener> ansi::Handler for Term<T> {
cell.reset(&template);
}
},
+ ansi::ClearMode::Below => {
+ for cell in &mut self.grid[self.cursor.point.line][self.cursor.point.col..] {
+ cell.reset(&template);
+ }
+ if self.cursor.point.line < self.grid.num_lines() - 1 {
+ self.grid
+ .region_mut((self.cursor.point.line + 1)..)
+ .each(|cell| cell.reset(&template));
+ }
+ },
+ ansi::ClearMode::All => {
+ if self.mode.contains(TermMode::ALT_SCREEN) {
+ self.grid.region_mut(..).each(|c| c.reset(&template));
+ } else {
+ self.grid.clear_viewport(&template);
+ }
+ },
ansi::ClearMode::Saved => self.grid.clear_history(),
}
}