Documentation ¶
Overview ¶
Package fliptree renders a tree of nodes as text in reverse: children first, then parent.
For example: given main -> {feat1 -> feat1.1, feat2 -> feat2.1} The tree would look like this:
┌── feat2.1 ┌─┴ feat2 │ ┌── feat1.1 ├─┴ feat1 main
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultNodeMarker = lipgloss.NewStyle().SetString("□")
DefaultNodeMarker is the marker used for each node in the tree.
Functions ¶
Types ¶
type CycleError ¶
type CycleError struct { // Nodes that form the cycle. Nodes []int }
CycleError is returned when a cycle is detected in the tree.
func (*CycleError) Error ¶
func (e *CycleError) Error() string
type Graph ¶
type Graph[T any] struct { // Values specifies the value for each node in the graph. // All nodes must have a value. Values []T // Edges returns the nodes that are directly reachable // from the given node as indexes into the Values slice. Edges func(T) []int // Roots are indexes of nodes in the Values slice // at which we start rendering the tree. // // Each root will be rendered as a separate tree. Roots []int // View returns the text for the node. // The view for a node may be multiline, and may have its own styling. View func(T) string }
Graph defines a directed graph.
type Style ¶
type Style[T any] struct { // Joint defines how the connecting joints between nodes are rendered. Joint lipgloss.Style // NodeMarker returns the style of the marker // placed next to each node based on the node's value. // // By default, all nodes are marked with [DefaultNodeMarker]. NodeMarker func(T) lipgloss.Style }
Style configures the visual appearance of the tree.
func DefaultStyle ¶
DefaultStyle returns the default style for rendering trees.
Click to show internal directories.
Click to hide internal directories.