diff options
| author | mo8it <mo8it@proton.me> | 2024-08-24 00:14:12 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-08-24 00:14:12 +0200 |
| commit | 570bc9f32d7ef0bf741fab44d15f7cd54a1f3fc1 (patch) | |
| tree | 528eae66ebf8fc3250c827a0e5468e6e7569e141 /src/watch/state.rs | |
| parent | 47976caa69e24ea9ee5d38918a0abea89ff10983 (diff) | |
Start list without Ratatui
Diffstat (limited to 'src/watch/state.rs')
| -rw-r--r-- | src/watch/state.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/watch/state.rs b/src/watch/state.rs index 6bf8e69..26c83d5 100644 --- a/src/watch/state.rs +++ b/src/watch/state.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use ratatui::crossterm::{ +use crossterm::{ style::{style, Stylize}, terminal, }; @@ -76,7 +76,8 @@ impl<'a> WatchState<'a> { self.done_status = DoneStatus::Pending; } - self.render() + self.render()?; + Ok(()) } pub fn handle_file_change(&mut self, exercise_ind: usize) -> Result<()> { @@ -120,7 +121,7 @@ impl<'a> WatchState<'a> { self.writer.flush() } - pub fn render(&mut self) -> Result<()> { + pub fn render(&mut self) -> io::Result<()> { // Prevent having the first line shifted if clearing wasn't successful. self.writer.write_all(b"\n")?; clear_terminal(&mut self.writer)?; @@ -155,14 +156,15 @@ impl<'a> WatchState<'a> { } let line_width = terminal::size()?.0; - let progress_bar = progress_bar( + progress_bar( + &mut self.writer, self.app_state.n_done(), self.app_state.exercises().len() as u16, line_width, )?; writeln!( self.writer, - "{progress_bar}Current exercise: {}", + "\nCurrent exercise: {}", self.app_state.current_exercise().terminal_link(), )?; @@ -171,7 +173,7 @@ impl<'a> WatchState<'a> { Ok(()) } - pub fn show_hint(&mut self) -> Result<()> { + pub fn show_hint(&mut self) -> io::Result<()> { self.show_hint = true; self.render() } |
