Atui.Input (Atui v0.1.0)

Copy Markdown View Source

Reads the terminal and sends decoded keys to a target process.

Two processes are involved. A pump sits blocked in a read on stdin — it can do nothing else, which is exactly why it is on its own. A decoder collects those bytes, runs them through Atui.Key, and forwards {:atui_key, key} messages to the runtime.

The decoder's receive timeout is what makes a bare ESC usable: if no further byte follows within esc_timeout the pending buffer is flushed as :esc rather than waiting forever for an arrow key that is not coming.

Summary

Functions

Starts the decoder (and its pump), linked to the caller.

Functions

start_link(target, opts \\ [])

Starts the decoder (and its pump), linked to the caller.

Options:

  • :read — 0-arity function returning bytes, :eof or {:error, term}. Defaults to a blocking one-byte read of stdin; override it in tests.
  • :esc_timeout — ms to wait before a lone ESC is reported (default 40)