diff options
| author | Akshay Nair <phenax5@gmail.com> | 2024-12-20 20:45:11 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2024-12-20 20:45:11 +0530 |
| commit | 69f9c8ac053de7793c31c87572c9e044ae8369ee (patch) | |
| tree | e4d017be238d1064c274a33a55550fccc968d21b /src/Chelleport.hs | |
| parent | 496c7d048df6a9a3650c0a0b996888decb4ea9d1 (diff) | |
| download | chelleport-69f9c8ac053de7793c31c87572c9e044ae8369ee.tar.gz chelleport-69f9c8ac053de7793c31c87572c9e044ae8369ee.zip | |
Minor refactor
Diffstat (limited to 'src/Chelleport.hs')
| -rw-r--r-- | src/Chelleport.hs | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/src/Chelleport.hs b/src/Chelleport.hs index 6c06af4..ae5ec6e 100644 --- a/src/Chelleport.hs +++ b/src/Chelleport.hs @@ -32,7 +32,7 @@ run = do (const eventHandler) (runEff ctx . Chelleport.View.render) -initialState :: (MonadIO m) => m State +initialState :: (Monad m) => m State initialState = do let cells = fromMaybe (pure undefined) $ generateGrid 0 (rows, columns) hintKeys pure $ @@ -55,8 +55,8 @@ eventHandler event = | isKeyPressWith ev SDL.KeycodeEscape -> Just ShutdownApp | isKeyPressWith ev SDL.KeycodeSpace -> if withShift ev - then Just ChainLeftClick - else Just TriggerLeftClick + then Just $ ChainMouseClick LeftClick + else Just $ TriggerMouseClick LeftClick | isKeyPressWith ev SDL.KeycodeTab -> Just ResetKeys | isKeyPressed ev && isValidKey (eventToKeycode ev) -> Just $ HandleKeyInput $ eventToKeycode ev @@ -66,11 +66,7 @@ eventHandler event = Just $ UpdateShiftState False _ -> Nothing -update :: - (MonadAppShell m, MonadDraw m, MonadControl m) => - State -> - AppAction -> - m (State, Maybe AppAction) +update :: (MonadAppShell m, MonadDraw m, MonadControl m) => State -> AppAction -> m (State, Maybe AppAction) -- Act on key inputs update state (HandleKeyInput key) = do case (toKeyChar key, validChars) of @@ -115,16 +111,16 @@ update state (MoveMousePosition (row, col)) = do update state ResetKeys = do pure (state {stateKeySequence = [], stateIsMatched = False}, Nothing) --- Trigger left click -update state TriggerLeftClick = do +-- Trigger click +update state (TriggerMouseClick btn) = do hideWindow - pressMouseButton LeftClick + pressMouseButton btn pure (state, Just ShutdownApp) -- Chain clicks -update state ChainLeftClick = do +update state (ChainMouseClick btn) = do hideWindow - pressMouseButton LeftClick + pressMouseButton btn showWindow pure (state, Just ResetKeys) |
