Skip to main content

ERASE_FROM_START

Constant ERASE_FROM_START 

Source
pub const ERASE_FROM_START: &str = "\u{1b}[1J";
Expand description

Erases from the start of the screen to the cursor.

Equivalent to CSI 1 J

Note that ERASE_FROM_START and ERASE_TO_END are not opposite. Both will also erase character at the cursor position.

§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 to the end of the screen.
buf += codes::ERASE_FROM_START;

// 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