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 ¶
- Variables
- func CleanupClosed(ctx context.Context, root string, current TerminalSession, ...) error
- func FindFontGallery(ctx context.Context, root, postScript string) (string, error)
- type DisplayFont
- type Gallery
- func (g *Gallery) BindTTY(ctx context.Context, tty string) error
- func (g *Gallery) CheckTTY(ctx context.Context, tty string) error
- func (g *Gallery) Close() error
- func (g *Gallery) Commit(ctx context.Context, revision *Revision) error
- func (g *Gallery) FontForTypography(ctx context.Context, revision *Revision, source imagefont.PreserveOptions, ...) (TypographyFont, error)
- func (g *Gallery) Initialize(ctx context.Context) (*Revision, error)
- func (g *Gallery) LookupFontPS(ctx context.Context, postScript string) (string, error)
- func (g *Gallery) MarkRegistering(ctx context.Context, revision *Revision) error
- func (g *Gallery) Prepare(ctx context.Context, img image.Image, columns int) (*Revision, error)
- func (g *Gallery) PreparePreservingWithLimit(ctx context.Context, img image.Image, columns, glyphLimit int) (*Revision, error)
- func (g *Gallery) PrepareWithLimit(ctx context.Context, img image.Image, columns, glyphLimit int) (*Revision, error)
- func (g *Gallery) State() State
- type Revision
- type State
- type TerminalSession
- type TypographyFont
Constants ¶
This section is empty.
Variables ¶
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") )
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.
Types ¶
type DisplayFont ¶
DisplayFont is an immutable rendering of a prepared revision for one text face and cell geometry. Commit the revision after successful activation.
type Gallery ¶
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 (*Gallery) BindTTY ¶
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
CheckTTY reads ownership without binding unowned legacy galleries.
func (*Gallery) Commit ¶
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 ¶
Initialize prepares the gallery identity without changing committed metadata.
func (*Gallery) LookupFontPS ¶
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 ¶
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 ¶
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.
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 ¶
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.