INNER CODE UNIT · Rust
install_panic_hook
Canop/broot · src/cli/mod.rs:215
fn install_panic_hook(capture_mouse: bool) {
let hook = std::panic::take_hook();
std::panic::set_hook(Box::new(move |panic_info| {
use crokey::crossterm::{
event::PopKeyboardEnhancementFlags,
terminal,
};
let mut w = std::io::stderr();
let _ = terminal::disable_raw_mode();
// popping when nothing was pushed is a no-op for terminals
// supporting the keyboard enhancement protocol, and ignored
// by the other ones
let _ = w.queue(PopKeyboardEnhancementFlags);
if capture_mouse {
let _ = w.queue(DisableMouseCapture);
}
let _ = w.queue(cursor::Show);
let _ = w.queue(LeaveAlternateScreen);