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

action

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package action is Cove's command registry — the keystone of the discoverability thesis (PRD §5.4). Every user action is a named entry here; the palette, the keybinding dispatcher, and (later) TOML rebinding and plugins all read this one data structure. An action that is not in the registry does not exist.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	ID     string // "file.save"
	Title  string // "File: Save" — what the palette shows
	Key    string
	When   Context
	Hidden bool // bound but not palette-listed (movement keys)
	Do     func(app any) tea.Cmd
}

Action is one named command. Key is the default binding in tea.KeyMsg.String() form ("ctrl+s", "shift+down", ...); empty means palette-only. Do returns a tea.Cmd (usually nil); the receiver is the app, passed as any to avoid an import cycle.

type Context

type Context string

Context scopes a binding to whichever pane has focus. Global actions fire anywhere in edit mode.

const (
	Global  Context = "global"
	Editor  Context = "editor"
	Sidebar Context = "sidebar"
	Git     Context = "git"    // the git panel
	Search  Context = "search" // the project-search results panel
	Review  Context = "review" // the agent review panel
)

type Registry

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

func NewRegistry

func NewRegistry() *Registry

func (*Registry) ByID

func (r *Registry) ByID(id string) *Action

ByID returns the action with the given ID, or nil.

func (*Registry) Lookup

func (r *Registry) Lookup(ctx Context, key string) *Action

Lookup resolves a key press for a focused context, falling back to Global. Returns nil if unbound.

func (*Registry) Owner added in v0.10.0

func (r *Registry) Owner(id, key string, when Context) string

Owner returns the ID of a different action bound to key in a context that collides with when (same context, or Global on either side — Lookup falls back to Global, so those shadow each other). "" means no conflict.

func (*Registry) Palette

func (r *Registry) Palette() []Action

Palette returns all palette-visible actions sorted by title, so the "Category:" prefixes group together instead of surfacing in whatever order newRegistry happens to declare them.

func (*Registry) Rebind

func (r *Registry) Rebind(id, key string) bool

Rebind changes an action's key (empty = palette-only) and reindexes. Returns false for unknown IDs. On key conflict, the later-registered action wins.

func (*Registry) Register

func (r *Registry) Register(a Action)

Jump to

Keyboard shortcuts

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