Tuix.Input.Parser (tuix v0.1.0)

Copy Markdown View Source

Incremental parser turning raw terminal input bytes into Tuix.Event.Key structs.

parse/1 returns {events, rest} where rest is an incomplete trailing escape sequence to be prepended to the next chunk of input.

Summary

Functions

Parses a binary of input bytes into key events.

Functions

parse(data)

@spec parse(binary()) :: {[Tuix.Event.Key.t()], binary()}

Parses a binary of input bytes into key events.

Examples

iex> Tuix.Input.Parser.parse("a")
{[%Tuix.Event.Key{key: "a"}], ""}

iex> Tuix.Input.Parser.parse("\e[A")
{[%Tuix.Event.Key{key: :up}], ""}