class Byebug::ControlCommandProcessor
def initialize(interface)
def initialize(interface) super() @interface = interface @byebug_context_was_dead = true # Assume we haven't started. end
def process_commands(verbose=false)
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
def prompt(context)
The prompt shown before reading a command.
def prompt(context) p = '(byebug:ctrl) ' p = afmt("pre-prompt")+p+"\n"+afmt("prompt") if Byebug.annotate.to_i > 2 return p end