Documentation
¶
Overview ¶
Package filetree implements the file explorer panel for grut. It provides a navigable tree view of the filesystem with lazy directory loading, symlink safety, icon support, and cursor-based navigation.
Package filetree provides the file tree panel for grut.
Package filetree provides file operation helpers for the grut file explorer. All operations validate that paths stay within the tree's root directory (path jailing) to prevent directory-traversal attacks.
Package filetree provides a filesystem watcher for the grut file explorer. It uses fsnotify for event-based watching with a debounce window, and falls back to polling when fsnotify is unavailable or fails.
Index ¶
- type Config
- type DirChangedMsg
- type FileTree
- func (ft *FileTree) Blur()
- func (ft *FileTree) Close()
- func (ft *FileTree) CursorIsDir() bool
- func (ft *FileTree) CursorPath() string
- func (ft *FileTree) Focus()
- func (ft *FileTree) Init(ctx context.Context) tea.Cmd
- func (ft *FileTree) KeyBindings() []panels.KeyBinding
- func (ft *FileTree) SetActionsCfg(cfg config.ActionsConfig)
- func (ft *FileTree) SetBaseBranch(branch string)
- func (ft *FileTree) SetGitClient(gc git.StatusReader)
- func (ft *FileTree) SetSize(width, height int)
- func (ft *FileTree) Title() string
- func (ft *FileTree) Update(msg tea.Msg) (panels.Panel, tea.Cmd)
- func (ft *FileTree) View(width, height int) string
- type RefreshMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.2.0
type Config interface {
GetIconMode() string
GetMaxDepth() int
GetShowHidden() bool
GetShowIcons() bool
GetSortDirectoriesFirst() bool
GetGitStatusMarkers() bool
GetFollowSymlinks() bool
}
Config defines the configuration subset needed by the file tree panel. The concrete config.FileTreeConfig satisfies this interface, but tests and embedders can supply lightweight stubs without importing the config package.
This follows the narrow-interface injection pattern described in CONTRIBUTING.md § "Config Interface Pattern".
type DirChangedMsg ¶
type DirChangedMsg struct{ Path string }
Messages emitted by the filetree panel. DirChangedMsg is sent when a directory is expanded.
type FileTree ¶
type FileTree struct {
// contains filtered or unexported fields
}
FileTree is the file explorer panel. It implements panels.Panel.
func (*FileTree) Close ¶
func (ft *FileTree) Close()
Close implements panels.Closer. It stops the filesystem watcher and releases associated resources (F29).
func (*FileTree) CursorIsDir ¶ added in v0.1.0
CursorIsDir reports whether the node under the cursor is a directory.
func (*FileTree) CursorPath ¶ added in v0.1.0
cursorPath returns the absolute path of the node at the current cursor position. Returns "" when the visible list is empty or cursor is out of range.
func (*FileTree) Init ¶
--------------------------------------------------------------------------- panels.Panel interface --------------------------------------------------------------------------- Init implements panels.Panel.
func (*FileTree) KeyBindings ¶
func (ft *FileTree) KeyBindings() []panels.KeyBinding
KeyBindings implements panels.Panel.
func (*FileTree) SetActionsCfg ¶
func (ft *FileTree) SetActionsCfg(cfg config.ActionsConfig)
SetActionsCfg stores the actions configuration for right-click menus.
func (*FileTree) SetBaseBranch ¶ added in v0.1.0
SetBaseBranch configures the default base branch for the "b" toggle (branch diff filter). Typically set from config.GitConfig.DefaultBranch.
func (*FileTree) SetGitClient ¶
func (ft *FileTree) SetGitClient(gc git.StatusReader)
SetGitClient configures the filetree with a git client for git-aware filtering. When set, the user can press "g" to toggle between all files and only git-changed files.
type RefreshMsg ¶
type RefreshMsg struct{}
RefreshMsg tells the filetree to reload its directory listing.