Phosphor::Router
Documents key bindings for the application.
The router is a documentation layer only — actual event routing happens
via View#subscribe. Router.define collects binding declarations so
generate_help can produce a keybinding reference for the ? keybinding.
See DESIGN.md § "Router: your routes.rb" for the full rationale and a worked example.
Class methods
Evaluates the DSL block and returns the resulting Definition.
Call once at application startup. The Definition is passed to
generate_help when the user presses ? to view keybindings.
ROUTER = Router.define do
global do
bind key: "ctrl+c", to: :quit
bind key: "?", to: :help
end
screen DashboardScreen do
bind key: "j/↓", to: :select_next
bind key: "k/↑", to: :select_prev
end
end
Formats definition as a human-readable keybinding reference.
Global bindings are listed first under a "Global" header, followed by per-screen sections separated by blank lines. Each screen section opens with the short class name (no module prefix). Keys are left-padded to the width of the widest key across all sections for visual alignment.
Returns plain text with no ANSI styling — Style is applied by the
widget that renders the output.