graphics

package
v0.0.0-...-936c5c3 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package graphics serializes Kitty image commands with Bubble Tea's frame writes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Eligible

func Eligible() bool

func Fit

func Fit(img *mermaid.Image, width, height int, cellW, cellH float64) (int, int)

Fit preserves aspect ratio in physical pixels, not square character cells.

func FitInline

func FitInline(img *mermaid.Image, width int, cellW, cellH float64) (int, int)

FitInline shrinks diagrams to the available width without magnifying small charts. Mermaid's 2x raster is for sharpness; its natural display size is half its PNG dimensions. The dedicated viewer still fits the whole available area.

Types

type Capability

type Capability struct{ CellWidth, CellHeight float64 }

func CellSize

func CellSize(fallback Capability) Capability

CellSize uses the current terminal pixels on resize, including font changes.

func Probe

func Probe() (Capability, bool)

Probe runs before Bubble Tea owns input. A bounded, positive graphics/version/ cell-size handshake is required; environment variables alone are insufficient.

type Writer

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

func NewWriter

func NewWriter(out io.Writer) *Writer

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) Fd

func (w *Writer) Fd() uintptr

Fd preserves Bubble Tea's terminal sizing and raw-mode detection.

func (*Writer) ID

func (w *Writer) ID(img *mermaid.Image) int

func (*Writer) Read

func (w *Writer) Read(p []byte) (int, error)

func (*Writer) Row

func (w *Writer) Row(id int, img *mermaid.Image, cols, rows, row, from, to int) string

Row uses 256-cell tiles so every coordinate has a representable diacritic, including very tall diagrams and zoomed views. All cells encode all 3 values.

func (*Writer) Use

func (w *Writer) Use(images []*mermaid.Image)

Use drops image data no longer used by the current document. Actual terminal deletion happens on the output goroutine, never concurrently with a frame.

func (*Writer) Write

func (w *Writer) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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