mirror of
https://github.com/jtdaugherty/brick.git
synced 2025-01-07 14:36:59 +03:00
Add more cursor handler options
This commit is contained in:
parent
c366b5644c
commit
adf4f806e4
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user