panemodal

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package panemodal renders a modal inside an arbitrary rectangular box rather than over the whole screen, and puts the modal's mouse hit regions where the box actually is on screen.

A modal.Modal renders and registers its hit regions against the surface it is handed: coordinates run from (0,0) of that surface. Handed a pane, the modal has no idea the pane starts partway down the screen, so every region it registers is wrong by the pane's origin. Render fixes that by translating the regions the modal just registered by the box origin.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(m *modal.Modal, box Box, background string, handler *mouse.Handler) string

Render draws m inside box on top of background (the pane's own content, rendered at box.W x box.H) and registers m's hit regions at their true screen positions. The result is exactly box.H lines of exactly box.W cells, ready to blit at (box.X, box.Y).

When the box is roomy the modal is centred in it with the pane's content dimmed around it. When the box is tight (see dimMarginX/dimMarginY) the modal fills the box and the pane's content is not shown at all.

handler may be nil, in which case no regions are registered. Note that modal.Modal.Render clears the handler's hit map, so the modal's regions are the only ones in it afterwards — anything the pane registered before this call is gone, exactly as it is for a full-screen modal.

func RenderFunc

func RenderFunc(box Box, background string, handler *mouse.Handler, draw Draw) string

RenderFunc is Render for anything that draws itself into a given size and registers its hit regions on a handler — a modal.Modal, a filefind.Finder, a projectsearch.Search. draw is called with the box's own dimensions and with handler; whatever regions it registers are then translated by the box origin, so a surface that knows only its own coordinates still lands where it is drawn.

The compositing rules are Render's: a surface sized to its own content, centred with the pane dimmed around it, when the box has room for a readable margin; otherwise a second pass with fill set, which asks the surface to take the whole box, and no pane content behind it. The two passes are why draw must be cheap and free of side effects beyond its own layout — it may be called twice for one frame. The result is always exactly box.H lines of exactly box.W cells.

handler may be nil, in which case draw is called with nil and registers nothing. A surface that clears the handler (modal.Modal does) leaves the pane's earlier regions gone, exactly as a full-screen modal does; a surface that only adds to it leaves them in place, so hosts that care about ordering hand RenderFunc a scratch handler and merge its regions themselves.

Types

type Box

type Box struct {
	X, Y, W, H int
}

Box is a rectangle in screen coordinates: the pane the modal is drawn into. The field names mirror the workspace pane layout's Box.

type Draw

type Draw func(width, height int, fill bool, h *mouse.Handler) string

Draw renders a surface into a box of the given size and registers its hit regions on h (which may be nil). fill asks the surface to *be* the box — exactly width by height, no margin — rather than to size itself to its own content; see RenderFunc for when it is set.

Jump to

Keyboard shortcuts

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