From 8787162d7c973fad5a737172be81d7cafe9348ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Wed, 28 Apr 2021 23:36:05 +0200 Subject: move main loop to state --- src/main.rs | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 1149f83..21b6465 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,10 +5,7 @@ use crate::state::State; use crate::state::Threads; use std::io::{stdin, stdout}; -use termion::event::Key; -use termion::input::TermRead; use termion::raw::IntoRawMode; -use termion::screen::AlternateScreen; fn main() { let stdin = stdin(); @@ -31,19 +28,6 @@ fn main() { threads.init(&mut screen); - let mut state = State::Threads(threads); - - for c in stdin.keys() { - let c = c.unwrap(); - // Global keybinds - match c { - Key::Char('q') => break, - _ => () - } - - // Pass to current state - state = match state { - State::Threads(s) => s.tick(&mut screen, c), - }; - } + let state = State::Threads(threads); + state.run(screen, stdin); } -- cgit v1.2.1