Documentation
¶
Overview ¶
Package filetree renders an interactive directory tree.
The model holds a flat slice of visible nodes and tracks the cursor, the set of expanded directories, and an optional selection set for multi-select operations. Expand/collapse, navigation, and selection all run through the standard Bubble Tea Update loop.
The tree is constructed from a nested Node literal; consumers own the data shape, so the same component renders a project file system, a JSON document, a Linear/Notion outline, or anything else with a directory analogy.
Index ¶
- type Model
- func (m *Model) Collapse(path string)
- func (m *Model) Expand(path string)
- func (m Model) Init() tea.Cmd
- func (m Model) IsSelected(path string) bool
- func (m Model) Selected() string
- func (m Model) SelectedNode() (Node, bool)
- func (m Model) SelectedPaths() []string
- func (m *Model) SetCursor(path string)
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m Model) View() string
- func (m Model) WithMultiSelect(b bool) Model
- func (m Model) WithTitle(t string) Model
- type Node
- type SelectMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Model ¶
Model is the Bubble Tea state of the file tree.
func (Model) IsSelected ¶
IsSelected reports whether the given path is in the multi-select set.
func (Model) Selected ¶
Selected returns the slash-joined path under the cursor, or "" if the tree is empty.
func (Model) SelectedNode ¶
SelectedNode returns the Node under the cursor; second value is false when the tree is empty.
func (Model) SelectedPaths ¶
SelectedPaths returns paths in the multi-select set, sorted by visible order.
func (*Model) SetCursor ¶
SetCursor moves the cursor to the row whose path matches; no-op if absent.
func (Model) Update ¶
Update handles arrow keys, expand/collapse (right/left or l/h), and Enter / space.
func (Model) View ¶
View renders the tree. Title (if set) is on the first line, followed by visible rows. Long names are truncated to width-3 with an ellipsis.
func (Model) WithMultiSelect ¶
WithMultiSelect enables space-toggle selection.
