Class: Debugger::ListCommand
Overview
Implements debugger “list” command.
Constant Summary
Constants inherited
from Command
Command::DEF_OPTIONS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
commands, #find, inherited, #initialize, load_commands, #match, method_missing, options, register_setting_get, register_setting_set, register_setting_var, settings, settings_map
Class Method Details
.help(cmd) ⇒ Object
55
56
57
58
59
60
61
62
63
|
# File 'lib/ruby-debug/commands/list.rb', line 55
def help(cmd)
%{
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
|
.help_command ⇒ Object
51
52
53
|
# File 'lib/ruby-debug/commands/list.rb', line 51
def help_command
'list'
end
|
Instance Method Details
#execute ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/ruby-debug/commands/list.rb', line 16
def execute
listsize = Command.settings[:listsize]
if !@match || !(@match[1] || @match[2])
b = @state.previous_line ?
@state.previous_line + listsize : @state.line - (listsize/2)
e = b + listsize - 1
elsif @match[1] == '-'
b = if @state.previous_line
if @state.previous_line > 0
@state.previous_line - listsize
else
@state.previous_line
end
else
@state.line - (listsize/2)
end
e = b + listsize - 1
elsif @match[1] == '='
@state.previous_line = nil
b = @state.line - (listsize/2)
e = b + listsize -1
else
b, e = @match[2].split(/[-,]/)
if e
b = b.to_i
e = e.to_i
else
b = b.to_i - (listsize/2)
e = b + listsize - 1
end
end
@state.previous_line = display_list(b, e, @state.file, @state.line)
end
|
#regexp ⇒ Object
12
13
14
|
# File 'lib/ruby-debug/commands/list.rb', line 12
def regexp
/^\s* l(?:ist)? (?:\s*([-=])|\s+(.+))? $/x
end
|