class

TermBuf::Input::SequenceScanner

Inherits Reference < Object

Splits a stream of bytes arriving from the terminal into complete escape sequences and everything else.

Anything waiting on a reply to a query it made needs this to tell that reply from a keystroke that happened to arrive at the same moment, and Decoder needs the same split for the same reason. Bytes that do not form a complete sequence yet are held back rather than guessed at.

#feed yields each chunk it can classify; whatever is left over is #pending and is put in front of the next chunk fed in. #flush gives up on what is held and yields it as text, which is what a timeout means.

Constants

BEL = 7_u8

The bell, which is one of the two things that can end an OSC string.

ESC = 27_u8

The escape byte every sequence begins with.

MAX_SEQUENCE = 1024

A sequence longer than this is treated as a stray escape followed by ordinary input. Without a bound, one ESC with nothing after it would hold every later byte hostage.

Constructors

Instance methods

clear

Discards anything held back.

Source
feed(chunk : Bytes, & : Kind, Bytes -> ) : Nil

Feeds bytes in, yielding each complete chunk that can be classified.

Source
flush

Treats whatever is held back as ordinary text, which is what a timeout means: no more of that sequence is coming.

Source
pending

Bytes held back because they do not yet form a complete sequence.

Source
pending?

Whether anything is being held back, without copying it out.

Source

Nested types