backend

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ASCII

type ASCII struct {
}

ASCII renders an image as ANSI-styled ASCII characters. It works in terminals that do not implement a graphical image protocol.

func NewASCII

func NewASCII() *ASCII

func (*ASCII) Clear

func (*ASCII) Clear(area Area) string

Clear erases only the previous text-art rectangle, preserving the reader header and Bubble Tea's alternate-screen layout.

func (*ASCII) Name

func (*ASCII) Name() string

func (*ASCII) Render

func (*ASCII) Render(img image.Image, area Area) (string, error)

type Area

type Area struct {
	X, Y       int
	Cols, Rows int
}

Area is a 1-based terminal rectangle measured in character cells.

type CellSizeRenderer added in v1.2.0

type CellSizeRenderer interface {
	SetCellSize(width, height int)
	CellAspect() float64
}

CellSizeRenderer uses the terminal's pixel dimensions for a character cell. Sixel rasters are sized in pixels, so they need this information to match a layout expressed in character cells.

type Dots

type Dots struct{}

Dots renders images as ANSI-colored Unicode Braille characters. Each terminal cell represents a 2 by 4 pixel block, providing more detail than ASCII art while requiring no graphics protocol.

func NewDots

func NewDots() *Dots

func (*Dots) Clear

func (*Dots) Clear(area Area) string

Clear erases the terminal cells occupied by the prior Braille rendering.

func (*Dots) Name

func (*Dots) Name() string

func (*Dots) Render

func (*Dots) Render(img image.Image, area Area) (string, error)

type Iterm

type Iterm struct{}

Iterm renders images with the iTerm2 inline image protocol.

func NewIterm

func NewIterm() *Iterm

func (*Iterm) Clear

func (*Iterm) Clear(area Area) string

Clear removes inline images with an erase-display command. The iTerm2 image protocol has no command for deleting one placed image; erasing individual cells does not remove it. The TUI redraws its text layer immediately after this command when a page is replaced.

func (*Iterm) Name

func (*Iterm) Name() string

func (*Iterm) Render

func (*Iterm) Render(img image.Image, area Area) (string, error)

type Kitty

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

Kitty renders images with the Kitty graphics protocol.

func NewKitty

func NewKitty() *Kitty

func (*Kitty) Clear

func (k *Kitty) Clear(Area) string

func (*Kitty) Name

func (*Kitty) Name() string

func (*Kitty) Render

func (k *Kitty) Render(img image.Image, area Area) (string, error)

type Renderer

type Renderer interface {
	Name() string
	Render(image.Image, Area) (string, error)
	Clear(Area) string
}

Renderer converts an image into terminal protocol escape sequences. It never writes to stdout: Bubble Tea remains the sole output owner.

func NewRenderer

func NewRenderer(protocol string) (Renderer, error)

NewRenderer returns the requested renderer. The auto setting keeps Kitty as the default and selects iTerm2 or Sixel when the terminal identifies itself as supporting one of those protocols.

type Sixel

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

Sixel renders images with the DEC Sixel graphics protocol.

func NewSixel

func NewSixel() *Sixel

func (*Sixel) CellAspect added in v1.2.0

func (s *Sixel) CellAspect() float64

func (*Sixel) Clear

func (s *Sixel) Clear(area Area) string

Clear replaces the prior image rectangle with the terminal background, preserving the header and footer Bubble Tea draws in the alternate screen.

func (*Sixel) Name

func (*Sixel) Name() string

func (*Sixel) Render

func (s *Sixel) Render(img image.Image, area Area) (string, error)

func (*Sixel) RenderSpread

func (s *Sixel) RenderSpread(images []image.Image, areas []Area) (string, error)

RenderSpread draws a book spread as one raster. Some Sixel terminals do not preserve horizontal cursor placement between consecutive sixel commands, so emitting a single raster prevents the second page from covering the first.

func (*Sixel) SetCellSize added in v1.2.0

func (s *Sixel) SetCellSize(width, height int)

SetCellSize updates the pixel dimensions used to translate character-cell layout coordinates into a Sixel raster. Invalid measurements keep the last known dimensions.

type SpreadRenderer

type SpreadRenderer interface {
	RenderSpread([]image.Image, []Area) (string, error)
}

SpreadRenderer can draw several images in one protocol command. Backends that do not implement it receive each page through Renderer.Render instead.

Jump to

Keyboard shortcuts

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