Documentation
¶
Index ¶
- func CellInModal(x, y, top, left, mw, mh int) bool
- func ClampMenuOrigin(modal string, viewW, viewH, anchorTop, anchorLeft int) (int, int)
- func ClampOverlayOrigin(modalW, modalH, viewW, viewH, top, left int) (int, int)
- func ClampOverlayOriginAtPoint(modal string, viewW, viewH, top, left int) (int, int)
- func DevStackDepthFooter(depth int, dev bool) string
- func DimSurface(s string, opacity float64) string
- func ModalCellSize(modal string) (w, h int)
- func OverlayView(mainView, modalView string, viewWidth, viewHeight, top, left int) string
- func OverlayViewAtPoint(mainView, modalView string, viewWidth, viewHeight, anchorTop, anchorLeft int) string
- func OverlayViewAtPointWithMask(mainView, modalView string, viewWidth, viewHeight, anchorTop, anchorLeft int, ...) string
- func OverlayViewAtPointWithTransparency(mainView, modalView string, viewWidth, viewHeight, anchorTop, anchorLeft int) string
- func OverlayViewInCenter(mainView, modalView string, viewWidth, viewHeight int) string
- func OverlayViewInCenterInMain(mainView, modalView string) string
- func OverlayViewInCenterWithMask(mainView, modalView string, viewWidth, viewHeight int, maskRune rune) string
- func OverlayViewInCenterWithOffset(mainView, modalView string, viewWidth, viewHeight, deltaTop, deltaLeft int) string
- func OverlayViewInCenterWithOffsetWithMask(mainView, modalView string, viewWidth, viewHeight, deltaTop, deltaLeft int, ...) string
- func OverlayViewInCenterWithOffsetWithTransparency(mainView, modalView string, viewWidth, viewHeight, deltaTop, deltaLeft int) string
- func OverlayViewInCenterWithTransparency(mainView, modalView string, viewWidth, viewHeight int) string
- func OverlayViewWithMask(mainView, modalView string, viewWidth, viewHeight, top, left int, ...) string
- func OverlayViewWithTransparency(mainView, modalView string, viewWidth, viewHeight, top, left int) string
- type FocusTrap
- type OverlayConfig
- type OverlayOnCloser
- type OverlayStack
- func (s *OverlayStack) Depth() int
- func (s *OverlayStack) MainReceivesKeyMsg() bool
- func (s *OverlayStack) MainReceivesMouseMsg() bool
- func (s *OverlayStack) Pop() (popped tea.Model, cmd tea.Cmd)
- func (s *OverlayStack) Push(m tea.Model, cfg OverlayConfig) tea.Cmd
- func (s *OverlayStack) StackDepth() int
- func (s *OverlayStack) Top() tea.Model
- func (s *OverlayStack) Update(msg tea.Msg) tea.Cmd
- func (s *OverlayStack) View(baseMain string, viewW, viewH int) string
- type Placement
- type PlacementKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CellInModal ¶
CellInModal reports whether terminal cell coordinates (x, y) fall inside the modal rectangle [left, left+mw) × [top, top+mh). Use coordinates after ClampOverlayOrigin / Placement.ClampedOrigin so hit-testing matches painted overlay geometry.
Bubble Tea v1 tea.MouseMsg uses zero-based X and Y for the terminal cell (column, row), matching top and left passed into OverlayView (also zero-based from the top-left of the view).
func ClampMenuOrigin ¶
ClampMenuOrigin is an alias for ClampOverlayOriginAtPoint: same implementation, for call sites that anchor a menu or popover at a cursor cell (typically tea.MouseMsg.Y as top, tea.MouseMsg.X as left).
func ClampOverlayOrigin ¶
ClampOverlayOrigin applies the same origin adjustment as OverlayView: if the modal rectangle would extend past the viewport edge, top and/or left are shifted so the rectangle fits; then negative coordinates are clamped to zero.
modalW and modalH must match how OverlayView measures that modal string (see ModalCellSize).
func ClampOverlayOriginAtPoint ¶
ClampOverlayOriginAtPoint runs ModalCellSize(modal) then ClampOverlayOrigin. Use for anchors such as a context menu at (top, left) (e.g. Bubble Tea mouse Y/X as row/column) so hit-testing with CellInModal matches OverlayView(modal, …, top, left).
func DevStackDepthFooter ¶
func DimSurface ¶
func ModalCellSize ¶
ModalCellSize returns display-cell width (max per line) and line count for a modal string, using the same rules as OverlayView when measuring the modal for placement and clamping.
func OverlayView ¶
OverlayView composites modalView on top of mainView. Only the rectangle at (top, left) with the modal's size is replaced; all other cells show the main view. Returns a single string with viewHeight lines, each viewWidth cells wide (padding/truncation as needed).
Main and modal strings may contain ANSI (e.g. from lipgloss); overlay uses display-cell width (grapheme-aware, matching lipgloss) so alignment is correct. After the modal, graphics state that originated under the modal is re-applied so background colors and other SGR attributes still apply to the visible tail of each line. A full SGR reset (and hyperlink reset) is inserted immediately before the modal so the main line’s active pen does not bleed into the first cells of the modal.
func OverlayViewAtPoint ¶
func OverlayViewAtPoint(mainView, modalView string, viewWidth, viewHeight, anchorTop, anchorLeft int) string
OverlayViewAtPoint composites modalView with its top-left anchored at (anchorTop, anchorLeft) after the same overflow clamp as OverlayView. Use Bubble Tea v1 mouse coordinates as anchorTop = msg.Y (row) and anchorLeft = msg.X (column).
func OverlayViewAtPointWithMask ¶
func OverlayViewAtPointWithMask(mainView, modalView string, viewWidth, viewHeight, anchorTop, anchorLeft int, maskRune rune) string
OverlayViewAtPointWithMask is like OverlayViewAtPoint but uses OverlayViewWithMask.
func OverlayViewAtPointWithTransparency ¶
func OverlayViewAtPointWithTransparency(mainView, modalView string, viewWidth, viewHeight, anchorTop, anchorLeft int) string
OverlayViewAtPointWithTransparency is like OverlayViewAtPoint but uses OverlayViewWithTransparency.
func OverlayViewInCenter ¶
OverlayViewInCenter centers modalView in a viewport of viewWidth×viewHeight and composites with OverlayView. The viewport may be the full terminal, a tab/content region, or any rectangle you pass to OverlayView—this is the general “center in viewport” helper, not full-screen-only.
When the background is not the entire terminal, pass the same width and height you use for that region. If the region matches the main view’s cell bounds, use ModalCellSize(mainView) or OverlayViewInCenterInMain.
Centering uses ModalCellSize(modalView), matching OverlayView’s internal modal measurement (not lipgloss.Size).
func OverlayViewInCenterInMain ¶
OverlayViewInCenterInMain derives the viewport size from ModalCellSize(mainView) and centers modalView over mainView. Use when the overlay applies to exactly the main string’s cell bounds (e.g. an inner panel or log region).
func OverlayViewInCenterWithMask ¶
func OverlayViewInCenterWithMask(mainView, modalView string, viewWidth, viewHeight int, maskRune rune) string
OverlayViewInCenterWithMask is like OverlayViewInCenter but uses OverlayViewWithMask.
func OverlayViewInCenterWithOffset ¶
func OverlayViewInCenterWithOffset(mainView, modalView string, viewWidth, viewHeight, deltaTop, deltaLeft int) string
OverlayViewInCenterWithOffset centers modalView, adds deltaTop and deltaLeft (e.g. nudge a loading banner upward), then composites. Overflow clamping matches OverlayView (applied inside OverlayView).
func OverlayViewInCenterWithOffsetWithMask ¶
func OverlayViewInCenterWithOffsetWithMask(mainView, modalView string, viewWidth, viewHeight, deltaTop, deltaLeft int, maskRune rune) string
OverlayViewInCenterWithOffsetWithMask is like OverlayViewInCenterWithOffset but uses OverlayViewWithMask.
func OverlayViewInCenterWithOffsetWithTransparency ¶
func OverlayViewInCenterWithOffsetWithTransparency(mainView, modalView string, viewWidth, viewHeight, deltaTop, deltaLeft int) string
OverlayViewInCenterWithOffsetWithTransparency is like OverlayViewInCenterWithOffset but uses OverlayViewWithTransparency.
func OverlayViewInCenterWithTransparency ¶
func OverlayViewInCenterWithTransparency(mainView, modalView string, viewWidth, viewHeight int) string
OverlayViewInCenterWithTransparency is like OverlayViewInCenter but uses OverlayViewWithTransparency.
func OverlayViewWithMask ¶
func OverlayViewWithMask(mainView, modalView string, viewWidth, viewHeight, top, left int, maskRune rune) string
OverlayViewWithMask is like OverlayView but treats any cell whose rune equals maskRune as transparent (pass-through to the main view). Use 0 for maskRune to behave like OverlayView.
func OverlayViewWithTransparency ¶
func OverlayViewWithTransparency(mainView, modalView string, viewWidth, viewHeight, top, left int) string
OverlayViewWithTransparency is like OverlayView but cells in the modal that are ASCII space (' ') are treated as transparent: the main view shows through at those positions. Non-space modal cells (including styled spaces from lipgloss that carry a background) still replace the main view.
Types ¶
type FocusTrap ¶
type FocusTrap struct {
Stack *OverlayStack
}
type OverlayConfig ¶
type OverlayConfig struct {
Placement Placement
DimOpacity float64
CloseOnEscape bool
CloseOnClickOutside bool
}
func DefaultOverlayConfig ¶
func DefaultOverlayConfig() OverlayConfig
type OverlayOnCloser ¶
type OverlayStack ¶
type OverlayStack struct {
// contains filtered or unexported fields
}
func (*OverlayStack) Depth ¶
func (s *OverlayStack) Depth() int
func (*OverlayStack) MainReceivesKeyMsg ¶
func (s *OverlayStack) MainReceivesKeyMsg() bool
func (*OverlayStack) MainReceivesMouseMsg ¶
func (s *OverlayStack) MainReceivesMouseMsg() bool
func (*OverlayStack) Push ¶
func (s *OverlayStack) Push(m tea.Model, cfg OverlayConfig) tea.Cmd
func (*OverlayStack) StackDepth ¶
func (s *OverlayStack) StackDepth() int
func (*OverlayStack) Top ¶
func (s *OverlayStack) Top() tea.Model
type Placement ¶
type Placement struct {
// contains filtered or unexported fields
}
func RightDrawer ¶
func RightDrawer() Placement
func (Placement) ClampedOrigin ¶
ClampedOrigin returns Origin followed by the same overflow clamp as OverlayView. Use this when forwarding tea.MouseMsg or storing overlay bounds so geometry matches the compositor.
func (Placement) Origin ¶
Origin returns the placement anchor before OverlayView overflow clamping: negative top/left are pinned to 0, but if the modal is wider or taller than the viewport the origin is not shifted until compositing—use ClampedOrigin or ClampOverlayOrigin for coordinates that must match painting (e.g. mouse hit-testing).
type PlacementKind ¶
type PlacementKind uint8
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
colors
command
|
|
|
confirm
command
|
|
|
form
command
|
|
|
simple
command
|
|
|
spinner
command
|
|
|
stack
command
|
|
|
transparency
command
|
|
|
v2simple
command
|
|
|
internal
|
|
|
Package overlayv2 provides OverlayStack for Bubble Tea v2 (charm.land/bubbletea/v2).
|
Package overlayv2 provides OverlayStack for Bubble Tea v2 (charm.land/bubbletea/v2). |






