blob: a518534a6b32f81d21152a3427c48a6696bc7a39 (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
mod db;
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);
let mut threads = {
// open database
let db = crate::db::open(notmuch::DatabaseMode::ReadOnly).unwrap();
// get threads
let query = db.create_query("tag:inbox").unwrap();
let threads = query.search_threads().unwrap();
Threads::new(threads)
};
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),
};
}
}
|