Skip to content

Commit 59d571e

Browse files
st0012ko1
authored andcommitted
Colorize values of info command with colored insepct.
1 parent b403c5b commit 59d571e

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lib/debug/thread_client.rb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require 'objspace'
22
require 'pp'
3-
require 'irb/color'
3+
require "irb/color_printer"
4+
45
require_relative 'frame_info'
56

67
module DEBUGGER__
@@ -22,6 +23,10 @@ def colorize str, color
2223
end
2324
end
2425

26+
def colored_inspect(obj)
27+
IRB::ColorPrinter.pp(obj, "")
28+
end
29+
2530
def colorize_blue(str)
2631
colorize(str, [:BLUE, :BOLD])
2732
end
@@ -288,22 +293,24 @@ def show_by_editor path = nil
288293

289294
def show_locals
290295
if s = current_frame&.self
291-
puts " %self => #{s}"
296+
puts " %self => #{colored_inspect(s)}"
292297
end
293298
if current_frame&.has_return_value
294-
puts " %return => #{current_frame.return_value}"
299+
puts " %return => #{colored_inspect(current_frame.return_value)}"
295300
end
296301
if b = current_frame&.binding
297302
b.local_variables.each{|loc|
298-
puts " #{loc} => #{b.local_variable_get(loc).inspect}"
303+
value = b.local_variable_get(loc)
304+
puts " #{loc} => #{colored_inspect(value)}"
299305
}
300306
end
301307
end
302308

303309
def show_ivars
304310
if s = current_frame&.self
305311
s.instance_variables.each{|iv|
306-
puts " #{iv} => #{s.instance_variable_get(iv)}"
312+
value = s.instance_variable_get(iv)
313+
puts " #{iv} => #{colored_inspect(value)}"
307314
}
308315
end
309316
end

0 commit comments

Comments
 (0)