Scroll so focused element is always visible

This commit is contained in:
Joscha 2020-02-11 12:14:51 +00:00
parent 9f507b5b9e
commit 70bbc3a69a
3 changed files with 4 additions and 3 deletions

View file

@ -134,9 +134,10 @@ onKeyWithEditor ed cs ev = updateEditor ed cs ev
{- And the rest of the Brick application -} {- And the rest of the Brick application -}
clientDraw :: ClientState -> [Widget ResourceName] clientDraw :: ClientState -> [Widget ResourceName]
clientDraw cs = [padTop (Pad 1) $ padLeft (Pad 2) tree] clientDraw cs = [padTop (Pad 1) $ padLeft (Pad 2) vp]
where where
tree = renderTree boxDrawingBranching (csEditor cs) (csTree cs) tree = renderTree boxDrawingBranching (csEditor cs) (csTree cs)
vp = viewport RnViewport Vertical tree
clientHandleEvent clientHandleEvent
:: ClientState :: ClientState

View file

@ -30,7 +30,7 @@ decorateExpand True widget = withDefAttr "expand" widget
decorateExpand False widget = withDefAttr "noexpand" widget decorateExpand False widget = withDefAttr "noexpand" widget
decorateFocus :: Bool -> Widget n -> Widget n decorateFocus :: Bool -> Widget n -> Widget n
decorateFocus True widget = withDefAttr "focus" widget decorateFocus True widget = visible $ withDefAttr "focus" widget
decorateFocus False widget = withDefAttr "nofocus" widget decorateFocus False widget = withDefAttr "nofocus" widget
decorateFlags :: Node -> Widget n -> Widget n decorateFlags :: Node -> Widget n -> Widget n

View file

@ -2,5 +2,5 @@ module Forest.Client.ResourceName
( ResourceName(..) ( ResourceName(..)
) where ) where
data ResourceName = RnEditor data ResourceName = RnViewport | RnEditor
deriving (Show, Eq, Ord) deriving (Show, Eq, Ord)