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

imagegallery

package
v1.35.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 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 (
	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 to start a new image gallery")
)
View Source
var ErrPending = errors.New("a previous sharp preview may still be registered; retry that saved image with the same font settings or open a new Terminal tab")

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.

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) 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) 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