Help us shape the future of Go! Take the 2026 Go Developer Survey

filetree

package
v1.4.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadChildren

func LoadChildren(projectPath, parentPath string, depth int, opts LoadOptions, statuses map[string]GitFileStatus) tea.Cmd

func LoadFileTree

func LoadFileTree(projectPath string, opts LoadOptions) tea.Cmd

func LoadFileTreeExpanded added in v0.624.6

func LoadFileTreeExpanded(projectPath string, opts LoadOptions, expanded map[string]bool, statuses map[string]GitFileStatus) tea.Cmd

LoadFileTreeExpanded reloads the tree from disk re-reading the children of every directory the user had expanded, so a refresh (manual or automatic) does not collapse the view back to the root level.

func LoadFilteredTree

func LoadFilteredTree(projectPath, query string, opts LoadOptions, statuses map[string]GitFileStatus) tea.Cmd

func LoadGitStatus

func LoadGitStatus(projectPath string) tea.Cmd

Types

type Component

type Component interface {
	tea.Model
	layout.Sizeable
	layout.Bindings
	SelectedFile() string
	// ShowHidden reports whether hidden files/directories are currently shown.
	ShowHidden() bool
	// SetShowHidden sets the hidden-files visibility and reloads the tree.
	SetShowHidden(show bool) tea.Cmd
	// ToggleHidden flips the hidden-files visibility and reloads the tree.
	ToggleHidden() tea.Cmd
}

type FileNode

type FileNode struct {
	Name       string
	Path       string
	IsDir      bool
	IsExpanded bool
	Children   []*FileNode
	GitStatus  GitFileStatus
	Depth      int
	Icon       string
	Loaded     bool
}

func NewFileNode

func NewFileNode(name, path string, isDir bool, depth int, status GitFileStatus) *FileNode

func NewRootNode

func NewRootNode(projectPath string) *FileNode

func (*FileNode) SetExpanded

func (n *FileNode) SetExpanded(expanded bool)

type FileSelectedMsg

type FileSelectedMsg struct {
	Path         string
	RelativePath string
}

type FileTree

type FileTree struct {
	// contains filtered or unexported fields
}

func New

func New(projectPath string, opts ...Option) *FileTree

func (*FileTree) BindingKeys

func (t *FileTree) BindingKeys() []key.Binding

func (*FileTree) GetSize

func (t *FileTree) GetSize() (int, int)

func (*FileTree) Init

func (t *FileTree) Init() tea.Cmd

func (*FileTree) SelectedFile

func (t *FileTree) SelectedFile() string

func (*FileTree) SetShowHidden added in v0.500.0

func (t *FileTree) SetShowHidden(show bool) tea.Cmd

SetShowHidden sets the hidden-files visibility and reloads the tree (keeping any active fuzzy filter). It is a no-op when the value is unchanged.

func (*FileTree) SetSize

func (t *FileTree) SetSize(width, height int) tea.Cmd

func (*FileTree) ShowHidden added in v0.500.0

func (t *FileTree) ShowHidden() bool

ShowHidden reports whether hidden files/directories are currently shown.

func (*FileTree) ToggleHidden added in v0.500.0

func (t *FileTree) ToggleHidden() tea.Cmd

ToggleHidden flips the hidden-files visibility and reloads the tree.

func (*FileTree) Update

func (t *FileTree) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*FileTree) View

func (t *FileTree) View() string

type FileTreeRefreshMsg

type FileTreeRefreshMsg struct {
	Root *FileNode
	Err  error
}

type FilterResultsMsg

type FilterResultsMsg struct {
	Query string
	Root  *FileNode
	Err   error
}

type GitFileStatus

type GitFileStatus int
const (
	GitStatusClean GitFileStatus = iota
	GitStatusModified
	GitStatusAdded
	GitStatusDeleted
	GitStatusUntracked
	GitStatusRenamed
)

func MergeGitStatus

func MergeGitStatus(current, next GitFileStatus) GitFileStatus

func (GitFileStatus) Priority

func (s GitFileStatus) Priority() int

type GitStatusUpdateMsg

type GitStatusUpdateMsg struct {
	Statuses map[string]GitFileStatus
	Err      error
}

type KeyMap

type KeyMap struct {
	Up           key.Binding
	Down         key.Binding
	Expand       key.Binding
	Collapse     key.Binding
	Open         key.Binding
	Search       key.Binding
	Refresh      key.Binding
	CancelSearch key.Binding
	NewFile      key.Binding
}

func DefaultKeyMap

func DefaultKeyMap() KeyMap

func (KeyMap) FullHelp

func (k KeyMap) FullHelp() [][]key.Binding

func (KeyMap) ShortHelp

func (k KeyMap) ShortHelp() []key.Binding

type LoadChildrenMsg

type LoadChildrenMsg struct {
	ParentPath string
	Children   []*FileNode
	Err        error
}

type LoadOptions

type LoadOptions struct {
	ShowHidden bool
}

type Option

type Option func(*FileTree)

func WithKeyMap

func WithKeyMap(keys KeyMap) Option

func WithShowHidden

func WithShowHidden(show bool) Option

type SetShowHiddenMsg added in v0.500.0

type SetShowHiddenMsg struct {
	ShowHidden bool
}

SetShowHiddenMsg requests the file tree to update its hidden-files visibility and reload. It is broadcast (e.g. from the settings page) so the live tree reflects a config change without a restart.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL