Sha256: ebff0dace796c8066f62e98aa4828c5a0a5ab50811976b0a8fe172989444269c
Contents?: true
Size: 1.49 KB
Versions: 2
Compression:
Stored size: 1.49 KB
Contents
module Debugger class ListCommand < Command def regexp /^\s*l(?:ist)?(?:\s+(.+))?$/ end def execute if not @match[1] b = @state.previous_line ? @state.previous_line + 10 : @state.line - 5 e = b + 9 elsif @match[1] == '-' b = @state.previous_line ? @state.previous_line - 10 : @state.line - 5 e = b + 9 elsif @match[1] == '=' @state.previous_line = nil b = @state.line - 5 e = b + 9 else b, e = @match[1].split(/[-,]/) if e b = b.to_i e = e.to_i else b = b.to_i - 5 e = b + 9 end end @state.previous_line = b display_list(b, e, @state.file, @state.line) end class << self def help_command 'list' end def help(cmd) %{ l[ist]\t\tlist forward l[ist] -\tlist backward l[ist] =\tlist current line l[ist] nn-mm\tlist given lines } end end private def display_list(b, e, file, line) print "[%d, %d] in %s\n", b, e, file if lines = Debugger.source_for(file) n = 0 b.upto(e) do |n| if n > 0 && lines[n-1] if n == line print "=> %d %s\n", n, lines[n-1].chomp else print " %d %s\n", n, lines[n-1].chomp end end end else print "No sourcefile available for %s\n", file end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby-debug-0.3-mswin32 | lib/ruby-debug/commands/list.rb |
ruby-debug-0.3 | lib/ruby-debug/commands/list.rb |