26 lines
992 B
Haskell
26 lines
992 B
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 . textInputFocus
|
|
|
|
textInputFocus :: World -> Maybe ((String -> Identity String) -> World -> Identity World)
|
|
textInputFocus w = case w ^. hud . subInventory of
|
|
NoSubInventory{} -> case he ^? diSelection . _Just . slSec of
|
|
Just (-1) -> Just $ hud . diInvFilter . _Just
|
|
Just 2 -> Just $ hud . diCloseFilter . _Just
|
|
_ -> Nothing
|
|
CombineInventory{} -> case he ^? subInventory . ciSelection . _Just . slSec of
|
|
Just (-1) -> Just $ hud . subInventory . ciFilter . _Just
|
|
_ -> Nothing
|
|
DisplayTerminal{_termID = tmid} -> case w ^? cWorld . lWorld . terminals . ix tmid . tmStatus . tiText of
|
|
Just _ -> return $ cWorld . lWorld . terminals . ix tmid . tmStatus . tiText
|
|
Nothing -> Nothing
|
|
_ -> Nothing
|
|
where
|
|
he = w ^. hud
|