mirror of
https://github.com/jtdaugherty/brick.git
synced 2024-11-29 10:54:48 +03:00
Move focus ring code to library
This commit is contained in:
parent
a699e172ba
commit
7f09d6e5d1
@ -12,29 +12,6 @@ data St =
|
|||||||
, focus :: FocusRing
|
, focus :: FocusRing
|
||||||
}
|
}
|
||||||
|
|
||||||
data FocusRing = FocusRingEmpty
|
|
||||||
| FocusRingNonemtpy [Name] Int
|
|
||||||
|
|
||||||
focusRing :: [Name] -> FocusRing
|
|
||||||
focusRing [] = FocusRingEmpty
|
|
||||||
focusRing names = FocusRingNonemtpy names 0
|
|
||||||
|
|
||||||
focusNext :: FocusRing -> FocusRing
|
|
||||||
focusNext FocusRingEmpty = FocusRingEmpty
|
|
||||||
focusNext (FocusRingNonemtpy ns i) = FocusRingNonemtpy ns i'
|
|
||||||
where
|
|
||||||
i' = (i + 1) `mod` (length ns)
|
|
||||||
|
|
||||||
focusPrev :: FocusRing -> FocusRing
|
|
||||||
focusPrev FocusRingEmpty = FocusRingEmpty
|
|
||||||
focusPrev (FocusRingNonemtpy ns i) = FocusRingNonemtpy ns i'
|
|
||||||
where
|
|
||||||
i' = (i + (length ns) - 1) `mod` (length ns)
|
|
||||||
|
|
||||||
focusGetCurrent :: FocusRing -> Maybe Name
|
|
||||||
focusGetCurrent FocusRingEmpty = Nothing
|
|
||||||
focusGetCurrent (FocusRingNonemtpy ns i) = Just $ ns !! i
|
|
||||||
|
|
||||||
drawUI :: St -> Widget
|
drawUI :: St -> Widget
|
||||||
drawUI st =
|
drawUI st =
|
||||||
hBox [ hLimit 25 $ vBox [ "-- header --"
|
hBox [ hLimit 25 $ vBox [ "-- header --"
|
||||||
|
24
src/Brick.hs
24
src/Brick.hs
@ -161,3 +161,27 @@ runVty draw chooseCursor handleEv state vty = do
|
|||||||
shutdown vty
|
shutdown vty
|
||||||
exitWith status
|
exitWith status
|
||||||
Right newState -> runVty draw chooseCursor handleEv newState vty
|
Right newState -> runVty draw chooseCursor handleEv newState vty
|
||||||
|
|
||||||
|
data FocusRing = FocusRingEmpty
|
||||||
|
| FocusRingNonemtpy [Name] Int
|
||||||
|
|
||||||
|
focusRing :: [Name] -> FocusRing
|
||||||
|
focusRing [] = FocusRingEmpty
|
||||||
|
focusRing names = FocusRingNonemtpy names 0
|
||||||
|
|
||||||
|
focusNext :: FocusRing -> FocusRing
|
||||||
|
focusNext FocusRingEmpty = FocusRingEmpty
|
||||||
|
focusNext (FocusRingNonemtpy ns i) = FocusRingNonemtpy ns i'
|
||||||
|
where
|
||||||
|
i' = (i + 1) `mod` (length ns)
|
||||||
|
|
||||||
|
focusPrev :: FocusRing -> FocusRing
|
||||||
|
focusPrev FocusRingEmpty = FocusRingEmpty
|
||||||
|
focusPrev (FocusRingNonemtpy ns i) = FocusRingNonemtpy ns i'
|
||||||
|
where
|
||||||
|
i' = (i + (length ns) - 1) `mod` (length ns)
|
||||||
|
|
||||||
|
focusGetCurrent :: FocusRing -> Maybe Name
|
||||||
|
focusGetCurrent FocusRingEmpty = Nothing
|
||||||
|
focusGetCurrent (FocusRingNonemtpy ns i) = Just $ ns !! i
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user