Skip to main content

Module modeline

Module modeline 

Source
Expand description

Built-in modeline element vocabulary + shared per-pane content resolution (slice ML.1a-render).

The modeline’s content strategy is common across renderers: this module computes each built-in element’s ElementContent (text + theme role) from (pane, RenderState), host-side, so the TUI (ML.1a) and GPUI (ML.2) peers paint identical content and differ ONLY in layout / paint (and GPUI-only richness like tooltips and clicks). See docs/dev/architecture/modeline.md §4 (host-side computation), §8 (theme roles), §10 (cross-renderer parity).

Two halves:

  • descriptors — register_builtin_elements registers the core.* set into the shared ModelineService once at boot (host owns the built-ins; modes/plugins own theirs, §6).
  • content — resolve_builtin_content computes per-pane built-in (core.*) content host-side. Mode/plugin elements (lsp, diff, …) are pushed over the event bus and drained into the content store (ML.3); the renderer reads them from the snapshot, so they never round-trip through this module.

Structs§

ModelineHitMap
ML.4: every clickable region on screen, rebuilt each frame.
ModelineHitZone
ML.4: one clickable region of a painted modeline row.
ModelineLayout
A pane modeline’s resolved per-zone layout (ML.5): the ordered element descriptors for each zone after applying the ui.modeline.* config, plus the configured inter-element separator. Descriptors are borrowed from the snapshot registry ('a).

Constants§

CORE_LANG
Detected language label. Right zone, far right.
CORE_MODE
Modal-state label ([NORMAL]). Left zone, first.
CORE_PATH
Buffer path + dirty marker (or a pane provider’s custom label).
CORE_POSITION
Cursor line:column. Right zone.
CORE_ZOOM
ZP.4: zoom marker (Z) on the zoomed pane. Right zone, ahead of position — the marker is state about the pane, not about where the cursor is in it, so it reads better beside the mode tag’s side of the row than buried past line:col.
ROLE_LANG
ROLE_MODE
ROLE_MODE_ITEM
The modeline role a mode tags content with when it contributes a segment to the modeline (e.g. diff-mode’s +N ~M stats) (DX.4, BC.6). Lives in lattice-mode (not host) because it is the role modes reach for — ModelineRole::new(ROLE_MODE_ITEM) — so it belongs with the mode-contribution substrate, letting lattice-diff reach it without the host. The host’s own element roles (modeline.path, modeline.position, modeline.lang, modeline.mode) stay host-side; the host re-exports this one so renderer style maps + crate::modeline call sites are unchanged.
ROLE_PATH
ROLE_POSITION
ROLE_ZOOM
ZP.4: the zoom marker’s role. Reuses the mode role’s slot in the theme rather than minting a colour: the marker is modal state about the pane, and matching the mode tag is what says so.

Functions§

modal_label
Modal-state short label for the active document, read from the published RenderState (no actor crossing). Shared by the modeline resolver and the renderers’ modal_label accessors so the vocabulary has one definition.
modal_label_short
Lean 3-letter modal label for the modeline (ML.5d). The full name (modal_label) is echoed in the echo area on mode change; the persistent modeline tag stays compact + modern (Helix-style NOR/INS/VIS), disambiguated by colour through the modeline.mode theme role. Same source-of-truth read as modal_label (published RenderState, no actor crossing).
pane_path_segment
The buffer-label segment for pane: a pane provider’s custom label when one is supplied (provider_label — the file-tree / oil / help M.4 mechanism, resolved renderer-side and passed in so the assembly stays common), else the document path + dirty marker (or the registry name slot for non-document panes). Empty only for the genuinely-nameless case, which the caller treats as hidden.
register_builtin_elements
Register the host’s built-in modeline descriptors. Called once at boot against the shared service (the same instance the renderers snapshot and modes reach via ctx.service::<ModelineServiceHandle>()). Priorities are uniform leftward→rightward in every zone; the renderer right-aligns the Right block (see Zone).
resolve_builtin_content
Resolve a built-in (core.*) element’s content for pane. Pure reads off the published RenderState — O(1), no allocation proportional to document size (paramount #1).
resolve_layout
Resolve the full per-zone modeline layout for a pane from the descriptor registry + the ui.modeline.{left,center,right,separator} typed options (ML.5; design §11).