irb 1.1.0.pre.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +55 -0
- data/Rakefile +10 -0
- data/bin/console +6 -0
- data/bin/setup +6 -0
- data/doc/irb/irb-tools.rd.ja +184 -0
- data/doc/irb/irb.rd.ja +411 -0
- data/exe/irb +11 -0
- data/irb.gemspec +84 -0
- data/lib/irb.rb +870 -0
- data/lib/irb/cmd/chws.rb +34 -0
- data/lib/irb/cmd/fork.rb +39 -0
- data/lib/irb/cmd/help.rb +46 -0
- data/lib/irb/cmd/load.rb +67 -0
- data/lib/irb/cmd/nop.rb +39 -0
- data/lib/irb/cmd/pushws.rb +41 -0
- data/lib/irb/cmd/subirb.rb +43 -0
- data/lib/irb/color.rb +233 -0
- data/lib/irb/completion.rb +339 -0
- data/lib/irb/context.rb +458 -0
- data/lib/irb/ext/change-ws.rb +46 -0
- data/lib/irb/ext/history.rb +157 -0
- data/lib/irb/ext/loader.rb +129 -0
- data/lib/irb/ext/multi-irb.rb +265 -0
- data/lib/irb/ext/save-history.rb +117 -0
- data/lib/irb/ext/tracer.rb +72 -0
- data/lib/irb/ext/use-loader.rb +77 -0
- data/lib/irb/ext/workspaces.rb +67 -0
- data/lib/irb/extend-command.rb +328 -0
- data/lib/irb/frame.rb +81 -0
- data/lib/irb/help.rb +37 -0
- data/lib/irb/init.rb +312 -0
- data/lib/irb/input-method.rb +298 -0
- data/lib/irb/inspector.rb +142 -0
- data/lib/irb/lc/.document +4 -0
- data/lib/irb/lc/error.rb +32 -0
- data/lib/irb/lc/help-message +52 -0
- data/lib/irb/lc/ja/encoding_aliases.rb +11 -0
- data/lib/irb/lc/ja/error.rb +31 -0
- data/lib/irb/lc/ja/help-message +55 -0
- data/lib/irb/locale.rb +182 -0
- data/lib/irb/magic-file.rb +38 -0
- data/lib/irb/notifier.rb +232 -0
- data/lib/irb/output-method.rb +92 -0
- data/lib/irb/ruby-lex.rb +499 -0
- data/lib/irb/ruby_logo.aa +38 -0
- data/lib/irb/slex.rb +282 -0
- data/lib/irb/src_encoding.rb +7 -0
- data/lib/irb/version.rb +17 -0
- data/lib/irb/workspace.rb +181 -0
- data/lib/irb/ws-for-case-2.rb +15 -0
- data/lib/irb/xmp.rb +170 -0
- data/man/irb.1 +207 -0
- metadata +140 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
-+smJYYN?mm-
|
3
|
+
HB"BBYT TQg NggT
|
4
|
+
9Q+g Nm,T 8g NJW
|
5
|
+
YS+ N2NJ"Sg N?
|
6
|
+
BQg #( gT Nggggk J
|
7
|
+
5j NJ NJ NNge
|
8
|
+
#Q #JJ NgT N(
|
9
|
+
@j bj mT J
|
10
|
+
Bj @/d NJ (
|
11
|
+
#q #(( NgT #J
|
12
|
+
5d #(t mT $d
|
13
|
+
#q @(@J NJB;
|
14
|
+
@( 5d ? HHH H HQmgggggggmN qD
|
15
|
+
5d #uN 2QdH E O
|
16
|
+
5 5JSd Nd NJH @d j
|
17
|
+
Fd @J4d s NQH #d (
|
18
|
+
#( #o6d Nd NgH #d #d
|
19
|
+
4 B&Od v NgT #d F
|
20
|
+
#( 9JGd NH NgUd F
|
21
|
+
#d #GJQ d NP $
|
22
|
+
#J #U+#Q N Q # j
|
23
|
+
j /W BQ+ BQ d NJ NJ
|
24
|
+
- NjJH HBIjTQggPJQgW N W k #J
|
25
|
+
#J b HYWgggN j s Nag d NN b #d
|
26
|
+
#J 5- D s Ngg N d Nd F
|
27
|
+
Fd BKH2 #+ s NNgg J Q J ]
|
28
|
+
F H @ J N y K(d P I
|
29
|
+
F4 E N? #d y #Q NJ E j
|
30
|
+
F W Nd q m Bg NxW N(H-
|
31
|
+
F d b @ m Hd gW vKJ
|
32
|
+
NJ d K d s Bg aT FDd
|
33
|
+
b # d N m BQ mV N>
|
34
|
+
e5 Nd #d NggggggQWH HHHH NJ -
|
35
|
+
m7 NW H N HSVO1z=?11-
|
36
|
+
NgTH bB kH WBHWWHBHWmQgg&gggggNNN
|
37
|
+
NNggggggNN
|
38
|
+
|
data/lib/irb/slex.rb
ADDED
@@ -0,0 +1,282 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
#
|
3
|
+
# irb/slex.rb - simple lex analyzer
|
4
|
+
# $Release Version: 0.9.6$
|
5
|
+
# $Revision$
|
6
|
+
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
7
|
+
#
|
8
|
+
# --
|
9
|
+
#
|
10
|
+
#
|
11
|
+
#
|
12
|
+
|
13
|
+
require "e2mmap"
|
14
|
+
require_relative "notifier"
|
15
|
+
|
16
|
+
# :stopdoc:
|
17
|
+
module IRB
|
18
|
+
class SLex
|
19
|
+
|
20
|
+
extend Exception2MessageMapper
|
21
|
+
def_exception :ErrNodeNothing, "node nothing"
|
22
|
+
def_exception :ErrNodeAlreadyExists, "node already exists"
|
23
|
+
|
24
|
+
DOUT = Notifier::def_notifier("SLex::")
|
25
|
+
D_WARN = DOUT::def_notifier(1, "Warn: ")
|
26
|
+
D_DEBUG = DOUT::def_notifier(2, "Debug: ")
|
27
|
+
D_DETAIL = DOUT::def_notifier(4, "Detail: ")
|
28
|
+
|
29
|
+
DOUT.level = Notifier::D_NOMSG
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
@head = Node.new("")
|
33
|
+
end
|
34
|
+
|
35
|
+
def def_rule(token, preproc = nil, postproc = nil, &block)
|
36
|
+
D_DETAIL.pp token
|
37
|
+
|
38
|
+
postproc = block if block_given?
|
39
|
+
create(token, preproc, postproc)
|
40
|
+
end
|
41
|
+
|
42
|
+
def def_rules(*tokens, &block)
|
43
|
+
if block_given?
|
44
|
+
p = block
|
45
|
+
end
|
46
|
+
for token in tokens
|
47
|
+
def_rule(token, nil, p)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def preproc(token, proc)
|
52
|
+
node = search(token)
|
53
|
+
node.preproc=proc
|
54
|
+
end
|
55
|
+
|
56
|
+
# need a check?
|
57
|
+
def postproc(token)
|
58
|
+
node = search(token, proc)
|
59
|
+
node.postproc=proc
|
60
|
+
end
|
61
|
+
|
62
|
+
def search(token)
|
63
|
+
@head.search(token.split(//))
|
64
|
+
end
|
65
|
+
|
66
|
+
def create(token, preproc = nil, postproc = nil)
|
67
|
+
@head.create_subnode(token.split(//), preproc, postproc)
|
68
|
+
end
|
69
|
+
|
70
|
+
def match(token)
|
71
|
+
case token
|
72
|
+
when Array
|
73
|
+
when String
|
74
|
+
return match(token.split(//))
|
75
|
+
else
|
76
|
+
return @head.match_io(token)
|
77
|
+
end
|
78
|
+
ret = @head.match(token)
|
79
|
+
D_DETAIL.exec_if{D_DETAIL.printf "match end: %s:%s\n", ret, token.inspect}
|
80
|
+
ret
|
81
|
+
end
|
82
|
+
|
83
|
+
def inspect
|
84
|
+
format("<SLex: @head = %s>", @head.inspect)
|
85
|
+
end
|
86
|
+
|
87
|
+
#----------------------------------------------------------------------
|
88
|
+
#
|
89
|
+
# class Node -
|
90
|
+
#
|
91
|
+
#----------------------------------------------------------------------
|
92
|
+
class Node
|
93
|
+
# if postproc is nil, this node is an abstract node.
|
94
|
+
# if postproc is non-nil, this node is a real node.
|
95
|
+
def initialize(preproc = nil, postproc = nil)
|
96
|
+
@Tree = {}
|
97
|
+
@preproc = preproc
|
98
|
+
@postproc = postproc
|
99
|
+
end
|
100
|
+
|
101
|
+
attr_accessor :preproc
|
102
|
+
attr_accessor :postproc
|
103
|
+
|
104
|
+
def search(chrs, opt = nil)
|
105
|
+
return self if chrs.empty?
|
106
|
+
ch = chrs.shift
|
107
|
+
if node = @Tree[ch]
|
108
|
+
node.search(chrs, opt)
|
109
|
+
else
|
110
|
+
if opt
|
111
|
+
chrs.unshift ch
|
112
|
+
self.create_subnode(chrs)
|
113
|
+
else
|
114
|
+
SLex.fail ErrNodeNothing
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def create_subnode(chrs, preproc = nil, postproc = nil)
|
120
|
+
if chrs.empty?
|
121
|
+
if @postproc
|
122
|
+
D_DETAIL.pp node
|
123
|
+
SLex.fail ErrNodeAlreadyExists
|
124
|
+
else
|
125
|
+
D_DEBUG.puts "change abstract node to real node."
|
126
|
+
@preproc = preproc
|
127
|
+
@postproc = postproc
|
128
|
+
end
|
129
|
+
return self
|
130
|
+
end
|
131
|
+
|
132
|
+
ch = chrs.shift
|
133
|
+
if node = @Tree[ch]
|
134
|
+
if chrs.empty?
|
135
|
+
if node.postproc
|
136
|
+
DebugLogger.pp node
|
137
|
+
DebugLogger.pp self
|
138
|
+
DebugLogger.pp ch
|
139
|
+
DebugLogger.pp chrs
|
140
|
+
SLex.fail ErrNodeAlreadyExists
|
141
|
+
else
|
142
|
+
D_WARN.puts "change abstract node to real node"
|
143
|
+
node.preproc = preproc
|
144
|
+
node.postproc = postproc
|
145
|
+
end
|
146
|
+
else
|
147
|
+
node.create_subnode(chrs, preproc, postproc)
|
148
|
+
end
|
149
|
+
else
|
150
|
+
if chrs.empty?
|
151
|
+
node = Node.new(preproc, postproc)
|
152
|
+
else
|
153
|
+
node = Node.new
|
154
|
+
node.create_subnode(chrs, preproc, postproc)
|
155
|
+
end
|
156
|
+
@Tree[ch] = node
|
157
|
+
end
|
158
|
+
node
|
159
|
+
end
|
160
|
+
|
161
|
+
#
|
162
|
+
# chrs: String
|
163
|
+
# character array
|
164
|
+
# io must have getc()/ungetc(); and ungetc() must be
|
165
|
+
# able to be called arbitrary number of times.
|
166
|
+
#
|
167
|
+
def match(chrs, op = "")
|
168
|
+
D_DETAIL.print "match>: ", chrs, "op:", op, "\n"
|
169
|
+
if chrs.empty?
|
170
|
+
if @preproc.nil? || @preproc.call(op, chrs)
|
171
|
+
DOUT.printf(D_DETAIL, "op1: %s\n", op)
|
172
|
+
@postproc.call(op, chrs)
|
173
|
+
else
|
174
|
+
nil
|
175
|
+
end
|
176
|
+
else
|
177
|
+
ch = chrs.shift
|
178
|
+
if node = @Tree[ch]
|
179
|
+
if ret = node.match(chrs, op+ch)
|
180
|
+
return ret
|
181
|
+
else
|
182
|
+
chrs.unshift ch
|
183
|
+
if @postproc and @preproc.nil? || @preproc.call(op, chrs)
|
184
|
+
DOUT.printf(D_DETAIL, "op2: %s\n", op.inspect)
|
185
|
+
ret = @postproc.call(op, chrs)
|
186
|
+
return ret
|
187
|
+
else
|
188
|
+
return nil
|
189
|
+
end
|
190
|
+
end
|
191
|
+
else
|
192
|
+
chrs.unshift ch
|
193
|
+
if @postproc and @preproc.nil? || @preproc.call(op, chrs)
|
194
|
+
DOUT.printf(D_DETAIL, "op3: %s\n", op)
|
195
|
+
@postproc.call(op, chrs)
|
196
|
+
return ""
|
197
|
+
else
|
198
|
+
return nil
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
def match_io(io, op = "")
|
205
|
+
if op == ""
|
206
|
+
ch = io.getc
|
207
|
+
if ch == nil
|
208
|
+
return nil
|
209
|
+
end
|
210
|
+
else
|
211
|
+
ch = io.getc_of_rests
|
212
|
+
end
|
213
|
+
if ch.nil?
|
214
|
+
if @preproc.nil? || @preproc.call(op, io)
|
215
|
+
D_DETAIL.printf("op1: %s\n", op)
|
216
|
+
@postproc.call(op, io)
|
217
|
+
else
|
218
|
+
nil
|
219
|
+
end
|
220
|
+
else
|
221
|
+
if node = @Tree[ch]
|
222
|
+
if ret = node.match_io(io, op+ch)
|
223
|
+
ret
|
224
|
+
else
|
225
|
+
io.ungetc ch
|
226
|
+
if @postproc and @preproc.nil? || @preproc.call(op, io)
|
227
|
+
DOUT.exec_if{D_DETAIL.printf "op2: %s\n", op.inspect}
|
228
|
+
@postproc.call(op, io)
|
229
|
+
else
|
230
|
+
nil
|
231
|
+
end
|
232
|
+
end
|
233
|
+
else
|
234
|
+
io.ungetc ch
|
235
|
+
if @postproc and @preproc.nil? || @preproc.call(op, io)
|
236
|
+
D_DETAIL.printf("op3: %s\n", op)
|
237
|
+
@postproc.call(op, io)
|
238
|
+
else
|
239
|
+
nil
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
# :startdoc:
|
248
|
+
|
249
|
+
if $0 == __FILE__
|
250
|
+
case $1
|
251
|
+
when "1"
|
252
|
+
tr = SLex.new
|
253
|
+
print "0: ", tr.inspect, "\n"
|
254
|
+
tr.def_rule("=") {print "=\n"}
|
255
|
+
print "1: ", tr.inspect, "\n"
|
256
|
+
tr.def_rule("==") {print "==\n"}
|
257
|
+
print "2: ", tr.inspect, "\n"
|
258
|
+
|
259
|
+
print "case 1:\n"
|
260
|
+
print tr.match("="), "\n"
|
261
|
+
print "case 2:\n"
|
262
|
+
print tr.match("=="), "\n"
|
263
|
+
print "case 3:\n"
|
264
|
+
print tr.match("=>"), "\n"
|
265
|
+
|
266
|
+
when "2"
|
267
|
+
tr = SLex.new
|
268
|
+
print "0: ", tr.inspect, "\n"
|
269
|
+
tr.def_rule("=") {print "=\n"}
|
270
|
+
print "1: ", tr.inspect, "\n"
|
271
|
+
tr.def_rule("==", proc{false}) {print "==\n"}
|
272
|
+
print "2: ", tr.inspect, "\n"
|
273
|
+
|
274
|
+
print "case 1:\n"
|
275
|
+
print tr.match("="), "\n"
|
276
|
+
print "case 2:\n"
|
277
|
+
print tr.match("=="), "\n"
|
278
|
+
print "case 3:\n"
|
279
|
+
print tr.match("=>"), "\n"
|
280
|
+
end
|
281
|
+
exit
|
282
|
+
end
|
data/lib/irb/version.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
#
|
3
|
+
# irb/version.rb - irb version definition file
|
4
|
+
# $Release Version: 0.9.6$
|
5
|
+
# $Revision$
|
6
|
+
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
|
7
|
+
#
|
8
|
+
# --
|
9
|
+
#
|
10
|
+
#
|
11
|
+
#
|
12
|
+
|
13
|
+
module IRB # :nodoc:
|
14
|
+
VERSION = "1.1.0.pre.4"
|
15
|
+
@RELEASE_VERSION = VERSION
|
16
|
+
@LAST_UPDATE_DATE = "2019-09-01"
|
17
|
+
end
|
@@ -0,0 +1,181 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
#
|
3
|
+
# irb/workspace-binding.rb -
|
4
|
+
# $Release Version: 0.9.6$
|
5
|
+
# $Revision$
|
6
|
+
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
7
|
+
#
|
8
|
+
# --
|
9
|
+
#
|
10
|
+
#
|
11
|
+
#
|
12
|
+
|
13
|
+
require "delegate"
|
14
|
+
|
15
|
+
module IRB # :nodoc:
|
16
|
+
class WorkSpace
|
17
|
+
# Creates a new workspace.
|
18
|
+
#
|
19
|
+
# set self to main if specified, otherwise
|
20
|
+
# inherit main from TOPLEVEL_BINDING.
|
21
|
+
def initialize(*main)
|
22
|
+
if main[0].kind_of?(Binding)
|
23
|
+
@binding = main.shift
|
24
|
+
elsif IRB.conf[:SINGLE_IRB]
|
25
|
+
@binding = TOPLEVEL_BINDING
|
26
|
+
else
|
27
|
+
case IRB.conf[:CONTEXT_MODE]
|
28
|
+
when 0 # binding in proc on TOPLEVEL_BINDING
|
29
|
+
@binding = eval("proc{binding}.call",
|
30
|
+
TOPLEVEL_BINDING,
|
31
|
+
__FILE__,
|
32
|
+
__LINE__)
|
33
|
+
when 1 # binding in loaded file
|
34
|
+
require "tempfile"
|
35
|
+
f = Tempfile.open("irb-binding")
|
36
|
+
f.print <<EOF
|
37
|
+
$binding = binding
|
38
|
+
EOF
|
39
|
+
f.close
|
40
|
+
load f.path
|
41
|
+
@binding = $binding
|
42
|
+
|
43
|
+
when 2 # binding in loaded file(thread use)
|
44
|
+
unless defined? BINDING_QUEUE
|
45
|
+
IRB.const_set(:BINDING_QUEUE, Thread::SizedQueue.new(1))
|
46
|
+
Thread.abort_on_exception = true
|
47
|
+
Thread.start do
|
48
|
+
eval "require \"irb/ws-for-case-2\"", TOPLEVEL_BINDING, __FILE__, __LINE__
|
49
|
+
end
|
50
|
+
Thread.pass
|
51
|
+
end
|
52
|
+
@binding = BINDING_QUEUE.pop
|
53
|
+
|
54
|
+
when 3 # binding in function on TOPLEVEL_BINDING(default)
|
55
|
+
@binding = eval("self.class.send(:remove_method, :irb_binding) if defined?(irb_binding); private; def irb_binding; binding; end; irb_binding",
|
56
|
+
TOPLEVEL_BINDING,
|
57
|
+
__FILE__,
|
58
|
+
__LINE__ - 3)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
if main.empty?
|
63
|
+
@main = eval("self", @binding)
|
64
|
+
else
|
65
|
+
@main = main[0]
|
66
|
+
end
|
67
|
+
IRB.conf[:__MAIN__] = @main
|
68
|
+
|
69
|
+
unless main.empty?
|
70
|
+
case @main
|
71
|
+
when Module
|
72
|
+
@binding = eval("IRB.conf[:__MAIN__].module_eval('binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
|
73
|
+
else
|
74
|
+
begin
|
75
|
+
@binding = eval("IRB.conf[:__MAIN__].instance_eval('binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
|
76
|
+
rescue TypeError
|
77
|
+
IRB.fail CantChangeBinding, @main.inspect
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
case @main
|
83
|
+
when Object
|
84
|
+
use_delegator = @main.frozen?
|
85
|
+
else
|
86
|
+
use_delegator = true
|
87
|
+
end
|
88
|
+
|
89
|
+
if use_delegator
|
90
|
+
@main = SimpleDelegator.new(@main)
|
91
|
+
IRB.conf[:__MAIN__] = @main
|
92
|
+
@main.singleton_class.class_eval do
|
93
|
+
private
|
94
|
+
define_method(:exit) do |*a, &b|
|
95
|
+
# Do nothing, will be overridden
|
96
|
+
end
|
97
|
+
define_method(:binding, Kernel.instance_method(:binding))
|
98
|
+
define_method(:local_variables, Kernel.instance_method(:local_variables))
|
99
|
+
end
|
100
|
+
@binding = eval("IRB.conf[:__MAIN__].instance_eval('binding', __FILE__, __LINE__)", @binding, *@binding.source_location)
|
101
|
+
end
|
102
|
+
|
103
|
+
@binding.local_variable_set(:_, nil)
|
104
|
+
end
|
105
|
+
|
106
|
+
# The Binding of this workspace
|
107
|
+
attr_reader :binding
|
108
|
+
# The top-level workspace of this context, also available as
|
109
|
+
# <code>IRB.conf[:__MAIN__]</code>
|
110
|
+
attr_reader :main
|
111
|
+
|
112
|
+
# Evaluate the given +statements+ within the context of this workspace.
|
113
|
+
def evaluate(context, statements, file = __FILE__, line = __LINE__)
|
114
|
+
eval(statements, @binding, file, line)
|
115
|
+
end
|
116
|
+
|
117
|
+
def local_variable_set(name, value)
|
118
|
+
@binding.local_variable_set(name, value)
|
119
|
+
end
|
120
|
+
|
121
|
+
def local_variable_get(name)
|
122
|
+
@binding.local_variable_get(name)
|
123
|
+
end
|
124
|
+
|
125
|
+
# error message manipulator
|
126
|
+
def filter_backtrace(bt)
|
127
|
+
return nil if bt =~ /irb\/.*\.rb/
|
128
|
+
return nil if bt =~ /irb\.rb/
|
129
|
+
case IRB.conf[:CONTEXT_MODE]
|
130
|
+
when 1
|
131
|
+
return nil if bt =~ %r!/tmp/irb-binding!
|
132
|
+
when 3
|
133
|
+
bt = bt.sub(/:\s*in `irb_binding'/, '')
|
134
|
+
end
|
135
|
+
bt
|
136
|
+
end
|
137
|
+
|
138
|
+
def code_around_binding
|
139
|
+
if @binding.respond_to?(:source_location)
|
140
|
+
file, pos = @binding.source_location
|
141
|
+
else
|
142
|
+
file, pos = @binding.eval('[__FILE__, __LINE__]')
|
143
|
+
end
|
144
|
+
|
145
|
+
if defined?(::SCRIPT_LINES__[file]) && lines = ::SCRIPT_LINES__[file]
|
146
|
+
code = ::SCRIPT_LINES__[file].join('')
|
147
|
+
else
|
148
|
+
begin
|
149
|
+
code = File.read(file)
|
150
|
+
rescue SystemCallError
|
151
|
+
return
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
# NOT using #use_colorize? of IRB.conf[:MAIN_CONTEXT] because this method may be called before IRB::Irb#run
|
156
|
+
use_colorize = IRB.conf.fetch(:USE_COLORIZE, true)
|
157
|
+
if use_colorize
|
158
|
+
lines = Color.colorize_code(code).lines
|
159
|
+
else
|
160
|
+
lines = code.lines
|
161
|
+
end
|
162
|
+
pos -= 1
|
163
|
+
|
164
|
+
start_pos = [pos - 5, 0].max
|
165
|
+
end_pos = [pos + 5, lines.size - 1].min
|
166
|
+
|
167
|
+
if use_colorize
|
168
|
+
fmt = " %2s #{Color.colorize("%#{end_pos.to_s.length}d", [:BLUE, :BOLD])}: %s"
|
169
|
+
else
|
170
|
+
fmt = " %2s %#{end_pos.to_s.length}d: %s"
|
171
|
+
end
|
172
|
+
body = (start_pos..end_pos).map do |current_pos|
|
173
|
+
sprintf(fmt, pos == current_pos ? '=>' : '', current_pos + 1, lines[current_pos])
|
174
|
+
end.join("")
|
175
|
+
"\nFrom: #{file} @ line #{pos + 1} :\n\n#{body}#{Color.clear}\n"
|
176
|
+
end
|
177
|
+
|
178
|
+
def IRB.delete_caller
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|