Srender renders the list as a string.
()
| 115 | |
| 116 | // Srender renders the list as a string. |
| 117 | func (p TreePrinter) Srender() (string, error) { |
| 118 | if p.TreeStyle == nil { |
| 119 | p.TreeStyle = NewStyle() |
| 120 | } |
| 121 | if p.TextStyle == nil { |
| 122 | p.TextStyle = NewStyle() |
| 123 | } |
| 124 | |
| 125 | var result strings.Builder |
| 126 | if p.Root.Text != "" { |
| 127 | result.WriteString(p.TextStyle.Sprint(p.Root.Text)) |
| 128 | result.WriteByte('\n') |
| 129 | } |
| 130 | result.WriteString(walkOverTree(p.Root.Children, p, "")) |
| 131 | return result.String(), nil |
| 132 | } |
| 133 | |
| 134 | // walkOverTree is a recursive function, |
| 135 | // which analyzes a TreePrinter and connects the items with specific characters. |
no test coverage detected