diff options
| -rw-r--r-- | src/main.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs index 44b33d1..4c6c409 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,13 @@ -use std::io::{Stdout, Write, stdin, stdout}; +use std::io::{Write, stdin, stdout}; use termion::color; use termion::event::Key; use termion::input::TermRead; -use termion::raw::{IntoRawMode, RawTerminal}; +use termion::raw::IntoRawMode; +use termion::screen::AlternateScreen; fn main() { let stdin = stdin(); - let mut stdout = stdout().into_raw_mode().unwrap(); + let mut screen = AlternateScreen::from(stdout().into_raw_mode().unwrap()); // open database let db = notmuch::Database::open(&"/home/gustav/.mail", notmuch::DatabaseMode::ReadOnly).unwrap(); @@ -21,7 +22,7 @@ fn main() { .collect(); let mut i: isize = 0; - show_threads(&mut stdout, &threads, i as usize); + show_threads(&mut screen, &threads, i as usize); for c in stdin.keys() { match c.unwrap() { @@ -31,11 +32,11 @@ fn main() { _ => () } i = i.rem_euclid(threads.len() as isize); - show_threads(&mut stdout, &threads, i as usize); + show_threads(&mut screen, &threads, i as usize); } } -fn show_threads(stdout: &mut RawTerminal<Stdout>, threads: &Vec<String>, highlight: usize) { +fn show_threads<W: Write>(stdout: &mut W, threads: &Vec<String>, highlight: usize) { write!(stdout, "{}", termion::clear::All).unwrap(); for (i, thread) in threads.iter().enumerate() { |
