Expand description
File-tree buffer (DESIGN.md §5.9 buffer-as-content).
v1 status (B.1.d): a flattened, lazily-expanded tree rendered
one entry per line. <CR> on a directory toggles its expansion;
on a file opens that file as a new Document buffer through the
standard :e FILE path. Standard motions (j/k/0/$/G/gg/<C-d>/…)
navigate via the active-buffer routing in lattice_core::ui::pane – the
file tree carries no special motion bindings of its own.
The buffer is read-only (mutations error with the same
“read-only” echo as the help buffer). The rendered text is a
[lattice_core::Buffer] derived from the entry list; the same
buffer feeds syntax highlighting and motions that need the line
text.
§Where does “the root”, “the entry list”, “nerd-fonts” live?
Not on FileTreeBuffer. M.3.2.c.5 retired the struct fields;
the canonical answer for each is a BufferLocal owned by
file-tree-mode:
modes::FileTreeRoot– the rooted directory.modes::FileTreeEntries– the flat list of visible entries.modes::FileTreeNerdFonts– the nerd-font toggle.
The FileTreeBuffer carries only the rendered rope + cursor +
scroll. Operations that need the entry list / root / nerd-fonts
flag take them as explicit parameters or read them from
buffer-locals through the App’s chokepoint helpers. Mutations
to the entry list flow through toggle_entries_at (a pure
function that takes &mut Vec<FileTreeEntry>), so the App can
orchestrate “update locals + re-render rope” as one atomic step
and no struct mirror exists to drift.
Re-exports§
pub use modes::FileTreeEntries;pub use modes::FileTreeMode;pub use modes::FileTreeNerdFonts;pub use modes::FileTreeRoot;pub use modes::register_file_tree_modes;
Modules§
- modes
file-tree-mode– major mode for the file-tree buffer + itsBufferLocal-owned per-buffer state (root, entries, nerd-fonts toggle).
Structs§
- File
Tree Buffer - One open file-tree buffer. Carries only the rendered rope and
motion state (cursor + scroll). All “where does this buffer
point” data – root, entry list, nerd-fonts toggle – lives in
the App’s
BufferLocalsmap under themodes::FileTreeRoot/modes::FileTreeEntries/modes::FileTreeNerdFontskeys. - File
Tree Entry - One row in the rendered file tree.
depthcontrols the indentation prefix;kinddecides whether<CR>toggles expansion or opens a file.
Enums§
Functions§
- entry_
at_ line - Look up the entry at
linein an entry list. The App readsFileTreeEntriesfrom buffer-locals and calls this withapp.cursor.linefor<CR>dispatch. - initial_
entries - Build the initial entry list for
root: the root itself as a depth-0 expanded directory, plus its immediate children at depth 1. - listing_
entries - Project the tree’s entries into the shape
directory-listing-modereads (DL.2’s shared local). - render_
to_ buffer - Serialise the entry list to a [
Buffer]. Each row is<indent><marker><icon><name>where<marker>is▾for an expanded dir,▸for a collapsed dir, andfor a file. Indent is two spaces perdepth. The<icon>glyph comes fromlattice_core::ui::icons::glyph_for_entry– nerd-fonts whennerd_fontsis true, the BMP-block fallback palette otherwise. Both palettes occupy two cells, so column geometry is the same either way. - render_
to_ text - The tree’s rope text: indent, expand marker, name — and no icon.
- toggle_
entries_ at - Toggle expansion of the directory entry at
index(1-based withinentries). Children of newly-expanded directories are inserted right after the directory’s row at depth + 1; closing a directory removes every entry whose depth is strictly greater than the closing one until depth drops back. No-op for non-directory rows.