mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Use IO#getch to read one char in raw mode
This commit is contained in:
parent
89c5d5a64e
commit
805b0a4811
1 changed files with 3 additions and 8 deletions
|
@ -1,3 +1,5 @@
|
|||
require 'io/console'
|
||||
|
||||
class Reline::ANSI
|
||||
RAW_KEYSTROKE_CONFIG = {
|
||||
[27, 91, 65] => :ed_prev_history, # ↑
|
||||
|
@ -24,14 +26,7 @@ class Reline::ANSI
|
|||
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
|
||||
@@input.getch&.ord
|
||||
end
|
||||
|
||||
def self.ungetc(c)
|
||||
|
|
Loading…
Add table
Reference in a new issue