@@ -224,91 +224,91 @@ module DebuggerFramework
224
224
promptname (level, name) = " $level |$name > "
225
225
function RunDebugger (stack, repl = Base. active_repl, terminal = Base. active_repl. t)
226
226
227
- state = DebuggerState (stack, 1 , repl, nothing , Dict {Symbol, Any} (), nothing , terminal)
228
-
229
- # Setup debug panel
230
- panel = LineEdit. Prompt (promptname (state. level, " debug" );
231
- prompt_prefix= " \e [38;5;166m" ,
232
- prompt_suffix= Base. text_colors[:white ],
233
- on_enter = s-> true )
234
-
235
- panel. hist = REPL. REPLHistoryProvider (Dict {Symbol,Any} (:debug => panel))
236
- Base. REPL. history_reset_state (panel. hist)
237
-
238
- search_prompt, skeymap = Base. LineEdit. setup_search_keymap (panel. hist)
239
- search_prompt. complete = Base. REPL. LatexCompletions ()
240
-
241
- state. main_mode = panel
242
-
243
- panel. on_done = (s,buf,ok)-> begin
244
- line = String (take! (buf))
245
- old_level = state. level
246
- if ! ok || strip (line) == " q"
247
- LineEdit. transition (s, :abort )
248
- LineEdit. reset_state (s)
249
- return false
250
- end
251
- if isempty (strip (line)) && length (panel. hist. history) > 0
252
- command = panel. hist. history[end ]
253
- else
254
- command = strip (line)
255
- end
256
- do_print_status = true
257
- cmd1 = split (command,' ' )[1 ]
258
- do_print_status = try
259
- execute_command (state, state. stack[state. level], Val {Symbol(cmd1)} (), command)
260
- catch err
261
- isa (err, AbstractDiagnostic) || rethrow (err)
262
- caught = false
263
- for interp_idx in length (state. top_interp. stack): - 1 : 1
264
- if process_exception! (state. top_interp. stack[interp_idx], err, interp_idx == length (top_interp. stack))
265
- interp = state. top_interp = state. top_interp. stack[interp_idx]
266
- resize! (state. top_interp. stack, interp_idx)
267
- caught = true
268
- break
269
- end
270
- end
271
- ! caught && rethrow (err)
272
- display_diagnostic (STDERR, state. interp. code, err)
273
- println (STDERR)
274
- LineEdit. reset_state (s)
275
- return true
276
- end
277
- if old_level != state. level
278
- panel. prompt = promptname (state. level," debug" )
279
- end
280
- LineEdit. reset_state (s)
281
- if isempty (state. stack)
282
- LineEdit. transition (s, :abort )
283
- LineEdit. reset_state (s)
284
- return false
285
- end
286
- if do_print_status
287
- print_status (Base. pipe_writer (terminal), state)
288
- end
289
- return true
290
- end
291
-
292
- const repl_switch = Dict {Any,Any} (
293
- ' ` ' => function (s,args ... )
294
- if isempty (s) || position (LineEdit . buffer (s)) == 0
295
- prompt = language_specific_prompt (state, state . stack[ 1 ])
296
- buf = copy (LineEdit . buffer (s) )
297
- LineEdit. transition (s, prompt) do
298
- LineEdit. state (s, prompt). input_buffer = buf
299
- end
300
- else
301
- LineEdit . edit_insert (s,key)
302
- end
303
- end
304
- )
305
-
306
- state . standard_keymap = Dict{Any,Any}[skeymap, LineEdit . history_keymap, LineEdit . default_keymap, LineEdit . escape_defaults]
307
- panel . keymap_dict = LineEdit. keymap ([repl_switch;state . standard_keymap])
308
-
309
- # Skip evaluated values (e.g. constants)
310
- print_status (Base. pipe_writer (terminal), state)
311
- Base. REPL. run_interface (terminal, LineEdit. ModalInterface ([panel,search_prompt]))
227
+ state = DebuggerState (stack, 1 , repl, nothing , Dict {Symbol, Any} (), nothing , terminal)
228
+
229
+ # Setup debug panel
230
+ panel = LineEdit. Prompt (promptname (state. level, " debug" );
231
+ prompt_prefix= " \e [38;5;166m" ,
232
+ prompt_suffix= Base. text_colors[:white ],
233
+ on_enter = s-> true )
234
+
235
+ panel. hist = REPL. REPLHistoryProvider (Dict {Symbol,Any} (:debug => panel))
236
+ Base. REPL. history_reset_state (panel. hist)
237
+
238
+ search_prompt, skeymap = Base. LineEdit. setup_search_keymap (panel. hist)
239
+ search_prompt. complete = Base. REPL. LatexCompletions ()
240
+
241
+ state. main_mode = panel
242
+
243
+ panel. on_done = (s,buf,ok)-> begin
244
+ line = String (take! (buf))
245
+ old_level = state. level
246
+ if ! ok || strip (line) == " q"
247
+ LineEdit. transition (s, :abort )
248
+ LineEdit. reset_state (s)
249
+ return false
250
+ end
251
+ if isempty (strip (line)) && length (panel. hist. history) > 0
252
+ command = panel. hist. history[end ]
253
+ else
254
+ command = strip (line)
255
+ end
256
+ do_print_status = true
257
+ cmd1 = split (command,' ' )[1 ]
258
+ do_print_status = try
259
+ execute_command (state, state. stack[state. level], Val {Symbol(cmd1)} (), command)
260
+ catch err
261
+ isa (err, AbstractDiagnostic) || rethrow (err)
262
+ caught = false
263
+ for interp_idx in length (state. top_interp. stack): - 1 : 1
264
+ if process_exception! (state. top_interp. stack[interp_idx], err, interp_idx == length (top_interp. stack))
265
+ interp = state. top_interp = state. top_interp. stack[interp_idx]
266
+ resize! (state. top_interp. stack, interp_idx)
267
+ caught = true
268
+ break
269
+ end
270
+ end
271
+ ! caught && rethrow (err)
272
+ display_diagnostic (STDERR, state. interp. code, err)
273
+ println (STDERR)
274
+ LineEdit. reset_state (s)
275
+ return true
276
+ end
277
+ if old_level != state. level
278
+ panel. prompt = promptname (state. level," debug" )
279
+ end
280
+ LineEdit. reset_state (s)
281
+ if isempty (state. stack)
282
+ LineEdit. transition (s, :abort )
283
+ LineEdit. reset_state (s)
284
+ return false
285
+ end
286
+ if do_print_status
287
+ print_status (Base. pipe_writer (terminal), state)
288
+ end
289
+ return true
290
+ end
291
+
292
+ const key = ' ` '
293
+ const repl_switch = Dict {Any,Any} (
294
+ key => function (s,args ... )
295
+ if isempty (s) || position (LineEdit . buffer (s)) == 0
296
+ prompt = language_specific_prompt (state, state . stack[ 1 ] )
297
+ buf = copy ( LineEdit. buffer (s))
298
+ LineEdit. transition (s, prompt) do
299
+ LineEdit . state (s, prompt) . input_buffer = buf
300
+ end
301
+ else
302
+ LineEdit . edit_insert (s,key)
303
+ end
304
+ end
305
+ )
306
+
307
+ state . standard_keymap = Dict{Any,Any}[skeymap, LineEdit. history_keymap, LineEdit . default_keymap, LineEdit . escape_defaults]
308
+ panel . keymap_dict = LineEdit . keymap ([repl_switch;state . standard_keymap])
309
+
310
+ print_status (Base. pipe_writer (terminal), state)
311
+ Base. REPL. run_interface (terminal, LineEdit. ModalInterface ([panel,search_prompt]))
312
312
end
313
313
314
314
end # module
0 commit comments