aboutsummaryrefslogtreecommitdiff
path: root/src/gui/mod.rs
diff options
context:
space:
mode:
authorJoris2022-10-09 17:38:26 +0200
committerJoris2022-10-09 17:38:26 +0200
commit3c935cc0728f25dab169d2a05dfa153242946c4a (patch)
treeb826abb5bf25be6ec75e04e71b1de2f7469b935f /src/gui/mod.rs
parent9a5fe39f8ea1e2a88876c68a797ced28fbfd8457 (diff)
downloadflashcards-3c935cc0728f25dab169d2a05dfa153242946c4a.tar.gz
flashcards-3c935cc0728f25dab169d2a05dfa153242946c4a.tar.bz2
flashcards-3c935cc0728f25dab169d2a05dfa153242946c4a.zip
Abort with C-c
Diffstat (limited to 'src/gui/mod.rs')
-rw-r--r--src/gui/mod.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/gui/mod.rs b/src/gui/mod.rs
index 92cd943..3599df8 100644
--- a/src/gui/mod.rs
+++ b/src/gui/mod.rs
@@ -51,13 +51,17 @@ pub fn start(conn: &Connection, term: &mut Term, events: &Events, deck_name: &st
match db::pick_random_ready(conn) {
Some(card) => {
- let difficulty = question::ask(term, events, &title, &card)?;
- answers += 1;
- db::update(
- conn,
- &card.question,
- &space_repetition::update(card.state, difficulty),
- )?;
+ match question::ask(term, events, &title, &card)? {
+ question::Response::Aborted => break,
+ question::Response::Answered { difficulty } => {
+ answers += 1;
+ db::update(
+ conn,
+ &card.question,
+ &space_repetition::update(card.state, difficulty),
+ )?;
+ }
+ }
}
None => {
let message = match db::next_ready(conn) {