PryRemoteEm::Client::Keyboard

Public Class Methods

new(c) click to toggle source
# File lib/pry-remote-em/client/keyboard.rb, line 6
def initialize(c)
  @con            = c
  # TODO check actual current values to determine if it's enabled or not
  @buff_enabled   = true
  # On EM < 1.0.0.beta.4 the keyboard handler and Termios don't work well together
  # readline will complain that STDIN isn't a tty after Termios manipulation, so
  # just don't let it happen
  @manip_buff     = Gem.loaded_specs["eventmachine"].version >= Gem::Version.new("1.0.0.beta.4")
  bufferio(false)
  # TODO retain the old SIGINT handler and reset it later
  trap :SIGINT do
    @con.send_data({:ssc => true})
  end
end

Public Instance Methods

bufferio(enable) click to toggle source

Makes stdin buffered or unbuffered. In unbuffered mode read and select will not wait for "n"; also will not echo characters. This probably does not work on Windows. On EventMachine < 1.0.0.beta.4 this method doesn't do anything

# File lib/pry-remote-em/client/keyboard.rb, line 36
def bufferio(enable)
  return if !@manip_buff || (enable && @buff_enabled) || (!enable && !@buff_enabled)
  attr = Termios.getattr($stdin)
  enable ? (attr.c_lflag |= Termios::ICANON | Termios::ECHO) : (attr.c_lflag &= ~(Termios::ICANON|Termios::ECHO))
  Termios.setattr($stdin, Termios::TCSANOW, attr)
  @buff_enabled = enable
end
receive_data(d) click to toggle source
# File lib/pry-remote-em/client/keyboard.rb, line 21
def receive_data(d)
  @con.send_data({:sd => d})
end
unbind() click to toggle source
# File lib/pry-remote-em/client/keyboard.rb, line 25
def unbind
  bufferio(true)
  trap :SIGINT do
    Process.exit
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.