Help us shape the future of Go! Take the 2026 Go Developer Survey

imagegallery

package
v1.42.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package imagegallery stores private revision metadata and immutable typography fonts for terminal image scrollback. It never registers fonts or controls the terminal.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOtherTTY = errors.New("image gallery belongs to another Terminal tab")
	ErrBusy     = errors.New("image gallery is already in use; finish the other image command first")
	ErrFull     = errors.New("image gallery is full. Open a new Terminal tab with your normal text font to start another gallery")
)
View Source
var ErrPending = errors.New("a previous sharp preview may still be registered; retry that saved image with the same font settings. Alternatively, open a new Terminal tab with your normal text font")

Functions

func CleanupClosed

func CleanupClosed(ctx context.Context, root string, current TerminalSession, inventory func(context.Context) (liveTTYs, liveFonts []string, err error), unregister func(context.Context, string) error) error

CleanupClosed reclaims galleries only after inventory returns a complete, successful list of Terminal tabs while the gallery lock is held. A live owner or a live tab selecting any gallery font preserves its scrollback artifacts. Busy, unowned, or malformed galleries are left alone. The stable lock inode and its containing directory remain to avoid racing another Open operation.

func FindFontGallery added in v1.40.3

func FindFontGallery(ctx context.Context, root, postScript string) (string, error)

FindFontGallery locates the exact selected immutable font, including legacy root galleries. It does not transfer TTY ownership or change native state.

Types

type DisplayFont

type DisplayFont struct {
	FontPath, PostScript string
	Existing             bool
}

DisplayFont is an immutable rendering of a prepared revision for one text face and cell geometry. Commit the revision after successful activation.

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

Gallery holds an exclusive filesystem lock until Close. It is not safe for concurrent method calls. The caller must close it on every exit path.

func Open

func Open(ctx context.Context, directory string) (*Gallery, error)

func (*Gallery) BindTTY

func (g *Gallery) BindTTY(ctx context.Context, tty string) error

BindTTY records the tab that owns these immutable scrollback artifacts. The gallery lock makes ownership recording and font activation indivisible with respect to cleanup. Older galleries acquire ownership on their next use.

func (*Gallery) CheckTTY added in v1.40.3

func (g *Gallery) CheckTTY(ctx context.Context, tty string) error

CheckTTY reads ownership without binding unowned legacy galleries.

func (*Gallery) Close

func (g *Gallery) Close() error

func (*Gallery) Commit

func (g *Gallery) Commit(ctx context.Context, revision *Revision) error

Commit atomically publishes a prepared revision after successful activation.

func (*Gallery) FontForTypography

func (g *Gallery) FontForTypography(ctx context.Context, revision *Revision, source imagefont.PreserveOptions, companions ...imagefont.PreserveOptions) (TypographyFont, error)

func (*Gallery) Initialize

func (g *Gallery) Initialize(ctx context.Context) (*Revision, error)

Initialize prepares the gallery identity without changing committed metadata.

func (*Gallery) LookupFontPS

func (g *Gallery) LookupFontPS(ctx context.Context, postScript string) (string, error)

LookupFontPS resolves a selected gallery font to its immutable private file. It lets callers restore login-session registration before asking CoreText for that font's lineage. Ordinary fonts and other galleries return no path. It does not inspect installed fonts, register anything, or change metadata.

func (*Gallery) MarkRegistering

func (g *Gallery) MarkRegistering(ctx context.Context, revision *Revision) error

MarkRegistering must precede the first native registration for this revision. A failed reply can still leave a registered or active font, so later requests must retain this exact attempt until its successful commit.

func (*Gallery) Prepare

func (g *Gallery) Prepare(ctx context.Context, img image.Image, columns int) (*Revision, error)

Prepare caches a reduced PNG and allocates an immutable image placement. Existing placements retain their codepoints. Showing the same image at a different width allocates a new placement while reusing its cached PNG. The source image is not modified.

func (*Gallery) PreparePreservingWithLimit added in v1.40.3

func (g *Gallery) PreparePreservingWithLimit(ctx context.Context, img image.Image, columns, glyphLimit int) (*Revision, error)

PreparePreservingWithLimit uses the preserved font's measured Plane-15 capacity. Version 2 retains the same logical offsets; only FontForTypography emits them.

func (*Gallery) PrepareWithLimit added in v1.28.0

func (g *Gallery) PrepareWithLimit(ctx context.Context, img image.Image, columns, glyphLimit int) (*Revision, error)

PrepareWithLimit retains room for later images by limiting new allocations. Replaying an existing placement consumes no capacity and remains permitted. The limit is checked under the gallery lock before writing any new artifacts.

func (*Gallery) State

func (g *Gallery) State() State

type Revision

type Revision struct {
	Text          string
	Columns, Rows int
	Existing      bool
	// contains filtered or unexported fields
}

Revision allocates immutable image characters without generating a font. Commit it after its typography fonts are registered and activated.

type State

type State struct {
	Initialized                                  bool
	ID, ProfileName                              string
	Revision, ImageCount, UsedGlyphs, MaxColumns int
}

State is a copy of the currently committed gallery metadata.

type TerminalSession

type TerminalSession struct {
	Directory string
	TTY       string
}

TerminalSession identifies the current renderer's session-hashed directory. Terminal can reuse a TTY after a tab closes, so a TTY alone is not its identity.

type TypographyFont

type TypographyFont struct {
	DisplayFont
	Text    string
	Related []DisplayFont
}

TypographyFont keeps the gallery's immutable image assignments while using a local copy of the caller's text face. Plane-15 image characters leave the original font's BMP private-use icons available to shell prompts.

Jump to

Keyboard shortcuts

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