Screen
Phui\Screen configures the terminal and runs the render loop. Every setter returns the screen, so calls chain.
Mounting and running
static mount(Component|string $component): staticCreates a screen with $component as the root of the tree.
Screen::mount(App::class)->run();run(
int $targetFps = 60,
bool $installErrorHandler = true,
): mixedRuns the loop until the app completes or quits, and returns the value passed to complete().
start(bool $installErrorHandler = true): staticTakes over the terminal without entering a loop, for driving frames yourself.
frame(): boolProcesses input and renders one frame. Returns whether the app is still running.
stop(): voidRestores the terminal and ends the run.
Terminal options
mouse(
bool $enabled = true,
MouseTracking $tracking = MouseTracking::DRAG,
): staticSets mouse reporting and how much movement is tracked.
focusTracking(bool $enabled = true): staticSets whether the terminal reports window focus changes as a FocusEvent.
bracketedPaste(bool $enabled = true): staticSets whether pastes arrive as a single PasteEvent rather than as keypresses.
cursor(bool $visible = true): staticSets whether the terminal cursor is shown.
inline(int $height = 15): staticRenders into a region of $height rows in the current terminal rather than taking over the whole screen.
captureOutput(bool $enabled = true): staticSets whether output written outside the renderer is captured and reported as a StrayOutputEvent.
colours(ColourMode $mode): staticForces a ColourMode instead of detecting one.
Application setup
theme(Theme $theme): staticSets the active Theme.
service(string $class, object $instance): staticRegisters a service, retrieved in a component with get().
bindings(
?Binding $focusNext = null,
?Binding $focusPrevious = null,
?Binding $toggleDebug = null,
?Binding $quit = null,
): staticReplaces the framework bindings. A null entry keeps the default.
debug(bool $enabled = true): staticSets whether the debug bar is available.
backend(Backend $backend): static
clock(Clock $clock): staticReplace the terminal backend and the clock, used by testing.
Exceptions
Classes in the Phui\Exceptions namespace, all extending RuntimeException.
CompleteException(
public readonly mixed $value = null,
)Thrown by complete() to end the run. Caught by the runtime, which returns $value from run().
QuitExceptionThrown to end the run without a value.
NotATerminalExceptionThrown when the process is not attached to a terminal.
static MissingServiceException::for(string $class): selfThrown by get() when no service is registered under $class.
static MissingColoursException::for(string $class): selfThrown by resolve() when a colours class has no static for() factory.