diff options
| author | mo8it <mo8it@proton.me> | 2024-04-12 15:27:29 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-04-12 15:27:29 +0200 |
| commit | a534de0312ff47d5e87b3bf60d508bdaafb98fbc (patch) | |
| tree | 5686cbf97017f5887d1cb1726aad9f79a9d84211 /src/watch.rs | |
| parent | 98c5088a39439389a4e198839b47819bfa1b1712 (diff) | |
Implement going to the next exercise
Diffstat (limited to 'src/watch.rs')
| -rw-r--r-- | src/watch.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/watch.rs b/src/watch.rs index 928fc5f..357b5c7 100644 --- a/src/watch.rs +++ b/src/watch.rs @@ -26,9 +26,9 @@ use self::{ enum WatchEvent { Input(InputEvent), FileChange { exercise_ind: usize }, + TerminalResize, NotifyErr(notify::Error), TerminalEventErr(io::Error), - TerminalResize, } /// Returned by the watch mode to indicate what to do afterwards. @@ -60,15 +60,15 @@ pub fn watch(app_state: &mut AppState) -> Result<WatchExit> { while let Ok(event) = rx.recv() { match event { + WatchEvent::Input(InputEvent::Next) => { + watch_state.next_exercise()?; + } WatchEvent::Input(InputEvent::Hint) => { watch_state.show_hint()?; } WatchEvent::Input(InputEvent::List) => { return Ok(WatchExit::List); } - WatchEvent::TerminalResize => { - watch_state.render()?; - } WatchEvent::Input(InputEvent::Quit) => break, WatchEvent::Input(InputEvent::Unrecognized(cmd)) => { watch_state.handle_invalid_cmd(&cmd)?; @@ -76,6 +76,9 @@ pub fn watch(app_state: &mut AppState) -> Result<WatchExit> { WatchEvent::FileChange { exercise_ind } => { watch_state.run_exercise_with_ind(exercise_ind)?; } + WatchEvent::TerminalResize => { + watch_state.render()?; + } WatchEvent::NotifyErr(e) => { return Err(Error::from(e).context("Exercise file watcher failed")) } |
