From 934507472c92ccada3f30be183fea5066427efda Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 23 Sep 2019 17:26:38 +0900 Subject: [PATCH] Retrieve key-buffer that was supposed to lose --- lib/reline/ansi.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/reline/ansi.rb b/lib/reline/ansi.rb index 9d9f79f7b5..b12dc2f6d3 100644 --- a/lib/reline/ansi.rb +++ b/lib/reline/ansi.rb @@ -38,6 +38,15 @@ class Reline::ANSI @@buf.unshift(c) end + def self.retrieve_keybuffer + result = select([@@input], [], [], 0.1) + return if result.nil? + str = @@input.read_nonblock(1024) + str.bytes.each do |c| + @@buf.push(c) + end + end + def self.get_screen_size @@input.winsize rescue Errno::ENOTTY @@ -112,6 +121,7 @@ class Reline::ANSI end def self.prep + retrieve_keybuffer int_handle = Signal.trap('INT', 'IGNORE') otio = `stty -g`.chomp setting = ' -echo -icrnl cbreak'