[ruby/reline] Change quoted_insert and bracketed_paste to a single

key input
(https://github.com/ruby/reline/pull/792)

8f331edb07
This commit is contained in:
tomoya ishida 2024-12-16 22:53:30 +09:00 committed by git
parent 3c9f3c3e9b
commit 4428c51f01
7 changed files with 74 additions and 46 deletions

View file

@ -35,6 +35,20 @@ module Reline
def reset_color_sequence
self.class::RESET_COLOR
end
# Read a single encoding valid character from the input.
def read_single_char(keyseq_timeout)
buffer = String.new(encoding: Encoding::ASCII_8BIT)
loop do
timeout = buffer.empty? ? Float::INFINITY : keyseq_timeout
c = getc(timeout)
return unless c
buffer << c
encoded = buffer.dup.force_encoding(encoding)
return encoded if encoded.valid_encoding?
end
end
end
end