JuliaDB.jl icon indicating copy to clipboard operation
JuliaDB.jl copied to clipboard

Show methods print colour codes

Open MikeInnes opened this issue 7 years ago • 9 comments

Table with 8279 rows, 2 columns:
Columns:
[1m#  [22m[1mcolname  [22mtype
──────────────────
1  1        String
2  2        String

This comes up in Juno, for example, where we show to a string to display in-editor. Should check if the IO stream is for a terminal or not.

MikeInnes avatar Dec 06 '17 13:12 MikeInnes

Any idea how to do this?

shashi avatar Dec 06 '17 16:12 shashi

maybe something like this: print_with_color(:blue, "Hello world\n")

Mirage10 avatar Dec 06 '17 17:12 Mirage10

Jupyter converts these escape sequences to HTML! Maybe Juno should too as a long term solution.

@Mirage10 I think mike doesn't want any escape chars.

shashi avatar Dec 12 '17 10:12 shashi

Good idea. cc @pfitzseb

MikeInnes avatar Dec 12 '17 10:12 MikeInnes

On it.

AFAIK this should only happen when Julia is started with --color=yes, so there shouldn't be any problems with Juno release.

pfitzseb avatar Dec 12 '17 11:12 pfitzseb

Should be fixed with https://github.com/JunoLab/atom-ink/pull/155/commits/f32c69f851e90a03a86250ecd5210dd735baee1d, but I can't reproduce the initial example.

pfitzseb avatar Dec 12 '17 14:12 pfitzseb

Hey @pfitzseb what state is this in right now? Is it possible for JuliaDB to detect a non-terminal output and not use escaping?

shashi avatar May 29 '18 04:05 shashi

It's actually not only a problem of Juno/Atom. It also occurs when generating docs from Weave/Documenter (or when exporting a notebook to markdown): would the same fix work there too?

piever avatar May 29 '18 09:05 piever

Juno is correctly interpreting those ANSI escape codes now, so they shouldn't show up in our output anymore. I'm not entirely sure how it's possible to figure out whether a given display supports colored output -- unless I'm misunderstanding Base's display system, that's not really possible without custom mime types. Sure, show supports an IOContext as it's first argument, and that can define :color => true (or not), but that is mostly disconnected from display except for the mimetype.

pfitzseb avatar May 29 '18 10:05 pfitzseb