//! A guard that restores the terminal state on drop. use crossterm::cursor::Show; use crossterm::execute; use crossterm::terminal::{LeaveAlternateScreen, disable_raw_mode}; /// A guard that ensures the terminal is restored to its original state /// when dropped. #[derive(Default, Debug)] pub struct TerminalModeGuard; impl TerminalModeGuard {} impl Drop for TerminalModeGuard { #[allow( clippy::let_underscore_must_use, reason = "We want to ignore errors during cleanup." )] fn drop(&mut self) { let _ = disable_raw_mode(); let mut stdout = std::io::stdout(); let _ = execute!(stdout, LeaveAlternateScreen, Show); } }