1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-24 22:01:47 +03:00

term: implement EraseInDisplay::EraseScrollback

refs: https://github.com/wez/wezterm/issues/194
This commit is contained in:
Wez Furlong 2020-05-25 17:13:08 -07:00
parent 4d5848422d
commit 33e387be7d
3 changed files with 19 additions and 1 deletions

View File

@ -469,6 +469,15 @@ impl Screen {
} }
} }
pub fn erase_scrollback(&mut self) {
let len = self.lines.len();
let to_clear = len - self.physical_rows;
for _ in 0..to_clear {
self.lines.pop_front();
self.stable_row_index_offset += 1;
}
}
/// --------- /// ---------
/// | /// |
/// |--- top /// |--- top

View File

@ -1333,7 +1333,7 @@ impl TerminalState {
} }
EraseInDisplay::EraseDisplay => 0..rows, EraseInDisplay::EraseDisplay => 0..rows,
EraseInDisplay::EraseScrollback => { EraseInDisplay::EraseScrollback => {
error!("TODO: ed: no support for xterm Erase Saved Lines yet"); self.screen_mut().erase_scrollback();
return; return;
} }
}; };

View File

@ -183,3 +183,12 @@ fn test_ed() {
Compare::TEXT | Compare::ATTRS, Compare::TEXT | Compare::ATTRS,
); );
} }
#[test]
fn test_ed_erase_scrollback() {
let mut term = TestTerm::new(3, 3, 3);
term.print("abc\r\ndef\r\nghi\r\n111\r\n222\r\na\x1b[3J");
assert_all_contents(&term, file!(), line!(), &["111", "222", "a "]);
term.print("b");
assert_all_contents(&term, file!(), line!(), &["111", "222", "ab "]);
}