Skip to main content

TerminalSetup

Trait TerminalSetup 

Source
pub trait TerminalSetup {
    type B: Backend;

    // Required methods
    fn enable(&mut self) -> Result<()>;
    fn create_terminal(&mut self) -> Result<Terminal<Self::B>>;
    fn disable(&mut self);
    fn print_done(&self);
}
Expand description

Abstracts terminal setup/teardown so a UI’s generic core can be tested with a ratatui::backend::TestBackend and no-op TTY operations. The real crossterm implementation (CrosstermSetup) lives in the binary, since it can only be exercised against a real terminal.

Required Associated Types§

Source

type B: Backend

The backend the terminal draws through: crossterm in production, a TestBackend under test.

Required Methods§

Source

fn enable(&mut self) -> Result<()>

Take over the terminal - raw mode and the alternate screen.

Source

fn create_terminal(&mut self) -> Result<Terminal<Self::B>>

Build the terminal the UI draws into. Called after Self::enable.

Source

fn disable(&mut self)

Hand the terminal back. Must tolerate being called twice: the panic hook calls it too, and a panic during teardown would otherwise leave a terminal in raw mode.

Source

fn print_done(&self)

Print whatever should remain on screen after the UI exits.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§