summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index a718a90..edb4d60 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -51,7 +51,7 @@ fn prompt(anki: &AnkiClient) {
// needs to be done twice to account for lag on the other end
anki.request(GuiCurrentCardRequest {}).unwrap();
let card = anki.request(GuiCurrentCardRequest {}).unwrap();
- clear_screen();
+ clear_with_bar(&anki, &card);
display_html(&card.question);
loop {
match event::read().unwrap() {
@@ -63,7 +63,7 @@ fn prompt(anki: &AnkiClient) {
};
}
anki.request(GuiShowAnswerRequest {}).unwrap();
- clear_screen();
+ clear_with_bar(&anki, &card);
{
let length = html2text(&card.question).len();
let text = &html2text(&card.answer)[(2 + length)..];
@@ -84,6 +84,30 @@ fn prompt(anki: &AnkiClient) {
event::read().unwrap();
}
+fn clear_with_bar(anki: &AnkiClient, current_card: &GuiCurrentCardResponse) {
+ let deck_name = &current_card.deck_name;
+ let deck_stats = anki
+ .request(GetDeckStatsRequest {
+ decks: vec![deck_name.to_string()],
+ })
+ .unwrap()
+ .into_iter()
+ .next()
+ .unwrap()
+ .1;
+ clear_screen();
+ execute!(
+ stdout(),
+ SetForegroundColor(Color::Blue),
+ Print(&format!("{:?} ", deck_stats.new_count)),
+ SetForegroundColor(Color::Red),
+ Print(&format!("{:?} ", deck_stats.learn_count)),
+ SetForegroundColor(Color::Green),
+ Print(&format!("{:?}\n", deck_stats.review_count)),
+ ResetColor
+ );
+}
+
fn clear_screen() {
execute!(
stdout(),