diff --git a/src/Forest/Client.hs b/src/Forest/Client.hs index 846cbb0..9ed37fe 100644 --- a/src/Forest/Client.hs +++ b/src/Forest/Client.hs @@ -124,9 +124,10 @@ clientHandleEvent cs _ = continue cs clientAttrMap :: AttrMap clientAttrMap = attrMap Vty.defAttr - [ ("expand", Vty.currentAttr `Vty.withStyle` Vty.bold `Vty.withForeColor` Vty.yellow) - , ("focus", Vty.currentAttr `Vty.withBackColor` Vty.blue) - , ("flags", Vty.currentAttr `Vty.withForeColor` Vty.brightBlack) + [ ("expand", Vty.defAttr `Vty.withStyle` Vty.bold `Vty.withForeColor` Vty.yellow) + , ("focus", Vty.defAttr `Vty.withBackColor` Vty.blue) + , ("flags", Vty.defAttr `Vty.withForeColor` Vty.brightBlack) + , (treeLineAttr, Vty.defAttr `Vty.withForeColor` Vty.brightBlack) ] clientApp :: App ClientState Event ResourceName diff --git a/src/Forest/Client/WidgetTree.hs b/src/Forest/Client/WidgetTree.hs index fb134d7..7b4cad3 100644 --- a/src/Forest/Client/WidgetTree.hs +++ b/src/Forest/Client/WidgetTree.hs @@ -3,6 +3,7 @@ module Forest.Client.WidgetTree ( WidgetTree(..) , renderWidgetTree + , treeLineAttr , IndentOptions(..) , boxDrawingBranching , boxDrawingLine @@ -15,6 +16,7 @@ import Brick.BorderMap import Control.Monad.Trans.Reader import qualified Data.Text as T import qualified Graphics.Vty as Vty +import Lens.Micro data WidgetTree n = WidgetTree (Widget n) [WidgetTree n] @@ -50,9 +52,10 @@ indentWith firstLine otherLines wrapped = Widget renderWidget = do context <- ask result <- render $ hLimit (availWidth context - maxWidth) wrapped - let resultHeight = Vty.imageHeight $ image result + let attribute = attrMapLookup treeLineAttr $ context ^. ctxAttrMapL + resultHeight = Vty.imageHeight $ image result textLines = firstLine : replicate (resultHeight - 1) otherLines - leftImage = Vty.vertCat $ map (Vty.text' Vty.defAttr) textLines + leftImage = Vty.vertCat $ map (Vty.text' attribute) textLines newImage = leftImage Vty.<|> image result newResult = offsetResult (Location (maxWidth, 0)) $ result{image=newImage} pure newResult @@ -68,6 +71,9 @@ renderWidgetTree :: IndentOptions -> WidgetTree n -> Widget n renderWidgetTree opts (WidgetTree node children) = node <=> indent opts (map (renderWidgetTree opts) children) +treeLineAttr :: AttrName +treeLineAttr = "treeLine" + -- | These options control how a tree is rendered. For more information on how -- the various options are used, try rendering a tree with 'boxDrawingBranhing' -- and inspect the results.