pub mod compliance;
pub mod components;
pub mod export;
pub mod licenses;
pub mod quality;
pub mod source;
pub mod vulnerabilities;
use crossterm::{
event::DisableMouseCapture,
execute,
terminal::{LeaveAlternateScreen, disable_raw_mode},
};
pub(crate) fn restore_terminal() {
let _ = disable_raw_mode();
let _ = execute!(std::io::stdout(), LeaveAlternateScreen, DisableMouseCapture);
}
pub(crate) fn install_panic_hook() {
static INSTALL: std::sync::Once = std::sync::Once::new();
INSTALL.call_once(|| {
let previous = std::panic::take_hook();
std::panic::set_hook(Box::new(move |info| {
restore_terminal();
previous(info);
}));
});
}
pub(crate) const fn floor_char_boundary(s: &str, index: usize) -> usize {
if index >= s.len() {
s.len()
} else {
let bytes = s.as_bytes();
let mut i = index;
while i > 0 && bytes[i] & 0b1100_0000 == 0b1000_0000 {
i -= 1;
}
i
}
}