Expand description
Plugin widget runtime.
Plugins describe panels as a WidgetSpec
tree. The runtime in this module owns the panel registry, runs the
reconciler against the previous spec, renders the resulting tree
into [TextPropertyEntry]s, and (in later phases) routes events
back through the hook system.
v1 supports the Row / Col / HintBar / Raw widget kinds.
Additional kinds (Toggle, Button, TextInput, List, Tree,
Layer, Transient, Table) plug into the render dispatch
without changing the IPC shape.
See docs/internal/plugin-widget-library-design.md for the full
design.
Structs§
- Embed
Rect - A rectangle reserved by a
WindowEmbedwidget. All coordinates are in display columns (not bytes), so the host can map straight to screen cells viainner.x + col_in_row.width_colsis the column count;height_rowsmatches the spec’srows. The host’s floating-panel render walks these and invokes the per-window paint path scoped to the rect. - Focus
Cursor - Where the host should place the buffer’s hardware cursor — the
terminal’s blinking caret — when a
TextInputis focused. Built by the renderer; the dispatcher translates(buffer_row, byte_in_row)to an absolute byte position in the virtual buffer and sets the panel buffer’s primary cursor there. When a non-text widget is focused (Toggle / Button / List) or the panel has no tabbable widgets, this isNoneand the host hides the cursor entirely. - HitArea
- One clickable rectangle within a rendered widget panel.
- Overlay
Row - One row produced by an
Overlaywidget.buffer_rowis the 0-based row inside the panel’s inner area where the entry should be painted; the host’s paint pass writes overlay rows after the main entries so they sit on top. - Render
Output - What a single render of a
WidgetSpecproduces. - Scroll
Region - A scrollable
Listwidget’s geometry + scroll state, surfaced so the host can paint a draggable scrollbar over the list’s rightmost column and hit-test mouse press/drag against it. Threaded through the compositor (Row/Col/Section) identically toEmbedRect—buffer_row/col_in_roware panel-relative display coordinates.width_colsspans the list’s column socol_in_row + width_cols - 1is the scrollbar column;height_rowsis the visible track height.total/visible/scrollfeedScrollbarState. - Widget
Panel State - Per-panel state retained between renders. The reconciler will use
the previous spec to compute the minimum mutation when a future
UpdateWidgetPanelarrives. - Widget
Registry - Global registry of mounted widget panels.
Enums§
- Widget
Instance State - Widget instance state retained across spec updates, keyed by
the widget’s stable
key. This is the “Spec/instance separation” described in §6 of the design doc — a plugin can rebuild itsWidgetSpecfrom scratch on every model change without losing scroll offset, cursor position, expanded keys, or focus, because stateful widgets look up their instance state bykey.
Functions§
- append_
tree_ nodes_ in_ spec - Append
new_nodes(and their item keys) to an existing Tree’s node list, preserving everything already present. Returns true when a matching Tree was found and extended. - find_
widget_ by_ key - Locate a widget node in a spec tree by its stable
key. Returns the matched node, orNoneif no widget has that key. - render_
spec - Render a spec to a
RenderOutput. - render_
spec_ no_ autofocus - Like
render_specbut does not fall back to focusing the first tabbable widget whenfocus_keymatches none. Use this when the host owns the focus ring and a state of “no widget focused” is meaningful — e.g. the search overlay, where focus can rest on the input (no toggle highlighted) rather than always on a toolbar control. Pass""for no focus. - set_
list_ items_ in_ spec - In-place mutate a
List’sitemsanditem_keysfields. Returns true when a matching List was found and updated. - set_
raw_ entries_ in_ spec - Replace a
Rawwidget’sentriesin place. Returns true when a matchingRawwas found and updated. - set_
toggle_ checked_ in_ spec - In-place mutate a
Toggle’scheckedfield by walking the spec tree and matching onwidget_key. Used by theWidgetMutate::SetCheckedIPC fast path. - set_
tree_ checked_ keys_ in_ spec - Stamp
Some(checked)onto everyTreeNodewhose item-key appears inkeys. Used byWidgetMutation::SetCheckedKeys— the host writes the new checkbox state into the spec so the next render reflects it without round-tripping through the plugin. Nodes not inkeysare unchanged. Nodes whose existingcheckedisNoneare left asNone(a node only becomes checkable by the plugin emittingSome(_)in the spec). - set_
tree_ nodes_ in_ spec - In-place mutate a
Tree’snodesanditem_keysfields. Returns true when a matching Tree was found and updated. - tree_
parent_ index - Resolve the absolute
nodesindex of the parent ofchild_idxin aTree. The parent of a node at depthdis the most recent earlier node at depthd - 1. ReturnsNonefor top-level nodes (depth 0) and for out-of-range indices.
Type Aliases§
- PanelId
- Plugin-allocated panel identifier. Unique within a plugin; the editor does not interpret the value.