Documentation
¶
Overview ¶
Package app contains the main application logic for Neru.
This package orchestrates all components of the Neru application, serving as the central coordinator that manages state transitions, mode switching, and integration between various subsystems. The App struct is the heart of the application.
Index ¶
- Constants
- type App
- func (a *App) ActivateMode(mode Mode)
- func (a *App) CaptureInitialCursorPosition()
- func (a *App) Cleanup()
- func (a *App) Config() *config.Config
- func (a *App) CurrentMode() Mode
- func (a *App) DisableEventTap()
- func (a *App) EnableEventTap()
- func (a *App) EventTap() ports.EventTapPort
- func (a *App) ExitMode()
- func (a *App) GetConfigPath() string
- func (a *App) GetSystrayComponent() SystrayComponent
- func (a *App) GridContext() *grid.Context
- func (a *App) GridEnabled() bool
- func (a *App) HandleKeyPress(key string)
- func (a *App) HintsContext() *hints.Context
- func (a *App) HintsEnabled() bool
- func (a *App) IsEnabled() bool
- func (a *App) IsFocusedAppExcluded() bool
- func (a *App) IsOverlayHiddenForScreenShare() bool
- func (a *App) Logger() *zap.Logger
- func (a *App) OffEnabledStateChanged(id uint64)
- func (a *App) OffScreenShareStateChanged(id uint64)
- func (a *App) OnEnabledStateChanged(callback func(bool)) uint64
- func (a *App) OnScreenShareStateChanged(callback func(bool)) uint64
- func (a *App) OverlayManager() OverlayManager
- func (a *App) RecursiveGridEnabled() bool
- func (a *App) ReloadConfig(ctx context.Context, configPath string) error
- func (a *App) Renderer() *ui.OverlayRenderer
- func (a *App) Run() error
- func (a *App) ScrollContext() *scroll.Context
- func (a *App) SetEnabled(v bool)
- func (a *App) SetHintOverlayNeedsRefresh(value bool)
- func (a *App) SetModeGrid()
- func (a *App) SetModeHints()
- func (a *App) SetModeIdle()
- func (a *App) SetModeRecursiveGrid()
- func (a *App) SetModeScroll()
- func (a *App) SetOverlayHiddenForScreenShare(hide bool)
- func (a *App) Stop()
- func (a *App) ToggleEnabled()
- func (a *App) ToggleOverlayHiddenForScreenShare() bool
- type ComponentCreationOptions
- type ComponentFactory
- func (f *ComponentFactory) CreateGridComponent(opts ComponentCreationOptions) (*components.GridComponent, error)
- func (f *ComponentFactory) CreateHintsComponent(opts ComponentCreationOptions) (*components.HintsComponent, error)
- func (f *ComponentFactory) CreateModeIndicatorComponent(opts ComponentCreationOptions) (*components.ModeIndicatorComponent, error)
- func (f *ComponentFactory) CreateRecursiveGridComponent(opts ComponentCreationOptions) (*components.RecursiveGridComponent, error)
- func (f *ComponentFactory) CreateScrollComponent(opts ComponentCreationOptions) (*components.ScrollComponent, error)
- type HotkeyService
- type IPCController
- type IPCControllerActions
- type IPCControllerInfo
- type IPCControllerLifecycle
- type IPCControllerModes
- type IPCControllerOverlay
- type Mode
- type ModeService
- type Option
- func WithConfig(cfg *config.Config) Option
- func WithConfigPath(path string) Option
- func WithEventTap(eventTap ports.EventTapPort) Option
- func WithHotkeyService(hotkeyService HotkeyService) Option
- func WithIPCServer(ipcServer ports.IPCPort) Option
- func WithLogger(logger *zap.Logger) Option
- func WithOverlayManager(overlayManager OverlayManager) Option
- func WithWatcher(watcher Watcher) Option
- type OverlayManager
- type SystrayComponent
- type Watcher
Constants ¶
const ( ModeIdle = domain.ModeIdle ModeHints = domain.ModeHints ModeGrid = domain.ModeGrid ModeScroll = domain.ModeScroll )
Mode constants from domain package.
const ( // MaxExecDisplayLength is the maximum length for executable display names. MaxExecDisplayLength = 30 // SystrayQuitTimeout is the timeout for systray quit. SystrayQuitTimeout = 10 * time.Second // GCTickerInterval is the interval for garbage collection. GCTickerInterval = 5 * time.Minute // HighMemoryThreshold is the heap allocation threshold for triggering GC (100MB). HighMemoryThreshold = 100 * 1024 * 1024 // 100MB // LowMemoryThreshold is the normal heap allocation threshold (50MB). LowMemoryThreshold = 50 * 1024 * 1024 // 50MB // HighMemoryGCInterval is the GC interval when memory pressure is high. HighMemoryGCInterval = 1 * time.Minute // GC every 1 minute when high memory // LowMemoryGCInterval is the GC interval when memory pressure is normal. LowMemoryGCInterval = 5 * time.Minute // GC every 5 minutes when low memory // BytesPerMB is the number of bytes in a megabyte. BytesPerMB = 1024 * 1024 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
ConfigPath string
// contains filtered or unexported fields
}
App represents the main application instance containing all state and dependencies.
func New ¶
New creates a new App instance with the provided options. It applies sensible defaults and allows customization through functional options.
func (*App) ActivateMode ¶
ActivateMode activates the specified mode.
func (*App) CaptureInitialCursorPosition ¶
func (a *App) CaptureInitialCursorPosition()
CaptureInitialCursorPosition captures the initial cursor position.
func (*App) DisableEventTap ¶
func (a *App) DisableEventTap()
DisableEventTap disables the event tap.
func (*App) GetConfigPath ¶
GetConfigPath returns the config path.
func (*App) GetSystrayComponent ¶ added in v1.12.1
func (a *App) GetSystrayComponent() SystrayComponent
GetSystrayComponent returns the systray component.
func (*App) GridContext ¶
GridContext returns the grid context.
func (*App) GridEnabled ¶
GridEnabled returns true if grid is enabled.
func (*App) HandleKeyPress ¶
HandleKeyPress delegates key press handling to the mode handler.
func (*App) HintsContext ¶
HintsContext returns the hints context.
func (*App) HintsEnabled ¶
HintsEnabled returns true if hints are enabled.
func (*App) IsFocusedAppExcluded ¶
IsFocusedAppExcluded checks if the focused app is excluded.
func (*App) IsOverlayHiddenForScreenShare ¶ added in v1.19.0
IsOverlayHiddenForScreenShare returns whether the overlay is hidden from screen sharing.
func (*App) OffEnabledStateChanged ¶ added in v1.18.1
OffEnabledStateChanged unsubscribes a callback by ID.
func (*App) OffScreenShareStateChanged ¶ added in v1.19.0
OffScreenShareStateChanged unsubscribes a callback by ID.
func (*App) OnEnabledStateChanged ¶ added in v1.12.1
OnEnabledStateChanged registers a callback for when the enabled state changes. Returns a subscription ID that can be used to unsubscribe later.
func (*App) OnScreenShareStateChanged ¶ added in v1.19.0
OnScreenShareStateChanged registers a callback for when the screen share state changes.
func (*App) OverlayManager ¶
func (a *App) OverlayManager() OverlayManager
OverlayManager returns the overlay manager.
func (*App) RecursiveGridEnabled ¶ added in v1.20.0
RecursiveGridEnabled returns true if recursive-grid is enabled.
func (*App) ReloadConfig ¶
ReloadConfig reloads the configuration from the specified path. If validation fails, shows an alert and keeps the current config. Preserves the current app state (enabled/disabled, current mode).
func (*App) Renderer ¶
func (a *App) Renderer() *ui.OverlayRenderer
Renderer returns the overlay renderer.
func (*App) ScrollContext ¶
ScrollContext returns the scroll context.
func (*App) SetEnabled ¶
SetEnabled sets the enabled state of the application.
func (*App) SetHintOverlayNeedsRefresh ¶
SetHintOverlayNeedsRefresh sets the hint overlay needs refresh flag.
func (*App) SetModeGrid ¶
func (a *App) SetModeGrid()
SetModeGrid switches the application to grid mode.
func (*App) SetModeHints ¶
func (a *App) SetModeHints()
SetModeHints sets the mode to hints. SetModeHints switches the application to hints mode.
func (*App) SetModeIdle ¶
func (a *App) SetModeIdle()
SetModeIdle switches the application to idle mode.
func (*App) SetModeRecursiveGrid ¶ added in v1.20.0
func (a *App) SetModeRecursiveGrid()
SetModeRecursiveGrid switches the application to recursive-grid mode.
func (*App) SetModeScroll ¶ added in v1.11.0
func (a *App) SetModeScroll()
SetModeScroll switches the application to scroll mode.
func (*App) SetOverlayHiddenForScreenShare ¶ added in v1.19.0
SetOverlayHiddenForScreenShare sets whether the overlay should be hidden from screen sharing.
func (*App) ToggleEnabled ¶ added in v1.21.4
func (a *App) ToggleEnabled()
ToggleEnabled atomically toggles the enabled state.
func (*App) ToggleOverlayHiddenForScreenShare ¶ added in v1.21.4
ToggleOverlayHiddenForScreenShare atomically toggles the screen share hidden state.
type ComponentCreationOptions ¶ added in v1.11.0
type ComponentCreationOptions struct {
SkipIfDisabled bool // Skip creation if component is disabled in config
Required bool // Component is required (return error if creation fails)
OverlayType string // Type of overlay to create ("hints", "grid", "action", "scroll")
}
ComponentCreationOptions defines options for component creation.
type ComponentFactory ¶ added in v1.11.0
type ComponentFactory struct {
// contains filtered or unexported fields
}
ComponentFactory provides standardized component creation patterns.
func NewComponentFactory ¶ added in v1.11.0
func NewComponentFactory( config *config.Config, logger *zap.Logger, overlayManager OverlayManager, ) *ComponentFactory
NewComponentFactory creates a new component factory.
func (*ComponentFactory) CreateGridComponent ¶ added in v1.11.0
func (f *ComponentFactory) CreateGridComponent( opts ComponentCreationOptions, ) (*components.GridComponent, error)
CreateGridComponent creates a grid component with standardized error handling.
func (*ComponentFactory) CreateHintsComponent ¶ added in v1.11.0
func (f *ComponentFactory) CreateHintsComponent( opts ComponentCreationOptions, ) (*components.HintsComponent, error)
CreateHintsComponent creates a hints component with standardized error handling.
func (*ComponentFactory) CreateModeIndicatorComponent ¶ added in v1.21.0
func (f *ComponentFactory) CreateModeIndicatorComponent( opts ComponentCreationOptions, ) (*components.ModeIndicatorComponent, error)
CreateModeIndicatorComponent creates the shared mode indicator overlay component.
func (*ComponentFactory) CreateRecursiveGridComponent ¶ added in v1.20.0
func (f *ComponentFactory) CreateRecursiveGridComponent( opts ComponentCreationOptions, ) (*components.RecursiveGridComponent, error)
CreateRecursiveGridComponent creates a recursive-grid component with standardized error handling.
func (*ComponentFactory) CreateScrollComponent ¶ added in v1.11.0
func (f *ComponentFactory) CreateScrollComponent( opts ComponentCreationOptions, ) (*components.ScrollComponent, error)
CreateScrollComponent creates a scroll component with standardized error handling. This component now only owns scroll context and key mappings; the visual mode indicator overlay is managed separately.
type HotkeyService ¶
type HotkeyService interface {
// Register registers a new hotkey with the given key string and callback.
// Returns a HotkeyID that can be used to unregister the hotkey later.
Register(keyString string, callback hotkeys.Callback) (hotkeys.HotkeyID, error)
// UnregisterAll unregisters all registered hotkeys.
UnregisterAll()
}
HotkeyService defines the interface for hotkey management. It provides methods for registering and unregistering global hotkeys.
type IPCController ¶
type IPCController struct {
// Services
HintService *services.HintService
GridService *services.GridService
ActionService *services.ActionService
ScrollService *services.ScrollService
ConfigService *config.Service
// State
AppState *state.AppState
// Infrastructure
Logger *zap.Logger
// Mode management
Modes *modes.Handler
// Reload callback for full app-level config reload
ReloadConfig func(ctx context.Context, configPath string) error
// Command Handlers map
Handlers map[string]func(context.Context, ipc.Command) ipc.Response
// contains filtered or unexported fields
}
IPCController handles IPC command routing and execution.
func NewIPCController ¶
func NewIPCController( hintService *services.HintService, gridService *services.GridService, actionService *services.ActionService, scrollService *services.ScrollService, configService *config.Service, appState *state.AppState, config *config.Config, modesHandler *modes.Handler, reloadConfig func(ctx context.Context, configPath string) error, logger *zap.Logger, ) *IPCController
NewIPCController creates a new IPC controller with the given dependencies.
func (*IPCController) HandleCommand ¶
HandleCommand routes an IPC command to the appropriate handler.
func (*IPCController) UpdateConfig ¶ added in v1.24.0
func (c *IPCController) UpdateConfig(cfg *config.Config)
UpdateConfig updates the stored config.
type IPCControllerActions ¶ added in v1.14.0
type IPCControllerActions struct {
// contains filtered or unexported fields
}
IPCControllerActions handles action-related IPC commands.
func NewIPCControllerActions ¶ added in v1.14.0
func NewIPCControllerActions( actionService *services.ActionService, logger *zap.Logger, ) *IPCControllerActions
NewIPCControllerActions creates a new action command handler.
func (*IPCControllerActions) RegisterHandlers ¶ added in v1.14.0
func (h *IPCControllerActions) RegisterHandlers( handlers map[string]func(context.Context, ipc.Command) ipc.Response, )
RegisterHandlers registers action command handlers.
type IPCControllerInfo ¶ added in v1.11.0
type IPCControllerInfo struct {
// contains filtered or unexported fields
}
IPCControllerInfo handles info and config-related IPC commands.
func NewIPCControllerInfo ¶ added in v1.11.0
func NewIPCControllerInfo( configService *config.Service, appState *state.AppState, config *config.Config, modes *modes.Handler, hintService *services.HintService, gridService *services.GridService, actionService *services.ActionService, scrollService *services.ScrollService, reloadConfig func(ctx context.Context, configPath string) error, logger *zap.Logger, ) *IPCControllerInfo
NewIPCControllerInfo creates a new info/config command handler.
func (*IPCControllerInfo) RegisterHandlers ¶ added in v1.11.0
func (h *IPCControllerInfo) RegisterHandlers( handlers map[string]func(context.Context, ipc.Command) ipc.Response, )
RegisterHandlers registers info/config command handlers.
func (*IPCControllerInfo) ResolveConfigPath ¶ added in v1.11.0
func (h *IPCControllerInfo) ResolveConfigPath() string
ResolveConfigPath determines the configuration file path for status reporting.
func (*IPCControllerInfo) UpdateConfig ¶ added in v1.24.0
func (h *IPCControllerInfo) UpdateConfig(cfg *config.Config)
UpdateConfig updates the stored config.
type IPCControllerLifecycle ¶ added in v1.11.0
type IPCControllerLifecycle struct {
// contains filtered or unexported fields
}
IPCControllerLifecycle handles lifecycle-related IPC commands.
func NewIPCControllerLifecycle ¶ added in v1.11.0
func NewIPCControllerLifecycle( appState *state.AppState, modes *modes.Handler, logger *zap.Logger, ) *IPCControllerLifecycle
NewIPCControllerLifecycle creates a new lifecycle command handler.
func (*IPCControllerLifecycle) RegisterHandlers ¶ added in v1.11.0
func (h *IPCControllerLifecycle) RegisterHandlers( handlers map[string]func(context.Context, ipc.Command) ipc.Response, )
RegisterHandlers registers lifecycle command handlers.
type IPCControllerModes ¶ added in v1.11.0
type IPCControllerModes struct {
// contains filtered or unexported fields
}
IPCControllerModes handles mode-related IPC commands.
func NewIPCControllerModes ¶ added in v1.11.0
func NewIPCControllerModes(modes *modes.Handler, logger *zap.Logger) *IPCControllerModes
NewIPCControllerModes creates a new mode command handler.
func (*IPCControllerModes) RegisterHandlers ¶ added in v1.11.0
func (h *IPCControllerModes) RegisterHandlers( handlers map[string]func(context.Context, ipc.Command) ipc.Response, )
RegisterHandlers registers mode command handlers.
type IPCControllerOverlay ¶ added in v1.19.0
type IPCControllerOverlay struct {
// contains filtered or unexported fields
}
IPCControllerOverlay handles overlay-related IPC commands.
func NewIPCControllerOverlay ¶ added in v1.19.0
func NewIPCControllerOverlay(appState *state.AppState, logger *zap.Logger) *IPCControllerOverlay
NewIPCControllerOverlay creates a new overlay command handler.
func (*IPCControllerOverlay) RegisterHandlers ¶ added in v1.19.0
func (h *IPCControllerOverlay) RegisterHandlers( handlers map[string]func(context.Context, ipc.Command) ipc.Response, )
RegisterHandlers registers overlay command handlers.
type ModeService ¶ added in v1.10.5
type ModeService interface {
// Show activates the mode's overlay/interface.
Show(ctx context.Context) error
// Hide deactivates the mode's overlay/interface.
Hide(ctx context.Context) error
}
ModeService defines the common interface for mode-specific services. This ensures grid, hints, and scroll services have identical APIs.
type Option ¶ added in v1.10.5
Option is a functional option for configuring an App instance.
func WithConfig ¶ added in v1.10.5
WithConfig sets the application configuration. Note: cfg can be nil, in which case default configuration will be used.
func WithConfigPath ¶ added in v1.10.5
WithConfigPath sets the configuration file path.
func WithEventTap ¶ added in v1.10.5
func WithEventTap(eventTap ports.EventTapPort) Option
WithEventTap sets the event tap implementation. Note: eventTap can be nil, will be initialized during app startup if not provided.
func WithHotkeyService ¶ added in v1.10.5
func WithHotkeyService(hotkeyService HotkeyService) Option
WithHotkeyService sets the hotkey service implementation. Note: hotkeyService can be nil, will be initialized during app startup if not provided.
func WithIPCServer ¶ added in v1.10.5
WithIPCServer sets the IPC server implementation. Note: ipcServer can be nil, will be initialized during app startup if not provided.
func WithLogger ¶ added in v1.10.5
WithLogger sets the application logger.
func WithOverlayManager ¶ added in v1.10.5
func WithOverlayManager(overlayManager OverlayManager) Option
WithOverlayManager sets the overlay manager implementation. Note: overlayManager can be nil, will be initialized during app startup if not provided.
func WithWatcher ¶ added in v1.10.5
WithWatcher sets the app watcher implementation. Note: watcher can be nil, will be initialized during app startup if not provided.
type OverlayManager ¶
type OverlayManager = overlay.ManagerInterface
OverlayManager defines the interface for overlay window management.
type SystrayComponent ¶ added in v1.12.1
type SystrayComponent interface {
OnReady()
OnExit()
Close()
}
SystrayComponent defines the interface for systray functionality.
type Watcher ¶
type Watcher interface {
Start()
Stop()
OnActivate(callback appwatcher.AppCallback)
OnDeactivate(callback appwatcher.AppCallback)
OnTerminate(callback appwatcher.AppCallback)
OnScreenParametersChanged(callback func())
}
Watcher defines the interface for application lifecycle monitoring.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package components provides feature-specific implementations.
|
Package components provides feature-specific implementations. |
|
grid
Package grid provides grid-based navigation functionality for Neru.
|
Package grid provides grid-based navigation functionality for Neru. |
|
hints
Package hints provides accessibility tree-based hint generation and navigation.
|
Package hints provides accessibility tree-based hint generation and navigation. |
|
modeindicator
Package modeindicator provides the mode indicator overlay component.
|
Package modeindicator provides the mode indicator overlay component. |
|
overlayutil
Package overlayutil provides shared utilities for overlay management.
|
Package overlayutil provides shared utilities for overlay management. |
|
recursivegrid
Package recursivegrid provides the recursivegrid component.
|
Package recursivegrid provides the recursivegrid component. |
|
scroll
Package scroll provides Vim-style scrolling functionality for the Neru application.
|
Package scroll provides Vim-style scrolling functionality for the Neru application. |
|
systray
Package systray provides system tray functionality for the Neru application.
|
Package systray provides system tray functionality for the Neru application. |
|
Package modes implements the different operational modes for Neru.
|
Package modes implements the different operational modes for Neru. |
|
Package services implements application use cases and orchestration logic.
|
Package services implements application use cases and orchestration logic. |
|
modeindicator
Package modeindicator provides the mode indicator service.
|
Package modeindicator provides the mode indicator service. |