MCPcopy
hub / github.com/mum4k/termdash / drawTree

Function drawTree

container/draw.go:32–69  ·  view source on GitHub ↗

drawTree draws this container and all of its sub containers.

(c *Container)

Source from the content-addressed store, hash-verified

30
31// drawTree draws this container and all of its sub containers.
32func drawTree(c *Container) error {
33 var errStr string
34
35 root := rootCont(c)
36 size := root.term.Size()
37 ar, err := root.opts.margin.apply(image.Rect(0, 0, size.X, size.Y))
38 if err != nil {
39 return err
40 }
41 root.area = ar
42
43 preOrder(root, &errStr, visitFunc(func(c *Container) error {
44 first, second, err := c.split()
45 if err != nil {
46 return err
47 }
48 if c.first != nil {
49 ar, err := c.first.opts.margin.apply(first)
50 if err != nil {
51 return err
52 }
53 c.first.area = ar
54 }
55
56 if c.second != nil {
57 ar, err := c.second.opts.margin.apply(second)
58 if err != nil {
59 return err
60 }
61 c.second.area = ar
62 }
63 return drawCont(c)
64 }))
65 if errStr != "" {
66 return errors.New(errStr)
67 }
68 return nil
69}
70
71// drawBorder draws the border around the container if requested.
72func drawBorder(c *Container) error {

Callers 1

DrawMethod · 0.85

Calls 8

rootContFunction · 0.85
preOrderFunction · 0.85
visitFuncFuncType · 0.85
drawContFunction · 0.85
splitMethod · 0.80
NewMethod · 0.80
SizeMethod · 0.65
applyMethod · 0.45

Tested by

no test coverage detected