render

package
v2.14.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package render converts the fixed 80x24 canvas.Grid into the styled, ANSI- encoded strings the bubbletea front door renders. bubbletea's renderer owns the wire — the per-frame diffing and writing — while this package provides the full-frame Grid→ANSI encoder (GridToANSI), the letterbox and undersized-resize interstitial composers (Letterbox / Undersized), the per-session SGR color downgrade (sgr.go), and the non-UTF8 ASCII glyph fallback (asciiFallback).

The former custom cell-diff "renderer of record" was retired when the front door moved to bubbletea; see the bubbletea-frontdoor OpenSpec change.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GridToANSI

func GridToANSI(g canvas.Grid, caps session.Caps) string

GridToANSI renders g as 24 rows of SGR-styled glyphs separated by "\n", with NO cursor positioning. Each row emits a full SGR for its first cell, re-emits SGR only when the style changes, and ends with an SGR reset so rows compose cleanly into a larger frame. Colors are downgraded to caps.ColorDepth; non-ASCII runes degrade to ASCII when caps.UTF8 is false. Every row is exactly canvas.Cols visible columns wide (one glyph per cell; continuation cells emit nothing).

This is the full-frame, diff-free encoder used by the bubbletea front door: the model converts the active grid to this string for View(), and bubbletea's renderer owns the wire diffing.

func Letterbox

func Letterbox(body string, termCols, termRows int, depth session.ColorDepth) string

Letterbox centers an 80×24 body (as produced by GridToANSI — exactly canvas.Cols visible columns per row) within a termCols×termRows terminal, drawing a dim border in the surrounding margin. When the terminal is not larger than the canvas in either dimension, the body is returned unchanged (the undersized case is handled separately by Undersized). The result is termRows newline-separated lines so it can be the whole View() output.

func Undersized

func Undersized(termCols, termRows int) string

Undersized renders the centered "please resize" interstitial that replaces the active screen when the terminal is smaller than 80×24, matching the wording the retired renderer used. The result is termRows newline-separated lines.

Types

This section is empty.

Jump to

Keyboard shortcuts

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