class Reline::ANSI

def self.inner_getc

def self.inner_getc
  unless @@buf.empty?
    return @@buf.shift
  end
  until c = @@input.raw(intr: true) { @@input.wait_readable(0.1) && @@input.getbyte }
    Reline.core.line_editor.resize
  end
  (c == 0x16 && @@input.raw(min: 0, time: 0, &:getbyte)) || c
rescue Errno::EIO
  # Maybe the I/O has been closed.
  nil
rescue Errno::ENOTTY
  nil
end