Expand description
File-tree buffer model – re-exported from lattice-file-tree.
Moved from lattice-ui-tui in Phase 5.2 first wave. The
definitions live in lattice-file-tree; this module
provides the canonical host-side import path so consumers
can write lattice_host::file_tree::* instead of reaching
into lattice-file-tree directly. Existing
lattice_ui_tui::file_tree::* imports keep working via
a pub use lattice_host::file_tree; re-export in
lattice-ui-tui’s lib.rs.
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 Entries - 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 - File
Tree Entry - One row in the rendered file tree.
depthcontrols the indentation prefix;kinddecides whether<CR>toggles expansion or opens a file. - File
Tree Mode - Major mode for file-tree buffers. Read-only contribution
(
ReadOnly = true); any buffer whose major isfile-tree-moderejects mutating operators. - File
Tree Nerd Fonts - Whether the file-tree renders nerd-font icon glyphs inline.
- File
Tree Root - Filesystem path the file-tree buffer is rooted at. Single source of truth (M.3.2.c.5).
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). - register_
file_ tree_ modes - Register every
lattice-file-tree-owned mode againstregistry. Called from the App’s boot path alongsidelattice_mode::register_foundation_modesetc. Mirrorslattice_oil::register_oil_modes. - 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.