Files
loop/src/Dodge/InputFocus.hs
T
2025-08-26 16:46:02 +01:00

33 lines
1.1 KiB
Haskell

module Dodge.InputFocus (inTextInputFocus) where
import Dodge.Data.Terminal.Status
import Data.Maybe
import Dodge.Data.World
import LensHelp
inTextInputFocus :: World -> Bool
inTextInputFocus = isJust . inputFocusI
inputFocusI :: World -> Maybe ((String -> Identity String) -> World -> Identity World)
inputFocusI = textInputFocus
textInputFocus ::
Applicative f =>
World ->
Maybe ((String -> f String) -> World -> f World)
textInputFocus w = case w ^? hud . subInventory of
Just NoSubInventory{} -> case he ^? diSelection . _Just . _1 of
Just (-1) -> Just $ hud . diInvFilter . _Just
Just 2 -> Just $ hud . diCloseFilter . _Just
_ -> Nothing
Just CombineInventory{} -> case he ^? subInventory . ciSelection . _Just . _1 of
Just (-1) -> Just $ hud . subInventory . ciFilter . _Just
_ -> Nothing
Just DisplayTerminal{_termID = tmid} -> do
-- connectionstatus <- w ^? cWorld . lWorld . terminals . ix tmid . tmStatus
-- guard $ connectionstatus == TerminalTextInput
return $ cWorld . lWorld . terminals . ix tmid . tmStatus . tiText
_ -> Nothing
where
he = w ^. hud