In Files

  • reline/ansi.rb

Reline::ANSI

Public Class Methods

encoding() click to toggle source
 
               # File reline/ansi.rb, line 5
def self.encoding
  Encoding.default_external
end
            
getc_with_bracketed_paste() click to toggle source
 
               # File reline/ansi.rb, line 87
def self.getc_with_bracketed_paste
  buffer = String.new(encoding: Encoding::ASCII_8BIT)
  buffer << inner_getc
  while START_BRACKETED_PASTE.start_with?(buffer) or END_BRACKETED_PASTE.start_with?(buffer) do
    if START_BRACKETED_PASTE == buffer
      @@in_bracketed_paste_mode = true
      return inner_getc
    elsif END_BRACKETED_PASTE == buffer
      @@in_bracketed_paste_mode = false
      ungetc(-1)
      return inner_getc
    end
    begin
      succ_c = nil
      Timeout.timeout(Reline.core.config.keyseq_timeout * 100) {
        succ_c = inner_getc
      }
    rescue Timeout::Error
      break
    else
      buffer << succ_c
    end
  end
            
inner_getc() click to toggle source
 
               # File reline/ansi.rb, line 71
def self.inner_getc
  unless @@buf.empty?
    return @@buf.shift
  end
  until c = @@input.raw(intr: true, &:getbyte)
    sleep 0.1
  end
  (c == 0x16 && @@input.raw(min: 0, tim: 0, &:getbyte)) || c
rescue Errno::EIO
  # Maybe the I/O has been closed.
  nil
end
            
input=(val) click to toggle source
 
               # File reline/ansi.rb, line 61
def self.input=(val)
  @@input = val
end
            
output=(val) click to toggle source
 
               # File reline/ansi.rb, line 66
def self.output=(val)
  @@output = val
end
            
win?() click to toggle source
 
               # File reline/ansi.rb, line 9
def self.win?
  false
end