Skip to content
docsv0.3.0

ShortcutRegistryInterface

Registers and resolves keyboard shortcut bindings by key within a scope (e.g. a modal's own scope vs the `'global'` default), so a TUI runtime can look up "what command does this keypress trigger right now" without every screen/overlay maintaining its own key-to-command table.

ShortcutRegistryInterface::register()

abstract public function register(Milpa\Live\ValueObjects\Tui\ShortcutBinding $binding): void

Registers a binding, replacing any existing binding for the same key within the same scope.

Parameters

Parameters of register()
NameTypeDescription
$bindingMilpa\Live\ValueObjects\Tui\ShortcutBinding

ShortcutRegistryInterface::resolve()

abstract public function resolve(string $key, string $scope = 'global'): ?Milpa\Live\ValueObjects\Tui\ShortcutBinding

Resolves the binding for `$key` within `$scope`. Implementations SHOULD fall back to the `'global'` scope when no binding is registered for `$key` in the requested (non-global) scope, so global shortcuts remain reachable from any scope.

Parameters

Parameters of resolve()
NameTypeDescription
$keystring
$scopestring

Returns

`null` if no binding matches, in either the requested scope or the global fallback.

ShortcutRegistryInterface::all()

abstract public function all(?string $scope = null): array

All registered bindings, optionally filtered to one scope.

Parameters

Parameters of all()
NameTypeDescription
$scope?string

Returns

All bindings if `$scope` is `null`; only that scope's bindings otherwise.