grid

package
v1.12.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2025 License: MIT Imports: 11 Imported by: 0

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

View Source
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

func (c *Context) GridOverlay() **Overlay

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

func (c *Context) SetGridOverlay(gridOverlay **Overlay)

SetGridOverlay sets the grid overlay.

func (*Context) SetGridOverlayValue

func (c *Context) SetGridOverlayValue(gridOverlay *Overlay)

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) Clear

func (o *Overlay) Clear()

Clear clears the grid overlay and resets state.

func (*Overlay) Config

func (o *Overlay) Config() config.GridConfig

Config returns the grid config.

func (*Overlay) Destroy

func (o *Overlay) Destroy()

Destroy destroys the grid overlay window.

func (*Overlay) DrawGrid

func (o *Overlay) DrawGrid(grid *domainGrid.Grid, currentInput string, style Style) error

DrawGrid renders the flat grid with all 3-char cells visible.

func (*Overlay) DrawScrollHighlight

func (o *Overlay) DrawScrollHighlight(
	xCoordinate, yCoordinate, width, height int,
	color string,
	borderWidth int,
)

DrawScrollHighlight draws a scroll highlight.

func (*Overlay) Hide

func (o *Overlay) Hide()

Hide hides the grid overlay.

func (*Overlay) Logger

func (o *Overlay) Logger() *zap.Logger

Logger returns the logger.

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

func (o *Overlay) SetHideUnmatched(hide bool)

SetHideUnmatched sets whether to hide unmatched cells.

func (*Overlay) SetMaxCells added in v1.11.0

func (o *Overlay) SetMaxCells(maxCells int)

SetMaxCells sets the maximum number of cells to render (0 = no limit).

func (*Overlay) SetViewport added in v1.11.0

func (o *Overlay) SetViewport(viewport image.Rectangle)

SetViewport sets the current viewport for lazy rendering and forces a full redraw on next draw.

func (*Overlay) Show

func (o *Overlay) Show()

Show displays the grid overlay.

func (*Overlay) ShowSubgrid

func (o *Overlay) ShowSubgrid(cell *domainGrid.Cell, style Style)

ShowSubgrid draws a 3x3 subgrid inside the selected cell.

func (*Overlay) UpdateMatches

func (o *Overlay) UpdateMatches(prefix string)

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

func (s Style) BackgroundColor() string

BackgroundColor returns the background color.

func (Style) BorderColor

func (s Style) BorderColor() string

BorderColor returns the border color.

func (Style) BorderWidth

func (s Style) BorderWidth() int

BorderWidth returns the border width.

func (Style) FontFamily

func (s Style) FontFamily() string

FontFamily returns the font family.

func (Style) FontSize

func (s Style) FontSize() int

FontSize returns the font size.

func (Style) MatchedBackgroundColor

func (s Style) MatchedBackgroundColor() string

MatchedBackgroundColor returns the matched background color.

func (Style) MatchedBorderColor

func (s Style) MatchedBorderColor() string

MatchedBorderColor returns the matched border color.

func (Style) MatchedTextColor

func (s Style) MatchedTextColor() string

MatchedTextColor returns the matched text color.

func (Style) Opacity

func (s Style) Opacity() float64

Opacity returns the opacity.

func (Style) TextColor

func (s Style) TextColor() string

TextColor returns the text color.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL