Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add colors and spaces when showing the method table #4957

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function show_delim_array(io::IO, itr, op, delim, cl, delim_one)
print(io, cl)
end

show_comma_array(io::IO, itr, o, c) = show_delim_array(io, itr, o, ',', c, false)
show_comma_array(io::IO, itr, o, c) = show_delim_array(io, itr, o, ", ", c, false)
show(io::IO, t::Tuple) = show_delim_array(io, t, '(', ',', ')', true)

## AST decoding helpers ##
Expand Down Expand Up @@ -408,7 +408,11 @@ function argtype_decl_string(n, t)
if t <: Vararg && t !== None && t.parameters[1] === Any
return string(n, "...")
end
return string(n, "::", t)
if have_color
return string(n, "::", color_normal, t, default_color_answer)
else
return string(n, "::", t)
end
end

function show(io::IO, m::Method)
Expand All @@ -417,7 +421,7 @@ function show(io::IO, m::Method)
tv = (tv,)
end
if !isempty(tv)
show_delim_array(io, tv, '{', ',', '}', false)
show_delim_array(io, tv, '{', ", ", '}', false)
end
li = m.func.code
e = uncompressed_ast(li)
Expand All @@ -428,8 +432,14 @@ function show(io::IO, m::Method)
else
decls = map(argtype_decl_string, argnames, {m.sig...})
end
if have_color
print(io, default_color_answer)
end
print(io, "(")
print_joined(io, decls, ",", ",")
print_joined(io, decls, ", ")
if have_color
print(io, default_color_answer)
end
print(io, ")")
if li.line > 0
print(io, " at ", li.file, ":", li.line)
Expand All @@ -448,7 +458,8 @@ function show_method_table(io::IO, mt::MethodTable, max::Int=-1, header=true)
while !is(d,())
if max==-1 || n<max || (rest==0 && n==max && d.next === ())
println(io)
print(io, name)
# Add a color to the name of the method
print_with_color(:blue, io, "$name")
show(io, d)
n += 1
else
Expand Down