Expand description
Help buffer model – re-exported from lattice-help.
Moved from lattice-ui-tui in Phase 5.2 first wave.
Modules§
- topics
- Help topic registry (DESIGN.md §5.11).
Structs§
- Help
Anchor - Named scroll target inside a help buffer’s content.
- Help
Buffer - One open help buffer. The content is a real
Buffer(rope- backed), so it composes with everything else that consumesBuffer– search, motions, syntax highlighting (once a help major mode + tree-sitter grammar lands). - Help
Content - M.3.2.c.5: pair of (slim help buffer, parsed metadata) returned from every help factory. The App splits this into:
- Help
Link - One
[[…]]link inside a help buffer’s content.rangeis the byte interval within the rendered text (NOT including the[[]]delimiters – the renderer can highlight just the inner text or the full match depending on style). - Help
Metadata - M.3.2.c.5: parsed-out metadata that travels alongside a
freshly-constructed
HelpBuffer. Bundles the data the help-mode owns per-buffer so the App can seed it intobuffer_locals[id]at popup-open time. Replaces thelinks/anchors/highlightsfields that used to live directly onHelpBuffer. - Inline
Code - PU.1b-2b: build the per-line
Style::Linkspans forlinkswith NO grammar base — the link-only overlay the host seeds into a help buffer’sExtraHighlightslocal so the cells-workerDisplayMatrixcarries link styling (the grammar can’t: the[label](url)markup is stripped before it parses, so it never emits a Link capture). Same per-line logic as [overlay_link_styles], just onto an empty base. One inline`code`span found in a help buffer’s text. - Popup
Snapshot - Renderer-agnostic snapshot of a help popup’s content + view +
metadata, pushed onto the
<C-o>back-stack when following a help link swaps the popup’s content in place. PU-A.2: moved here fromlattice-host— this is help’s back-stack history, not generic popup state, so it lives with the rest of the help model.
Enums§
- Help
Link Target - What a
[[…]]link points at. Renderers / link-following motions dispatch on this.
Functions§
- anchor_
line - Look up an anchor by name and return the line it points at.
- command_
link - Helper for help-content formatters. Renders a command link in
standard markdown form:
[name](command:name). - escape_
link_ text - Escape the link syntax’s own punctuation —
\,[,],(,)— with a backslash, so a label or URL may contain it. Chords are the reason:]f,di(,da),ci]are ordinary motions and text objects, and unescaped each one ended the label or the URL early. The parsers (extract_links_and_clean,parse_help_links) unescape. - extract_
links_ and_ clean - generate_
heading_ anchors - Walk
linesfor ATX-style markdown headings (#,##, …) and emit aHelpAnchorper heading whose name is the GitHub-style slug. Used by the help-topic loader so authors can write[label](#slug)in markdown bodies and have the link route in- editor without manually-managed anchor lists. - inline_
code_ spans - HP.2: find every inline
`code`span intext. - key_
link - Helper for help-content formatters. Renders a chord link in
standard markdown form:
[chord](key:chord). - link_at
- Find the metadata link whose label range contains
pos. - link_
highlights - mode_
link - Helper for help-content formatters. Renders a mode link in
standard markdown form:
[name](mode:name). Used by:describe-buffer(the “modes active here” section). - one_
line - Strip every
[label](url)markdown link intextdown to just its label and return the cleaned-up text plus aHelpLinkper link with its byte range computed against the CLEANED text. This is what the help-buffer constructor uses so the user readsex:writeinstead of[ex:write](command:ex:write). The link’s URL still drives navigation – it’s stored on the returnedHelpLink::targetbut the URL bytes don’t appear in the rendered output. Collapse a multi-line diagnostic message to a single line. LSP messages can contain newlines (e.g. rust-analyzer’s “expectedFoo, foundBar\n – in fn::method”). The help-buffer’s row layout assumes one row per entry; squash to keep visual alignment. - parse_
help_ lines - Parse
linesinto a help buffer + metadata. Walks the joined text once, stripping[label](url)markdown links down to their visible labels and indexing each link’s range against the cleaned text. The buffer’s content is the cleaned text; links land on the metadata. - parse_
help_ lines_ and_ anchors - Parse
lines+ explicitanchorsinto a help buffer + metadata. - parse_
help_ links - Walk
text, locating every[label](url)markdown link and resolving the URL’s scheme into a typedHelpLinkTarget. Each returnedHelpLink’srangecovers the LABEL bytes (what the user sees as a clickable token) – the surrounding[,],(,), and URL bytes aren’t part of the highlighted range. - slugify_
heading - Convert a markdown heading line (“## 1. Tree-sitter, core”) into the GitHub-style slug (“1-tree-sitter-core”) used for intra-doc anchor links. Algorithm:
- source_
link - Helper for help-content formatters. Renders a source link in
standard markdown form:
[path:line](file:path:line). - topic_
link - Helper for help-content formatters. Renders a topic link in
standard markdown form:
[name](help:name). Used by:describe-*cross-references.