[client] Fix rendering of editor
This commit is contained in:
parent
661c233ce1
commit
385ec894ef
1 changed files with 13 additions and 17 deletions
|
|
@ -212,25 +212,21 @@ renderNode focused node =
|
||||||
decorateExpand (not $ OMap.null $ nodeChildren node) $
|
decorateExpand (not $ OMap.null $ nodeChildren node) $
|
||||||
txtWrap $ nodeText node
|
txtWrap $ nodeText node
|
||||||
|
|
||||||
beingEdited :: UiState n -> Path -> Maybe (EditorInfo n)
|
|
||||||
beingEdited s path = do
|
|
||||||
e <- uiEditor s
|
|
||||||
if eiReply e
|
|
||||||
then do
|
|
||||||
p <- parent path
|
|
||||||
guard $ p == eiPath e
|
|
||||||
else
|
|
||||||
guard $ path == eiPath e
|
|
||||||
pure e
|
|
||||||
|
|
||||||
nodeToTree :: (Ord n, Show n) => UiState n -> Path -> Node -> Maybe [WidgetTree n] -> WidgetTree n
|
nodeToTree :: (Ord n, Show n) => UiState n -> Path -> Node -> Maybe [WidgetTree n] -> WidgetTree n
|
||||||
nodeToTree s path node = withChildren $ case beingEdited s path of
|
nodeToTree s path node maybeChildren = case uiEditor s of
|
||||||
Just e -> renderNodeEditor $ eiEditor e
|
Nothing ->
|
||||||
Nothing -> renderNode isFocused node
|
let isFocused = path == uiFocused s
|
||||||
|
in WidgetTree (renderNode isFocused node) children
|
||||||
|
Just e ->
|
||||||
|
let renderedEditor = renderNodeEditor $ eiEditor e
|
||||||
|
renderedEditorTree = WidgetTree renderedEditor []
|
||||||
|
in if path /= eiPath e
|
||||||
|
then WidgetTree (renderNode False node) children
|
||||||
|
else if eiReply e
|
||||||
|
then WidgetTree (renderNode False node) $ children ++ [renderedEditorTree]
|
||||||
|
else WidgetTree renderedEditor children
|
||||||
where
|
where
|
||||||
withChildren :: Widget n -> Maybe [WidgetTree n] -> WidgetTree n
|
children = fromMaybe [] maybeChildren
|
||||||
withChildren nodeWidget = WidgetTree nodeWidget . fromMaybe []
|
|
||||||
isFocused = isNothing (uiEditor s) && (path == uiFocused s)
|
|
||||||
|
|
||||||
renderUiState :: (Ord n, Show n) => IndentOptions -> UiState n -> Widget n
|
renderUiState :: (Ord n, Show n) => IndentOptions -> UiState n -> Widget n
|
||||||
renderUiState opts s =
|
renderUiState opts s =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue