From aa76b29ff7dbf4af8d83c9f461889249fe53ea77 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Fri, 3 Mar 2017 23:22:54 -0500 Subject: [PATCH] Handle CSI command J3 (Clear saved lines) Xterm supports an extension to the CSI command `Erase in Display (ED)`, under the command number 3. This command is used to clear the scrollback buffer - e.g. anything not visible on the screen. Since scrollback is not part of alacritty, the handler for this command currently does nothing. If at some point scrollback is implemented, the corresponding `match` arm can be modified to properly handle this. For an example of a program which uses this command, run the `clear` command (using ncurses 6.0). In a supported terminal such as `gnome-terminal`, this will clear anything off of the screen from the scrollback buffer. Before this change, `alacritty` would generate an `Unhandled CSI` message. --- src/ansi.rs | 3 +++ src/term/mod.rs | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ansi.rs b/src/ansi.rs index c37f2090..d2c255a5 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -330,6 +330,8 @@ pub enum ClearMode { Above, /// Clear entire terminal All, + /// Clear 'saved' lines (scrollback) + Saved } /// Mode for clearing tab stops @@ -709,6 +711,7 @@ impl<'a, H, W> vte::Perform for Performer<'a, H, W> 0 => ClearMode::Below, 1 => ClearMode::Above, 2 => ClearMode::All, + 3 => ClearMode::Saved, _ => unhandled!(), }; diff --git a/src/term/mod.rs b/src/term/mod.rs index 08299987..4ee685b1 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -1443,7 +1443,9 @@ impl ansi::Handler for Term { for cell in &mut self.grid[self.cursor.point.line][..self.cursor.point.col] { cell.reset(&template); } - } + }, + // If scrollback is implemented, this should clear it + ansi::ClearMode::Saved => return } }