class MindControl::REPL::CoollineAdapter
Adapter for Coolline for use with Pry
.
Attributes
cool[R]
Public Class Methods
new( input, output )
click to toggle source
@param [IO] stdin The object to use for input. @param [IO] stdout The object to use for output.
# 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
Public Instance Methods
completion_proc=( proc )
click to toggle source
# 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()
click to toggle source
Read char from input in raw mode.#
@return [Fixnum]
# File lib/mind_control/repl.rb, line 92 def getch cool.input.getch end
readline( prompt )
click to toggle source
Read user input with given prompt.
@param [String] prompt @return [String]
# File lib/mind_control/repl.rb, line 83 def readline( prompt ) cool.readline prompt end