aboutsummaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/message.rs2
-rw-r--r--src/gui/mod.rs22
-rw-r--r--src/gui/question.rs14
3 files changed, 22 insertions, 16 deletions
diff --git a/src/gui/message.rs b/src/gui/message.rs
index b938150..bc6473a 100644
--- a/src/gui/message.rs
+++ b/src/gui/message.rs
@@ -34,7 +34,7 @@ pub fn show<B: Backend>(
if wait {
if let Event::Input(Key::Char('q')) = events.next()? {
- break
+ break;
}
} else {
break;
diff --git a/src/gui/mod.rs b/src/gui/mod.rs
index 3599df8..b39cbcf 100644
--- a/src/gui/mod.rs
+++ b/src/gui/mod.rs
@@ -50,19 +50,17 @@ pub fn start(conn: &Connection, term: &mut Term, events: &Events, deck_name: &st
let title = title(deck_name, answers, db::count_available(conn).unwrap_or(0));
match db::pick_random_ready(conn) {
- Some(card) => {
- 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),
- )?;
- }
+ Some(card) => 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) {
Some(ready) => format!(
diff --git a/src/gui/question.rs b/src/gui/question.rs
index 851c0af..37101c1 100644
--- a/src/gui/question.rs
+++ b/src/gui/question.rs
@@ -77,7 +77,7 @@ pub fn ask<B: Backend>(
let formatted_input = match state.answer {
Answer::Write => format!("{}█", state.input),
- _ => state.input.clone()
+ _ => state.input.clone(),
};
let answer = Paragraph::new(util::center_vertically(chunks[2], &formatted_input))
.style(match state.answer {
@@ -160,7 +160,11 @@ pub fn ask<B: Backend>(
let mut words = state.input.split_whitespace().collect::<Vec<&str>>();
if words.len() > 0 {
words.truncate(words.len() - 1);
- state.input = format!("{}{}", words.join(" "), if words.len() > 0 {" " } else {""});
+ state.input = format!(
+ "{}{}",
+ words.join(" "),
+ if words.len() > 0 { " " } else { "" }
+ );
}
}
Key::Ctrl('c') => {
@@ -182,7 +186,11 @@ pub fn ask<B: Backend>(
state.answer = Answer::Difficulty { difficulty: *d }
}
}
- Key::Char('\n') => return Ok(Response::Answered { difficulty: selected }),
+ Key::Char('\n') => {
+ return Ok(Response::Answered {
+ difficulty: selected,
+ })
+ }
_ => {}
},
}