Class: Byebug::ListCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/byebug/commands/list.rb

Overview

Implements byebug “list” command.

Constant Summary

Constants inherited from Command

Command::DEF_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, format_subcmd, format_subcmds, help, inherited, #initialize, load_commands, #match, method_missing, options, register_setting_get, register_setting_set, register_setting_var, settings, settings_map

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



40
41
42
43
44
45
46
47
48
# File 'lib/byebug/commands/list.rb', line 40

def description
  %{
    l[ist]\t\tlist forward
    l[ist] -\tlist backward
    l[ist] =\tlist current line
    l[ist] nn-mm\tlist given lines
    * NOTE - to turn on autolist, use 'set autolist'
  }
end

.namesObject



36
37
38
# File 'lib/byebug/commands/list.rb', line 36

def names
  %w(list)
end

Instance Method Details

#executeObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/byebug/commands/list.rb', line 20

def execute
  Byebug.source_reload if Command.settings[:autoreload]
  lines = LineCache::getlines @state.file, Command.settings[:autoreload]
  if !lines
    errmsg "No sourcefile available for #{@state.file}\n" if @state.file != '(irb)'
    return @state.previous_line
  end

  b, e = set_line_range(Command.settings[:listsize], lines.size)
  return @state.previous_line if b < 0

  print "[#{b}, #{e}] in #{@state.file}\n"
  @state.previous_line = display_list(b, e, lines, @state.line)
end

#regexpObject



16
17
18
# File 'lib/byebug/commands/list.rb', line 16

def regexp
  /^\s* l(?:ist)? (?:\s*([-=])|\s+(.+))? $/x
end