diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-09-08 21:04:46 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2019-09-10 00:56:31 +0900 |
commit | 805b0a481132938638dbd32830cf5dca3910efb1 (patch) | |
tree | dc27df679000ea7226840931c89a8b3245330b1d /lib | |
parent | 89c5d5a64e12cea23b230913b79c3d499bf30b12 (diff) |
Use IO#getch to read one char in raw mode
Diffstat (limited to 'lib')
-rw-r--r-- | lib/reline/ansi.rb | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/lib/reline/ansi.rb b/lib/reline/ansi.rb index a3401b9c9f..41f291809e 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,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) |