gfx

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 20 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gfx shows pixel images over terminal cells through the graphics protocol a terminal is verified to draw

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Placeholder

func Placeholder(c *uv.Cell) bool

Reports whether a cell is a kitty placeholder, which keeps its colors as they name the image

func Sweep

func Sweep()

Removes every shared memory object this process left behind

Types

type Packet

type Packet struct {
	// contains filtered or unexported fields
}

Opaque packed frame

type Protocol

type Protocol int

Way a terminal takes an image

const (
	None Protocol = iota
	KittyCells
	KittyPlaced
	Sixel
	ITerm
)

func (Protocol) String

func (p Protocol) String() string

Name of the protocol as settings and status lines show it

type Stats

type Stats struct {
	Latency  time.Duration
	Divisor  float64
	Frames   int
	Acked    int
	Timeouts int
	Failed   int
}

Numbers for a status line

type Surface

type Surface struct {
	// contains filtered or unexported fields
}

Image shown over a box of cells, frame after frame, by one protocol

func (*Surface) Budget

func (s *Surface) Budget(cols, rows int) (w, h int)

Pixels across and down the next frame should be rendered at for a box of cols by rows cells

func (*Surface) Emit

func (s *Surface) Emit(p *Packet, x, y int, now time.Time) string

Escape text that shows a packet with the top left cell of its box at screen cell x, y

func (*Surface) Encoded

func (s *Surface) Encoded(seq []byte, cols, rows int) *Packet

Packet of a sixel or iTerm2 sequence encoded elsewhere, drawn from the top left cell of a box of cells

func (*Surface) Pack

func (s *Surface) Pack(rgb []byte, w, h, cols, rows int) *Packet

Packs a frame of three byte pixels for a box of cells, nil without a protocol or whole pixels

func (*Surface) Paint

func (s *Surface) Paint(buf *uv.Buffer, x, y, cols, rows int, bg color.Color)

Fills the cells of the box as the image needs them under it

func (*Surface) Protocol

func (s *Surface) Protocol() Protocol

Way the surface draws its images

func (*Surface) Ready

func (s *Surface) Ready(now time.Time) bool

Whether a new frame may be emitted now

func (*Surface) Release

func (s *Surface) Release() string

Escape text that removes every image of the surface from the terminal, and forgets the inflight state

func (*Surface) SetRate

func (s *Surface) SetRate(fps int)

Frames per second the surface is asked to keep up with, clamped to what the protocol takes

func (*Surface) Stats

func (s *Surface) Stats() Stats

Numbers for a status line

type Terminal

type Terminal struct {
	// contains filtered or unexported fields
}

Terminal as named by the environment and as it answered the probe

func New

func New() *Terminal

Terminal read from the process environment

func NewWith

func NewWith(getenv func(string) string) *Terminal

Terminal read from an environment lookup, for tests

func (*Terminal) Cell

func (t *Terminal) Cell() (w, h int)

Pixels across and down one cell, measured or assumed

func (*Terminal) Describe

func (t *Terminal) Describe() string

One line of what was found, for a status line

func (*Terminal) Draws

func (t *Terminal) Draws(p Protocol) bool

Reports whether the terminal has been verified to draw the protocol

func (*Terminal) Guess

func (t *Terminal) Guess() Protocol

Best protocol worth trying when the person forces images, the verified one else iTerm2 where it is plausible

func (*Terminal) Measure

func (t *Terminal) Measure() tea.Cmd

Cell and pixel size queries again, after a resize

func (*Terminal) Measured

func (t *Terminal) Measured() bool

Reports whether the cell size came from the terminal rather than the assumption

func (*Terminal) NewSurface

func (t *Terminal) NewSurface(p Protocol) *Surface

Surface drawing through the given protocol, which must be one the terminal returned from Protocol or Guess

func (*Terminal) Probe

func (t *Terminal) Probe() tea.Cmd

Queries worth sending at start, nil when none is

func (*Terminal) Program

func (t *Terminal) Program() string

Identity of the terminal, a known name or the lower cased TERM

func (*Terminal) Protocol

func (t *Terminal) Protocol() Protocol

Best protocol the terminal has been verified to draw, None when none is

func (*Terminal) Tmux

func (t *Terminal) Tmux() bool

Reports whether the terminal multiplexer wraps the session

func (*Terminal) Update

func (t *Terminal) Update(msg tea.Msg) bool

Takes a terminal answer, reporting whether anything changed that a card should repaint for

func (*Terminal) Wrap

func (t *Terminal) Wrap(seq string) string

Sequence wrapped for tmux to pass to the terminal under it, unchanged outside tmux

Jump to

Keyboard shortcuts

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