compositor

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FastHash

func FastHash(s string) uint64

FastHash computes a FNV-1a hash for cache invalidation benchmarks.

func HexColor

func HexColor(hex string) vterm.Color

HexColor converts a #RRGGBB string to a vterm.Color.

func RenderTerminal

func RenderTerminal(term *vterm.VTerm, width, height int, showCursor bool, fg, bg vterm.Color) string

RenderTerminal renders a vterm into a canvas and returns the ANSI string.

func RenderTerminalWithCanvas

func RenderTerminalWithCanvas(canvas *Canvas, term *vterm.VTerm, width, height int, showCursor bool, fg, bg vterm.Color) string

RenderTerminalWithCanvas renders a vterm 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 NewCanvas

func NewCanvas(width, height int) *Canvas

NewCanvas creates a new canvas filled with blank cells.

func (*Canvas) DrawBorder

func (c *Canvas) DrawBorder(x, y, w, h int, style vterm.Style, focused bool)

DrawBorder draws a single or double line border.

func (*Canvas) DrawScreen

func (c *Canvas) DrawScreen(x, y, w, h int, screen [][]vterm.Cell, cursorX, cursorY int, showCursor bool, viewOffset int, selActive bool, selStartX, selStartY, selEndX, selEndY int)

DrawScreen draws a vterm screen into the canvas with clipping.

func (*Canvas) DrawText

func (c *Canvas) DrawText(x, y int, text string, style vterm.Style)

DrawText draws a string starting at the given position.

func (*Canvas) Fill

func (c *Canvas) Fill(style vterm.Style)

Fill sets the entire canvas to the given style.

func (*Canvas) Render

func (c *Canvas) Render() string

Render converts the canvas to an ANSI string.

func (*Canvas) Resize

func (c *Canvas) Resize(width, height int)

Resize resets the canvas dimensions when the size changes.

func (*Canvas) SetCell

func (c *Canvas) SetCell(x, y int, cell vterm.Cell)

SetCell sets a cell if within bounds.

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) Invalidate

func (c *ChromeCache) Invalidate()

Invalidate clears the cache.

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 PositionedVTermLayer

type PositionedVTermLayer struct {
	*VTermLayer
	PosX, PosY    int
	Width, Height int
}

PositionedVTermLayer wraps a VTermLayer with explicit positioning. This allows the layer to be positioned within a larger canvas.

func (*PositionedVTermLayer) Draw

func (l *PositionedVTermLayer) Draw(s uv.Screen, r uv.Rectangle)

Draw renders the VTerm snapshot at the specified position within the canvas.

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.

func (*StringDrawable) Draw

func (d *StringDrawable) Draw(screen uv.Screen, r uv.Rectangle)

Draw renders the string onto the screen buffer.

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.

func (*VTermLayer) Draw

func (l *VTermLayer) Draw(s uv.Screen, r uv.Rectangle)

Draw renders the VTerm snapshot directly to the screen buffer. This is the hot path - every optimization here matters.

func (*VTermLayer) DrawAt

func (l *VTermLayer) DrawAt(s uv.Screen, posX, posY, maxWidth, maxHeight int)

DrawAt renders the VTerm snapshot at a specific position with given dimensions. This is the core rendering logic shared by VTermLayer and PositionedVTermLayer.

type VTermSnapshot

type VTermSnapshot struct {
	Screen       [][]vterm.Cell
	DirtyLines   []bool
	AllDirty     bool
	CursorX      int
	CursorY      int
	ViewOffset   int
	CursorHidden bool
	ShowCursor   bool
	Width        int
	Height       int
	// Selection state (used during rendering)
	SelActive            bool
	SelStartX, SelStartY int
	SelEndX, SelEndY     int
}

VTermSnapshot captures the state needed to render a VTerm. This is created while holding Tab.mu and can be safely used for rendering without holding any locks, avoiding data races with PTY output.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL