2024-03-01 01:03:17 -07:00
|
|
|
use std::{io::stdout, panic};
|
|
|
|
|
|
|
|
|
|
use crossterm::{
|
|
|
|
|
cursor::Show,
|
|
|
|
|
event::DisableMouseCapture,
|
2025-03-04 22:31:38 -07:00
|
|
|
terminal::{LeaveAlternateScreen, disable_raw_mode},
|
2024-03-01 01:03:17 -07:00
|
|
|
};
|
2024-02-27 18:47:51 -07:00
|
|
|
|
|
|
|
|
pub fn crossterm_panic_handler() {
|
|
|
|
|
let original_hook = panic::take_hook();
|
|
|
|
|
panic::set_hook(Box::new(move |panic_info| {
|
2024-03-01 01:03:17 -07:00
|
|
|
let _ = crossterm::execute!(stdout(), LeaveAlternateScreen, DisableMouseCapture, Show);
|
|
|
|
|
let _ = disable_raw_mode();
|
2024-02-27 18:47:51 -07:00
|
|
|
original_hook(panic_info);
|
|
|
|
|
}));
|
|
|
|
|
}
|