зеркало из https://github.com/github/ruby.git
Use IO#getch to read one char in raw mode
This commit is contained in:
Родитель
89c5d5a64e
Коммит
805b0a4811
|
@ -1,3 +1,5 @@
|
||||||
|
require 'io/console'
|
||||||
|
|
||||||
class Reline::ANSI
|
class Reline::ANSI
|
||||||
RAW_KEYSTROKE_CONFIG = {
|
RAW_KEYSTROKE_CONFIG = {
|
||||||
[27, 91, 65] => :ed_prev_history, # ↑
|
[27, 91, 65] => :ed_prev_history, # ↑
|
||||||
|
@ -24,14 +26,7 @@ class Reline::ANSI
|
||||||
unless @@buf.empty?
|
unless @@buf.empty?
|
||||||
return @@buf.shift
|
return @@buf.shift
|
||||||
end
|
end
|
||||||
c = nil
|
@@input.getch&.ord
|
||||||
loop do
|
|
||||||
result = select([@@input], [], [], 0.1)
|
|
||||||
next if result.nil?
|
|
||||||
c = @@input.read(1)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
c&.ord
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.ungetc(c)
|
def self.ungetc(c)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче