(I'm the author of term-painter
)
@mackwic: have you seen this thread? It suggest using CLICOLOR
and CLICOLOR_FORCED
variables; apparently CMake use those variables, too. I would use them instead of Rust specific ones. What do you think?
Since you shouldn't put essential information in color (there are color-blind people who can't see it) that shouldn't be a big loss, just a loss in emphasis on some text.
I have to disagree. As a human, parsing text can be done much quicker when relevant parts are emphasized. Doing this without colors is sadly somewhat limited. This difference in readability can be quite notable and shouldn't be ignored. Yes, there are colorblind people, but most of them (like myself) "just" have problems with a few colors. The inability to see any color at all is very rare. And I have no problem with adjusting my color scheme to avoid using some colors that my eyes don't like.
Ability to disable colors easily: Absolutely. Off by default/colors should be avoided: No.
Regarding the Win-support discussion:
Supporting different operating systems is hard, but I (!!) think that only supporting one (ansi_term
) or having different APIs (like @mackwic suggested) is not the right way to go. With my library I chose the "expose a maybe-surprising API and tell the users about it"-philosophy. But I am certainly not perfectly happy with that!
I tried to summarize the discussion:
- Using
println!
can lead to strange behaviour, because the time ofDisplay
ing is not defined. Everything that can be used withprintln!
can be used withformat!
and theDisplay
impl can't tell the difference. Every solution that works withprintln!
and alike will not be able to fully work on Windows (again, because offormat!
). Furthermore such a solution would not be able to warn it's user about the usage offormat!
-- the user would get confusing results. - Controlling the output to
stdout
within the painting library would resolve the issue above. But even if the library would define a macro (saycoloredln!
) to make printing easy, usingprintln!
is still the natural choice for Rust programmers. Furthermore there are many macros and functionality that is build aroundprintln!
. With solution (1.) it would be possible to use those macros as well, which is a big advantage IMO. - Proxying
stdout
and do stuff right before printing, like @DanielKeep mentioned. While this sounds crazy at first, I think it's a fairly good idea. It solves both problems above, at least.
I am really interested in developing a solution better than everything we have so far!
EDIT: I also want to add, that solution (1.) (and hence my crate term-painter
) also depends on the exact implementation of println!
-- in particular the order of operations. This is not good.