mirror of
https://github.com/notohh/rustlings.git
synced 2024-12-17 22:58:08 -05:00
Small improvements to showing progress
This commit is contained in:
parent
396ee4d618
commit
8cac21511c
3 changed files with 27 additions and 18 deletions
|
@ -520,7 +520,6 @@ impl AppState {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.write()?;
|
self.write()?;
|
||||||
stdout.write_all(b"\n")?;
|
|
||||||
|
|
||||||
Ok(first_pending_exercise_ind)
|
Ok(first_pending_exercise_ind)
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,13 +151,15 @@ fn main() -> Result<ExitCode> {
|
||||||
app_state.set_current_exercise_ind(first_pending_exercise_ind)?;
|
app_state.set_current_exercise_ind(first_pending_exercise_ind)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stdout.write_all(b"\n\n")?;
|
||||||
|
|
||||||
let pending = app_state.n_pending();
|
let pending = app_state.n_pending();
|
||||||
if pending == 1 {
|
if pending == 1 {
|
||||||
stdout.write_all(b"One exercise pending: ")?;
|
stdout.write_all(b"One exercise pending: ")?;
|
||||||
} else {
|
} else {
|
||||||
write!(
|
write!(
|
||||||
stdout,
|
stdout,
|
||||||
"{pending}/{} exercises are pending. The first: ",
|
"{pending}/{} exercises pending. The first: ",
|
||||||
app_state.exercises().len(),
|
app_state.exercises().len(),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
40
src/term.rs
40
src/term.rs
|
@ -164,26 +164,34 @@ pub fn show_exercises_check_progress(
|
||||||
|
|
||||||
let mut exercise_num = 1;
|
let mut exercise_num = 1;
|
||||||
for exercise_progress in progresses {
|
for exercise_progress in progresses {
|
||||||
let color = match exercise_progress {
|
match exercise_progress {
|
||||||
ExerciseCheckProgress::None => Color::Reset,
|
ExerciseCheckProgress::None => (),
|
||||||
ExerciseCheckProgress::Checking => Color::Blue,
|
ExerciseCheckProgress::Checking => {
|
||||||
ExerciseCheckProgress::Done => Color::Green,
|
stdout.queue(SetForegroundColor(Color::Blue))?;
|
||||||
ExerciseCheckProgress::Pending => Color::Red,
|
}
|
||||||
};
|
ExerciseCheckProgress::Done => {
|
||||||
|
stdout.queue(SetForegroundColor(Color::Green))?;
|
||||||
stdout.queue(SetForegroundColor(color))?;
|
}
|
||||||
write!(stdout, "{exercise_num:<3}")?;
|
ExerciseCheckProgress::Pending => {
|
||||||
|
stdout.queue(SetForegroundColor(Color::Red))?;
|
||||||
if exercise_num % n_cols == 0 {
|
}
|
||||||
stdout.write_all(b"\n")?;
|
|
||||||
} else {
|
|
||||||
stdout.write_all(b" ")?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exercise_num += 1;
|
write!(stdout, "{exercise_num:<3}")?;
|
||||||
|
stdout.queue(ResetColor)?;
|
||||||
|
|
||||||
|
if exercise_num != progresses.len() {
|
||||||
|
if exercise_num % n_cols == 0 {
|
||||||
|
stdout.write_all(b"\n")?;
|
||||||
|
} else {
|
||||||
|
stdout.write_all(b" ")?;
|
||||||
|
}
|
||||||
|
|
||||||
|
exercise_num += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stdout.queue(ResetColor)?.flush()
|
stdout.flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clear_terminal(stdout: &mut StdoutLock) -> io::Result<()> {
|
pub fn clear_terminal(stdout: &mut StdoutLock) -> io::Result<()> {
|
||||||
|
|
Loading…
Reference in a new issue