summaryrefslogtreecommitdiff
path: root/src/watch/state.rs
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-05-14 01:49:22 +0200
committermo8it <mo8it@proton.me>2024-05-14 01:49:22 +0200
commitc8481d35c120ff99213e6ed73ba889e51cac10c5 (patch)
treefa6e94b279a0f0ff85b87fea33b5a0566f83179c /src/watch/state.rs
parent96a44f3dcf2dd9e2562b757d7840084b45b90b61 (diff)
Done documentation
Diffstat (limited to 'src/watch/state.rs')
-rw-r--r--src/watch/state.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/watch/state.rs b/src/watch/state.rs
index abd21fb..14c3f01 100644
--- a/src/watch/state.rs
+++ b/src/watch/state.rs
@@ -1,7 +1,7 @@
use anyhow::Result;
use crossterm::{
style::{style, Stylize},
- terminal::size,
+ terminal,
};
use std::io::{self, StdoutLock, Write};
@@ -84,6 +84,7 @@ impl<'a> WatchState<'a> {
self.run_current_exercise()
}
+ /// Move on to the next exercise if the current one is done.
pub fn next_exercise(&mut self) -> Result<ExercisesProgress> {
if self.done_status == DoneStatus::Pending {
return Ok(ExercisesProgress::CurrentPending);
@@ -113,7 +114,7 @@ impl<'a> WatchState<'a> {
}
pub fn render(&mut self) -> Result<()> {
- // Prevent having the first line shifted.
+ // Prevent having the first line shifted if clearing wasn't successful.
self.writer.write_all(b"\n")?;
clear_terminal(&mut self.writer)?;
@@ -145,11 +146,11 @@ When you are done experimenting, enter `n` to move on to the next exercise 🦀"
writeln!(
self.writer,
"A solution file can be found at {}\n",
- style(TerminalFileLink(solution_path)).underlined().green()
+ style(TerminalFileLink(solution_path)).underlined().green(),
)?;
}
- let line_width = size()?.0;
+ let line_width = terminal::size()?.0;
let progress_bar = progress_bar(
self.app_state.n_done(),
self.app_state.exercises().len() as u16,