diff options
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(()) +} |