Class: Byebug::ControlCommandProcessor
- Defined in:
- lib/byebug/processors/control_command_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
Prompt shown before reading a command.
Constructor Details
#initialize(interface) ⇒ ControlCommandProcessor
Returns a new instance of ControlCommandProcessor.
4 5 6 7 |
# File 'lib/byebug/processors/control_command_processor.rb', line 4 def initialize(interface) super(interface) @context_was_dead = false # Assume we haven't started. end |
Instance Method Details
#process_commands(verbose = false) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/byebug/processors/control_command_processor.rb', line 9 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) } if @context_was_dead print "The program finished.\n" @context_was_dead = false 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, SystemCallError rescue print "INTERNAL ERROR!!! #{$!}\n" rescue nil print $!.backtrace.map{|l| "\t#{l}"}.join("\n") rescue nil ensure @interface.close end |
#prompt(context) ⇒ Object
Prompt shown before reading a command.
42 43 44 |
# File 'lib/byebug/processors/control_command_processor.rb', line 42 def prompt(context) return '(byebug:ctrl) ' end |