Add longer example node

This commit is contained in:
Joscha 2020-02-09 15:50:35 +00:00
parent 49d0c8039e
commit 4706033c32
2 changed files with 42 additions and 7 deletions

View file

@ -53,10 +53,10 @@ newClientState node = ClientState
} }
clientDraw :: ClientState -> [Widget ResourceName] clientDraw :: ClientState -> [Widget ResourceName]
clientDraw cs = [joinBorders $ withBorderStyle unicode $ debug <=> tree] clientDraw cs = [joinBorders $ withBorderStyle unicode $ tree <+> debug]
where where
tree = borderWithLabel (txt "Tree") $ renderTree boxDrawingBranching (csEditor cs) (csTree cs) tree = borderWithLabel (txt "Tree") $ renderTree boxDrawingBranching (csEditor cs) (csTree cs)
debug = borderWithLabel (txt "Debug") $ hLimit 80 $ txtWrap $ T.pack $ show $ csTree cs debug = borderWithLabel (txt "Debug") $ txtWrap $ T.pack $ show $ csTree cs
isQuitEvent :: BrickEvent a b -> Bool isQuitEvent :: BrickEvent a b -> Bool
isQuitEvent (VtyEvent (Vty.EvKey (Vty.KChar 'q') [])) = True isQuitEvent (VtyEvent (Vty.EvKey (Vty.KChar 'q') [])) = True

View file

@ -78,7 +78,7 @@ mapChildren f node = map (uncurry f) $ Map.toAscList $ nodeChildren node
newtype Path = Path newtype Path = Path
{ pathElements :: [NodeId] { pathElements :: [NodeId]
} deriving (Show, Eq, Ord, ToJSON, FromJSON) } deriving (Show, Eq, Ord, Semigroup, Monoid, ToJSON, FromJSON)
localPath :: Path localPath :: Path
localPath = Path [] localPath = Path []
@ -100,7 +100,42 @@ narrowSet x s = Set.fromList [Path ys | Path (y:ys) <- Set.toList s, x == y]
{- For testing -} {- For testing -}
exampleNode :: Node exampleNode :: Node
exampleNode = Node "Tool box" False False True False $ Map.fromList exampleNode =
[ ("hammer", Node "Hammer" False True False True Map.empty) Node "forest" False False True True (Map.fromList
, ("nail", Node "Nail" False True False False Map.empty) [("0", Node "CHANGELOG.md" True True False False (Map.fromList []))
] , ("1", Node "LICENSE" False False False True (Map.fromList []))
, ("2", Node "README.md" False False False True (Map.fromList []))
, ("3", Node "Setup.hs" True True False False (Map.fromList []))
, ("4", Node "client" True False True False (Map.fromList
[("0", Node "Main.hs" False True True False (Map.fromList []))
]))
, ("5", Node "forest.cabal" True True True False (Map.fromList []))
, ("6", Node "gen_file_node.py" True False False True (Map.fromList []))
, ("7", Node "package.yaml" True False True False (Map.fromList []))
, ("8", Node "server" True True True False (Map.fromList
[("0", Node "Main.hs" False False True True (Map.fromList []))
]))
, ("9", Node "src" False False False True (Map.fromList
[("0", Node "Forest" False True True False (Map.fromList
[("0", Node "Api.hs" True True True False (Map.fromList []))
, ("1", Node "Broadcast.hs" False False False False (Map.fromList []))
, ("2", Node "Client" True True True False (Map.fromList
[("0", Node "Node.hs" True True True True (Map.fromList []))
, ("1", Node "NodeEditor.hs" True False False True (Map.fromList []))
, ("2", Node "ResourceName.hs" True False False False (Map.fromList []))
, ("3", Node "Tree.hs" False True True True (Map.fromList []))
, ("4", Node "WidgetTree.hs" True False True False (Map.fromList []))
]))
, ("3", Node "Node.hs" True False False False (Map.fromList []))
, ("4", Node "Server.hs" False False False False (Map.fromList []))
, ("5", Node "TreeModule" False True False True (Map.fromList
[("0", Node "ConstModule.hs" True False False False (Map.fromList []))
]))
, ("6", Node "TreeModule.hs" True True False False (Map.fromList []))
, ("7", Node "Util.hs" False True False True (Map.fromList []))
]))
, ("1", Node "Forest.hs" False True False False (Map.fromList []))
]))
, ("10", Node "stack.yaml" True False False True (Map.fromList []))
, ("11", Node "stack.yaml.lock" False False False True (Map.fromList []))
])