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 colour to show(::Method) #40916

Closed
wants to merge 1 commit into from
Closed

Add colour to show(::Method) #40916

wants to merge 1 commit into from

Conversation

tecosaur
Copy link
Contributor

This is a follow-up from #40913. First PR / interaction here, so please let me know if there's anything like a commit message guideline etc. I've missed 🙂.

Simply put, I think adding colour to show(::Method) makes it easier to find information at a glance.

The original spiel

I love being able to see all the various implement methods, or methods using a certain type in Julia.
However, I didn't find it easy to find what I was looking for at a glance. Particularly for functions with many (tens-hundreds) of implementations. So, I've tried adding a bit of colour. I've found it really helpful, and think it would be good if something like it were the default.

Example

Current output for methods(sum)

image

My output for methods(sum)

image

@tecosaur
Copy link
Contributor Author

I've been notified in #40913 that this is a second take on #40251.

@oscardssmith oscardssmith added display and printing Aesthetics and correctness of printed representations of objects. REPL Julia's REPL (Read Eval Print Loop) labels May 22, 2021
printstyled(io, "::", d[2]; color=:yellow)
else
printstyled(io, "::", typespec[1]; color=:yellow)
printstyled(io, "{", typespec[2]; color=247)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that in general we try to only use the 16 standard colors in the REPL since they are the ones most widely supported.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does anything not support 256-color? I thought perhaps TTYs but I just checked my TTY and it seems to work there...
image

@tecosaur
Copy link
Contributor Author

Something else I'd think is worth considering, but maybe outside of this PR: terminal hyperlinks to the referenced files.
i.e.

printf '\e]8;;file:///usr/share/julia/stdlib/v1.6/SparseArrays/src/sparsevector.jl\e\\\e[32msparsevector.jl\e]8;;\e\\\n'

@tecosaur
Copy link
Contributor Author

tecosaur commented May 22, 2021

Another thought: It could be a nice idea to implement coloured type representation, and then re-use that here instead of the hacky {-splitting etc. while also getting a better result.

For instance, instead of
image
one could have something like
image

@JeffBezanson
Copy link
Member

Ideally this should share code with stacktrace printing.

@tecosaur
Copy link
Contributor Author

I'm guessing this is the sort of thing you're thinking of?

image

This would require some sort of in-built syntax highlighting, and if Julia were to go that route, would it be best to include https://github.com/KristofferC/OhMyREPL.jl ? This is now both a bit off-topic and speculative but given how much nicer it makes the REPL experience (to me at least) I'd think it would be a nice thing for all users to have, and I'd imagine it would provide primatives that would make doing the sort of highlighting above really easy. I'm going a bit out a limb though, @KristofferC might have something to add on this.

Add color to show(io, Method) with printstyled, and also modify the
header displayed when representing a list of methods to emphasise the
number and function name.
@tecosaur
Copy link
Contributor Author

Clearly, #40251 is preferred at this point.

@tecosaur tecosaur closed this Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
display and printing Aesthetics and correctness of printed representations of objects. REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants