Skip to main content

Module file_tree

Module file_tree 

Source
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 + its BufferLocal-owned per-buffer state (root, entries, nerd-fonts toggle).

Structs§

FileTreeBuffer
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 BufferLocals map under the modes::FileTreeRoot / modes::FileTreeEntries / modes::FileTreeNerdFonts keys.
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
FileTreeEntry
One row in the rendered file tree. depth controls the indentation prefix; kind decides whether <CR> toggles expansion or opens a file.
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).

Enums§

FileTreeEntryKind

Functions§

entry_at_line
Look up the entry at line in an entry list. The App reads FileTreeEntries from buffer-locals and calls this with app.cursor.line for <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-mode reads (DL.2’s shared local).
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.
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, and for a file. Indent is two spaces per depth. The <icon> glyph comes from lattice_core::ui::icons::glyph_for_entry – nerd-fonts when nerd_fonts is 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 within entries). 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.