mirror of
https://github.com/ruby/ruby.git
synced 2025-09-18 18:13:58 +02:00
[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:
parent
3c9f3c3e9b
commit
4428c51f01
7 changed files with 74 additions and 46 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue