Documentation ¶
Index ¶
- Constants
- func Padding(style DepthStyler, s Symbols, depth int) string
- func RenderConnector(style DepthStyler, s Symbols, depth int) string
- func RenderStarter(style DepthStyler, s Symbols, depth int) string
- func RenderTerminator(style DepthStyler, s Symbols, depth int) string
- type DepthStyler
- type ErrorMsg
- type KeyMap
- type Model
- func (m *Model) Blur()
- func (m *Model) Children() Nodes
- func (m *Model) Cursor() int
- func (m *Model) Focus()
- func (m *Model) Focused() bool
- func (m *Model) GotoBottom() tea.Cmd
- func (m *Model) GotoTop() tea.Cmd
- func (m *Model) Height() int
- func (m *Model) Init() tea.Cmd
- func (m *Model) MoveDown(n int) tea.Cmd
- func (m *Model) MoveUp(n int) tea.Cmd
- func (m *Model) PastBottom() bool
- func (m *Model) ScrollPercent() float64
- func (m *Model) SetCursor(pos int) tea.Cmd
- func (m *Model) SetHeight(h int)
- func (m *Model) SetStyles(s Styles)
- func (m *Model) SetWidth(w int)
- func (m *Model) SetYOffset(n int)
- func (m *Model) ToggleExpand()
- func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m *Model) View() string
- func (m *Model) Width() int
- func (m *Model) YOffset() int
- type Msg
- type Node
- type NodeState
- type Nodes
- type Style
- type Styles
- type Symbols
Constants ¶
const Ellipsis = "…"
Variables ¶
This section is empty.
Functions ¶
func Padding ¶
func Padding(style DepthStyler, s Symbols, depth int) string
Padding is expected to output a whitespace, or equivalent, used when two nodes at the same level are not children to the same parent.
func RenderConnector ¶
func RenderConnector(style DepthStyler, s Symbols, depth int) string
RenderConnector is expected to output a continuator marker used to connect two nodes which are children on the same parent.
func RenderStarter ¶
func RenderStarter(style DepthStyler, s Symbols, depth int) string
RenderStarter is expected to output the marker used for every node in the tree.
func RenderTerminator ¶
func RenderTerminator(style DepthStyler, s Symbols, depth int) string
RenderTerminator is expected to output a terminator marker used for the last node in a list of nodes.
Types ¶
type DepthStyler ¶
type DepthStyler interface { Width(int) DepthStyler Render(depth int, strs ...string) string }
type KeyMap ¶
type KeyMap struct { LineUp key.Binding LineDown key.Binding PageUp key.Binding PageDown key.Binding HalfPageUp key.Binding HalfPageDown key.Binding GotoTop key.Binding GotoBottom key.Binding Expand key.Binding }
KeyMap defines keybindings. It satisfies the github.com/charm/bubbles/help.KeyMap interface.
func DefaultKeyMap ¶
func DefaultKeyMap() KeyMap
DefaultKeyMap returns a default set of keybindings.
type Model ¶
type Model struct { *viewport.Model KeyMap KeyMap Styles Styles Symbols Symbols // contains filtered or unexported fields }
Model is the Bubble Tea model for this user interface.
func (*Model) Focus ¶
func (m *Model) Focus()
Focus focuses the tree, allowing the user to move around the tree nodes. interact.
func (*Model) GotoBottom ¶
GotoBottom moves the selection to the last row.
func (*Model) MoveDown ¶
MoveDown moves the selection down by any number of row. It can not go below the last row.
func (*Model) MoveUp ¶
MoveUp moves the selection up by any number of row. It can not go above the first row.
func (*Model) PastBottom ¶
PastBottom returns whether the viewport is scrolled beyond the last line. This can happen when adjusting the viewport height.
func (*Model) ScrollPercent ¶
ScrollPercent returns the amount scrolled as a float between 0 and 1.
func (*Model) SetYOffset ¶
SetYOffset sets Y offset of the tree's viewport.
func (*Model) ToggleExpand ¶
func (m *Model) ToggleExpand()
ToggleExpand toggles the expanded state of the node pointed at by m.cursor
type Node ¶
type Node interface { tea.Model // Parent should return the parent of the current node, or nil if a root node. Parent() Node // Children should return a list of Nodes which represent the children of the current node. Children() Nodes // State should return the annotation for the current node, which are used for computing various display states. State() NodeState }
Node represents the base model for the elements of the Treeish implementation
type NodeState ¶
type NodeState uint16
NodeState is used for passing information from a Treeish element to the view itself
const ( NodeNone NodeState = 0 // NodeCollapsed hints that the current node is collapsed NodeCollapsed NodeState = 1 << iota // NodeSelected hints that the current node should be rendered as selected NodeSelected // NodeCollapsible hints that the current node can be collapsed NodeCollapsible // NodeHidden hints that the current node is not going to be displayed NodeHidden // NodeLastChild shows the node to be the last in the children list NodeLastChild // NodeIsMultiLine shows if the node should not be truncated to the viewport's max width NodeIsMultiLine // NodeMaxState serves no other purpose than as a sentinel value for outside Node interface // implementations to append their own states. NodeMaxState )
type Nodes ¶
type Nodes []Node
Nodes is a slice of Node elements, usually representing the children of a Node.
type Styles ¶
type Styles struct { Line lipgloss.Style Selected lipgloss.Style Symbol DepthStyler }
Styles contains style definitions for this list component. By default, these values are generated by DefaultStyles.
func DefaultStyles ¶
func DefaultStyles() Styles
DefaultStyles returns a set of default style definitions for this tree.
type Symbols ¶
func DefaultSymbols ¶
func DefaultSymbols() Symbols
DefaultSymbols returns a set of default Symbols for drawing the tree.
func DoubleSymbols ¶
func DoubleSymbols() Symbols
DoubleSymbols returns a symbols comprised of two thin strokes.
func NormalEdgeSymbols ¶
func NormalEdgeSymbols() Symbols
func NormalSymbols ¶
func NormalSymbols() Symbols
NormalSymbols returns a standard-type symbols with a normal weight and 90 degree corners.
func RoundedSymbols ¶
func RoundedSymbols() Symbols
RoundedSymbols returns a symbols with rounded corners.
func ThickEdgeSymbols ¶
func ThickEdgeSymbols() Symbols
func ThickSymbols ¶
func ThickSymbols() Symbols
ThickSymbols returns a symbols that's thicker than the one returned by NormalSymbols.