lib/remedy/console.rb in remedy-0.0.5 vs lib/remedy/console.rb in remedy-0.1.0
- old
+ new
@@ -1,29 +1,28 @@
-require 'remedy/console_resized'
+require 'remedy/console_resize'
module Remedy
module Console
require 'io/console'
TIOCGWINSZ = 0x40087468
module_function
def input
- STDIN
+ @input ||= $stdin
end
def output
- STDOUT
+ @output ||= $stdout
end
def raw
raw!
result = yield
ensure
cooked!
-
return result
end
def raw!
input.echo = false
@@ -31,19 +30,17 @@
end
def cooked!
input.echo = true
input.cooked!
- rescue NoMethodError
- %x{stty -raw echo 2> /dev/null}
end
def columns
size.last
end
alias_method :width, :columns
-
+
def rows
size.first
end
alias_method :height, :rows
@@ -59,10 +56,10 @@
def interactive?
input.isatty
end
def set_console_resized_hook!
- ConsoleResized.set_console_resized_hook! do
+ Console::Resize.set_console_resized_hook! do
yield
end
end
class UnknownConsoleSize < IOError; end