Skip to content
docsv0.3.0

FocusManagerInterface

Ordered-id rotation for "which thing has keyboard focus right now", shared by both TUI runtimes. {@see \Milpa\Live\Tui\FocusManager} is the one implementation; putting it behind this contract lets {@see \Milpa\Live\Tui\RetainedTuiLoop} reuse it instead of reimplementing the same modulo-wrapped rotation math ad hoc against a bare string.

FocusManagerInterface::currentId()

abstract public function currentId(): ?string

The id currently holding focus, or null when nothing does.

Returns

The currently focused id, or `null` if {@see ids()} is empty.

FocusManagerInterface::focus()

abstract public function focus(string $id): void

Explicitly focuses `$id`. MUST be a no-op — not an error — if `$id` is not among {@see ids()}, leaving the current focus unchanged.

Parameters

Parameters of focus()
NameTypeDescription
$idstring

FocusManagerInterface::next()

abstract public function next(): ?string

Advances focus to the next id, wrapping around to the first id after the last.

Returns

The newly focused id, or `null` if {@see ids()} is empty.

FocusManagerInterface::previous()

abstract public function previous(): ?string

Moves focus to the previous id, wrapping around to the last id before the first.

Returns

The newly focused id, or `null` if {@see ids()} is empty.

FocusManagerInterface::ids()

abstract public function ids(): array

The full ordered list of ids this manager rotates focus through.