From 70bbc3a69a655f0b86d604be2a0ef3c0fa3d7534 Mon Sep 17 00:00:00 2001 From: Joscha Date: Tue, 11 Feb 2020 12:14:51 +0000 Subject: [PATCH] Scroll so focused element is always visible --- client/Main.hs | 3 ++- src/Forest/Client/Node.hs | 2 +- src/Forest/Client/ResourceName.hs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/client/Main.hs b/client/Main.hs index 55cd526..cd9b188 100644 --- a/client/Main.hs +++ b/client/Main.hs @@ -134,9 +134,10 @@ onKeyWithEditor ed cs ev = updateEditor ed cs ev {- And the rest of the Brick application -} clientDraw :: ClientState -> [Widget ResourceName] -clientDraw cs = [padTop (Pad 1) $ padLeft (Pad 2) tree] +clientDraw cs = [padTop (Pad 1) $ padLeft (Pad 2) vp] where tree = renderTree boxDrawingBranching (csEditor cs) (csTree cs) + vp = viewport RnViewport Vertical tree clientHandleEvent :: ClientState diff --git a/src/Forest/Client/Node.hs b/src/Forest/Client/Node.hs index d65bfd6..f4e6e1e 100644 --- a/src/Forest/Client/Node.hs +++ b/src/Forest/Client/Node.hs @@ -30,7 +30,7 @@ decorateExpand True widget = withDefAttr "expand" widget decorateExpand False widget = withDefAttr "noexpand" widget 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 decorateFlags :: Node -> Widget n -> Widget n diff --git a/src/Forest/Client/ResourceName.hs b/src/Forest/Client/ResourceName.hs index 4753e80..99adc15 100644 --- a/src/Forest/Client/ResourceName.hs +++ b/src/Forest/Client/ResourceName.hs @@ -2,5 +2,5 @@ module Forest.Client.ResourceName ( ResourceName(..) ) where -data ResourceName = RnEditor +data ResourceName = RnViewport | RnEditor deriving (Show, Eq, Ord)