Class: Byebug::ControlCommandProcessor
- Defined in:
- lib/byebug/processor.rb
Defined Under Namespace
Classes: State
Instance Attribute Summary
Attributes inherited from Processor
Instance Method Summary collapse
-
#initialize(interface) ⇒ ControlCommandProcessor
constructor
A new instance of ControlCommandProcessor.
- #process_commands(verbose = false) ⇒ Object
-
#prompt(context) ⇒ Object
The prompt shown before reading a command.
Methods inherited from Processor
Constructor Details
#initialize(interface) ⇒ ControlCommandProcessor
Returns a new instance of ControlCommandProcessor.
366 367 368 369 370 |
# File 'lib/byebug/processor.rb', line 366 def initialize(interface) super() @interface = interface @byebug_context_was_dead = true # Assume we haven't started. end |
Instance Method Details
#process_commands(verbose = false) ⇒ Object
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
# File 'lib/byebug/processor.rb', line 372 def process_commands(verbose=false) control_cmds = Command.commands.select do |cmd| cmd.allow_in_control end state = State.new(@interface, control_cmds) commands = control_cmds.map{|cmd| cmd.new(state) } unless @byebug_context_was_dead if Byebug.annotate.to_i > 2 aprint 'exited' print "The program finished.\n" end @byebug_context_was_dead = true end while input = @interface.read_command(prompt(nil)) print "+#{input}" if verbose catch(:debug_error) do if cmd = commands.find{|c| c.match(input) } cmd.execute else errmsg "Unknown command\n" end end end rescue IOError, Errno::EPIPE rescue Exception print "INTERNAL ERROR!!! #{$!}\n" rescue nil print $!.backtrace.map{|l| "\t#{l}"}.join("\n") rescue nil ensure @interface.close end |
#prompt(context) ⇒ Object
The prompt shown before reading a command. Note: have an unused ‘context’ parameter to match the local interface.
407 408 409 410 411 412 |
# File 'lib/byebug/processor.rb', line 407 def prompt(context) p = '(byebug:ctrl) ' p = afmt("pre-prompt")+p+"\n"+afmt("prompt") if Byebug.annotate.to_i > 2 return p end |