Documentation
¶
Index ¶
- Variables
- func Card(lines []string, maxWidth int) string
- func CardBodyHeight(totalHeight, pinnedRows int) int
- func CardBodyWidth(totalWidth int) int
- func CardOrigin() (x, y int)
- func CardWithStyle(lines []string, maxWidth int, style CardStyle) string
- func ContentWidth(totalWidth int) int
- func FrameWidth(maxWidth int, lines []string) int
- func Overlay(base string, layer string) string
- func OverlayOrigin(base, layer string) (x, y int)
- func Subtle(text string) string
- func SubtleWithStyle(text string, style lipgloss.Style) string
- func Title(text string) string
- func TitleWithStyle(text string, style lipgloss.Style) string
- type CardStyle
- type Column
- type FocusRing
- type KeyBinding
- type KeyGroup
- type KeyGroups
- type KeyMap
- type KeyMapMode
- type KeyMapOptions
- type List
- func (l List) Count() int
- func (l List) Cursor() int
- func (l List) Height() int
- func (l List) Layout() layout.Node
- func (l *List) MoveDown()
- func (l *List) MoveUp()
- func (l List) Offset() int
- func (l *List) Select(i int)
- func (l *List) SetCount(n int)
- func (l *List) SetHeight(h int)
- func (l List) View(render func(index int, selected bool) string) string
- type Paginator
- func (p *Paginator) NextPage()
- func (p Paginator) Page() int
- func (p Paginator) PageSize() int
- func (p Paginator) Pages() int
- func (p *Paginator) PrevPage()
- func (p Paginator) Range() (first, last int)
- func (p *Paginator) SelectPage(page int)
- func (p *Paginator) SetPageSize(n int)
- func (p *Paginator) SetTotal(n int)
- func (p Paginator) Total() int
- func (p Paginator) View() string
- type Progress
- type ProgressStyle
- type Rect
- type Spinner
- type Stopwatch
- type TabBar
- func (t *TabBar) Active() int
- func (t *TabBar) ActiveID() string
- func (t *TabBar) HitTest(rects map[string]layout.Rect, x, y int) (int, bool)
- func (t *TabBar) Layout() layout.Node
- func (t *TabBar) Next()
- func (t *TabBar) Prev()
- func (t *TabBar) SetActive(i int)
- func (t *TabBar) WithBorder(b TabBarBorder) *TabBar
- func (t *TabBar) WithColors(f, i, bg color.Color) *TabBar
- func (t *TabBar) WithGlyphs(g TabGlyphs) *TabBar
- func (t *TabBar) WithID(id string) *TabBar
- type TabBarBorder
- type TabGlyphs
- type TabItem
- type Table
- func (t Table) Cursor() int
- func (t Table) Header() string
- func (t Table) HeaderWithStyle(style TableStyle) string
- func (t *Table) MoveDown()
- func (t *Table) MoveUp()
- func (t *Table) Select(i int)
- func (t Table) SelectedRow() []string
- func (t *Table) SetColumns(cols []Column)
- func (t *Table) SetHeight(h int)
- func (t *Table) SetRows(rows [][]string)
- func (t Table) View(renderRow func(text string, selected bool) string) string
- func (t Table) ViewWithStyle(style TableStyle) string
- type TableStyle
- type TextField
- func (f *TextField) Backspace()
- func (f *TextField) ClearSelection()
- func (f TextField) CursorColumn() int
- func (f *TextField) Delete()
- func (f *TextField) DeleteWordLeft()
- func (f *TextField) DeleteWordRight()
- func (f *TextField) Insert(r rune)
- func (f *TextField) MoveLeft()
- func (f *TextField) MoveLeftSelecting()
- func (f *TextField) MoveRight()
- func (f *TextField) MoveRightSelecting()
- func (f *TextField) MoveWordLeft()
- func (f *TextField) MoveWordLeftSelecting()
- func (f *TextField) MoveWordRight()
- func (f *TextField) MoveWordRightSelecting()
- func (f TextField) SelectedText() string
- func (f TextField) Selection() (start, end int, ok bool)
- func (f *TextField) SetCursor(cursor int)
- type TextPosition
- type TextRange
- type Textarea
- func (t *Textarea) Backspace()
- func (t *Textarea) ClearSelection()
- func (t Textarea) Col() int
- func (t Textarea) CursorCell() (x, y int)
- func (t *Textarea) Delete()
- func (t *Textarea) DeleteWordLeft()
- func (t *Textarea) DeleteWordRight()
- func (t *Textarea) Insert(r rune)
- func (t *Textarea) InsertNewline()
- func (t *Textarea) MoveDown()
- func (t *Textarea) MoveDownSelecting()
- func (t *Textarea) MoveLeft()
- func (t *Textarea) MoveLeftSelecting()
- func (t *Textarea) MoveLineEnd()
- func (t *Textarea) MoveLineEndSelecting()
- func (t *Textarea) MoveLineStart()
- func (t *Textarea) MoveLineStartSelecting()
- func (t *Textarea) MoveRight()
- func (t *Textarea) MoveRightSelecting()
- func (t *Textarea) MoveUp()
- func (t *Textarea) MoveUpSelecting()
- func (t *Textarea) MoveWordLeft()
- func (t *Textarea) MoveWordLeftSelecting()
- func (t *Textarea) MoveWordRight()
- func (t *Textarea) MoveWordRightSelecting()
- func (t Textarea) Offset() int
- func (t Textarea) Row() int
- func (t Textarea) SelectedText() string
- func (t Textarea) Selection() (TextRange, bool)
- func (t *Textarea) SetSize(width, height int)
- func (t *Textarea) SetSoftWrap(enabled bool)
- func (t *Textarea) SetValue(s string)
- func (t Textarea) SoftWrap() bool
- func (t Textarea) Value() string
- func (t Textarea) View() string
- func (t Textarea) ViewWithSelection(render func(text string, selected bool) string) string
- type Timer
- type Tree
- func (t Tree) CursorID() string
- func (t *Tree) MoveDown()
- func (t *Tree) MoveUp()
- func (t Tree) Offset() int
- func (t *Tree) SelectVisible(i int)
- func (t *Tree) SetHeight(h int)
- func (t *Tree) SetNodes(nodes []TreeNode)
- func (t *Tree) Toggle(id string)
- func (t Tree) View(render func(row TreeRow, selected bool) string) string
- func (t Tree) VisibleRows() []TreeRow
- type TreeNode
- type TreeRow
- type Viewport
- func (v Viewport) AtBottom() bool
- func (v Viewport) AtTop() bool
- func (v *Viewport) GotoBottom()
- func (v *Viewport) GotoTop()
- func (v *Viewport) HalfPageDown()
- func (v *Viewport) HalfPageUp()
- func (v Viewport) Layout() layout.Node
- func (v *Viewport) LineDown(n int)
- func (v *Viewport) LineUp(n int)
- func (v Viewport) Offset() int
- func (v *Viewport) PageDown()
- func (v *Viewport) PageUp()
- func (v Viewport) ScrollPercent() float64
- func (v *Viewport) ScrollToLine(i int)
- func (v *Viewport) SetContent(content string)
- func (v *Viewport) SetLines(lines []string)
- func (v *Viewport) SetSize(width, height int)
- func (v *Viewport) SetWrappedContent(content string)
- func (v Viewport) TotalLines() int
- func (v Viewport) View() string
- func (v Viewport) VisibleLines() int
- type ZoneMap
- type ZoneScanner
Constants ¶
This section is empty.
Variables ¶
var ( // SpinnerDots is the braille "dots" animation (single display cell wide). SpinnerDots = []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"} // SpinnerLine is the ASCII bar animation. SpinnerLine = []string{"|", "/", "-", "\\"} )
Preset frame sets. Apps may also pass their own to NewSpinner.
var TabGlyphsPowerline = TabGlyphs{Left: "\ue0ba", Right: "\ue0bc"}
var TabGlyphsSafe = TabGlyphs{Left: "[", Right: "]"}
Functions ¶
func CardBodyHeight ¶
CardBodyHeight returns the rows available for a body inside a Card of the given total height, after the card's top and bottom border and the pinnedRows of non-body content (title, footer, etc.) the app stacks around the body. The app still declares its own pinnedRows — that count is app layout, not card chrome — but the card's border math lives here.
func CardBodyWidth ¶
CardBodyWidth returns the usable content width for a body placed inside a Card of the given total width — the total minus the card's border and horizontal padding. Size a body widget with this (in Handle, on ResizeEvent) so it tracks the card chrome instead of a hardcoded constant.
func CardOrigin ¶
func CardOrigin() (x, y int)
CardOrigin is the cell offset of a Card's first content cell relative to the card's top-left corner: one border column plus two padding columns across, one border row down.
func ContentWidth ¶
func FrameWidth ¶
func Overlay ¶
Overlay draws layer centered over base as a cell-buffer composite. It delegates to the layout engine's compositor so there is a single ANSI-aware overlay implementation (see flatui/layout/overlay.go).
func OverlayOrigin ¶
OverlayOrigin returns where Overlay places layer's top-left cell inside the composed frame. Delegates to the layout engine so it stays in lockstep with Overlay's centering.
Types ¶
type Column ¶
Column is a table column: a header title and a fixed display width. Cells are padded to the width and truncated when wider.
type FocusRing ¶
type FocusRing struct {
// contains filtered or unexported fields
}
FocusRing is app-owned focus index state for cycling among focusable regions. It owns no key policy; apps decide whether Tab, Shift-Tab, mouse, or another command calls Next, Prev, or Select.
func (*FocusRing) Prev ¶
func (f *FocusRing) Prev()
Prev moves focus backward, wrapping at the beginning.
type KeyBinding ¶
KeyBinding is display metadata for a command binding. It is not input policy: apps still decide how terminal events map to behavior.
type KeyGroups ¶
type KeyGroups []KeyGroup
KeyGroups renders context-sensitive help across named groups.
func (KeyGroups) ViewWithOptions ¶
func (groups KeyGroups) ViewWithOptions(opts KeyMapOptions) string
ViewWithOptions renders grouped key metadata. It owns no key matching or input policy; apps still decide how events map to commands.
type KeyMap ¶
type KeyMap []KeyBinding
KeyMap is a small help-line renderer for key binding metadata.
type KeyMapMode ¶
type KeyMapMode int
KeyMapMode selects how grouped key bindings are rendered.
const ( // KeyMapShort renders the first enabled binding per group. KeyMapShort KeyMapMode = iota // KeyMapFull renders every enabled binding per group. KeyMapFull )
type KeyMapOptions ¶
type KeyMapOptions struct {
Width int
Mode KeyMapMode
}
KeyMapOptions configures grouped key map rendering.
type List ¶
type List struct {
// RenderRow renders one row for Layout(); set by the app. It receives the
// item index and whether it is the selected row.
RenderRow func(index int, selected bool) string
// contains filtered or unexported fields
}
List is selection-and-scroll state over a flat sequence of items. The app owns it (like TextField and Viewport): no goroutines, no key policy. It holds no item data and imposes no appearance — the app supplies the item count, drives the cursor, and renders each visible row through a callback, so the selection marker and styling stay app policy, never the framework's. The selected row is always kept inside the visible window.
func (List) Layout ¶
Layout renders the visible rows via RenderRow as a single Text leaf. If RenderRow is unset, it renders nothing.
func (*List) MoveUp ¶
func (l *List) MoveUp()
MoveUp / MoveDown move the selection by one, keeping it visible.
func (*List) SetCount ¶
SetCount sets the number of selectable items, clamping the cursor and scroll.
type Paginator ¶
type Paginator struct {
// contains filtered or unexported fields
}
Paginator is app-owned page/range state. It owns no key policy; apps choose whether to bind arrows, h/l, PgUp/PgDn, or buttons.
func (*Paginator) NextPage ¶
func (p *Paginator) NextPage()
NextPage moves to the next page, clamped at the last page.
func (*Paginator) PrevPage ¶
func (p *Paginator) PrevPage()
PrevPage moves to the previous page, clamped at the first page.
func (Paginator) Range ¶
Range returns the half-open item index range [first, last) for the selected page. It returns 0, 0 when no page can be formed.
func (*Paginator) SelectPage ¶
SelectPage moves to page, clamped to the available page range.
func (*Paginator) SetPageSize ¶
SetPageSize sets the number of items per page, clamping the selected page.
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
Progress is a horizontal percentage indicator. The app owns the percentage and width; the widget only clamps values and renders a deterministic bar.
func NewProgress ¶
NewProgress returns a progress bar with the given fill width in cells.
func (*Progress) SetPercent ¶
SetPercent sets the fill percentage. Values outside 0..100 clamp.
func (*Progress) SetWidth ¶
SetWidth sets the fill bar width in cells. Negative widths clamp to zero.
func (Progress) View ¶
View renders the progress bar and a rounded percentage label. A zero-width bar still returns the label so compact layouts can show progress.
func (Progress) ViewWithStyle ¶
func (p Progress) ViewWithStyle(style ProgressStyle) string
type ProgressStyle ¶
ProgressStyle customizes Progress.ViewWithStyle. Zero-value styles render the same text without additional styling.
type Rect ¶
Rect is a cell-space rectangle: the same type the layout engine solves, so hit regions and solved geometry share one representation. X/Y are zero-based absolute frame coordinates; W/H must be positive to contain points.
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner is a frame-cycling activity indicator. The app advances it — via flatte.Every or any other tick source on the loop goroutine — so the widget owns no goroutine and no timer, consistent with the rest of flatui. View returns the current frame.
func NewSpinner ¶
NewSpinner builds a Spinner over a copy of frames. With no frames, View returns "" and Tick is a no-op.
type Stopwatch ¶
type Stopwatch struct {
// contains filtered or unexported fields
}
Stopwatch is app-owned elapsed-time state. It owns no goroutine and no key policy; apps decide how ticks are produced and which keys start or stop it.
func NewStopwatch ¶
func NewStopwatch() Stopwatch
NewStopwatch returns a stopped stopwatch at zero elapsed time.
func (*Stopwatch) Reset ¶
func (s *Stopwatch) Reset()
Reset clears elapsed time and stops the stopwatch.
func (*Stopwatch) Start ¶
func (s *Stopwatch) Start()
Start makes subsequent Tick calls advance elapsed time.
type TabBar ¶
type TabBar struct {
Items []TabItem
// contains filtered or unexported fields
}
TabBar is a tab-strip component. Set colors once via WithColors, then compose it into a layout tree via Layout().
func (*TabBar) HitTest ¶
HitTest maps an absolute frame point to a tab index using solved geometry. In the normal (unbordered) mode it looks up each tab's own rect (recorded by a full-frame solve when WithID was set). When those per-tab rects are absent — the bordered mode renders one pre-composed leaf, and some callers only register the strip rect — it falls back to the strip rect plus the widget's private per-label width math. It does not mutate the bar; callers apply the returned index.
func (*TabBar) Layout ¶
Layout builds the tab strip as a Row of styled Text leaves. The engine positions and sizes it; the widget computes no coordinates. When WithID was set, the strip and each tab carry IDs so a solve records their rects.
func (*TabBar) WithBorder ¶
func (t *TabBar) WithBorder(b TabBarBorder) *TabBar
func (*TabBar) WithGlyphs ¶
type TabBarBorder ¶
type TabBarBorder struct {
Style lipgloss.Border
Color color.Color
Top bool
Right bool
Bottom bool
Left bool
}
TabBarBorder customizes the border around a TabBar. Set any side to true to enable that side; Style defaults to lipgloss.InnerHalfBlockBorder().
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is a columnar, row-selectable, vertically-scrolling grid. The app owns it (like the other flatui widgets): no goroutines, no key policy. Row selection and keep-visible scrolling are delegated to an embedded List; Table adds column alignment. Header and body are rendered separately so the app controls placement and styling; row appearance (selection marker/style) is the app's callback, so there is no policy in core.
func (Table) HeaderWithStyle ¶
func (t Table) HeaderWithStyle(style TableStyle) string
func (*Table) MoveUp ¶
func (t *Table) MoveUp()
MoveUp / MoveDown / Select move the selected row, keeping it visible.
func (Table) SelectedRow ¶
SelectedRow returns the selected row's cells (nil when there are no rows).
func (*Table) SetColumns ¶
SetColumns sets the column titles and widths.
func (Table) View ¶
View returns the visible body rows, each aligned to the columns and passed through renderRow with whether it is the selected row. renderRow may be nil to render the aligned rows verbatim.
func (Table) ViewWithStyle ¶
func (t Table) ViewWithStyle(style TableStyle) string
type TableStyle ¶
TableStyle customizes Table styled rendering. Zero-value styles render the same text without additional styling.
type TextField ¶
TextField is a single-line editable string. Cursor is a byte offset into Value; the movement and edit methods keep it on a grapheme-cluster boundary so multi-rune clusters (combining marks, ZWJ emoji, regional-indicator flags) are treated as indivisible units and never split. clampCursor additionally guards against a manually-set offset landing inside a UTF-8 rune.
func (*TextField) ClearSelection ¶
func (f *TextField) ClearSelection()
func (TextField) CursorColumn ¶
CursorColumn returns the cursor offset in display cells within the rendered value (wide runes count their terminal width, not their byte or rune count).
func (*TextField) DeleteWordLeft ¶
func (f *TextField) DeleteWordLeft()
func (*TextField) DeleteWordRight ¶
func (f *TextField) DeleteWordRight()
func (*TextField) MoveLeftSelecting ¶
func (f *TextField) MoveLeftSelecting()
func (*TextField) MoveRightSelecting ¶
func (f *TextField) MoveRightSelecting()
func (*TextField) MoveWordLeft ¶
func (f *TextField) MoveWordLeft()
func (*TextField) MoveWordLeftSelecting ¶
func (f *TextField) MoveWordLeftSelecting()
func (*TextField) MoveWordRight ¶
func (f *TextField) MoveWordRight()
func (*TextField) MoveWordRightSelecting ¶
func (f *TextField) MoveWordRightSelecting()
func (TextField) SelectedText ¶
type TextPosition ¶
type TextRange ¶
type TextRange struct {
Start TextPosition
End TextPosition
}
type Textarea ¶
type Textarea struct {
// contains filtered or unexported fields
}
Textarea is a multi-line editable text buffer. The app owns it (like TextField): no goroutines, no key policy. Content is kept as logical lines; the cursor is a (row, byte-col) pair that the movement and edit methods keep on a grapheme-cluster boundary, so multi-rune clusters are never split. Vertical movement preserves a display "goal column"; the visible window scrolls to keep the cursor row in view. Width, when positive, horizontally scrolls long lines to keep the cursor cell visible unless soft-wrap is enabled.
func (*Textarea) ClearSelection ¶
func (t *Textarea) ClearSelection()
func (Textarea) CursorCell ¶
CursorCell is the cursor's display position relative to the visible window: x in display cells from the left of its line, y in rows from the top of the window. Pair with a frame origin to place Frame.Cursor.
func (*Textarea) DeleteWordLeft ¶
func (t *Textarea) DeleteWordLeft()
func (*Textarea) DeleteWordRight ¶
func (t *Textarea) DeleteWordRight()
func (*Textarea) InsertNewline ¶
func (t *Textarea) InsertNewline()
InsertNewline splits the current line at the cursor.
func (*Textarea) MoveDownSelecting ¶
func (t *Textarea) MoveDownSelecting()
func (*Textarea) MoveLeftSelecting ¶
func (t *Textarea) MoveLeftSelecting()
func (*Textarea) MoveLineEnd ¶
func (t *Textarea) MoveLineEnd()
func (*Textarea) MoveLineEndSelecting ¶
func (t *Textarea) MoveLineEndSelecting()
func (*Textarea) MoveLineStart ¶
func (t *Textarea) MoveLineStart()
func (*Textarea) MoveLineStartSelecting ¶
func (t *Textarea) MoveLineStartSelecting()
func (*Textarea) MoveRightSelecting ¶
func (t *Textarea) MoveRightSelecting()
func (*Textarea) MoveUpSelecting ¶
func (t *Textarea) MoveUpSelecting()
func (*Textarea) MoveWordLeft ¶
func (t *Textarea) MoveWordLeft()
func (*Textarea) MoveWordLeftSelecting ¶
func (t *Textarea) MoveWordLeftSelecting()
func (*Textarea) MoveWordRight ¶
func (t *Textarea) MoveWordRight()
func (*Textarea) MoveWordRightSelecting ¶
func (t *Textarea) MoveWordRightSelecting()
func (Textarea) SelectedText ¶
func (Textarea) Selection ¶
Selection returns the selected logical range, normalized as [Start,End). Col values are byte offsets into their rows. The range is false when no non-empty selection is active.
func (*Textarea) SetSize ¶
SetSize sets the visible window. Width caps the columns View emits and drives horizontal scrolling; height caps the rows View emits and drives vertical scrolling.
func (*Textarea) SetSoftWrap ¶
SetSoftWrap controls whether View wraps long logical lines to the textarea width. Soft-wrap is opt-in; the default keeps long lines horizontally windowed.
func (*Textarea) SetValue ¶
SetValue replaces the content (split on newlines) and resets the cursor.
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
Timer is app-owned countdown state. It owns no goroutine and no key policy; apps advance it from flatte.Every, tests, or any other loop-owned tick source.
func NewTimer ¶
NewTimer returns a countdown timer with the given duration. Non-positive durations are valid and start already done.
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree is expandable tree state. The app owns it and decides key policy, styling, and node data; Tree only tracks expansion, cursor, and scroll.
func (Tree) CursorID ¶
CursorID is the ID of the selected visible row, or "" when the tree is empty.
func (*Tree) MoveUp ¶
func (t *Tree) MoveUp()
MoveUp / MoveDown move the cursor by one visible row, keeping it visible.
func (*Tree) SelectVisible ¶
SelectVisible moves the cursor to the visible row index i.
func (*Tree) SetNodes ¶
SetNodes replaces the tree data, preserving expansion for IDs that still exist and still have children.
func (Tree) View ¶
View renders the visible window of rows. The app decides each row's marker, indentation, and styling through render.
func (Tree) VisibleRows ¶
VisibleRows returns all rows visible under the current expansion state.
type Viewport ¶
type Viewport struct {
// contains filtered or unexported fields
}
Viewport is a scrollable window over content. The app owns it (like TextField): no goroutines, no key policy. Feed it content with one of the Set* methods, size it with SetSize, scroll it with the movement methods (see below), and render the visible slice with View. View returns a plain string, so the widget works under alt-screen or inline rendering alike — the scroll model does not assume alt-screen.
func (*Viewport) GotoBottom ¶
func (v *Viewport) GotoBottom()
func (*Viewport) GotoTop ¶
func (v *Viewport) GotoTop()
GotoTop/GotoBottom jump to the first/last window.
func (*Viewport) HalfPageDown ¶
func (v *Viewport) HalfPageDown()
HalfPageDown/Up and PageDown/Up scroll by half / a full visible window.
func (*Viewport) HalfPageUp ¶
func (v *Viewport) HalfPageUp()
func (Viewport) ScrollPercent ¶
ScrollPercent is the fraction scrolled, 0.0 at top to 1.0 at bottom. When all content fits (nothing to scroll), it reports 1.0.
func (*Viewport) ScrollToLine ¶
ScrollToLine positions the window so line i is at the top (clamped).
func (*Viewport) SetContent ¶
SetContent splits content on newlines and windows it without wrapping; long lines are clipped at the viewport width on render.
func (*Viewport) SetLines ¶
SetLines sets pre-laid-out lines verbatim: no splitting, no wrapping. Lines wider than the viewport are clipped at its width on render.
func (*Viewport) SetSize ¶
SetSize sets the visible window dimensions. Width drives wrapping and clipping; height caps the number of rows View emits.
func (*Viewport) SetWrappedContent ¶
SetWrappedContent splits content on newlines and soft-wraps each line to the viewport width — ANSI- and display-width-aware, so SGR styles and wide runes are never split. Re-wraps automatically when the width changes via SetSize. If the width is not yet known, the wrap is deferred until SetSize provides one.
func (Viewport) TotalLines ¶
TotalLines is the number of content lines after ingestion/wrapping.
func (Viewport) View ¶
View returns the visible slice joined by newlines. Lines wider than the width are clipped (a no-op for already-wrapped content). Lines are not padded to the width or the height — the caller owns the surrounding frame.
func (Viewport) VisibleLines ¶
VisibleLines is how many content rows View currently emits.
type ZoneMap ¶
type ZoneMap struct {
// contains filtered or unexported fields
}
ZoneMap stores app-measured hit regions. It does not scan rendered output or own input policy; apps register rectangles from their layout calculations.
func (ZoneMap) At ¶
At returns the topmost registered zone at x,y. Later Set calls take priority when rectangles overlap.
func (ZoneMap) Local ¶
Local converts absolute x,y to coordinates relative to id's registered rectangle.
type ZoneScanner ¶
type ZoneScanner struct {
// contains filtered or unexported fields
}
ZoneScanner maps named rectangles to hit regions. Rects are fed from solved layout geometry via Set — the blessed render path composites through a cell buffer, which drops any inline string markers, so zones are always derived from coordinates rather than scanned out of rendered output.
func NewZoneScanner ¶
func NewZoneScanner() *ZoneScanner
func (ZoneScanner) At ¶
func (z ZoneScanner) At(x, y int) (string, bool)
At returns the last-inserted zone containing x,y. Later Set calls for new ids take priority when rectangles overlap.
func (*ZoneScanner) Reset ¶
func (z *ZoneScanner) Reset()
Reset clears all zones. Use before repopulating from geometry each frame.
func (*ZoneScanner) Set ¶
func (z *ZoneScanner) Set(id string, r Rect)
Set registers id at rect r, replacing any existing rect for id. A re-Set does not change hit priority; the original insertion order is preserved so At stays stable across frames.