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 ¶
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.
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 ¶
Box is a rectangle of styled lines at a screen position. Every line has the same display width.
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.
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 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 is where the caret is; a negative x hides it, while no
// field of the overlay is being typed in.
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.