Help us shape the future of Go! Take the 2026 Go Developer Survey

ghostcursor

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package ghostcursor draws a transient overlay cursor for pointer actions. Animated moves follow a deterministic Bezier arc so drags read as motion instead of teleports.

Index

Constants

This section is empty.

Variables

View Source
var ErrMoveAborted = errors.New("ghost cursor move aborted")

Functions

func Configure

func Configure(cfg Config)

func DragTo

func DragTo(x, y int)

func Enabled

func Enabled() bool

func FlashCaptureRect

func FlashCaptureRect(rect corefoundation.CGRect)

func Hide

func Hide()

func HoverAt

func HoverAt(x, y int)

func OverlaySharingType

func OverlaySharingType() appkit.NSWindowSharingType

func PressAt

func PressAt(x, y int)

func ReleaseAt

func ReleaseAt(x, y int)

func RenderPNG

func RenderPNG(opts RenderOptions) ([]byte, error)

RenderPNG rasterizes the current cursor style to a PNG.

Types

type ActivityState

type ActivityState int

ActivityState describes the current visual state of the cursor.

const (
	ActivityIdle ActivityState = iota
	ActivityMoving
	ActivityPressed
	ActivityDragging
	ActivityTyping
	ActivityThinking
	ActivityPaused
)

type Config

type Config struct {
	Enabled  bool
	Eyecandy EyecandyConfig
	Theme    Theme
	Tuning   TuningConfig
}

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

func Default

func Default() *Controller

func New

func New(cfg Config) *Controller

New returns a controller that marshals all AppKit work to the main thread.

func (*Controller) Close

func (c *Controller) Close()

Close releases AppKit and monitoring resources held by the controller.

func (*Controller) Configure

func (c *Controller) Configure(cfg Config)

func (*Controller) Enabled

func (c *Controller) Enabled() bool

func (*Controller) Hide

func (c *Controller) Hide()

func (*Controller) MoveTo

func (c *Controller) MoveTo(ctx context.Context, pos Position, opts MoveOptions) error

MoveTo blocks until the requested motion has completed or the next-interaction gate is satisfied. Callers may invoke it from any goroutine.

func (*Controller) SetActivity

func (c *Controller) SetActivity(activity ActivityState) error

func (*Controller) Show

func (c *Controller) Show(pos Position, activity ActivityState, hideAfter time.Duration) error

type CoordinateSpace

type CoordinateSpace int

CoordinateSpace identifies how a position should be interpreted.

const (
	CoordinateSpaceUnknown CoordinateSpace = iota
	CoordinateSpaceScreen
)

type CurveStyle

type CurveStyle int

CurveStyle controls how sampled motion progresses toward a target.

const (
	// CurveBezier is the default. Its zero value keeps existing callers on the
	// curved path without additional configuration.
	CurveBezier CurveStyle = iota
	CurveEaseInOut
	CurveLinear
)

type EyecandyConfig

type EyecandyConfig struct {
	SharingVisible bool
	RippleOnClick  bool
	CometTrail     bool
	VelocityTilt   bool
	HolographicOCR bool
	LiquidLens     bool
}

func DefaultEyecandyConfig

func DefaultEyecandyConfig() EyecandyConfig

type Info

type Info struct {
	Harness      string
	MatchName    string
	MatchPID     int
	PaletteID    int
	PaletteIndex int
	DotColor     string
	BorderColor  string
}

Info describes the detected harness and selected cursor colors.

func DetectInfo

func DetectInfo() Info

DetectInfo reports the detected host harness and selected palette.

type MoveOptions

type MoveOptions struct {
	Duration        time.Duration
	Activity        ActivityState
	HideAfter       time.Duration
	CurveStyle      CurveStyle
	Strength        float64
	Jitter          float64
	NextInteraction NextInteractionTiming
}

MoveOptions controls a blocking cursor movement.

type NextInteractionTiming

type NextInteractionTiming struct {
	DistancePx      float64
	Progress        float64
	IdleVelocityPPS float64
	Dwell           time.Duration
	MaxWait         time.Duration
}

NextInteractionTiming controls when MoveTo may return before the animation fully completes so input can be issued once the cursor is close enough.

type Position

type Position struct {
	Space     CoordinateSpace
	DisplayID uint32
	X         float64
	Y         float64
}

Position identifies a cursor location in a specific coordinate space.

func SamplePath

func SamplePath(start, end Position, opts MoveOptions) ([]Position, error)

SamplePath returns the screen-space keyframes for moving between start and end using the requested curve. The returned slice always contains the first and last point when the positions differ.

func ScreenPosition

func ScreenPosition(x, y int) Position

func TypingPositionForFrame

func TypingPositionForFrame(x, y, width, height float64) Position

type RenderColor

type RenderColor struct {
	Red   float64
	Green float64
	Blue  float64
	Alpha float64
}

RenderColor describes an sRGB color for offscreen cursor rendering.

type RenderOptions

type RenderOptions struct {
	Size       int
	Theme      Theme
	Activity   ActivityState
	Background RenderColor
	DX         float64
	DY         float64
	Speed      float64
}

RenderOptions controls offscreen cursor rendering.

type Theme

type Theme int

Theme selects a cursor palette family.

const (
	ThemeAuto Theme = iota
	ThemeCodex
	ThemeClaude
	ThemeNeutral
)

type TuningConfig

type TuningConfig struct {
	Brightness     float64
	CursorScale    float64
	BodyOpacity    float64
	OutlineOpacity float64
	GlowOpacity    float64
	GlowScale      float64
	IdleFadeDelay  time.Duration
	IdleFadeTime   time.Duration
	MoveGlowTime   time.Duration
}

func DefaultTuningConfig

func DefaultTuningConfig() TuningConfig

Jump to

Keyboard shortcuts

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