mirror of
https://git.aramjonghu.dev/AramJonghu/rustlings.git
synced 2026-09-02 08:23:31 +02:00
Implement going to the next exercise
This commit is contained in:
+7
-4
@@ -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"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user