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

more verbose multi-line display(c) for Char #19847

Merged
merged 6 commits into from
Jan 5, 2017

Conversation

stevengj
Copy link
Member

@stevengj stevengj commented Jan 3, 2017

show('$') prints a terse representation like '$'. I've been thinking it would be nice to have a more informative display in the REPL (and in other things like IJulia that use the 3-argument show via display). This PR does so, giving output like:

julia> '$'
'$': ASCII/Unicode U+0024 (category Sc: Symbol, currency)

julia> '⊗'
'⊗': Unicode U+2297 (category Sm: Symbol, math)

function show(io::IO, ::MIME"text/plain", c::Char)
show(io, c)
u = UInt32(c)
print(io, ": ", isascii(c) ? "ASCII/" : "", "Unicode U+", hex(u, u > 0xffff ? 8 : 4))
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Maybe use 6 instead of 8?

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

@quinnj
Copy link
Member

quinnj commented Jan 3, 2017

What is category Sc vs category Sm? Should it maybe just be category: Symbol, currency? What are the non-Symbol characters? control characters?

@stevengj
Copy link
Member Author

stevengj commented Jan 3, 2017

@quinnj, both the two-letter abbreviations and the expanded names for the Unicode character categories are standard, so it seemed useful to give them both.

@TotalVerb
Copy link
Contributor

Would the Unicode description, like

'$': Unicode U+0024 Dollar sign (category Sc ...)

be possible/desirable to add?

@stevengj
Copy link
Member Author

stevengj commented Jan 3, 2017

@TotalVerb, not without storing the Unicode character-name database somewhere; it's about a MB uncompressed IIRC (see also #19725 and related issues), so I'm not sure this is a great thing for us to do.

@stevengj
Copy link
Member Author

stevengj commented Jan 4, 2017

One option that occurred to me is to have a show(io, "text/html", c::Char) method that links to the complete description of the codepoint on e.g. www.fileformat.info, for example U+0302, but that doesn't help in the REPL.

@stevengj
Copy link
Member Author

stevengj commented Jan 4, 2017

It also occurred to me to output the tab-completion info, which @ScottPJones also suggested on the mailing list, but this seemed too REPL-specific. It seemed better to just have this in the REPL help, e.g. if you type ?⊗ it should tell you that you can type with \otimes<tab>, in addition to any other help.

Update: see #19858.

@stevengj
Copy link
Member Author

stevengj commented Jan 4, 2017

I'm not understanding the Travis failures here... oh, it was #19848.

@stevengj
Copy link
Member Author

stevengj commented Jan 4, 2017

Should be good to merge; the i686 travis failure seems to be an endemic unrelated problem at the moment.

@StefanKarpinski
Copy link
Sponsor Member

I like it. Should we make sure that repr(c) is still just 'x'?

@stevengj
Copy link
Member Author

stevengj commented Jan 4, 2017

I added a test for repr. (repr uses the 2-argument show, which hasn't been changed.)

@stevengj
Copy link
Member Author

stevengj commented Jan 5, 2017

Should be good to squash/merge; the Travis failure is the unrelated x86 problem we are having nowadays.

@stevengj stevengj merged commit f25d5a7 into JuliaLang:master Jan 5, 2017
@stevengj stevengj deleted the charshow branch January 5, 2017 16:22
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.

5 participants