Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

refs #15 adds ruby-termios to gem dependencies; warns about EM < 1.0.…

…0.beta

Interactive shell commands on EM < 1.0.0.beta will remain line buffered
because Termios and rb-readline don't get along EM 1.0.0.beta.4 either
adjusts STDIN in some way that is necessary, or EM < 1.0.0.beta.4
adjusts it in some way this is not good. Long story short, VIM is
definitely unusable as a shell command if the client is running on EM <
1.0.0.beta.4.
  • Loading branch information...
commit 16351e7634c5d93c640f3098ebb0f503870a7077 1 parent 08b8fc0
Caleb Crane simulacre authored
6 lib/pry-remote-em/client.rb
@@ -145,7 +145,11 @@ def readline(prompt)
145 145 send_data({:m => l[1..-1]})
146 146 elsif '.' == l[0]
147 147 send_data({:s => l[1..-1]})
148   - @keyboard = EM.open_keyboard(Keyboard, self)
  148 + if Gem.loaded_specs["eventmachine"].version < Gem::Version.new("1.0.0.beta4")
  149 + Kernel.puts "\033[1minteractive shell commands are not well supported when running on EventMachine prior 1.0.0.beta4\033[0m"
  150 + else
  151 + @keyboard = EM.open_keyboard(Keyboard, self)
  152 + end
149 153 else
150 154 send_data(l)
151 155 end # "!!" == l[0..1]
19 lib/pry-remote-em/client/keyboard.rb
@@ -4,7 +4,13 @@ module Client
4 4 module Keyboard
5 5
6 6 def initialize(c)
7   - @con = c
  7 + @con = c
  8 + # TODO check actual current values to determine if it's enabled or not
  9 + @buff_enabled = true
  10 + # On EM < 1.0.0.beta.4 the keyboard handler and Termios don't work well together
  11 + # readline will complain that STDIN isn't a tty after Termios manipulation, so
  12 + # just don't let it happen
  13 + @manip_buff = Gem.loaded_specs["eventmachine"].version >= Gem::Version.new("1.0.0.beta.4")
8 14 bufferio(false)
9 15 # TODO retain the old SIGINT handler and reset it later
10 16 trap :SIGINT do
@@ -25,11 +31,14 @@ def unbind
25 31
26 32 # Makes stdin buffered or unbuffered.
27 33 # In unbuffered mode read and select will not wait for "\n"; also will not echo characters.
28   - # This probably does not work on Windows
29   - def bufferio( enable, io = $stdin )
30   - attr = Termios::getattr( io )
  34 + # This probably does not work on Windows.
  35 + # On EventMachine < 1.0.0.beta.4 this method doesn't do anything
  36 + def bufferio(enable)
  37 + return if !@manip_buff || (enable && @buff_enabled) || (!enable && !@buff_enabled)
  38 + attr = Termios.getattr($stdin)
31 39 enable ? (attr.c_lflag |= Termios::ICANON | Termios::ECHO) : (attr.c_lflag &= ~(Termios::ICANON|Termios::ECHO))
32   - Termios::setattr( $stdin, Termios::TCSANOW, attr )
  40 + Termios.setattr($stdin, Termios::TCSANOW, attr)
  41 + @buff_enabled = enable
33 42 end
34 43 end # module::Keyboard
35 44 end # module::Client
2  pry-remote-em.gemspec
@@ -15,6 +15,6 @@ Gem::Specification.new do |s|
15 15 s.add_dependency 'eventmachine'
16 16 s.add_dependency 'pry', '~> 0.9.6'
17 17 s.add_dependency 'rb-readline'
18   - s.add_dependency 'termios'
  18 + s.add_dependency 'ruby-termios', '~> 0.9.6'
19 19 s.add_dependency 'highline'
20 20 end

0 comments on commit 16351e7

Please sign in to comment.
Something went wrong with that request. Please try again.