TermUI.Terminal.InputReader (TermUI v0.2.0)
View SourceGenServer that reads keyboard input from stdin and sends events to a target process.
Uses a port to read from stdin in a non-blocking way. Parses escape sequences and emits Event.Key structs to the configured target process.
Usage
{:ok, reader} = InputReader.start_link(target: self())
# Events will be sent as {:input, %Event.Key{}}Escape Sequence Handling
Some sequences are ambiguous (ESC alone vs ESC followed by another key). The reader uses a timeout (default 50ms) to disambiguate - if no more bytes arrive within the timeout, a lone ESC is emitted.
Summary
Functions
Returns a specification to start this module under a supervisor.
Starts the InputReader.
Stops the InputReader.
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec start_link(keyword()) :: GenServer.on_start()
Starts the InputReader.
Options
:target- PID to receive events (required):name- GenServer name (optional)
@spec stop(GenServer.server()) :: :ok
Stops the InputReader.