blit

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package blit renders Lip Gloss-styled ANSI strings into a tcell screen.

Lip Gloss produces strings carrying in-band SGR escape sequences; tcell owns a grid of individually styled cells. The two do not compose directly. This package bridges them: it decodes a styled string into grapheme clusters plus a running style, and writes each cluster into the destination screen as a tcell cell.

Decoding is delegated to github.com/charmbracelet/x/ansi, which arrives as a Lip Gloss dependency, and SGR interpretation to github.com/charmbracelet/x/cellbuf. Both use rivo/uniseg for grapheme segmentation, as does tcell itself, so all three agree on how many cells a cluster occupies. That agreement is what makes this bridge safe for emoji and CJK text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Draw

func Draw(scr tcell.Screen, x, y, w, h int, s string)

Draw renders a Lip Gloss-styled string into scr with its top-left corner at (x, y), clipped to a w by h cell rectangle. Content extending past the rectangle is dropped, not wrapped: callers are expected to have laid the string out already.

Newlines advance a row and return to the left edge of the rectangle; carriage returns return to the left edge alone. Escape sequences other than SGR are consumed and ignored, so unsupported terminal control cannot corrupt the grid.

func Size

func Size(s string) (w, h int)

Size reports the cell dimensions a styled string occupies: the width of its widest line and its line count. It decodes via the same path as Draw, so the two cannot disagree about how much room a string needs.

func SyncLipglossProfile

func SyncLipglossProfile(scr tcell.Screen)

SyncLipglossProfile points Lip Gloss at the terminal tcell actually opened.

Lip Gloss decides how much colour to emit by probing os.Stdout. That probe is wrong for us in both directions: tcell owns the terminal, so stdout tells us nothing useful, and if stdout is ever redirected Lip Gloss silently renders every style with no colour at all. tcell has already done real terminfo negotiation, so its answer is the authoritative one.

Call this once after Screen.Init and again on a Screen that has been reinitialised. Without it, chrome can come out unstyled for reasons that look like a blitter bug and are not.

Types

This section is empty.

Jump to

Keyboard shortcuts

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