encoding()
click to toggle source
def self.encoding
Encoding.default_external
end
getc_with_bracketed_paste()
click to toggle source
def self.getc_with_bracketed_paste
buffer = String.new(encoding: Encoding::ASCII_8BIT)
buffer << inner_getc
while START_BRACKETED_PASTE.start_with?(buffer) or END_BRACKETED_PASTE.start_with?(buffer) do
if START_BRACKETED_PASTE == buffer
@@in_bracketed_paste_mode = true
return inner_getc
elsif END_BRACKETED_PASTE == buffer
@@in_bracketed_paste_mode = false
ungetc(-1)
return inner_getc
end
begin
succ_c = nil
Timeout.timeout(Reline.core.config.keyseq_timeout * 100) {
succ_c = inner_getc
}
rescue Timeout::Error
break
else
buffer << succ_c
end
end
inner_getc()
click to toggle source
def self.inner_getc
unless @@buf.empty?
return @@buf.shift
end
until c = @@input.raw(intr: true, &:getbyte)
sleep 0.1
end
(c == 0x16 && @@input.raw(min: 0, tim: 0, &:getbyte)) || c
rescue Errno::EIO
nil
end
output=(val)
click to toggle source
def self.output=(val)
@@output = val
end
win?()
click to toggle source