etui/input

Types

Events decoded from a chunk, plus the bytes that did not form a complete sequence. remainder is always either empty or starts with ESC.

pub type Parsed {
  Parsed(events: List(backend.InputEvent), remainder: String)
}

Constructors

Values

pub fn flush(remainder: String) -> List(backend.InputEvent)

Turn a leftover remainder into events once it is clear no more input is coming (the read timed out).

A remainder always starts with ESC. If that is all it is, the user pressed Escape. A genuinely truncated sequence also yields Escape; its trailing bytes are dropped rather than delivered as stray key presses, because a half escape sequence is not text the user typed.

pub fn parse(chunk: String) -> Parsed

Decode as many events as possible from chunk.

input.parse("ab")                  // two KeyPress events
input.parse("\u{001B}[A")          // KeyPress("up")
input.parse("\u{001B}[")           // no events, remainder "\u{001B}["
✨ Search Document