AutocompleteProviderInterface
Suggests completions for a text-input or editor field. The TUI analog of pi-tui's `AutocompleteProvider` interface. A provider answers two questions: "does the current text+cursor trigger a completion query?" (via {@see shouldTrigger()}) and "what completions match the query?" (via {@see suggestions()}). The renderer or key handler that owns the field calls these to populate a `select-list` overlay showing the matches. Implementations are expected to be cheap and synchronous — a provider is consulted on every keystroke when a completion window is open, so blocking I/O or expensive lookups should be offloaded by the caller, not baked into the contract. Pure in-memory providers (slash commands, a small file list) are the intended use case.
AutocompleteProviderInterface::shouldTrigger()
abstract public function shouldTrigger(string $text, int $cursor): boolWhether the cursor at `$cursor` in `$text` should open a completion window. The provider decides what triggers a query — e.g. a slash command provider answers true when the cursor follows a `/` not preceded by a non-whitespace char, a file path provider answers true for `./`, `~/`, `../`, `@` prefixes.
Parameters
| Name | Type | Description |
|---|---|---|
| $text | string | |
| $cursor | int |
AutocompleteProviderInterface::suggestions()
abstract public function suggestions(string $text, int $cursor): arrayReturns the completion matches for the query extracted from `$text` at `$cursor`. Each suggestion is a `{value, label, description?}` array shaped the same way as a `select-list` item, so the caller can hand the result straight to a `SelectListRenderer` overlay.
Parameters
| Name | Type | Description |
|---|---|---|
| $text | string | |
| $cursor | int |