Display all node flags
This commit is contained in:
parent
31e59616f5
commit
49d0c8039e
2 changed files with 12 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue