Method: Termcontroller::Controller#initialize

Defined in:
lib/termcontroller/controller.rb

#initialize(target = nil, keybindings = {}) ⇒ Controller

Returns a new instance of Controller.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/termcontroller/controller.rb', line 43

def initialize(target=nil, keybindings={})
  @m = Mutex.new

  @target = target
  @target_stack = []

  @keybindings = keybindings
  @buf = ""
  @commands = Queue.new
  @mode = :cooked

  @kb = KeyboardMap.new
  @con = IO.console
  raise if !@con

  at_exit { quit }
  trap("CONT")  { resume }
  trap("WINCH") { @commands << :resize }

  setup

  @t = Thread.new { readloop }

  @@controllers << @t

end