This commit is contained in:
andromeda
2026-04-15 12:29:46 +02:00
parent 2dbe2c7811
commit d24c653bd2

View File

@@ -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(),