

Task

Clear the screen, output something on the display, and then restore the screen to the preserved state that it was in before the task was carried out.

There is no requirement to change the font or kerning in this task, however character decorations and attributes are expected to be preserved.   If the implementer decides to change the font or kerning during the display of the temporary screen, then these settings need to be restored prior to exit.




use std::io::{stdout, Write};
use std::time::Duration;
 
fn main() {
    let mut output = stdout();
 
    print!("\x1b[?1049h\x1b[H");
    println!("Alternate screen buffer");
 
    for i in (1..=5).rev() {
        print!("\rgoing back in {}...", i);
        output.flush().unwrap();
        std::thread::sleep(Duration::from_secs(1));
    }
 
    print!("\x1b[?1049l");
}