Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cell ¶
type Cell struct { Text string // contains filtered or unexported fields }
Cell is a colored and aligned cell in a column. Cells are the result of phrases wrapping to respect the column width. The color and alignment are inhérited from the origin TextBlock.
type Column ¶
type Column struct { Text []*TextBlock Cells []*Cell Color color.Attribute Align Alignment // contains filtered or unexported fields }
Column exposes a method to add extra text blocks
type Node ¶
Node exposes methods to add columns.
func (*Node) AddColumn ¶
AddColumn adds and returns a column to the node. Phrases can be added through the returned Column object.
func (*Node) Load ¶
Load loads data in the node
Example dataset:
{ "data": [ { "text": "node1", "color": color.BOLD } ], "children": [ { "data": [ { "text": "node2" }, { "text": "foo", "color": color.RED } ], "children": [ ] } ] }
would be rendered as:
node1 `- node2 foo
type TextBlock ¶
type TextBlock struct { Text string // contains filtered or unexported fields }
TextBlock is a colored and aligned phrase in a column.
type Tree ¶
type Tree struct { Separator string Widths []Width ForcedWidth int // contains filtered or unexported fields }
Tree exposes methods to populate and print a Tree.
Example:
Tree := tree.New() overallNode := Tree.AddNode() overallNode.AddColumn("overall")
node := overallNode.AddNode() node.AddColumn("avail") node.AddColumn() node.AddColumn("up", color.Green) node = node.AddNode() node.AddColumn("res#id") node.AddColumn("....") node.AddColumn("up", color.Green) col := node.AddColumn("label") col.AddText("warn", color.Yellow) col.AddText("err", color.Red)
func (*Tree) AddColumn ¶
AddColumn adds and returns a column to the head node. Phrases can be added through the returned Column object.
func (*Tree) PlugTree ¶
PlugTree add an existing tree head Node as child of the head node of the tree
func (*Tree) Render ¶
Render returns the string representation of the tree.
Each node is considered tabular, with cells content aligned and wrapped.
The widths parameter can used to set per-column min/max or exact widths:
widths = [
(0, 10), # col1: min 0, max 10 chars None, # col2: no constraints, auto detect 10 # col3: exactly 10 chars
]