Skip to main content

Module render

Module render 

Source
Expand description

Doc → gpui elements.

Numbers drive layout (sizes, line heights, paddings — the constants here); colors are paint, read from Theme. Blocks are a flat list, so nesting is left padding rather than nested containers, and the gap between two blocks is decided by the pair: list items sit tight, everything else breathes.

Ported from zeronsh/comet (MIT) and rebuilt against the flat block model.

Structs§

BlockLayouts
Where each block’s text landed, recorded as it painted.
Editing
What an editor paints over a document.
FenceHost
What an editor lends the blocks an installed crate::BlockRenderer paints — see Editing::fence.
Flat
Inline content flattened for shaping: one string, its runs, and the ranges that need painting underneath (link clicks, inline-code washes, mentions).
LeaveBlock
Return focus from inside a painted fence to the document around it.
Mention
A mention as it is shown: a favicon slot, then its label and title.
Shown
Where a mention’s range in a Text and its range in a Flat line up, in document order, as (text, flat) pairs.

Enums§

Annotation
A range the caller wants washed, and which wash it gets.
Caption
What an image’s one authored string is doing on the page.
CopyButton
Whether a fence paints the button that copies its text.
ImageOverlayCorner
The picture corner holding an app’s hover control.
Toggle
Who answers a press on a task block’s checkbox.

Constants§

PAINTED_CONTEXT
The key context around every painted fence. An editor’s bindings stop at it, so keys typed into a control the block paints stay that control’s.
PLAIN_LANGUAGE
What a fence with no info string calls itself, in its header and in a picker — one spelling, so the label and the menu row cannot disagree.
TABLE_CONTROL_SIZE
Reserved lane for editor table controls, inside the block bounds.

Functions§

flatten
Marks are ranges, gpui wants consecutive runs — so cut the text at every mark boundary and ask which marks cover each piece.
flatten_with
flatten with the app’s own marks painted — see crate::MarkPaint — and each mention described by preview. A name the app does not paint reads as the text it wraps.
image_source
What gpui loads for an image URL as written in a document.
markdown
Parse and render in one step — the common case for read-only content.
render
Render a document.
render_source
Paint a document’s own markdown source: a fence’s caret, selection and hit testing, without a fence’s box, band or copy button.
render_with
Render a document with a caret and a selection in it.

Type Aliases§

ImageOverlay
Builds a picture’s hover control from its block index and original URL.
OnImage
Handed the image block whose picture was clicked — see Editing::image.
OnLeave
Handed the block a painted fence is leaving — see FenceHost::leave.
OnRewrite
Handed a fence’s block index and its new code — see FenceHost::rewrite.
OnToggle
Handed the block whose checkbox was clicked — see Toggle::Handled.