From 72495172c25e00799f29eb2e79fe40ddfa189866 Mon Sep 17 00:00:00 2001 From: Nathan Lilienthal Date: Sat, 1 Sep 2018 20:30:03 -0400 Subject: Implement `ansi::ClearMode::Saved` The clearing the screen for the `ansi::ClearMode::Saved` enum value has been implemented. This is used to clear all lines which are currently outside of the visible region but still inside the scrollback buffer. The specifications of XTerm indicate that the clearing of saved lines should only clear the saved lines and not the saved lines plus the currently visible part of the grid. Applications like `clear` send both the escape for clearing history plus the escape for clearing history when requested, so all sources seem to agree here. To allow both clearing the screen and the saved lines when a key is pressed the `process_key_bindings` method has been altered so multiple bindings can be specified. So it is now possible to execute both `^L` and `ClearHistory` with just a single binding. The `process_mouse_bindings` method has also been changed for consistency. To make sure everything works properly a test has been added which clears the history and then attempts to scroll. Since scrolling is the only way for a user to check if scrollback is available, this seems like a nice abstraction to check if there is a scrollback. --- src/grid/mod.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/grid/mod.rs') diff --git a/src/grid/mod.rs b/src/grid/mod.rs index 6359a4ee..680aa7bd 100644 --- a/src/grid/mod.rs +++ b/src/grid/mod.rs @@ -219,14 +219,9 @@ impl Grid { /// Add lines to the visible area /// - /// The behavior in Terminal.app and iTerm.app is to keep the cursor at the - /// bottom of the screen as long as there is scrollback available. Once - /// scrollback is exhausted, new lines are simply added to the bottom of the - /// screen. - /// - /// Alacritty takes a different approach. Rather than trying to move with - /// the scrollback, we simply pull additional lines from the back of the - /// buffer in order to populate the new area. + /// Alacritty keeps the cursor at the bottom of the terminal as long as there + /// is scrollback available. Once scrollback is exhausted, new lines are + /// simply added to the bottom of the screen. fn grow_lines( &mut self, new_line_count: index::Line, -- cgit