use crossterm::{
cursor::Show,
event::DisableBracketedPaste,
execute,
terminal::{disable_raw_mode, LeaveAlternateScreen},
};
use std::io::{self, stdout};
pub struct RawModeGuard {
_private: (),
}
impl RawModeGuard {
pub(crate) fn new() -> Self {
Self { _private: () }
}
}
impl Drop for RawModeGuard {
fn drop(&mut self) {
let _ = cleanup_terminal();
}
}
fn cleanup_terminal() -> io::Result<()> {
disable_raw_mode()?;
execute!(stdout(), DisableBracketedPaste, LeaveAlternateScreen, Show)?;
Ok(())
}
#[cfg(test)]
mod tests {
}