diff options
| author | andromeda <andromeda@lenovo> | 2026-04-15 12:29:46 +0200 |
|---|---|---|
| committer | andromeda <andromeda@lenovo> | 2026-04-15 12:29:46 +0200 |
| commit | d24c653bd24ccf88e10567951dfa0fb8991072a8 (patch) | |
| tree | dbe4b117e83942954140b5d32f9c3d5e9cd78275 /src | |
| parent | 2dbe2c78114e446fe1ed31c071cb323239059e58 (diff) | |
add bar
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 28 |
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 = ¤t_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(), |
