class Reline::IO

Constants

RESET_COLOR

Public Class Methods

decide_io_gate() click to toggle source
# File reline/io.rb, line 6
def self.decide_io_gate
  if ENV['TERM'] == 'dumb'
    Reline::Dumb.new
  else
    require 'reline/io/ansi'

    case RbConfig::CONFIG['host_os']
    when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
      require 'reline/io/windows'
      io = Reline::Windows.new
      if io.msys_tty?
        Reline::ANSI.new
      else
        io
      end
    else
      Reline::ANSI.new
    end
  end
end

Public Instance Methods

dumb?() click to toggle source
# File reline/io.rb, line 27
def dumb?
  false
end
read_single_char(keyseq_timeout) click to toggle source

Read a single encoding valid character from the input.

# File reline/io.rb, line 40
def read_single_char(keyseq_timeout)
  buffer = String.new(encoding: Encoding::ASCII_8BIT)
  loop do
    timeout = buffer.empty? ? Float::INFINITY : keyseq_timeout
    c = getc(timeout)
    return unless c

    buffer << c
    encoded = buffer.dup.force_encoding(encoding)
    return encoded if encoded.valid_encoding?
  end
end
reset_color_sequence() click to toggle source
# File reline/io.rb, line 35
def reset_color_sequence
  self.class::RESET_COLOR
end
win?() click to toggle source
# File reline/io.rb, line 31
def win?
  false
end