diff options
| author | Akshay Nair <phenax5@gmail.com> | 2024-12-29 19:03:22 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2024-12-29 19:03:35 +0530 |
| commit | fc2a09facce2fe6d06769712ea992f99bf15c8e2 (patch) | |
| tree | d58a5b11207b88ca79d62a92bf47d8781d20d4e1 /src/Chelleport.hs | |
| parent | c1e05401d5c3cf90440e62a3423d2b52cfc46999 (diff) | |
| download | chelleport-fc2a09facce2fe6d06769712ea992f99bf15c8e2.tar.gz chelleport-fc2a09facce2fe6d06769712ea992f99bf15c8e2.zip | |
Make backspace delete a single character in search + split up key input action
Diffstat (limited to '')
| -rw-r--r-- | src/Chelleport.hs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Chelleport.hs b/src/Chelleport.hs index d4c21ed..8cc02c7 100644 --- a/src/Chelleport.hs +++ b/src/Chelleport.hs @@ -17,13 +17,14 @@ import qualified SDL run :: Configuration -> IO () run config = do ctx <- initializeContext - -- Cosplaying as elm + -- Cosplaying as elm's state machine runAppWithCtx ctx $ setupAppShell ctx (AppState.initialState config) AppState.update eventHandler View.render where runAppWithCtx :: (MonadIO m) => DrawContext -> AppM m x -> m x runAppWithCtx ctx = (`runReaderT` ctx) . runAppM +-- TODO: Make event handling independent of state eventHandler :: State -> SDL.Event -> Maybe AppAction eventHandler state event = case SDL.eventPayload event of @@ -43,9 +44,9 @@ eventHandler state event = Just $ SetMode $ ModeHints def -- <C-n>, <C-p>: Search increment next/prev | checkKey [ctrl, key SDL.KeycodeN, pressed] ev -> - Just $ IncrementHighlightIndex (stateRepetition state) + Just $ IncrementHighlightIndex 1 | checkKey [ctrl, key SDL.KeycodeP, pressed] ev -> - Just $ IncrementHighlightIndex (-1 * stateRepetition state) + Just $ IncrementHighlightIndex (-1) -- <C-hjkl>: Movement | checkKey [ctrl, hjkl, pressed] ev -> MoveMouseInDirection . hjklDirection <$> toKeyChar (eventToKeycode ev) @@ -56,7 +57,9 @@ eventHandler state event = else Just $ TriggerMouseClick LeftClick -- Backspace: Reset keys | checkKey [key SDL.KeycodeBackspace, pressed] ev -> - Just ResetKeys + case stateMode state of + ModeHints {} -> Just ResetKeys + ModeSearch {} -> Just DeleteLastInput -- <C-v>: Toggle mouse dragging | checkKey [ctrl, key SDL.KeycodeV, pressed] ev -> Just MouseDragToggle |
