lib/ruby_jard/console.rb in ruby_jard-0.2.2 vs lib/ruby_jard/console.rb in ruby_jard-0.2.3

- old
+ new

@@ -67,31 +67,19 @@ # If tput not found, fallback to hard-coded sequence. output.print "\e[?12l\e[?25h" end def getch(input, timeout) - return input.getch(min: 0, time: timeout) if input.respond_to?(:getch) - - raw! - disable_echo! - key = - begin - input.read_nonblock(255) - rescue IO::WaitReadable - io = IO.select([input], nil, nil, timeout) - if io.nil? - nil - else - retry - end - rescue IO::WaitWritable - nil - end - - key - ensure - cooked! - enable_echo! + input.read_nonblock(255) + rescue IO::WaitReadable + io = IO.select([input], nil, nil, timeout) + if io.nil? + nil + else + retry + end + rescue IO::WaitWritable + nil end def raw!(output = STDOUT) return unless output.tty?