mod state; 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(); let screen = AlternateScreen::from(stdout().into_raw_mode().unwrap()); // hide the cursor let mut screen = termion::cursor::HideCursor::from(screen); // open database let db = notmuch::Database::open(&"/home/gustav/.mail", notmuch::DatabaseMode::ReadOnly).unwrap(); // get threads let query = db.create_query("tag:inbox").unwrap(); let threads = query.search_threads().unwrap().collect(); // init initial state let mut threads = Threads { threads, i: 0, }; 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), }; } }