Documentation
¶
Overview ¶
Package filetree is nook's left-side file-tree pane.
It wraps the glyph components/file-tree Model with the file-system walking and bordered surface nook needs. The walk uses the same ignore rules as the project picker (skip .git, node_modules, vendor, dist, target, and dotfiles) so the two surfaces stay consistent.
The pane emits an OpenMsg when the user presses Enter on a file leaf; the host turns that into a buffer-open command. Directory expand / collapse stays inside the pane.
Index ¶
- func BuildTree(root string) glyphtree.Node
- func BuildTreeCmd(root string) tea.Cmd
- type BuildTreeMsg
- type OpenMsg
- type Pane
- func (p *Pane) Blur()
- func (p Pane) Built() bool
- func (p *Pane) Focus()
- func (p Pane) Focused() bool
- func (p *Pane) RefreshCmd() tea.Cmd
- func (p *Pane) Reveal(absPath string)
- func (p Pane) Selected() string
- func (p *Pane) SetNode(node glyphtree.Node)
- func (p *Pane) SetSize(w, h int)
- func (p *Pane) SetTheme(t theme.Theme)
- func (p Pane) Update(msg tea.Msg) (Pane, tea.Cmd)
- func (p Pane) View() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildTree ¶
BuildTree walks root and returns a single glyphtree.Node representing the project. Directories are sorted alphabetically with directories before files within each level. Errors during walk are silently skipped — the pane should never crash because a directory is unreadable.
func BuildTreeCmd ¶ added in v0.35.0
BuildTreeCmd walks root in a goroutine and returns a BuildTreeMsg the host model can hand to Pane.SetNode. Safe to fire multiple times — the handler ignores results whose Root no longer matches the pane's root.
Types ¶
type BuildTreeMsg ¶ added in v0.35.0
BuildTreeMsg carries the result of an async tree walk.
type OpenMsg ¶
type OpenMsg struct{ Path string }
OpenMsg is emitted when the user opens a file leaf in the tree. Path is absolute (rooted at the pane's root).
type Pane ¶
type Pane struct {
// contains filtered or unexported fields
}
Pane is nook's file-tree side pane.
func New ¶
New constructs a pane rooted at root. Construction is constant-time and does NOT walk the file system — that work happens asynchronously via BuildTreeCmd so first paint is never gated on the walk. View() renders a "Scanning…" placeholder until SetNode lands. This was the last sync FS call in nook's startup path; lightning-fast startup is a load-bearing property and must be preserved going forward.
func (Pane) Built ¶ added in v0.35.0
Built reports whether SetNode has landed at least once. Callers can use this to decide whether to show the pane's view or skip allocation.
func (*Pane) RefreshCmd ¶ added in v0.35.0
RefreshCmd returns a tea.Cmd that re-walks the file system off the UI thread and produces a BuildTreeMsg the host can hand back to SetNode. The previous synchronous Refresh blocked first paint on a home-directory launch (nook ~/.zshrc walks all of ~/repos and ~/Downloads); the async form preserves the snappy "Scanning…" placeholder behavior used at startup.
func (*Pane) Reveal ¶
Reveal expands the directories on the path to file and moves the cursor onto it. When the tree has not finished its initial walk yet, the reveal target is queued and replayed once SetNode lands. path must be slash-separated relative to root, or the function is a no-op.
func (Pane) Selected ¶
Selected returns the absolute path of the row under the cursor, or the empty string if the tree is empty.
func (*Pane) SetNode ¶ added in v0.35.0
SetNode replaces the pane's tree with a freshly walked node and replays any reveal target that came in while the walk was pending. Caller should match msg.Root against the pane's root before calling to discard stale walks (e.g. after a project-root change).
func (*Pane) SetTheme ¶ added in v0.38.0
SetTheme swaps the palette used for borders, the file/folder glyphs, and the cursor row. The wrapped glyph file-tree model uses its own internal palette tied to lipgloss tokens, so visual changes are limited to the nook-side framing; deeper recolor is a follow-up.
func (Pane) Update ¶
Update routes a message through the underlying glyph tree model and rewrites its SelectMsg into a nook OpenMsg when the user opens a file leaf.
func (Pane) View ¶
View renders the pane inside a rounded border. When width or height is too small the function returns an empty string; the host should not allocate space for the pane in that case. Until the first BuildTreeMsg lands the pane renders a "Scanning…" placeholder so first paint is never gated on the file-system walk.