Add option to clear terminal history and current screen content.

This commit is contained in:
Termina94 2021-08-13 12:10:32 +01:00 committed by GitHub
parent 24d0f561e8
commit abe2c57129
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -239,6 +239,8 @@ impl Command for LeaveAlternateScreen {
pub enum ClearType {
/// All cells.
All,
/// All plus history
Purge,
/// All cells from the cursor position downwards.
FromCursorDown,
/// All cells from the cursor position upwards.
@ -307,6 +309,7 @@ impl Command for Clear {
fn write_ansi(&self, f: &mut impl fmt::Write) -> fmt::Result {
f.write_str(match self.0 {
ClearType::All => csi!("2J"),
ClearType::Purge => csi!("3J"),
ClearType::FromCursorDown => csi!("J"),
ClearType::FromCursorUp => csi!("1J"),
ClearType::CurrentLine => csi!("2K"),