mediaview

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package mediaview is the full-pane image overlay: the thing `enter` opens on a photo, and `esc` closes again.

It draws over the whole frame rather than inside the thread column, for the reason the design record gives — a photo shown at thread width is not shown, it is acknowledged — and it draws into the alternate screen the app already owns, so nothing it puts on the screen reaches the scrollback the user gets back on exit.

Nothing is emitted before an open

The overlay renders no graphics sequence of any kind until Model.Show has been given a decoded file, and Show only runs after the key that asked for it. That is phase 8's exit criterion in the design record, and TestNoGraphicsBeforeAnOpen is what holds it: with `ui.inline_images` at its default a user who never presses enter never has an image protocol sequence written to their terminal by this component.

Cleaning up after a kitty image

Sixel and half-block art are cell contents: the next frame overwrites them. A kitty image is not — it belongs to the terminal and outlives any number of text redraws, so closing the overlay has to say so explicitly. Model.Close returns the sequence that removes exactly this image, which the host emits on its next frame. Deleting by id matters: kitty reads a bare delete as "every placement on screen", which would take the thread's inline art with it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

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

Model is the overlay.

func New

func New(roles theme.Roles) Model

func (*Model) ApplyMedia

func (m *Model) ApplyMedia(cfg config.MediaConfig)

ApplyMedia takes the media config: which protocol to draw with.

func (*Model) Close

func (m *Model) Close() string

Close hides the overlay and returns the sequence the host must emit on its next frame to remove any image the terminal is holding.

The sequence is returned rather than written, because this component has no output of its own: everything it draws goes through the host's View, and a component writing to stdout beside the renderer is how a frame gets torn in half.

func (*Model) Fail

func (m *Model) Fail(reason string)

Fail replaces the overlay's contents with a reason. The overlay stays up: the user asked for this photo, and closing the window they just opened is not an answer to "it did not download".

func (Model) IsVisible

func (m Model) IsVisible() bool

IsVisible reports whether the overlay owns the screen.

func (*Model) Open

func (m *Model) Open(caption, status string)

Open shows the overlay with a status line and no art yet. The caller starts the download; Model.Show finishes the job.

func (*Model) PendingTeardown

func (m *Model) PendingTeardown() string

PendingTeardown is Close's sequence for a host that renders before its next Update — it drains, so a second call returns "".

func (*Model) SetHints added in v0.0.14

func (m *Model) SetHints(hints []hintbar.Hint)

SetHints supplies the row this overlay draws along its foot. The app owns it: the strings come from the one hint registry (decision I-6), so a rebound key shows correctly and a literal cannot drift out of step with what the overlay actually honours.

func (*Model) SetSize

func (m *Model) SetSize(width, height int)

SetSize sets the overlay to the whole frame.

The renderer is rebuilt on every resize rather than being told the new bounds, because an image already rendered at the old size cannot be re-fitted — it is a grid of cells or a blob of pixels by then, not a picture. Anything on screen is dropped for the same reason; the host re-shows it.

func (*Model) Show

func (m *Model) Show(path string)

Show renders a downloaded file into the overlay.

An error is kept as the status rather than returned: by the time this runs the overlay is already on screen, and the reader needs to be told why it is empty inside the thing they opened, not in a notice behind it.

func (Model) View

func (m Model) View() string

View draws the overlay at exactly the frame size.

Jump to

Keyboard shortcuts

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