Class: MindControl::REPL::CoollineAdapter
- Inherits:
-
Object
- Object
- MindControl::REPL::CoollineAdapter
- Defined in:
- lib/mind_control/repl.rb
Overview
Adapter for Coolline for use with Pry.
Instance Attribute Summary collapse
-
#cool ⇒ Object
readonly
Returns the value of attribute cool.
Instance Method Summary collapse
- #completion_proc=(proc) ⇒ Object
-
#getch ⇒ Fixnum
Read char from input in raw mode.#.
-
#initialize(input, output) ⇒ CoollineAdapter
constructor
A new instance of CoollineAdapter.
-
#readline(prompt) ⇒ String
Read user input with given prompt.
Constructor Details
#initialize(input, output) ⇒ CoollineAdapter
Returns a new instance of CoollineAdapter.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/mind_control/repl.rb', line 61 def initialize( input, output ) # Setup Coolline @cool = Coolline.new do |cool| cool.input = input cool.output = output cool.word_boundaries = [ " ", "\t", ",", ";", '"', "'", "`", "<", ">", "=", ";", "|", "{", "}", "(", ")", "-" ] # By default Coolline will kill host program on Ctrl+c. Override it. ctrl_c_handler = cool.handlers.find { |handler| handler.char == ?\C-c } ctrl_c_handler.block = lambda { |instance| # XXX: Just close Pry instance.instance_variable_set "@should_exit", true } end end |
Instance Attribute Details
#cool ⇒ Object (readonly)
Returns the value of attribute cool.
55 56 57 |
# File 'lib/mind_control/repl.rb', line 55 def cool @cool end |
Instance Method Details
#completion_proc=(proc) ⇒ Object
96 97 98 99 100 |
# File 'lib/mind_control/repl.rb', line 96 def completion_proc=( proc ) cool.completion_proc = proc do proc.call cool.completed_word end end |
#getch ⇒ Fixnum
Read char from input in raw mode.#
92 93 94 |
# File 'lib/mind_control/repl.rb', line 92 def getch cool.input.getch end |
#readline(prompt) ⇒ String
Read user input with given prompt.
83 84 85 |
# File 'lib/mind_control/repl.rb', line 83 def readline( prompt ) cool.readline prompt end |