···11+use std::io::stdout;
22+33+use crossterm::{
44+ cursor,
55+ event::{DisableBracketedPaste, DisableMouseCapture},
66+ terminal::LeaveAlternateScreen,
77+};
88+19/// Sets the panic-hook to be customized color-eyre `panic_hook`.
210///
311/// Additionally the panic handler prints different information
···15231624 eyre_hook.install()?;
1725 std::panic::set_hook(Box::new(move |panic_info| {
1818- //TODO: exit from terminal if the app is in a terminal
2626+ // exit from terminal if the app is in a terminal
2727+ if crossterm::terminal::is_raw_mode_enabled().unwrap() {
2828+ let _ = crossterm::execute!(stdout(), DisableBracketedPaste);
2929+ let _ = crossterm::execute!(stdout(), DisableMouseCapture);
3030+ let _ = crossterm::execute!(stdout(), LeaveAlternateScreen, cursor::Show);
3131+ let _ = crossterm::terminal::disable_raw_mode();
3232+ }
19332034 // in release mode, do human_panic printing
2135 #[cfg(not(debug_assertions))]