lib/reline/ansi.rb in reline-0.2.6 vs lib/reline/ansi.rb in reline-0.2.7
- old
+ new
@@ -1,6 +1,7 @@
require 'io/console'
+require 'io/wait'
require 'timeout'
require_relative 'terminfo'
class Reline::ANSI
if Reline::Terminfo.enabled?
@@ -181,25 +182,19 @@
def self.empty_buffer?
unless @@buf.empty?
return false
end
- rs, = IO.select([@@input], [], [], 0.00001)
- if rs and rs[0]
- false
- else
- true
- end
+ !@@input.wait_readable(0)
end
def self.ungetc(c)
@@buf.unshift(c)
end
def self.retrieve_keybuffer
begin
- result = select([@@input], [], [], 0.001)
- return if result.nil?
+ return unless @@input.wait_readable(0.001)
str = @@input.read_nonblock(1024)
str.bytes.each do |c|
@@buf.push(c)
end
rescue EOFError