diff options
Diffstat (limited to 'src/state/mod.rs')
| -rw-r--r-- | src/state/mod.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/state/mod.rs b/src/state/mod.rs index 5313b4f..7b498f2 100644 --- a/src/state/mod.rs +++ b/src/state/mod.rs @@ -1,7 +1,29 @@ mod threads; +use std::io::{Stdin, Write}; +use termion::event::Key; +use termion::input::TermRead; + pub use threads::Threads; pub enum State { Threads(Threads), } + +impl State { + pub fn run<W: Write>(mut self, mut screen: W, stdin: Stdin) { + for c in stdin.keys() { + let c = c.unwrap(); + // Global keybinds + match c { + Key::Char('q') => break, + _ => () + } + + // Pass to current state + self = match self { + State::Threads(s) => s.tick(&mut screen, c), + }; + } + } +} |
