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.

Modules§

selectable
Text you can select with the pointer and copy out of.

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 atoms — ranges of a source text painted as something else — line up between that text and the text painted for it, in document order, as (source, shown) pairs.
SourceText
A source text and what render_source reads off it every frame: its lines, a hash of each, and its highlight spans.
SpanJob
Highlighting a SourceText in full. Send, so it can run off the thread that paints.
Spans
What a SpanJob found, for SourceText::set_spans.

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.
RevealMode
Where BlockLayouts::reveal_with puts a range that is not showing. A range already showing does not move either way.
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.
hover_bookmark
A web link’s hover card: its bookmark, picture on top.
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. None leaves that picture without one. An empty picture placeholder gets none.
OnImage
Handed the image block whose picture was clicked — see Editing::image.
OnImageMenu
Handed the image block whose picture was right-pressed and the press’s window position — see Editing::image_menu.
OnJump
Handed the heading block a clicked #fragment link names — see Editing::jump.
OnLeave
Handed the block a painted fence is leaving — see FenceHost::leave.
OnResize
Handed a resizable painted block’s index and where its grip was pressed — see FenceHost::resize.
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.