diff options
| author | srdusr <[email protected]> | 2025-07-22 10:05:00 +0200 |
|---|---|---|
| committer | srdusr <[email protected]> | 2025-07-22 10:05:00 +0200 |
| commit | fe660228f2bcce262a7e18b4ced25736778b1eeb (patch) | |
| tree | 9eb23d0963ca4b3f3926da7385485c5f9e93109d /src/main.rs | |
| parent | c0e22de0d853b609bb20f43ef0650b969afe49f0 (diff) | |
| download | typerpunk-fe660228f2bcce262a7e18b4ced25736778b1eeb.tar.gz typerpunk-fe660228f2bcce262a7e18b4ced25736778b1eeb.zip | |
Quit the game or go back to the main menu functionality added instead of just quitting the game
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(); |