mirror of
https://github.com/wez/wezterm.git
synced 2024-12-24 13:52:55 +03:00
term: implement EraseInDisplay::EraseScrollback
refs: https://github.com/wez/wezterm/issues/194
This commit is contained in:
parent
4d5848422d
commit
33e387be7d
@ -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
|
||||
|
@ -1333,7 +1333,7 @@ impl TerminalState {
|
||||
}
|
||||
EraseInDisplay::EraseDisplay => 0..rows,
|
||||
EraseInDisplay::EraseScrollback => {
|
||||
error!("TODO: ed: no support for xterm Erase Saved Lines yet");
|
||||
self.screen_mut().erase_scrollback();
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
@ -183,3 +183,12 @@ fn test_ed() {
|
||||
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 "]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user