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 ¶
- type Model
- func (m *Model) ApplyMedia(cfg config.MediaConfig)
- func (m *Model) Close() string
- func (m *Model) Fail(reason string)
- func (m Model) IsVisible() bool
- func (m *Model) Open(caption, status string)
- func (m *Model) PendingTeardown() string
- func (m *Model) SetSize(width, height int)
- func (m *Model) Show(path string)
- func (m Model) View() string
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 (*Model) ApplyMedia ¶
func (m *Model) ApplyMedia(cfg config.MediaConfig)
ApplyMedia takes the media config: which protocol to draw with.
func (*Model) Close ¶
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 ¶
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) Open ¶
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 ¶
PendingTeardown is Close's sequence for a host that renders before its next Update — it drains, so a second call returns "".
func (*Model) SetSize ¶
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.