class TermBuf::ResponseScanner

Overview

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

The prober needs this to tell a reply to its own query from a keystroke that happened to arrive at the same moment, and the input 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.

Defined in:

termbuf/caps/response_scanner.cr

Constant Summary

BEL = 7_u8
ESC = 27_u8
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 Method Summary

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def clear : Nil #

Discards anything held back.


[View source]
def feed(chunk : Bytes, & : Kind, Bytes -> ) : Nil #

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


[View source]
def flush(& : Kind, Bytes -> ) : Nil #

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


[View source]
def pending : Bytes #

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


[View source]
def pending? : Bool #

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


[View source]