Skip to main content

SAVE_SCREEN

Constant SAVE_SCREEN 

Source
pub const SAVE_SCREEN: &str = "\u{1b}[?47l";
Expand description

Saves the visible part of the screen buffer and the cursor position.

Equivalent to CSI ? 4 7 l.

The screen and cursor position may be restored to the saved state with LOAD_SCREEN.

The lines are not preserved; loaded text will not unwrap after resize.

If you have tui app and you want to preserve the terminal state, rather use ENABLE_ALTERNATIVE_BUFFER and DISABLE_ALTERNATIVE_BUFFER.

§Example

use termal_core::codes;

let mut buf = codes::CLEAR.to_string();

buf += "This text will be saved and restored";
buf += codes::SAVE_SCREEN;

buf += codes::CLEAR;
buf += "You will not see this text because it will be overwritten with \
    the saved screen";

buf += codes::LOAD_SCREEN;

println!("{buf}");

§Result in terminal