Skip to main content

max / ripgrow

711 B · 33 lines History Blame Raw
1 use std::time::Duration;
2
3 use crossterm::event::{self, Event};
4
5 mod app;
6 mod config;
7 mod pdf;
8 mod screens;
9 mod tui;
10
11 use app::App;
12
13 fn main() -> Result<(), Box<dyn std::error::Error>> {
14 let mut terminal = tui::init()?;
15 let result = run(&mut terminal);
16 tui::restore()?;
17 result
18 }
19
20 fn run(terminal: &mut tui::Tui) -> Result<(), Box<dyn std::error::Error>> {
21 let mut app = App::new()?;
22 while !app.should_quit {
23 terminal.draw(|f| app.render(f))?;
24 if event::poll(Duration::from_millis(200))?
25 && let Event::Key(key) = event::read()?
26 && key.kind == crossterm::event::KeyEventKind::Press
27 {
28 app.on_key(key);
29 }
30 }
31 Ok(())
32 }
33