Skip to content

smelt.layout

Tier: Host - Available in every runtime, including headless mode.

Classification: Advanced - Documented low-level capability for plugins that need full control. It may evolve more freely than the Supported facade.

Declarative, width-independent content layout primitives for transcript/tool display.

smelt.layout.cap

fun(child: any, opts: table): smelt.layout.Node

Types: smelt.layout.Node

Cap a child by rendered rows. opts.rows is numeric; opts.keep is head, tail, or head_tail; edge caps accept opts.marker = "above" | "below"; head_tail uses opts.head_rows and accepts opts.marker = "middle". opts.total_rows may provide the full source row count for clearer tail markers.

smelt.layout.code

fun(content: string, opts: table?): smelt.layout.Node

Types: smelt.layout.Node

Syntax-highlighted code layout leaf. opts.lang supplies the language name.

smelt.layout.content

fun(content_id: integer, opts: table?): smelt.layout.Node

Types: smelt.layout.Node

Opaque transcript content leaf. content_id comes from renderer metadata and is resolved by Rust without exposing the complete payload to Lua. opts.format is text (default), markdown, code, or file; text accepts hl_group / hl and ansi, Markdown accepts dim, italic, and inline, code accepts lang, and file accepts path plus an optional lang override.

smelt.layout.content_diff

fun(old_content_id: integer, new_content_id: integer, opts: table?): smelt.layout.Node

Types: smelt.layout.Node

Retained diff leaf. old_content_id and new_content_id come from transcript renderer metadata and are resolved by Rust without exposing source payloads to Lua. opts.anchor_content_id optionally identifies the edited source fragment, opts.path selects syntax, opts.lang overrides path-based syntax, and opts.full_file marks complete before/after files.

smelt.layout.diff

fun(opts: table): smelt.layout.Node

Types: smelt.layout.Node

Inline-diff render directive. The worker renders the diff directly into the block buffer. opts.old, opts.new are the before/after strings; opts.path picks syntax via extension; opts.anchor (defaults to opts.old) is the diff-view anchor; opts.lang overrides path-based syntax; opts.full_file treats opts.old as the complete pre-edit file for stable previews after writes.

smelt.layout.empty

fun(): smelt.layout.Node

Types: smelt.layout.Node

Explicit zero-row layout node. Use this instead of returning nil when a renderer intentionally hides content.

smelt.layout.file_view

fun(opts: table): smelt.layout.Node

Types: smelt.layout.Node

Syntax-highlighted file-view render directive. Uses a single line-number column and no diff bg. opts.content is the source text; opts.path picks syntax via extension; opts.lang overrides path-based syntax.

smelt.layout.group_children

fun(): smelt.layout.Node

Types: smelt.layout.Node

Opaque retained child-layout placeholder for transcript group renderers. Rust resolves each child independently, so updating one child does not serialize or recompile its siblings.

smelt.layout.gutter

fun(child: any, opts: table?): smelt.layout.Node

Types: smelt.layout.Node

Render child with an explicit non-selectable gutter prefix on each emitted row. opts.text defaults to two spaces. The prefix consumes display width before wrapping/measuring the child; opts.styled = true lets row-level styles include the prefix.

smelt.layout.hbox

fun(items: table): smelt.layout.Node

Types: smelt.layout.Node

Lay items out horizontally. Each entry is either a layout userdata (defaults to fill weight 1) or { layout, cols=N } / { layout, weight=N } / { layout, fit=true } for a fixed, weighted, or renderer-defined intrinsic-width slot. fit=true uses unwrapped content width when available, capped by the parent; fixed and fit slots are allocated before fill slots. The first item owns row-level copy metadata by default; set copy_owner=true on exactly one item when another column contains the primary copyable content.

smelt.layout.line

fun(spans: any, opts: table?): smelt.layout.Node

Types: smelt.layout.Node

Single styled line layout leaf. spans is a string or a one-dimensional span table; unlike runs, this does not wrap.

smelt.layout.markdown

fun(content: string, opts: table?): smelt.layout.Node

Types: smelt.layout.Node

Markdown layout leaf. opts.dim dims all spans; opts.italic italicizes inline-mode spans; opts.inline = true preserves line-by-line inline markdown without block parsing.

smelt.layout.panel

fun(child: any, opts: table?): smelt.layout.Node

Types: smelt.layout.Node

Render child inside a full-width background panel. opts.hl_group / opts.hl names the panel highlight group; opts.padding defaults to 1 cell/row.

smelt.layout.refresh

fun(child: any, opts: table): smelt.layout.Node

Types: smelt.layout.Node

Return child unchanged while requesting that its containing top-level transcript node be rendered again after opts.after_ms. The positive delay is declarative cache metadata and does not affect measurement, rendering, or selection.

smelt.layout.row_prefix

fun(child: any, opts: table): smelt.layout.Node

Types: smelt.layout.Node

Apply row chrome to child after the child has produced rows. opts.first is a styled line or string for row 1; opts.rest is used for every later row and defaults to opts.first. Prefix spans keep their own selectable flags: set selectable = false for pure chrome, leave it true for copyable labels. The widest prefix consumes display width before wrapping/measuring the child, so prefixed rows stay within the layout width. Put this outside layout.cap when cap markers should inherit the same row chrome.

smelt.layout.runs

fun(lines: any, opts: table?): smelt.layout.Node

Types: smelt.layout.Node

Styled inline text layout leaf. lines is a string or styled-lines table ({ { { text=..., syntax?, hl?, fg?, bg?, dim?, bold?, italic?, selectable?, title_suffix? }, ... }, ... }). opts.hl_group / opts.hl supplies a default theme group for spans without hl; opts.continuation_indent indents soft-wrapped continuation rows by display columns.

smelt.layout.separator

fun(opts: table?): smelt.layout.Node

Types: smelt.layout.Node

Full-width horizontal separator. opts.label is centered in the row and accepts the same styled span shape as smelt.layout.line; generated line fill is chrome and is not searchable/selectable unless opts.selectable is true. opts.dim defaults to true.

smelt.layout.style

fun(child: any, opts: table?): smelt.layout.Node

Types: smelt.layout.Node

Apply inherited style to a child layout. opts.hl_group / opts.hl names a theme group; opts.fg / opts.bg name theme colors; opts.dim, opts.bold, and opts.italic set text attributes. Child spans may override inherited fields.

smelt.layout.text

fun(content: string, opts: table?): smelt.layout.Node

Types: smelt.layout.Node

Plain text layout leaf. opts.hl_group / opts.hl may name a theme group; without it, text renders dimmed. opts.ansi = true enables ANSI parsing. Wrapping is computed by the transcript at the current width.

smelt.layout.vbox

fun(items: table): smelt.layout.Node

Types: smelt.layout.Node

Stack items vertically into a single block layout. Each item must be a layout userdata produced by a smelt.layout primitive.