redbear-power: fix panic hook to restore terminal on panic

This commit is contained in:
2026-07-07 17:22:20 +03:00
parent feba6e2ad8
commit dc9155a2a8
@@ -237,15 +237,13 @@ fn handle_mouse(me: MouseEvent, header: &Rect, table: &Rect, keybar: &Rect, app:
fn main() -> io::Result<()> {
let args = parse_args();
// v1.44: Restore terminal on panic so the user isn't left with
// a garbled screen in raw mode.
// Let panic unwind so the raw-mode / alternate-screen guards drop
// and restore the terminal before the default panic handler prints.
panic::set_hook(Box::new(|info| {
let _ = termion::raw::IntoRawMode::into_raw_mode(std::io::stdout());
let _ = std::io::Write::write_all(
&mut std::io::stderr(),
format!("redbear-power: {info}\n").as_bytes(),
);
std::process::exit(1);
}));
let cfg = if let Some(p) = args.config_path.as_ref() {