overlay

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package overlay is the contract between the UI's root model and the components that take over input while open: menus, pickers, bars on the context line and dialogs. It holds what they share (the boxes they draw, the mouse events they get, a scrolling list) and nothing of the model, so a component can live in a package of its own and be tested alone. Each component is built with the small host interface it acts on; the model implements those.

Index

Constants

View Source
const (
	MenuLine    = 0 // the menu bar; dropdowns and pickers open under it
	ContextLine = 2 // prompts and bars; completions open under it
)

The control panel's rows that overlays anchor to.

View Source
const SearchPrompt = " › "

SearchPrompt starts a search field, in pickers and bars.

Variables

This section is empty.

Functions

func KeyFor

func KeyFor(s string) tea.KeyPressMsg

KeyFor makes a key press from a keystroke like "alt+c", for chips that stand for a key when clicked.

Types

type Box

type Box struct {
	ID    string // identifies the box in mouse hit tests
	X, Y  int
	Lines []string
}

Box is a rectangle of styled lines at a screen position. Every line has the same display width.

func (Box) Height

func (b Box) Height() int

func (Box) Width

func (b Box) Width() int

type Liner

type Liner interface {
	ContextLine() (left, right string)
}

Liner is an overlay drawn on the context line, such as the find bar.

type List

type List struct {
	Sel, Top int
}

List is the highlighted row and scroll position of a list in a box.

func (*List) Move

func (l *List) Move(d, n int)

Move highlights the row d steps away, wrapping around the ends.

func (*List) Show

func (l *List) Show(rows int)

Show scrolls so the highlighted row is among the visible rows.

type MouseEvent

type MouseEvent struct {
	Kind     MouseKind
	Button   tea.MouseButton
	X, Y     int
	Box      string // ID of the topmost box under the mouse, "" for none
	Col, Row int    // position inside that box
}

MouseEvent is a mouse event with what's under it already worked out.

type MouseKind

type MouseKind int

MouseKind is what a mouse event is.

const (
	MousePress MouseKind = iota
	MouseMotion
	MouseRelease
	MouseWheel
)

type Overlay

type Overlay interface {
	// Indicator is the mode shown at the top right, e.g. "MENU".
	Indicator() string
	// Layout places the overlay's boxes on the screen, bottom first.
	Layout() []Box
	Key(k tea.KeyPressMsg) tea.Cmd
	Mouse(e MouseEvent) tea.Cmd
	// Status is what the status line says while the overlay is open: what
	// the highlighted item does, and the keys that apply.
	Status() (desc, keys string)
}

Overlay is a floating box drawn over the grid: a dropdown or context menu, the command palette or a dialog. While one is open it takes every key and mouse event, and Esc closes one level. Overlays are composited on top of the finished screen, so the grid underneath never moves.

type Text

type Text interface {
	Overlay
	Cursor() (x, y int)
	Changed() // the text changed
}

Text is an overlay with a text input, which gets the terminal cursor. The text is edited in the model's shared edit line, like any other entry.

Jump to

Keyboard shortcuts

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