diff options
| author | Akshay Nair <phenax5@gmail.com> | 2024-12-20 18:22:19 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2024-12-20 19:16:51 +0530 |
| commit | 4a13725300303940416bd6260af62ba478d30ec5 (patch) | |
| tree | c2897e0d80d373c9335b69cbf9c155c6264065f0 /src | |
| parent | 5dc3696f38433c79939bb182c4590a6ce04f4c63 (diff) | |
| download | chelleport-4a13725300303940416bd6260af62ba478d30ec5.tar.gz chelleport-4a13725300303940416bd6260af62ba478d30ec5.zip | |
Add tests for state management
Diffstat (limited to '')
| -rw-r--r-- | src/Chelleport.hs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Chelleport.hs b/src/Chelleport.hs index 6b443b5..98d1aa6 100644 --- a/src/Chelleport.hs +++ b/src/Chelleport.hs @@ -30,7 +30,7 @@ run = do ctx (runEff ctx initialState) (\state -> runEff ctx . update state) - eventToAction + (const eventHandler) (runEff ctx . Chelleport.View.render) initialState :: (MonadIO m) => m State @@ -48,8 +48,8 @@ initialState = do columns = 16 hintKeys = ['A' .. 'Z'] \\ "Q" -eventToAction :: EventHandler State AppAction -eventToAction _state event = +eventHandler :: SDL.Event -> Maybe AppAction +eventHandler event = case SDL.eventPayload event of SDL.QuitEvent -> Just ShutdownApp SDL.KeyboardEvent ev @@ -72,8 +72,8 @@ update :: m (State, Maybe AppAction) -- Act on key inputs update state (HandleKeyInput key) = do - case liftA2 (,) (toKeyChar key) validChars of - Just (keyChar, validChars') + case (toKeyChar key, validChars) of + (Just keyChar, Just validChars') | stateIsMatched state && keyChar `elem` ("HJKL" :: String) -> do incr <- incrementValue let action = IncrementMouseCursor $ directionalIncrement incr keyChar |
