diff --git a/src/event.rs b/src/event.rs index 64f3735..9d6782a 100644 --- a/src/event.rs +++ b/src/event.rs @@ -4,13 +4,11 @@ use crossterm::event::{Event as TermEvent, EventStream, KeyEvent}; use futures::{future::FutureExt, StreamExt}; use tokio::sync::mpsc; -const TICK_RATE: u64 = 150; -const FRAME_RATE: f64 = 60.0; +const FRAME_RATE: f64 = 2.0; pub enum Event { Key(KeyEvent), Render, - Tick, } pub struct Events { @@ -24,10 +22,8 @@ impl Events { tokio::task::spawn(async move { let mut stream = EventStream::new(); let mut render_interval = tokio::time::interval(Duration::from_secs_f64(1.0 / FRAME_RATE)); - let mut tick_interval = tokio::time::interval(Duration::from_millis(TICK_RATE)); loop { - let tick = tick_interval.tick(); let render = render_interval.tick(); let event = stream.next().fuse(); @@ -35,11 +31,11 @@ impl Events { event = event => { if let Some(Ok(TermEvent::Key(event))) = event { let _ = tx.send(Event::Key(event)).await; + let _ = tx.send(Event::Render).await; } } _ = render => { let _ = tx.send(Event::Render).await; }, - _ = tick => { let _ = tx.send(Event::Tick).await; }, } } }); diff --git a/src/main.rs b/src/main.rs index 6043c02..c010a8f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -96,7 +96,7 @@ async fn run() -> Result<(), Box> { match events.next().await { Some(Event::Render) => ui::draw(greeter.clone(), &mut terminal).await?, Some(Event::Key(key)) => keyboard::handle(greeter.clone(), key, ipc.clone()).await?, - Some(Event::Tick) | None => {} + _ => {} } } }