diff options
author | Joris | 2021-11-14 23:25:55 +0100 |
---|---|---|
committer | Joris | 2021-11-19 11:42:20 +0100 |
commit | 9f94611a42d41cf94cdccb00b5d2eec0d5d02970 (patch) | |
tree | 9bab5bc342e22aa38b13a2dbd3525bbfe2beedb5 /src/gui/gui.rs | |
parent | 59c44b15010eea5490896a5b5d427b415ad6f56a (diff) |
Add initial working version
Diffstat (limited to 'src/gui/gui.rs')
-rw-r--r-- | src/gui/gui.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/gui/gui.rs b/src/gui/gui.rs new file mode 100644 index 0000000..fdf686b --- /dev/null +++ b/src/gui/gui.rs @@ -0,0 +1,34 @@ +use crate::{db::db, gui::question, space_repetition, util::event::Events}; +use anyhow::Result; +use rusqlite::Connection; +use std::io; +use termion::{raw::IntoRawMode, screen::AlternateScreen}; +use tui::{backend::TermionBackend, Terminal}; + +pub fn start(conn: &Connection) -> Result<()> { + let stdout = io::stdout().into_raw_mode()?; + let stdout = AlternateScreen::from(stdout); + let backend = TermionBackend::new(stdout); + let mut terminal = Terminal::new(backend)?; + + let events = Events::new(); + + loop { + match db::pick_ready(&conn) { + Some(card) => { + let difficulty = + question::ask(&mut terminal, &events, &card, "German".to_string())?; + db::update( + &conn, + &card.question, + &space_repetition::update(card.state, difficulty), + )?; + } + None => { + break; + } + } + } + + Ok(()) +} |