Documentation
¶
Overview ¶
Package grid provides grid-based navigation functionality for Neru.
This package implements a comprehensive visual grid overlay system that allows users to navigate and click anywhere on the screen using keyboard input. Unlike accessibility tree-based approaches, the grid system works universally across all applications by dividing the screen into cells, making it the most reliable navigation method in Neru.
Index ¶
- Constants
- type Context
- func (c *Context) GridInstance() **domainGrid.Grid
- func (c *Context) GridOverlay() **Overlay
- func (c *Context) InActionMode() bool
- func (c *Context) PendingAction() *string
- func (c *Context) Reset()
- func (c *Context) SetGridInstance(gridInstance **domainGrid.Grid)
- func (c *Context) SetGridInstanceValue(gridInstance *domainGrid.Grid)
- func (c *Context) SetGridOverlay(gridOverlay **Overlay)
- func (c *Context) SetGridOverlayValue(gridOverlay *Overlay)
- func (c *Context) SetInActionMode(inActionMode bool)
- func (c *Context) SetPendingAction(action *string)
- type Overlay
- func (o *Overlay) Clear()
- func (o *Overlay) Config() config.GridConfig
- func (o *Overlay) Destroy()
- func (o *Overlay) DrawGrid(grid *domainGrid.Grid, currentInput string, style Style) error
- func (o *Overlay) DrawScrollHighlight(xCoordinate, yCoordinate, width, height int, color string, borderWidth int)
- func (o *Overlay) Hide()
- func (o *Overlay) Logger() *zap.Logger
- func (o *Overlay) ReplaceWindow()
- func (o *Overlay) ResizeToActiveScreen()
- func (o *Overlay) ResizeToMainScreen()
- func (o *Overlay) SetConfig(config config.GridConfig)
- func (o *Overlay) SetHideUnmatched(hide bool)
- func (o *Overlay) SetMaxCells(maxCells int)
- func (o *Overlay) SetViewport(viewport image.Rectangle)
- func (o *Overlay) Show()
- func (o *Overlay) ShowSubgrid(cell *domainGrid.Cell, style Style)
- func (o *Overlay) UpdateMatches(prefix string)
- func (o *Overlay) Window() C.OverlayWindow
- type Style
- func (s Style) BackgroundColor() string
- func (s Style) BorderColor() string
- func (s Style) BorderWidth() int
- func (s Style) FontFamily() string
- func (s Style) FontSize() int
- func (s Style) MatchedBackgroundColor() string
- func (s Style) MatchedBorderColor() string
- func (s Style) MatchedTextColor() string
- func (s Style) Opacity() float64
- func (s Style) TextColor() string
Constants ¶
const ( // DefaultGridLinesCount is the default number of grid lines. DefaultGridLinesCount = 4 // GridMaxChars is the max chars for grid. GridMaxChars = 9 // RoundingFactor is the factor for rounding. RoundingFactor = 0.5 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context holds the state and context for grid mode operations.
func (*Context) GridInstance ¶
func (c *Context) GridInstance() **domainGrid.Grid
GridInstance returns the grid instance.
func (*Context) GridOverlay ¶
GridOverlay returns the grid overlay.
func (*Context) InActionMode ¶
func (c *Context) InActionMode() bool
InActionMode returns whether the mode is in action mode.
func (*Context) PendingAction ¶
func (c *Context) PendingAction() *string
PendingAction returns the pending action to execute.
func (*Context) Reset ¶
func (c *Context) Reset()
Reset resets the grid context to its initial state.
func (*Context) SetGridInstance ¶
func (c *Context) SetGridInstance(gridInstance **domainGrid.Grid)
SetGridInstance sets the grid instance.
func (*Context) SetGridInstanceValue ¶
func (c *Context) SetGridInstanceValue(gridInstance *domainGrid.Grid)
SetGridInstanceValue sets the value of the grid instance pointer.
func (*Context) SetGridOverlay ¶
SetGridOverlay sets the grid overlay.
func (*Context) SetGridOverlayValue ¶
SetGridOverlayValue sets the value of the grid overlay pointer.
func (*Context) SetInActionMode ¶
func (c *Context) SetInActionMode(inActionMode bool)
SetInActionMode sets whether the mode is in action mode.
func (*Context) SetPendingAction ¶
func (c *Context) SetPendingAction(action *string)
SetPendingAction sets the action to execute when mode selection is complete.
type Overlay ¶
type Overlay struct {
// contains filtered or unexported fields
}
Overlay manages the rendering of grid overlays using native platform APIs.
func NewOverlay ¶
func NewOverlay(config config.GridConfig, logger *zap.Logger) *Overlay
NewOverlay creates a new grid overlay instance with its own window and prewarms common grid sizes.
func NewOverlayWithWindow ¶
func NewOverlayWithWindow( config config.GridConfig, logger *zap.Logger, windowPtr unsafe.Pointer, ) *Overlay
NewOverlayWithWindow creates a grid overlay instance using a shared window and prewarms common grid sizes.
func (*Overlay) Config ¶
func (o *Overlay) Config() config.GridConfig
Config returns the grid config.
func (*Overlay) DrawScrollHighlight ¶
func (o *Overlay) DrawScrollHighlight( xCoordinate, yCoordinate, width, height int, color string, borderWidth int, )
DrawScrollHighlight draws a scroll highlight.
func (*Overlay) ReplaceWindow ¶
func (o *Overlay) ReplaceWindow()
ReplaceWindow atomically replaces the underlying overlay window on the main thread.
func (*Overlay) ResizeToActiveScreen ¶
func (o *Overlay) ResizeToActiveScreen()
ResizeToActiveScreen resizes the overlay window with callback notification.
func (*Overlay) ResizeToMainScreen ¶
func (o *Overlay) ResizeToMainScreen()
ResizeToMainScreen resizes the overlay window to the current main screen.
func (*Overlay) SetConfig ¶
func (o *Overlay) SetConfig(config config.GridConfig)
SetConfig updates the overlay's config (e.g., after config reload).
func (*Overlay) SetHideUnmatched ¶
SetHideUnmatched sets whether to hide unmatched cells.
func (*Overlay) SetMaxCells ¶ added in v1.11.0
SetMaxCells sets the maximum number of cells to render (0 = no limit).
func (*Overlay) SetViewport ¶ added in v1.11.0
SetViewport sets the current viewport for lazy rendering and forces a full redraw on next draw.
func (*Overlay) ShowSubgrid ¶
func (o *Overlay) ShowSubgrid(cell *domainGrid.Cell, style Style)
ShowSubgrid draws a 3x3 subgrid inside the selected cell.
func (*Overlay) UpdateMatches ¶
UpdateMatches updates matched state without redrawing all cells.
func (*Overlay) Window ¶
func (o *Overlay) Window() C.OverlayWindow
Window returns the overlay window.
type Style ¶
type Style struct {
// contains filtered or unexported fields
}
Style represents the visual style for grid cells.
func BuildStyle ¶
func BuildStyle(cfg config.GridConfig) Style
BuildStyle returns Style based on action name using the provided config.
func (Style) BackgroundColor ¶
BackgroundColor returns the background color.
func (Style) BorderColor ¶
BorderColor returns the border color.
func (Style) MatchedBackgroundColor ¶
MatchedBackgroundColor returns the matched background color.
func (Style) MatchedBorderColor ¶
MatchedBorderColor returns the matched border color.
func (Style) MatchedTextColor ¶
MatchedTextColor returns the matched text color.