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

Conversation

andrioni
Copy link
Member

Following František's suggestion in https://groups.google.com/forum/#!topic/julia-dev/_5zo8o8AogQ, I've made some changes to how methods and method tables are printed.

This is how it currently looks like on OS X with iTerm and its default colors:
colorized output

Note: I've changed how parametric types are printed, but not tuples, since I tried to change the least amount of code used outside printing method tables possible.

@StefanKarpinski
Copy link
Member

I actually think that the types are the most important part, so making everything else bold strikes me as contrary to what we actually want.

@andrioni
Copy link
Member Author

Indeed, but maybe it would be better to use a different color in this case instead of bold.

I can't, however, decide which one is best. The list to choose from is black, red, green, yellow, blue, magenta, cyan and white.

@StefanKarpinski
Copy link
Member

Also, keep in mind that we've had long discussions about what is and isn't visible on various people's screens, so while enabling this as an option is nice, there's a strong chance that it will be completely illegible on some people's systems, so we may not want it on by default.

@andrioni
Copy link
Member Author

We could add more options to --color, something like no color, minimal colors and fully colored, but even then I still prefer to keep to the basic 16 colors, or even just the eight bold/bright variations.

@fhucho
Copy link

fhucho commented Nov 28, 2013

Yellow name with blue types looks best on my terminal but yellow will be invisible on light backgrounds... Couple of other options:

CL = "\e[0m"
BOLD = "\e[1m"
BLACK = "\e[30m"
RED = "\e[31m"
GREEN = "\e[32m"
YELLOW = "\e[33m"
BLUE = "\e[34m"
MAGENTA = "\e[35m"
CYAN = "\e[36m"
WHITE = "\e[37m"

function p(nm, tp)
    println("$(nm)sort$(CL)(r::$(tp)Range1{T<:Real}$(CL)) at range.jl:374")
    println("$(nm)sort$(CL)(v::$(tp)AbstractArray{T, 1}$(CL), d::$(tp)Integer$(CL), o::$(tp)Ordering$(CL), a::$(tp)Algorithm$(CL)) at deprecated.jl:19")
end

p("$YELLOW$BOLD", "$BOLD$BLUE")
p("$BLUE$BOLD", "$GREEN")
p("$BLUE$BOLD", "$BLUE")
p("$BLUE$BOLD", "$BLUE$BOLD")

@stevengj
Copy link
Member

It would be nice to also have a writemime(io::IO, ::MIME"text/html", x::MethodTable) that used similar formatting in HTML, for display in IJulia (where terminal coloring codes won't work). See also #4952.

@andrioni
Copy link
Member Author

Oh, I didn't know that worked! Should we use inline CSS or there is already a "default" custom stylesheet defined for IJulia?

Also, here's how it looks with yellow and blue:

Yellow and blue

@JeffBezanson
Copy link
Member

Blue is very dark and hard to read in many terminals I've seen.

@ViralBShah
Copy link
Member

Blue is unreadable on Windows.

@staticfloat
Copy link
Member

It would be so neat if we could interrogate the system for the current color profile and choose intelligent colors based on that. I'm for this in principle, but as @StefanKarpinski points out, terminal colors can be difficult when you have such freedom for the user to set it up however they want. I'm still a little mad at my terminal for making git commit messages unreadable when the "black" foreground color is actually black.

@stevengj stevengj mentioned this pull request Nov 28, 2013
@fhucho
Copy link

fhucho commented Nov 29, 2013

Bold or green types look quite readable and hopefully should look well on different terminals. To try it out paste this into the REPL:

CL = "\e[0m"
BOLD = "\e[1m"
BLACK = "\e[30m"
RED = "\e[31m"
GREEN = "\e[32m"
YELLOW = "\e[33m"
BLUE = "\e[34m"
MAGENTA = "\e[35m"
CYAN = "\e[36m"
WHITE = "\e[37m"

function p(nm, tp)
    println("$(nm)sort$(CL)(r::$(tp)Range1{T<:Real}$(CL)) at range.jl:374")
    println("$(nm)sort$(CL)(v::$(tp)AbstractArray{T, 1}$(CL), d::$(tp)Integer$(CL), o::$(tp)Ordering$(CL), a::$(tp)Algorithm$(CL)) at deprecated.jl:19")
end

p("", "$BOLD")
p("", "$GREEN")

@nalimilan
Copy link
Member

Here on Linux with a white background the bold font is more visible than green.

Just an idea: should keyword arguments use a slightly different appearance to make the difference more visible than a small ; compared to ,?

@simonster
Copy link
Member

It looks like readline is escaping the escape sequences when displaying the completion list for method(\t, at least in Konsole on Ubuntu 13.10:

julia> sort(\t
^[[1m^[[34msort^[[0m^[[1m(r::^[[0mRange1{T<:Real}^[[1m^[[1m) at range.jl:374
^[[1m^[[34msort^[[0m{T<:Real}^[[1m(r::^[[0mRange{T<:Real}^[[1m^[[1m) at range.jl:377
^[[1m^[[34msort^[[0m^[[1m(v::^[[0mAbstractArray{T, 1}^[[1m^[[1m) at sort.jl:321
^[[1m^[[34msort^[[0m^[[1m(v::^[[0mAbstractArray{T, 1}^[[1m, d::^[[0mInteger^[[1m, o::^[[0mOrdering^[[1m^[[1m) at deprecated.jl:19

@Keno
Copy link
Member

Keno commented Jun 12, 2014

Bump (just going through old issues :) )

@JeffBezanson
Copy link
Member

I like the extra spaces but the color issue is too much of a bikeshed.

@hayd
Copy link
Member

hayd commented May 23, 2015

I had been running a similar patch for a while which made types more consistently cyan (IIRC julia currently uses cyan in some places for types). This made methods much easier to read.

If the issue is with black and white backgrounds perhaps there ought to be config options... julia already prints quite a few things in color so probably there is already an issue.

@garrison
Copy link
Member

(FYI, to those watching this thread:) I created #11410, which puts spaces between function arguments but nowhere else.

@garrison garrison closed this in 49c504e May 29, 2015
mbauman pushed a commit to mbauman/julia that referenced this pull request Jun 6, 2015
This is meant to supercede JuliaLang#4957, where the outcome seemed to be

> I like the extra spaces but the color issue is too much of a bikeshed.

  -- @JeffBezanson

I am being fairly conservative in that I added spaces *only* to the method table.

Closes JuliaLang#4957.
tkelman pushed a commit to tkelman/julia that referenced this pull request Jun 6, 2015
This is meant to supercede JuliaLang#4957, where the outcome seemed to be

> I like the extra spaces but the color issue is too much of a bikeshed.

  -- @JeffBezanson

I am being fairly conservative in that I added spaces *only* to the method table.

Closes JuliaLang#4957.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.