Documentation
¶
Overview ¶
Package compositor composes vterm snapshots and UI layers into a single rendered frame. A Canvas holds the working cell grid and is reused across frames; snapshot rendering (RenderSnapshotWithCanvas) and delta-aware ANSI emission keep redraws cheap on the hot render path.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderSnapshotWithCanvas ¶ added in v0.0.19
func RenderSnapshotWithCanvas(canvas *Canvas, snap *VTermSnapshot, width, height int, fg, bg vterm.Color) string
RenderSnapshotWithCanvas renders a vterm snapshot into a reusable canvas.
Types ¶
type Canvas ¶
type Canvas struct {
Width int
Height int
Cells [][]vterm.Cell
// contains filtered or unexported fields
}
Canvas is a fixed-size buffer of styled cells.
func (*Canvas) DrawScreen ¶
func (c *Canvas) DrawScreen(x, y, w, h int, screen [][]vterm.Cell, cursor CursorState, viewOffset int, selection SelectionRegion)
DrawScreen draws a vterm screen into the canvas with clipping.
type ChromeCache ¶
type ChromeCache struct {
// contains filtered or unexported fields
}
ChromeCache caches a StringDrawable for static pane chrome. Reuse the cached drawable when layout/content hasn't changed.
func (*ChromeCache) Get ¶
func (c *ChromeCache) Get(content string, width, height int, focused bool, posX, posY int) *StringDrawable
Get returns the cached StringDrawable if the parameters match. Returns nil if cache is invalid and needs rebuild.
func (*ChromeCache) Set ¶
func (c *ChromeCache) Set(content string, width, height int, focused bool, posX, posY int, drawable *StringDrawable)
Set updates the cache with a new StringDrawable.
type CursorState ¶ added in v0.0.14
CursorState holds cursor position and visibility for DrawScreen.
type PositionedVTermLayer ¶
type PositionedVTermLayer struct {
*VTermLayer
PosX, PosY int
Width, Height int
}
type SelectionRegion ¶ added in v0.0.14
SelectionRegion holds selection bounds for DrawScreen.
type SnapshotDoubleBuffer ¶ added in v0.0.20
type SnapshotDoubleBuffer struct {
// contains filtered or unexported fields
}
SnapshotDoubleBuffer alternates between two snapshot buffers so the buffer mutated by an incremental snapshot is never the one most recently handed to a layer. Each buffer carries rows dirtied while the other buffer was the target, because vterm dirty tracking is per snapshot call, not per buffer.
It is not safe for concurrent use; callers must hold the same lock they hold when snapshotting the VTerm.
func (*SnapshotDoubleBuffer) MarkRowStale ¶ added in v0.0.20
func (d *SnapshotDoubleBuffer) MarkRowStale(y int)
MarkRowStale records that row y of the most recently handed-out snapshot was mutated in place after creation (e.g. chat cursor sanitization), so the next snapshot into that buffer must re-copy the row even if vterm dirty tracking says it is clean. A nil stale mask already means "fully stale" and needs no marking.
func (*SnapshotDoubleBuffer) Reset ¶ added in v0.0.20
func (d *SnapshotDoubleBuffer) Reset()
Reset discards both buffers and all stale-row tracking.
func (*SnapshotDoubleBuffer) Snapshot ¶ added in v0.0.20
func (d *SnapshotDoubleBuffer) Snapshot(term *vterm.VTerm, showCursor bool) *VTermSnapshot
Snapshot returns a current terminal snapshot without mutating the snapshot returned by the previous call.
type StringDrawable ¶
type StringDrawable struct {
// contains filtered or unexported fields
}
StringDrawable wraps a styled ANSI string to implement uv.Drawable. This allows string-based content to be composed onto a lipgloss.Canvas.
func NewStringDrawable ¶
func NewStringDrawable(content string, x, y int) *StringDrawable
NewStringDrawable creates a drawable from a styled string at the given position.
ANSI decoding (SGR styling + grapheme segmentation) happens once here rather than on every Draw call, since content is immutable per instance and drawableCache/borderCache reuse the same *StringDrawable across frames for byte-identical content.
type VTermLayer ¶
type VTermLayer struct {
Snap *VTermSnapshot
}
VTermLayer implements tea.Layer for direct cell-based rendering of a VTerm snapshot. This uses a snapshot to avoid data races - the snapshot is created while holding the VTerm lock, and rendering happens without any locks.
func NewVTermLayer ¶
func NewVTermLayer(snap *VTermSnapshot) *VTermLayer
NewVTermLayer creates a new layer from a VTerm snapshot.
type VTermSnapshot ¶
type VTermSnapshot struct {
Screen [][]vterm.Cell
DirtyLines []bool
AllDirty bool
CursorX int
CursorY int
ViewOffset int
CursorHidden bool
ShowCursor bool
// SuppressBlink strips the SGR blink attribute at draw time (chat tabs
// suppress assistant blink flicker without mutating snapshot rows).
SuppressBlink bool
Width int
Height int
// Selection state (used during rendering)
SelActive bool
SelStartX, SelStartY int
SelEndX, SelEndY int
}
func NewVTermSnapshot ¶
func NewVTermSnapshot(term *vterm.VTerm, showCursor bool) *VTermSnapshot
NewVTermSnapshot creates a snapshot from a VTerm. MUST be called while holding the appropriate lock on the VTerm.
func NewVTermSnapshotWithCache ¶
func NewVTermSnapshotWithCache(term *vterm.VTerm, showCursor bool, prev *VTermSnapshot) *VTermSnapshot
NewVTermSnapshotWithCache creates a snapshot from a VTerm, optionally reusing lines from a previous snapshot when dirty line tracking allows. MUST be called while holding the appropriate lock on the VTerm.