dispatch

package
v0.10.4 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeriveScope added in v0.10.3

func DeriveScope(action keybindings.Action) string

DeriveScope determines the intent scope from generated built-in metadata. Non-built-in actions have no scope.

func RouteIntent added in v0.10.3

func RouteIntent(scopes []Scope, intent intents.Intent) (tea.Cmd, bool)

Types

type Continuation

type Continuation struct {
	Key    string
	Desc   string
	Action bindings.Action
	IsLeaf bool
}

Continuation describes possible next keys while in sequence mode.

type Dispatcher

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

Dispatcher resolves key presses against active scopes and bindings.

func NewDispatcher

func NewDispatcher(availableBindings []bindings.Binding) (*Dispatcher, error)

func (*Dispatcher) ResetSequence

func (d *Dispatcher) ResetSequence()

func (*Dispatcher) Resolve

func (d *Dispatcher) Resolve(msg tea.KeyMsg, scopes []Scope) ResolveResult

Resolve applies dispatch rules for a key in the provided layer chain. Scopes must be ordered from innermost to outermost.

type LeakPolicy added in v0.10.3

type LeakPolicy int
const (
	LeakAll LeakPolicy = iota
	LeakGlobal
	LeakNone
)

type ResolveResult

type ResolveResult struct {
	Action        bindings.Action
	Scope         bindings.ScopeName
	Args          map[string]any
	Pending       bool
	Consumed      bool
	Continuations []Continuation
}

ResolveResult is the outcome of resolving a key press.

type Resolver

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

Resolver wraps a Dispatcher and extends the pipeline to resolve keys all the way to intents and scopes.

func NewResolver

func NewResolver(d *Dispatcher) *Resolver

NewResolver creates a Resolver that wraps the given dispatcher.

func (*Resolver) ResetSequence

func (r *Resolver) ResetSequence()

ResetSequence resets any in-progress key sequence.

func (*Resolver) ResolveAction

func (r *Resolver) ResolveAction(action keybindings.Action, args map[string]any) Result

ResolveAction resolves a dispatched action through configured-action aliasing and intent resolution.

func (*Resolver) ResolveBuiltInAction

func (r *Resolver) ResolveBuiltInAction(action keybindings.Action, args map[string]any) Result

ResolveBuiltInAction resolves an action while skipping configured Lua overrides.

func (*Resolver) ResolveKey

func (r *Resolver) ResolveKey(msg tea.KeyMsg, scopes []Scope) Result

ResolveKey resolves a key press through the full pipeline: key → binding → action → intent.

type Result

type Result struct {
	Intent        intents.Intent
	Scope         string
	Args          map[string]any
	LuaScript     string
	Pending       bool
	Consumed      bool
	Continuations []Continuation
}

Result is the outcome of full dispatch resolution.

type Scope added in v0.10.3

type Scope struct {
	Name    keybindings.ScopeName
	Leak    LeakPolicy
	Global  bool
	Handler ScopeHandler
}

Scope represents one routing layer in the intent dispatch chain. Scopes are ordered from innermost (highest priority) to outermost.

func VisibleScopes added in v0.10.3

func VisibleScopes(scopes []Scope) []Scope

type ScopeHandler added in v0.10.3

type ScopeHandler interface {
	HandleIntent(intent intents.Intent) (tea.Cmd, bool)
	Update(msg tea.Msg) tea.Cmd
}

type ScopeProvider added in v0.10.3

type ScopeProvider interface {
	Scopes() []Scope
}

Jump to

Keyboard shortcuts

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