@@ -73,10 +73,21 @@ function print_next_expr(io::IO, frame::Frame)
73
73
println (io)
74
74
end
75
75
76
+ function breakpoint_linenumbers (frame:: Frame )
77
+ framecode = frame. framecode
78
+ breakpoint_lines = Int[]
79
+ for stmtidx in 1 : length (framecode. breakpoints)
80
+ isassigned (framecode. breakpoints, stmtidx) || continue
81
+ bp = framecode. breakpoints[stmtidx]
82
+ push! (breakpoint_lines, JuliaInterpreter. linenumber (frame, stmtidx))
83
+ end
84
+ return breakpoint_lines
85
+ end
86
+
76
87
function print_status (io:: IO , frame:: Frame )
77
88
# Buffer to avoid flickering
78
89
outbuf = IOContext (IOBuffer (), io)
79
- printstyled (outbuf, " In " , locdesc (frame), " \n " ; color = :bold )
90
+ printstyled (outbuf, " In " , locdesc (frame), " \n " )
80
91
loc = locinfo (frame)
81
92
82
93
if loc != = nothing
@@ -85,7 +96,8 @@ function print_status(io::IO, frame::Frame)
85
96
else
86
97
read (loc. filepath, String)
87
98
end
88
- print_sourcecode (outbuf, data, loc. line, loc. defline)
99
+ breakpoint_lines = breakpoint_linenumbers (frame)
100
+ print_sourcecode (outbuf, data, loc. line, loc. defline, breakpoint_lines)
89
101
else
90
102
print_codeinfo (outbuf, frame)
91
103
end
@@ -110,9 +122,9 @@ function print_codeinfo(io::IO, frame::Frame)
110
122
111
123
color = (lineno < active_line) ? :white : :normal
112
124
if lineno == active_line
113
- printstyled (io, rpad (lineno, 4 ), bold = true , color = :yellow )
125
+ printstyled (io, rpad (lineno, 4 ), color = :yellow )
114
126
else
115
- printstyled (io, rpad (lineno, 4 ), bold = true , color = color)
127
+ printstyled (io, rpad (lineno, 4 ), color = color)
116
128
end
117
129
printstyled (io, line, color = color)
118
130
println (io)
@@ -188,13 +200,13 @@ end
188
200
189
201
const RESET = Crayon (reset = true )
190
202
191
- function print_sourcecode (io:: IO , code:: String , line:: Integer , defline:: Integer )
203
+ function print_sourcecode (io:: IO , code:: String , line:: Integer , defline:: Integer , breakpoint_lines :: Vector{Int} = [] )
192
204
code = highlight_code (code; context= io)
193
205
file = SourceFile (code)
194
206
startoffset, stopoffset = compute_source_offsets (code, file. offsets[line], defline, line+ NUM_SOURCE_LINES_UP_DOWN[]; file= file)
195
207
196
208
if startoffset == - 1
197
- printstyled (io, " Line out of file range (bad debug info?)" , color = :bold )
209
+ printstyled (io, " Line out of file range (bad debug info?)" )
198
210
return
199
211
end
200
212
@@ -214,6 +226,7 @@ function print_sourcecode(io::IO, code::String, line::Integer, defline::Integer)
214
226
# Count indentation level (only count spaces for now)
215
227
min_indentation = typemax (Int)
216
228
for textline in code
229
+ isempty (textline) && continue
217
230
indent_line = 0
218
231
for char in textline
219
232
char != ' ' && break
@@ -225,15 +238,17 @@ function print_sourcecode(io::IO, code::String, line::Integer, defline::Integer)
225
238
code[i] = code[i][min_indentation+ 1 : end ]
226
239
end
227
240
228
- stoplinelength += stoplinelength == ndigits (current_line)
241
+ filter! (x -> x in (startline: stopline), breakpoint_lines)
242
+
229
243
for textline in code
230
- prefix = lineno == current_line ? " > " :
231
- ndigits (lineno) > ndigits (current_line) ?
232
- " " :
233
- " "
244
+ break_on_line = lineno in breakpoint_lines
245
+ prefix = ( " " , :normal )
246
+ break_on_line && (prefix = ( " ● " , :light_red ))
247
+ lineno == current_line && (prefix = ( " > " , :yellow ))
234
248
printstyled (io,
235
- string (lpad (string (prefix, lineno), stoplinelength , " " ), " " ),
236
- color = lineno == current_line ? :yellow : :bold )
249
+ string (prefix[1 ], lpad (lineno, stoplinelength), " " ),
250
+ color = prefix[2 ])
251
+
237
252
println (io, textline)
238
253
lineno += 1
239
254
end
0 commit comments