//! Terminal setup and teardown. Owns the raw-mode + alternate-screen //! transitions so the rest of the app never has to think about them. use std::io::{Stdout, stdout}; use crossterm::execute; use crossterm::terminal::{ EnterAlternateScreen, LeaveAlternateScreen, disable_raw_mode, enable_raw_mode, }; use ratatui::Terminal; use ratatui::backend::CrosstermBackend; pub type Tui = Terminal>; pub fn init() -> std::io::Result { enable_raw_mode()?; let mut out = stdout(); execute!(out, EnterAlternateScreen)?; Terminal::new(CrosstermBackend::new(out)) } pub fn restore() -> std::io::Result<()> { disable_raw_mode()?; execute!(stdout(), LeaveAlternateScreen)?; Ok(()) }