diff --git a/lib/reline/ansi.rb b/lib/reline/ansi.rb index a3401b9c9f..92d4522aa4 100644 --- a/lib/reline/ansi.rb +++ b/lib/reline/ansi.rb @@ -1,3 +1,5 @@ +require 'io/console' + class Reline::ANSI RAW_KEYSTROKE_CONFIG = { [27, 91, 65] => :ed_prev_history, # ↑ @@ -24,14 +26,8 @@ def self.getc unless @@buf.empty? return @@buf.shift end - c = nil - loop do - result = select([@@input], [], [], 0.1) - next if result.nil? - c = @@input.read(1) - break - end - c&.ord + c = @@input.raw(&:getbyte) + (c == 0x16 && @@input.raw(min: 0, tim: 0, &:getbyte)) || c end def self.ungetc(c)