use std::io; use std::time::Duration; use everycycle_tui::audit::{AuditState, render}; use ratatui::DefaultTerminal; use ratatui::crossterm::event::{self, Event, KeyCode, KeyEventKind, KeyModifiers}; fn main() -> io::Result<()> { let mut terminal = ratatui::init(); let result = run(&mut terminal); ratatui::restore(); result } fn run(terminal: &mut DefaultTerminal) -> io::Result<()> { let mut state = AuditState::default(); state.refresh(); loop { terminal.draw(|frame| render(frame, frame.area(), &mut state))?; // Block for up to 250 ms so the screen redraws periodically even // without input. The audit screen does not animate today; this // is forward-compat for the live-ops screen that will replace // it as the default landing surface. if !event::poll(Duration::from_millis(250))? { continue; } let Event::Key(key) = event::read()? else { continue; }; if key.kind != KeyEventKind::Press { continue; } match (key.code, key.modifiers) { (KeyCode::Char('q' | 'Q') | KeyCode::Esc, _) | (KeyCode::Char('c' | 'C'), KeyModifiers::CONTROL) => return Ok(()), (KeyCode::Char('r' | 'R'), _) => state.refresh(), (KeyCode::Char('j') | KeyCode::Down, _) => state.select_next(), (KeyCode::Char('k') | KeyCode::Up, _) => state.select_prev(), _ => {} } } }