lib/guard/interactors/readline.rb in guard-0.9.2 vs lib/guard/interactors/readline.rb in guard-0.9.3
- old
+ new
@@ -26,10 +26,24 @@
rescue NotImplementedError
# Ignore, we just don't support it then
end
end
+ # Start the interactor.
+ #
+ def start
+ store_terminal_settings
+ super
+ end
+
+ # Stop the interactor.
+ #
+ def stop
+ super
+ restore_terminal_settings
+ end
+
# Read a line from stdin with Readline.
#
def read_line
while line = Readline.readline(prompt, true)
if line =~ /^\s*$/ or Readline::HISTORY.to_a[-2] == line
@@ -66,7 +80,21 @@
#
def prompt
::Guard.listener.paused? ? 'p> ' : '> '
end
+ private
+
+ # Stores the terminal settings so we can resore them
+ # when stopping.
+ #
+ def store_terminal_settings
+ @stty_save = `stty -g`.chomp
+ end
+
+ # Restore terminal settings
+ #
+ def restore_terminal_settings
+ system('stty', @stty_save)
+ end
end
end