Versions in this module Expand all Collapse all v2 v2.0.1 May 29, 2026 v2.0.0 Apr 23, 2026 Changes in this version + var ErrCyclicReference = errors.New("cyclic reference detected in tree") + var ErrDirectoryScan = errors.New("directory scan failed") + var ErrEmptyID = errors.New("empty node ID") + var ErrFileSystem = errors.New("file system operation failed") + var ErrNodeNotFound = errors.New("node not found in tree") + var ErrPathResolution = errors.New("path resolution failed") + var ErrTraversalLimit = errors.New("traversal limit exceeded") + var ErrTreeConstruction = errors.New("tree construction failed") + func NormalizeIconWidth(icon string) string + func PredAll[T any](predicates ...func(*Node[T]) bool) func(*Node[T]) bool + func PredAny[T any](predicates ...func(*Node[T]) bool) func(*Node[T]) bool + func PredContainsText[T any](text string) func(*Node[T]) bool + func PredHasExtension[T any](extensions ...string) func(*Node[T]) bool + func PredHasNameIgnoreCase[T any](name string) func(*Node[T]) bool + func PredHasName[T any](name string) func(*Node[T]) bool + func PredIsCollapsed[T any]() func(*Node[T]) bool + func PredIsDir[T any]() func(*Node[T]) bool + func PredIsExpanded[T any]() func(*Node[T]) bool + func PredIsFile[T any]() func(*Node[T]) bool + func PredIsHidden[T any]() func(*Node[T]) bool + func PredMatchesRegex[T any](pattern *regexp.Regexp) func(*Node[T]) bool + func PredNot[T any](predicate func(*Node[T]) bool) func(*Node[T]) bool + type DefaultNodeProvider struct + DisableIcons bool + func NewDefaultNodeProvider[T any](opts ...ProviderOption[T]) *DefaultNodeProvider[T] + func NewFileNodeProvider[T any](opts ...ProviderOption[T]) *DefaultNodeProvider[T] + func (p *DefaultNodeProvider[T]) Format(node *Node[T]) string + func (p *DefaultNodeProvider[T]) Icon(node *Node[T]) string + func (p *DefaultNodeProvider[T]) SetDefaultStyle(style lipgloss.Style) + func (p *DefaultNodeProvider[T]) SetFocusedStyle(style lipgloss.Style) + func (p *DefaultNodeProvider[T]) Style(node *Node[T], isFocused bool) lipgloss.Style + type ExpandFn func(node *Node[T]) bool + type FileInfo struct + Extra map[string]any + Path string + type FilterFn func(item T) bool + type FlatDataProvider interface + ID func(T) string + Name func(T) string + ParentID func(T) string + type FocusPolicyFn func(ctx context.Context, visible []*Node[T], current *Node[T], offset int) (*Node[T], error) + type KeyMap struct + Collapse []string + Down []string + Expand []string + ExtendDown []string + ExtendUp []string + Quit []string + Reset []string + SearchAccept []string + SearchCancel []string + SearchDelete []string + SearchStart []string + Toggle []string + Up []string + func DefaultKeyMap() KeyMap + type NestedDataProvider interface + Children func(T) []T + ID func(T) string + Name func(T) string + type Node struct + func NewFileSystemNode(path string, info os.FileInfo) *Node[FileInfo] + func NewNodeClone[T any](original *Node[T]) *Node[T] + func NewNodeSimple[T any](idAndName string, data T) *Node[T] + func NewNode[T any](id, name string, data T) *Node[T] + func (n *Node[T]) AddChild(child *Node[T]) + func (n *Node[T]) All(ctx context.Context) iter.Seq2[NodeInfo[T], error] + func (n *Node[T]) Children() []*Node[T] + func (n *Node[T]) Collapse() + func (n *Node[T]) Data() *T + func (n *Node[T]) Expand() + func (n *Node[T]) HasChildren() bool + func (n *Node[T]) ID() string + func (n *Node[T]) IsExpanded() bool + func (n *Node[T]) IsVisible() bool + func (n *Node[T]) Name() string + func (n *Node[T]) Parent() *Node[T] + func (n *Node[T]) SetChildren(children []*Node[T]) + func (n *Node[T]) SetData(data T) + func (n *Node[T]) SetExpanded(expanded bool) + func (n *Node[T]) SetName(name string) + func (n *Node[T]) SetVisible(visible bool) + func (n *Node[T]) Toggle() + type NodeInfo struct + Depth int + IsLast bool + Node *Node[T] + type NodeProvider interface + Format func(node *Node[T]) string + Icon func(node *Node[T]) string + Style func(node *Node[T], isFocused bool) lipgloss.Style + type Option struct + func WithExpandAll[T any]() Option[T] + func WithExpandFunc[T any](fn ExpandFn[T]) Option[T] + func WithFilterFunc[T any](filter FilterFn[T]) Option[T] + func WithFocusPolicy[T any](fn FocusPolicyFn[T]) Option[T] + func WithMaxDepth[T any](d int) Option[T] + func WithProgressCallback[T any](cb ProgressCallback[T]) Option[T] + func WithProvider[T any](p NodeProvider[T]) Option[T] + func WithSearcher[T any](fn SearchFn[T]) Option[T] + func WithTraversalCap[T any](cap int) Option[T] + func WithTruncate[T any](width int) Option[T] + type ProgressCallback func(processed int, node *Node[T]) + type ProviderOption func(*DefaultNodeProvider[T]) + func WithDefaultFileRules[T any]() ProviderOption[T] + func WithDefaultFolderRules[T any]() ProviderOption[T] + func WithDefaultIcon[T any](icon string) ProviderOption[T] + func WithFileExtensionRules[T any]() ProviderOption[T] + func WithFormatter[T any](formatter func(node *Node[T]) (string, bool)) ProviderOption[T] + func WithIconRule[T any](predicate func(*Node[T]) bool, icon string) ProviderOption[T] + func WithStyleRule[T any](predicate func(*Node[T]) bool, style, focused lipgloss.Style) ProviderOption[T] + type SearchFn func(ctx context.Context, node *Node[T], term string) bool + type Tree struct + func NewTreeFromFileSystem(ctx context.Context, path string, followSymlinks bool, ...) (*Tree[FileInfo], error) + func NewTreeFromFlatData[T any](ctx context.Context, items []T, provider FlatDataProvider[T], ...) (*Tree[T], error) + func NewTreeFromNestedData[T any](ctx context.Context, items []T, provider NestedDataProvider[T], ...) (*Tree[T], error) + func NewTreeFromWalker[T any](ctx context.Context, walker Walker[T], opts ...Option[T]) (*Tree[T], error) + func NewTree[T any](nodes []*Node[T], opts ...Option[T]) *Tree[T] + func (t *Tree[T]) AddFocusedID(ctx context.Context, id string) error + func (t *Tree[T]) All(ctx context.Context) iter.Seq2[NodeInfo[T], error] + func (t *Tree[T]) AllBottomUp(ctx context.Context) iter.Seq2[NodeInfo[T], error] + func (t *Tree[T]) AllFocused(ctx context.Context) iter.Seq2[NodeInfo[T], error] + func (t *Tree[T]) AllVisible(ctx context.Context) iter.Seq2[NodeInfo[T], error] + func (t *Tree[T]) BreadthFirst(ctx context.Context) iter.Seq2[NodeInfo[T], error] + func (t *Tree[T]) ClearAllFocus() + func (t *Tree[T]) CollapseAll(ctx context.Context) error + func (t *Tree[T]) ExpandAll(ctx context.Context) error + func (t *Tree[T]) FindByID(ctx context.Context, id string) (*Node[T], error) + func (t *Tree[T]) GetAllFocusedIDs() []string + func (t *Tree[T]) GetAllFocusedNodes() []*Node[T] + func (t *Tree[T]) GetFocusedID() string + func (t *Tree[T]) GetFocusedNode() *Node[T] + func (t *Tree[T]) HideAll(ctx context.Context) error + func (t *Tree[T]) IsFocused(id string) bool + func (t *Tree[T]) Move(ctx context.Context, offset int) (bool, error) + func (t *Tree[T]) MoveExtend(ctx context.Context, offset int) (bool, error) + func (t *Tree[T]) Nodes() []*Node[T] + func (t *Tree[T]) RemoveFocusedID(ctx context.Context, id string) error + func (t *Tree[T]) Render(ctx context.Context) (string, error) + func (t *Tree[T]) Search(ctx context.Context, term string) ([]*Node[T], error) + func (t *Tree[T]) SearchAndExpand(ctx context.Context, term string) ([]*Node[T], error) + func (t *Tree[T]) SetAllFocusedIDs(ctx context.Context, ids []string) error + func (t *Tree[T]) SetExpanded(ctx context.Context, id string, expanded bool) (bool, error) + func (t *Tree[T]) SetFocusedID(ctx context.Context, id string) (bool, error) + func (t *Tree[T]) SetNodes(nodes []*Node[T]) + func (t *Tree[T]) ShowAll(ctx context.Context) error + func (t *Tree[T]) ToggleFocused(ctx context.Context) + func (t *Tree[T]) ToggleFocusedID(ctx context.Context, id string) error + type TuiTreeModel struct + func NewTuiTreeModel[T any](tree *Tree[T], opts ...TuiTreeModelOption[T]) *TuiTreeModel[T] + func (m *TuiTreeModel[T]) BeginSearch() + func (m *TuiTreeModel[T]) Collapse() + func (m *TuiTreeModel[T]) EndSearch() + func (m *TuiTreeModel[T]) Expand() + func (m *TuiTreeModel[T]) ExtendFocusDown() + func (m *TuiTreeModel[T]) ExtendFocusUp() + func (m *TuiTreeModel[T]) Init() tea.Cmd + func (m *TuiTreeModel[T]) NavBar() string + func (m *TuiTreeModel[T]) NavigateDown() + func (m *TuiTreeModel[T]) NavigateUp() + func (m *TuiTreeModel[T]) Search(term string) ([]*Node[T], error) + func (m *TuiTreeModel[T]) Toggle() + func (m *TuiTreeModel[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd) + func (m *TuiTreeModel[T]) View() tea.View + type TuiTreeModelOption func(*TuiTreeModel[T]) + func WithTuiAllowResize[T any](allowResize bool) TuiTreeModelOption[T] + func WithTuiAltScreen[T any](enable bool) TuiTreeModelOption[T] + func WithTuiDisableNavBar[T any](disable bool) TuiTreeModelOption[T] + func WithTuiHeight[T any](h int) TuiTreeModelOption[T] + func WithTuiKeyMap[T any](k KeyMap) TuiTreeModelOption[T] + func WithTuiNavigationTimeout[T any](d time.Duration) TuiTreeModelOption[T] + func WithTuiSearchTimeout[T any](d time.Duration) TuiTreeModelOption[T] + func WithTuiWidth[T any](w int) TuiTreeModelOption[T] + type WalkItem struct + Data T + ID string + Name string + type Walker interface + Children func(context.Context, WalkItem[T]) ([]WalkItem[T], error) + Root func(context.Context) (WalkItem[T], error) Other modules containing this package github.com/Digital-Shane/treeview