blob: fdf686b2a5f3b3430b55e5348b4827d8f4c17cff (
plain)
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
|
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(())
}
|