Skip to main content

Module modes

Module modes 

Source
Expand description

file-tree-mode – major mode for the file-tree buffer + its BufferLocal-owned per-buffer state (root, entries, nerd-fonts toggle).

Lives here (rather than in lattice-mode) per the mode-architecture convention: “a mode lives with the crate that owns its associated feature.” FileTreeBuffer lives in this crate, so the mode + the three pieces of file-tree-mode-owned state live here too.

§What the BufferLocals carry

M.3.2.c.5 made BufferLocals the single source of truth for per-buffer mode-owned state. FileTreeBuffer itself carries only the rendered rope + cursor / scroll; every piece of “what does this buffer point at” information lives in the three locals declared below:

  • FileTreeRoot – the directory the tree is rooted at.
  • FileTreeEntries – the flat list of visible entries (root + every expanded subdir’s children). Mutated through the App-side toggle chokepoint that re-renders the rope.
  • FileTreeNerdFonts – whether the rendered rope embeds nerd-font glyphs.

The App reads through these directly; there is no struct mirror to drift.

Structs§

FileTreeEntries
Flat tree-of-entries backing the file-tree buffer. Each entry carries its depth + expansion state. The rendered rope is derived from this list – App-side toggle handlers mutate the entries through the [crate::toggle_entries_at] helper and re-write this local
FileTreeMode
Major mode for file-tree buffers. Read-only contribution (ReadOnly = true); any buffer whose major is file-tree-mode rejects mutating operators.
FileTreeNerdFonts
Whether the file-tree renders nerd-font icon glyphs inline.
FileTreeRoot
Filesystem path the file-tree buffer is rooted at. Single source of truth (M.3.2.c.5).

Functions§

register_file_tree_modes
Register every lattice-file-tree-owned mode against registry. Called from the App’s boot path alongside lattice_mode::register_foundation_modes etc. Mirrors lattice_oil::register_oil_modes.