lib/reline/ansi.rb in reline-0.5.0 vs lib/reline/ansi.rb in reline-0.5.1
- old
+ new
@@ -149,23 +149,29 @@
def self.output=(val)
@@output = val
end
def self.with_raw_input
- @@input.raw { yield }
+ if @@input.tty?
+ @@input.raw(intr: true) { yield }
+ else
+ yield
+ end
end
@@buf = []
def self.inner_getc(timeout_second)
unless @@buf.empty?
return @@buf.shift
end
- until c = @@input.raw(intr: true) { @@input.wait_readable(0.1) && @@input.getbyte }
- timeout_second -= 0.1
+ until @@input.wait_readable(0.01)
+ timeout_second -= 0.01
return nil if timeout_second <= 0
- Reline.core.line_editor.resize
+
+ Reline.core.line_editor.handle_signal
end
+ c = @@input.getbyte
(c == 0x16 && @@input.raw(min: 0, time: 0, &:getbyte)) || c
rescue Errno::EIO
# Maybe the I/O has been closed.
nil
rescue Errno::ENOTTY
@@ -307,11 +313,11 @@
move_cursor_up(-x)
end
end
def self.hide_cursor
- if Reline::Terminfo.enabled?
+ if Reline::Terminfo.enabled? && Reline::Terminfo.term_supported?
begin
@@output.write Reline::Terminfo.tigetstr('civis')
rescue Reline::Terminfo::TerminfoError
# civis is undefined
end
@@ -319,10 +325,10 @@
# ignored
end
end
def self.show_cursor
- if Reline::Terminfo.enabled?
+ if Reline::Terminfo.enabled? && Reline::Terminfo.term_supported?
begin
@@output.write Reline::Terminfo.tigetstr('cnorm')
rescue Reline::Terminfo::TerminfoError
# cnorm is undefined
end