mod threads; use std::io::{Stdin, Write}; use termion::event::Key; use termion::input::TermRead; pub use threads::Threads; pub struct Client { states: Vec, } impl Client { pub fn new(initial_state: State) -> Self { Self { states: vec![initial_state], } } pub fn run(mut self, mut screen: W, stdin: Stdin) { for c in stdin.keys() { let c = c.unwrap(); // Global keybinds match c { Key::Char('q') => { self.states.pop().unwrap(); if self.states.is_empty() { break; } }, _ => () } let next_state = match self.states.last_mut().unwrap() { State::Threads(s) => s.tick(&mut screen, c), }; if let Some(next_state) = next_state { self.states.push(next_state); } } } } pub enum State { Threads(Threads), }