Sha256: be56410c1e7f886a2b9ca135a9fcb4f55e0180d196294d6eaefa51356e3ea24e

Contents?: true

Size: 1.89 KB

Versions: 35

Compression:

Stored size: 1.89 KB

Contents

module Debugger
  module DisplayFunctions # :nodoc:
    def display_expression(exp)
      print "%s = %s\n", exp, debug_silent_eval(exp).to_s
    end
  end

  class AddDisplayCommand < Command # :nodoc:
    include DisplayFunctions

    def regexp
      /^\s*disp(?:lay)?\s+(.+)$/
    end

    def execute
      exp = @match[1]
      @state.display.push [true, exp]
      print "%d: ", @state.display.size
      display_expression(exp)
    end

    class << self
      def help_command
        'display'
      end

      def help(cmd)
        %{
          disp[lay] <expression>\tadd expression into display expression list
        }
      end
    end
  end

  class DisplayCommand < Command # :nodoc:
    self.always_run = true
    include DisplayFunctions
    
    def regexp
      /^\s*disp(?:lay)?$/
    end

    def execute
      n = 1
      for d in @state.display
        if d[0]
          print "%d: ", n
          display_expression(d[1])
        end
        n += 1
      end
    end

    class << self
      def help_command
        'display'
      end

      def help(cmd)
        %{
          disp[lay]\t\tdisplay expression list
        }
      end
    end
  end

  class DeleteDisplayCommand < Command # :nodoc:
    include DisplayFunctions

    def regexp
      /^\s*undisp(?:lay)?(?:\s+(\d+))?$/
    end

    def execute
      unless pos = @match[1]
        if confirm("Clear all expressions? (y/n) ")
          for d in @state.display
            d[0] = false
          end
        end
      else
        pos = pos.to_i
        if @state.display[pos-1]
          @state.display[pos-1][0] = false
        else
          print "Display expression %d is not defined\n", pos
        end
      end
    end

    class << self
      def help_command
        'undisplay'
      end

      def help(cmd)
        %{
          undisp[lay][ nnn]\tdelete one particular or all display expressions
        }
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
ruby-debug-0.4.5-mswin32 lib/ruby-debug/commands/display.rb
ruby-debug-0.7.5-mswin32 lib/ruby-debug/commands/display.rb
ruby-debug-0.7.4-mswin32 lib/ruby-debug/commands/display.rb
ruby-debug-0.7.3-mswin32 lib/ruby-debug/commands/display.rb
ruby-debug-0.7.2-mswin32 lib/ruby-debug/commands/display.rb
ruby-debug-0.7.1-mswin32 lib/ruby-debug/commands/display.rb
ruby-debug-0.7-mswin32 lib/ruby-debug/commands/display.rb
ruby-debug-0.6.2-mswin32 lib/ruby-debug/commands/display.rb
ruby-debug-0.6.1-mswin32 lib/ruby-debug/commands/display.rb
ruby-debug-0.6-mswin32 lib/ruby-debug/commands/display.rb
ruby-debug-0.5.2-mswin32 lib/ruby-debug/commands/display.rb
ruby-debug-0.5.1-mswin32 lib/ruby-debug/commands/display.rb
ruby-debug-0.5-mswin32 lib/ruby-debug/commands/display.rb
ruby-debug-0.4.4-mswin32 lib/ruby-debug/commands/display.rb
ruby-debug-0.5 lib/ruby-debug/commands/display.rb
ruby-debug-0.5.2 lib/ruby-debug/commands/display.rb
ruby-debug-0.6.1 lib/ruby-debug/commands/display.rb
ruby-debug-0.4.5 lib/ruby-debug/commands/display.rb
ruby-debug-0.4.4 lib/ruby-debug/commands/display.rb
ruby-debug-0.6 lib/ruby-debug/commands/display.rb