Skip to main content

Module listing_mode

Module listing_mode 

Source
Expand description

directory-listing-mode — the minor mode both listing majors share, owning entry presentation.

Design: docs/dev/architecture/directory-listing-mode.md. Sequencing: docs/dev/operations/slice-plans/directory-listing-mode.md (this is DL.2).

§Why a minor rather than two contributions

crate::oil::OilMode and crate::file_tree::FileTreeMode need identical presentation — a per-row icon and a per-row colour keyed on what the row points at — while differing in behaviour (oil is editable and diffs its rope on :w; the tree is read-only and expands directories). Shared behaviour across two majors is a minor mode, never the same contribution declared twice.

CV.5 is the bill for not having had one: the identical off-by-scroll bug sat in both majors’ paint paths, the report named only oil, and nothing announced that the tree was broken the same way. See prefer-minor-modes-over-duplication.

§What it owns, and what it does not

Owns the theme-element vocabulary (§4 of the design), the display options a listing pane needs, and — from DL.3 — the per-row icons and spans.

Owns no keymap. <CR> means “open” in the tree and nothing in oil, so entry navigation is major-owned. A mode owning no chords is fine; what it must not do is own half of something.

Structs§

DirectoryListingMode
The shared presentation minor. See the module docs.
ListingEntries
Per-row entry data for a listing buffer, written by whichever major owns the buffer and read by this mode’s presentation.
ListingEntry
One row of a listing, in the shape entry presentation needs: where it points and whether it is a directory.

Constants§

ELEM_LISTING_DIR
Directory rows.
ELEM_LISTING_FILE
Theme element every listing row falls back to.
ELEM_LISTING_HIDDEN
Dotfiles.
LISTING_LANGUAGE_ELEMENTS
The per-language elements, as (element name, palette key).

Functions§

listing_element_for
Which listing.* element a row resolves to.
listing_inlays
Build one leading inlay per listing row: the glyph [lattice_core::ui::icons::glyph_for_entry] picks, painted with the element listing_element_for resolves.
listing_name_spans
Build one span per listing row covering the entry NAME, painted with the same element listing_element_for gives that row’s icon.
register_listing_modes
Register the shared listing minor. Called from the host’s mode boot beside oil::register_oil_modes / file_tree::register_file_tree_modes.
register_listing_theme_elements
Register every listing.* element under owner. Idempotent by name, so re-activation on a second listing buffer is free.