From fb38e8fd9ba849860e301a68cdd262b286c05711 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 9 Oct 2022 17:47:07 +0200 Subject: Format code --- src/db/mod.rs | 8 +------- src/gui/message.rs | 2 +- src/gui/mod.rs | 22 ++++++++++------------ src/gui/question.rs | 14 +++++++++++--- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/db/mod.rs b/src/db/mod.rs index f59aad5..c2749dc 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -57,13 +57,7 @@ pub fn synchronize(conn: &Connection, entries: Vec) -> Result<()> { Ok(()) } -fn insert( - conn: &Connection, - now: u64, - question: &str, - responses: &str, - state: &str, -) -> Result<()> { +fn insert(conn: &Connection, now: u64, question: &str, responses: &str, state: &str) -> Result<()> { conn.execute( " INSERT INTO cards (question, responses, state, created, deck_read, ready) 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( 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( 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( let mut words = state.input.split_whitespace().collect::>(); 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( state.answer = Answer::Difficulty { difficulty: *d } } } - Key::Char('\n') => return Ok(Response::Answered { difficulty: selected }), + Key::Char('\n') => { + return Ok(Response::Answered { + difficulty: selected, + }) + } _ => {} }, } -- cgit v1.2.3