tryReadNextByte static method

int? tryReadNextByte({
  1. Duration delay = const Duration(milliseconds: 2),
})

Attempts to read the next byte for multi-byte escape sequences.

The optional delay gives the terminal a moment to deliver additional bytes (default 2ms). Returns null if no byte is available.

Implementation

static int? tryReadNextByte(
    {Duration delay = const Duration(milliseconds: 2)}) {
  try {
    sleep(delay);
    if (TerminalContext.input.hasTerminal) {
      return TerminalContext.input.readByteSync();
    }
  } catch (_) {}
  return null;
}