diff options
| author | Akshay Nair <phenax5@gmail.com> | 2024-12-26 00:17:53 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2024-12-26 00:20:47 +0530 |
| commit | 6ad789149036a9e97a9c66860828892efa432bd4 (patch) | |
| tree | b509812fc69f1af890c1c4ddbcda79f81bc9ab43 /src/Chelleport/AppState.hs | |
| parent | d9b2256047669b5a5dbac4baec7140f18a5b6eff (diff) | |
| download | chelleport-6ad789149036a9e97a9c66860828892efa432bd4.tar.gz chelleport-6ad789149036a9e97a9c66860828892efa432bd4.zip | |
Add c-hjkl for movement keys
Diffstat (limited to '')
| -rw-r--r-- | src/Chelleport/AppState.hs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Chelleport/AppState.hs b/src/Chelleport/AppState.hs index 25575f1..7687257 100644 --- a/src/Chelleport/AppState.hs +++ b/src/Chelleport/AppState.hs @@ -1,7 +1,7 @@ module Chelleport.AppState (initialState, update) where import Chelleport.AppShell (MonadAppShell (hideWindow, showWindow, shutdownApp)) -import Chelleport.Control (MonadControl (..), directionalIncrement) +import Chelleport.Control (MonadControl (..), directionalIncrement, hjklDirection) import Chelleport.Draw (MonadDraw (windowPosition, windowSize), pointerPositionIncrement, screenPositionFromCellPosition, wordPosition) import Chelleport.KeySequence (findMatchPosition, generateGrid, nextChars, toKeyChar) import Chelleport.OCR (MonadOCR (captureScreenshot), getWordsInImage) @@ -36,9 +36,7 @@ update state@(State {stateMode = ModeHints}) (HandleKeyInput keycode) = do case (toKeyChar keycode, validNextKeys) of (Just keyChar, Just validChars') | stateIsMatched state && keyChar `elem` ("HJKL" :: String) -> do - incr <- pointerPositionIncrement state - let action = IncrementMouseCursor $ directionalIncrement incr keyChar - pure (state, Just action) + pure (state, Just $ MoveMouseInDirection $ hjklDirection keyChar) | keyChar `elem` validChars' -> do let newKeySequence = stateKeySequence state ++ [keyChar] let matchPosition = findMatchPosition newKeySequence $ stateGrid state @@ -115,6 +113,11 @@ update state MouseDragToggle | stateIsDragging state = pure (state {stateIsDragging = False}, Just MouseDragEnd) | otherwise = do pure (state {stateIsDragging = True}, Just MouseDragStart) +-- Apply movement in given direction +update state (MoveMouseInDirection direction) = do + incr <- pointerPositionIncrement state + pure (state, Just $ IncrementMouseCursor $ directionalIncrement incr direction) + -- Move mouse to given position update state (MoveMousePosition (x, y)) = do moveMousePointer (intToCInt x) (intToCInt y) |
