enter_alt_screen

Function enter_alt_screen 

Source
pub fn enter_alt_screen() -> Cmd
Expand description

Creates a command that enters the alternate screen buffer.

This command sends an EnterAltScreenMsg to the program, which will cause the terminal to switch to the alternate screen buffer. The alternate screen is typically used by full-screen TUI applications to preserve the user’s terminal scrollback.

§Examples

use bubbletea_rs::{command, Model, Msg};

struct MyModel;

impl Model for MyModel {
    fn init() -> (Self, Option<command::Cmd>) {
        let model = Self {};
        // Enter alternate screen on startup
        let cmd = command::batch(vec![
            command::enter_alt_screen(),
            command::hide_cursor(),
        ]);
        (model, Some(cmd))
    }
     
    fn update(&mut self, msg: Msg) -> Option<command::Cmd> {
        None
    }
     
    fn view(&self) -> String {
        "TUI Application".to_string()
    }
}