add bar
This commit is contained in:
28
src/main.rs
28
src/main.rs
@@ -51,7 +51,7 @@ fn prompt(anki: &AnkiClient) {
|
|||||||
// needs to be done twice to account for lag on the other end
|
// needs to be done twice to account for lag on the other end
|
||||||
anki.request(GuiCurrentCardRequest {}).unwrap();
|
anki.request(GuiCurrentCardRequest {}).unwrap();
|
||||||
let card = anki.request(GuiCurrentCardRequest {}).unwrap();
|
let card = anki.request(GuiCurrentCardRequest {}).unwrap();
|
||||||
clear_screen();
|
clear_with_bar(&anki, &card);
|
||||||
display_html(&card.question);
|
display_html(&card.question);
|
||||||
loop {
|
loop {
|
||||||
match event::read().unwrap() {
|
match event::read().unwrap() {
|
||||||
@@ -63,7 +63,7 @@ fn prompt(anki: &AnkiClient) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
anki.request(GuiShowAnswerRequest {}).unwrap();
|
anki.request(GuiShowAnswerRequest {}).unwrap();
|
||||||
clear_screen();
|
clear_with_bar(&anki, &card);
|
||||||
{
|
{
|
||||||
let length = html2text(&card.question).len();
|
let length = html2text(&card.question).len();
|
||||||
let text = &html2text(&card.answer)[(2 + length)..];
|
let text = &html2text(&card.answer)[(2 + length)..];
|
||||||
@@ -84,6 +84,30 @@ fn prompt(anki: &AnkiClient) {
|
|||||||
event::read().unwrap();
|
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() {
|
fn clear_screen() {
|
||||||
execute!(
|
execute!(
|
||||||
stdout(),
|
stdout(),
|
||||||
|
|||||||
Reference in New Issue
Block a user