ratatui 0.26.3

A library that's all about cooking up terminal user interfaces
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use color_eyre::{config::HookBuilder, Result};

use crate::term;

pub fn init_hooks() -> Result<()> {
    let (panic, error) = HookBuilder::default().into_hooks();
    let panic = panic.into_panic_hook();
    let error = error.into_eyre_hook();
    color_eyre::eyre::set_hook(Box::new(move |e| {
        let _ = term::restore();
        error(e)
    }))?;
    std::panic::set_hook(Box::new(move |info| {
        let _ = term::restore();
        panic(info);
    }));
    Ok(())
}