aboutsummaryrefslogtreecommitdiffstats
path: root/src/state/mod.rs
blob: 7b498f214e14b12c3992b077e6b1261704895123 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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),
            };
        }
    }
}