From 49d0c8039ee221a0ad359a87ae94178b895088b7 Mon Sep 17 00:00:00 2001 From: Joscha Date: Sun, 9 Feb 2020 14:07:06 +0000 Subject: [PATCH] Display all node flags --- client/Main.hs | 1 + src/Forest/Client/Node.hs | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/client/Main.hs b/client/Main.hs index b47e6e4..cfb7e11 100644 --- a/client/Main.hs +++ b/client/Main.hs @@ -86,6 +86,7 @@ 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) ] clientApp :: App ClientState () ResourceName diff --git a/src/Forest/Client/Node.hs b/src/Forest/Client/Node.hs index b43275f..1f37e79 100644 --- a/src/Forest/Client/Node.hs +++ b/src/Forest/Client/Node.hs @@ -25,6 +25,15 @@ isFocused ds = (isLocalPath <$> dsFocused ds) == Just True isFolded :: DrawState -> Bool isFolded ds = not $ localPath `Set.member` dsUnfolded ds +decorateNode :: Node -> Widget n -> Widget n +decorateNode node widget = + let e = if nodeEdit node then "e" else "-" + d = if nodeDelete node then "d" else "-" + r = if nodeReply node then "r" else "-" + a = if nodeAct node then "a" else "-" + flags = "(" <> e <> d <> r <> a <> ")" + in widget <+> txt " " <+> withDefAttr "flags" (txt flags) + narrowDrawState :: NodeId -> DrawState -> DrawState narrowDrawState nodeId ds = ds { dsUnfolded = narrowSet nodeId $ dsUnfolded ds @@ -52,9 +61,9 @@ nodeToTree ds node = case dsEditor ds of Just ed | not focused -> WidgetTree nodeWidget subnodeWidgets | asReply ed -> WidgetTree nodeWidget (subnodeWidgets ++ [WidgetTree (renderNodeEditor ed) []]) - | otherwise -> WidgetTree (renderNodeEditor ed) subnodeWidgets + | otherwise -> WidgetTree (decorateNode node $ renderNodeEditor ed) subnodeWidgets where focused = isFocused ds folded = isFolded ds - nodeWidget = nodeToWidget focused node + nodeWidget = decorateNode node $ nodeToWidget focused node subnodeWidgets = if folded then [] else subnodesToTrees ds node