Documentation
¶
Overview ¶
Package ghostcursor draws transient cursor overlays on macOS. Use New to create a controller, Show to display a cursor, and MoveTo to animate it. Close releases the controller's window and event observers.
Example ¶
package main
import (
"fmt"
"github.com/tmc/axmcp/ghostcursor"
)
func main() {
cursor := ghostcursor.New(ghostcursor.Config{Enabled: true})
defer cursor.Close()
fmt.Println(cursor.Enabled())
}
Output: true
Index ¶
- Variables
- func RenderPNG(opts RenderOptions) ([]byte, error)
- type ActivityState
- type Config
- type Controller
- func (c *Controller) Close() error
- func (c *Controller) Configure(cfg Config)
- func (c *Controller) DragTo(x, y int)
- func (c *Controller) Enabled() bool
- func (c *Controller) FlashCaptureRect(rect Rect)
- func (c *Controller) Hide()
- func (c *Controller) HoverAt(x, y int)
- func (c *Controller) MoveTo(ctx context.Context, pos Position, opts MoveOptions) error
- func (c *Controller) PressAt(x, y int)
- func (c *Controller) ReleaseAt(x, y int)
- func (c *Controller) SetActivity(activity ActivityState) error
- func (c *Controller) SharingVisible() bool
- func (c *Controller) Show(pos Position, activity ActivityState, hideAfter time.Duration) error
- type CoordinateSpace
- type CurveStyle
- type EyecandyConfig
- type Info
- type MoveOptions
- type NextInteractionTiming
- type Position
- type Rect
- type RenderColor
- type RenderOptions
- type Theme
- type TuningConfig
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrMoveAborted = errors.New("ghost cursor move aborted")
Functions ¶
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 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() error
Close releases AppKit and monitoring resources held by the controller.
func (*Controller) Configure ¶
func (c *Controller) Configure(cfg Config)
func (*Controller) DragTo ¶
func (c *Controller) DragTo(x, y int)
DragTo shows the dragging cursor at x and y.
func (*Controller) Enabled ¶
func (c *Controller) Enabled() bool
func (*Controller) FlashCaptureRect ¶
func (c *Controller) FlashCaptureRect(rect Rect)
FlashCaptureRect briefly outlines rect using the controller's palette.
func (*Controller) Hide ¶
func (c *Controller) Hide()
func (*Controller) HoverAt ¶
func (c *Controller) HoverAt(x, y int)
HoverAt shows the idle cursor briefly at x and y.
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) PressAt ¶
func (c *Controller) PressAt(x, y int)
PressAt shows the pressed cursor at x and y.
func (*Controller) ReleaseAt ¶
func (c *Controller) ReleaseAt(x, y int)
ReleaseAt briefly shows the idle cursor at the release point.
func (*Controller) SetActivity ¶
func (c *Controller) SetActivity(activity ActivityState) error
func (*Controller) SharingVisible ¶
func (c *Controller) SharingVisible() bool
SharingVisible reports whether the controller allows its overlay in captures.
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
}
func DefaultEyecandyConfig ¶
func DefaultEyecandyConfig() EyecandyConfig
DefaultEyecandyConfig returns the default overlay effect settings.
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 ¶
ScreenPosition returns the position at screen coordinates x and y.
func TypingPositionForFrame ¶
TypingPositionForFrame returns a position near the leading edge of a text field.
type Rect ¶
type Rect struct {
X, Y, Width, Height float64
}
Rect describes a rectangle in screen coordinates, with a top-left origin.
type RenderColor ¶
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 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
DefaultTuningConfig returns the default appearance and timing settings.