Skip to main content

ERASE_BUFFER

Constant ERASE_BUFFER 

Source
pub const ERASE_BUFFER: &'static str;
Expand description

Erase the scrollback buffer.

Equivalent to CSI 3 J

Doesn’t erase the screen, only what is not visible on the screen because it was scrolled. If you wan’t to also erase the screen use ERASE_ALL, if you only want to erase the screen use ERASE_SCREEN.

§Example

use termal_core::{codes, Error, raw::{
    TermSize, Terminal, term_size
}};

// Fill the terminal with `#` and move to the center.
let TermSize { char_width: w, char_height: h, .. } = term_size()?;
let mut buf = "#".to_string() + &codes::repeat_char!(w * h - 1);
buf += &codes::move_to!(w / 2, h / 2);

// Erase the scrollback buffer.
buf += codes::ERASE_BUFFER;

// Print to the output and wait for enter. Screenshot is taken before enter
// is pressed.
Terminal::stdio().flushed(buf)?;
Terminal::stdio().read()?;

Ok::<_, Error>(())

§Result in terminal

Note that the scrollbar is full - there is nowhere to scroll - even though there was the prompt and cargo compilation log before the program ran.