Add more cursor handler options

This commit is contained in:
Jonathan Daugherty 2015-05-10 15:42:59 -07:00
parent c366b5644c
commit adf4f806e4
2 changed files with 9 additions and 5 deletions

View File

@ -10,8 +10,7 @@ import System.Exit
import Brick
data St =
St { focus :: FocusRing
, stEditor :: Editor
St { stEditor :: Editor
, trans :: Location
, counter :: Int
}
@ -48,8 +47,7 @@ handleEvent e st =
initialState :: St
initialState =
St { focus = focusRing [eName]
, stEditor = editor eName ""
St { stEditor = editor eName ""
, trans = Location (0, 0)
, counter = 0
}
@ -60,7 +58,7 @@ data MyEvent = VtyEvent Event
theApp :: App St MyEvent
theApp =
def { appDraw = drawUI
, appChooseCursor = focusRingCursor focus
, appChooseCursor = showFirstCursor
, appHandleEvent = handleEvent
}

View File

@ -431,6 +431,12 @@ focusGetCurrent :: FocusRing -> Maybe Name
focusGetCurrent FocusRingEmpty = Nothing
focusGetCurrent (FocusRingNonempty ns i) = Just $ ns !! i
neverShowCursor :: a -> [CursorLocation] -> Maybe CursorLocation
neverShowCursor = const $ const Nothing
showFirstCursor :: a -> [CursorLocation] -> Maybe CursorLocation
showFirstCursor = const $ listToMaybe
focusRingCursor :: (a -> FocusRing) -> a -> [CursorLocation] -> Maybe CursorLocation
focusRingCursor getRing st ls =
listToMaybe $ filter isCurrent ls