Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Serialize ¶
func Serialize(m *ElementMap) string
Serialize produces a compact, token-efficient text representation of an ElementMap for LLM consumption.
Format: [id:type:"label" row,col wxh] with * suffix on type for focused.
Example:
[1:panel:"File Browser" 0,0 40x20] [2:btn:"Save"* 12,35 6x1]
func SerializeJSON ¶
func SerializeJSON(m *ElementMap) string
SerializeJSON produces a structured JSON representation of an ElementMap.
Types ¶
type Color ¶
type Color int32
Color represents a terminal color. Negative values mean "default".
const DefaultColor Color = -1
func PaletteColor ¶
PaletteColor returns a palette-backed terminal color.
type DebugEvent ¶
type DebugInfo ¶
type DebugInfo struct {
Config DetectConfig `json:"config"`
Events []DebugEvent `json:"events"`
}
type DetectConfig ¶
type DetectConfig struct {
MajorityThresholdPct int `json:"majority_threshold_pct"`
MaxButtonWidth int `json:"max_button_width"`
MaxButtonLabelLen int `json:"max_button_label_len"`
Debug bool `json:"debug"`
}
DetectConfig controls configurable detection thresholds and diagnostics.
func DefaultDetectConfig ¶
func DefaultDetectConfig() DetectConfig
DefaultDetectConfig returns the default detection settings.
type Element ¶
type Element struct {
ID int `json:"id"`
Type ElementType `json:"type"`
Label string `json:"label"`
Description string `json:"description,omitempty"`
Bounds Rect `json:"bounds"`
Focused bool `json:"focused"`
Enabled bool `json:"enabled"`
Checked bool `json:"checked"`
Selected bool `json:"selected"`
Visible bool `json:"visible"`
Clipped bool `json:"clipped"`
Role string `json:"role,omitempty"`
Shortcut string `json:"shortcut,omitempty"`
Ref string `json:"ref,omitempty"`
VisibleBounds *Rect `json:"visible_bounds,omitempty"`
Children []int `json:"children,omitempty"` // IDs of contained elements; populated by BuildTree
}
Element represents a detected interactive or structural TUI element.
type ElementMap ¶
type ElementMap struct {
Elements []Element `json:"elements"`
Viewport Rect `json:"viewport"`
Scrolled bool `json:"scrolled"`
Debug *DebugInfo `json:"debug,omitempty"`
}
ElementMap is the result of detecting elements on a styled grid.
func Detect ¶
func Detect(g *Grid, opts ...Option) *ElementMap
Detect analyzes a styled terminal grid and returns detected UI elements. Elements are assigned sequential IDs starting from 1.
func (*ElementMap) Query ¶
func (m *ElementMap) Query(selector string) []Element
func (*ElementMap) QueryOne ¶
func (m *ElementMap) QueryOne(selector string) *Element
type ElementType ¶
type ElementType int
ElementType classifies a detected TUI element.
const ( ElementPanel ElementType = iota // Box-drawing bordered region ElementButton // Bracketed text like [Save], <OK> ElementInput // Cursor-adjacent editable field ElementMenuItem // Item in a vertical list/menu ElementStatusBar // Color-contiguous bar at screen edge ElementMenuBar // Horizontal menu at top ElementTab // Tab-bar label ElementText // Generic styled text region ElementCheckbox // Checkbox or radio button ElementProgressBar // Progress bar (block or ASCII) ElementTable // Tabular data with column separators ElementSeparator // Horizontal separator/divider line ElementDialog // Centered panel with buttons (modal) ElementScrollIndicator // Scroll arrows or block scrollbar ElementBreadcrumb // Path-like breadcrumb trail )
func (ElementType) ShortString ¶
func (t ElementType) ShortString() string
func (ElementType) String ¶
func (t ElementType) String() string
type Grid ¶
Grid is a styled 2D character grid — the input to element detection.
type Option ¶
type Option func(*DetectConfig)
Option configures Detect.
func WithMajorityThresholdPct ¶
WithMajorityThresholdPct sets the percentage threshold used for bar detection.
func WithMaxButtonLabelLen ¶
WithMaxButtonLabelLen sets the maximum allowed button label length.
func WithMaxButtonWidth ¶
WithMaxButtonWidth sets the maximum scan width for bracketed buttons.
Source Files
¶
- debug.go
- detect.go
- detect_breadcrumb.go
- detect_buttons.go
- detect_checkbox.go
- detect_dialog.go
- detect_input.go
- detect_menu.go
- detect_panels.go
- detect_progress.go
- detect_reverse.go
- detect_scroll.go
- detect_separator.go
- detect_statusbar.go
- detect_table.go
- detect_tabs.go
- element.go
- enrich.go
- grid.go
- options.go
- query.go
- serialize.go
- tree.go