KeyDecoder class
Turns raw terminal input bytes (read in raw mode) into KeyEvents.
The decoder is streaming: feed it each chunk from stdin with decode and it returns the events that completed in that chunk, buffering any partial escape sequence or partial UTF-8 character until the rest arrives. This keeps multi-byte input (arrow keys, accented characters pasted a chunk at a time) robust without the caller reasoning about byte boundaries.
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasPendingEscape → bool
-
Whether the only buffered input is a lone
ESC: either a bare Escape keypress or the start of a sequence whose rest has not arrived yet. LoneEscapeTimer resolves it by calling flush after escapeTimeout if no more input arrived meanwhile.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
decode(
List< int> bytes) → List<KeyEvent> -
Decodes
bytes, returning the keys that completed. Incomplete trailing sequences are retained for the next call. -
flush(
) → List< KeyEvent> -
Flushes any buffered bytes as a best-effort final decode (e.g. a lone
trailing
ESC). Call when input ends, or when hasPendingEscape has stayed set for escapeTimeout. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- escapeTimeout → const Duration
-
How long to wait, with hasPendingEscape set, before calling flush to
deliver the buffered
ESCas an Escape key (see LoneEscapeTimer). A terminal writes an escape sequence in one go, so its bytes arrive well within this; a bare Escape keypress is a lone byte that nothing follows.