diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs index 6fbd3e0..6a4bcba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -171,9 +171,16 @@ async fn input_handler(event: KeyEvent, app: &mut App, _event_tx: Arc<Mutex<()>> KeyCode::Backspace => { app.input_string.pop(); } - KeyCode::Esc => { - app.should_exit = true; - } + KeyCode::Esc => match app.state { + State::MainMenu => { + app.should_exit = true; + } + State::TypingGame | State::EndScreen => { + app.state = State::MainMenu; + app.input_string.clear(); + app.timer = None; + } + }, KeyCode::Enter => match app.state { State::MainMenu => { app.state = State::TypingGame; @@ -198,14 +205,12 @@ async fn input_handler(event: KeyEvent, app: &mut App, _event_tx: Arc<Mutex<()>> #[cfg(test)] mod test; +// Main function #[tokio::main] async fn main() -> Result<(), io::Error> { // Enable raw mode for terminal input enable_raw_mode()?; - // Print current working directory - println!("Current working directory: {:?}", std::env::current_dir()); - // Create a new instance of the App let mut app = App::new().unwrap(); |
