aboutsummaryrefslogtreecommitdiff
path: root/src/Chelleport.hs
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-12-14 18:28:19 +0530
committerAkshay Nair <phenax5@gmail.com>2024-12-14 18:28:19 +0530
commitf48587bda4dea13920a96dda06b735be484614a9 (patch)
treecbaf079ca8f1c02800cf2984a89e48d2690b3050 /src/Chelleport.hs
parentef178e85975ea2bdbd2043c92f0917e0fe19823a (diff)
downloadchelleport-f48587bda4dea13920a96dda06b735be484614a9.tar.gz
chelleport-f48587bda4dea13920a96dda06b735be484614a9.zip
Add left click on space + minor fixes
Diffstat (limited to '')
-rw-r--r--src/Chelleport.hs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/Chelleport.hs b/src/Chelleport.hs
index 9cc6a57..450ea0a 100644
--- a/src/Chelleport.hs
+++ b/src/Chelleport.hs
@@ -1,6 +1,6 @@
module Chelleport where
-import Chelleport.AppShell (Action (AppAction, SysQuit), setupAppShell)
+import Chelleport.AppShell (Action (AppAction, SysQuit), hideWindow, setupAppShell, shutdownApp)
import Chelleport.Context (DrawContext (ctxRenderer, ctxWindow))
import Chelleport.Control (moveMouse, triggerMouseLeftClick)
import Chelleport.Draw (colorLightGray, colorWhite, renderText)
@@ -73,7 +73,11 @@ render state ctx = do
update :: State -> DrawContext -> AppAction -> IO State
update state _ctx SetupGrid = pure state
-update state ctx TriggerLeftClick = state <$ triggerMouseLeftClick ctx
+update state ctx TriggerLeftClick = do
+ hideWindow ctx
+ triggerMouseLeftClick ctx
+ shutdownApp ctx
+ pure state
update state ctx (FilterSequence key) =
case validChars >>= (\chars -> (,chars) <$> toKeyChar key) of
Just (keyChar, validChars')
@@ -85,9 +89,7 @@ update state ctx (FilterSequence key) =
let hcell = height `div` unsafeCoerce (length rows)
case findMatchPosition newKeySequence rows of
Just (row, col) -> do
- let x = wcell * unsafeCoerce col
- let y = hcell * unsafeCoerce row
- moveMouse x y
+ moveMouse ctx (wcell * unsafeCoerce col) (hcell * unsafeCoerce row)
Nothing -> pure ()
pure state {stateKeySequence = newKeySequence}
_ -> pure state