Trait termion::screen::IntoAlternateScreen
source · pub trait IntoAlternateScreen: Write + Sized {
// Provided method
fn into_alternate_screen(self) -> Result<AlternateScreen<Self>> { ... }
}
Expand description
Extension trait for writers, providing the into_alternate_screen
function.
Provided Methods§
sourcefn into_alternate_screen(self) -> Result<AlternateScreen<Self>>
fn into_alternate_screen(self) -> Result<AlternateScreen<Self>>
Switch the terminal controlled by this writer to use the alternate screen. The terminal will be
restored to the main screen when the AlternateScreen
returned by this function is
dropped.
Examples found in repository?
More examples
examples/alternate_screen_raw.rs (line 19)
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
fn main() {
let stdin = stdin();
let mut screen = stdout().into_raw_mode().unwrap().into_alternate_screen().unwrap();
write!(screen, "{}", termion::cursor::Hide).unwrap();
write_alt_screen_msg(&mut screen);
screen.flush().unwrap();
for c in stdin.keys() {
match c.unwrap() {
Key::Char('q') => break,
Key::Char('1') => {
write!(screen, "{}", ToMainScreen).unwrap();
}
Key::Char('2') => {
write!(screen, "{}", ToAlternateScreen).unwrap();
write_alt_screen_msg(&mut screen);
}
_ => {}
}
screen.flush().unwrap();
}
write!(screen, "{}", termion::cursor::Show).unwrap();
}
Object Safety§
This trait is not object safe.