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

Some colours are grey #17

Closed
richfitz opened this issue Mar 27, 2015 · 10 comments
Closed

Some colours are grey #17

richfitz opened this issue Mar 27, 2015 · 10 comments

Comments

@richfitz
Copy link
Contributor

message(crayon::make_style("hotpink")("asdfa"))
gaborcsardi added a commit that referenced this issue Mar 27, 2015
The detection run at install time was cached.
@richfitz
Copy link
Contributor Author

richfitz commented Apr 2, 2015

Beautiful, thanks!

@richfitz
Copy link
Contributor Author

This is a problem again, at least on my system (linux, terminal, R 3.2.2 with github and CRAN versions of crayon). Can you reopen? Any idea how to detect regressions?

@richfitz
Copy link
Contributor Author

crayon

@gaborcsardi gaborcsardi reopened this Dec 22, 2015
@gaborcsardi
Copy link
Member

I am not sure if this is a regression. But it could be. What does crayon::num_colors() say? Sys.getenv()? (Remove authentication tokens!)

@richfitz
Copy link
Contributor Author

You're right, sorry for the false alarm -- my OSX system displays the colour correctly (reporting 256 for num_colors()) while Linux is reporting 8 colours.

That's coming from system("tput colors") reporting 8 colours, even though this is definitely not an 8 colour terminal.

Forcing the terminal type by running

TERM=xterm-256color tput colors

gives the right number. Likewise,

TERM=xterm-256color Rscript -e 'message(crayon::make_style("hotpink")("asdfa"))'

prints the pink correctly. So while this is definitely a configuration issue, this suggests that this 8 colour reporting/256 colour capability configuration is typical. This SO answer might provide a less stringent test, as it seems likely that 256 colour support will be more common than 8 colour support this century 😄

@gaborcsardi
Copy link
Member

Thanks for the links. The thing is, the method suggested in the SO answer does not work for me on OSX, in iterm. :/ I think if you know that your terminal supports 256 colors, you can just set TERM accordingly. This is the simplest solution, and I suspect that it is the only safe one that works on all platforms.

@richfitz
Copy link
Contributor Author

What would happen if rather than getting the result of tput just assuming 256? Is there even an 8 colour terminal easily available to see how it looks? Being able to rely in >8 colours makes using the package a lot easier (otherwise all end users will have to set TERM, even if it's several dependencies deep). I can dig around and see what the node packages for this do if that's useful. Or you can keep the current behaviour, which I agree is probably safest.

@gaborcsardi
Copy link
Member

What would happen if rather than getting the result of tput just assuming 256?

I have no idea.

Is there even an 8 colour terminal easily available to see how it looks?

Emacs is surely 8 color.

Being able to rely in >8 colours makes using the package a lot easier (otherwise all end users will have to set TERM, even if it's several dependencies deep).

I can default to 256 if TERM is xterm. I guess this solves most issues. But then I need a mechanism to fall back to 8 colors.

I can dig around and see what the node packages for this do if that's useful.

This is what the most popular node package does: https://github.com/chalk/supports-color/blob/master/index.js

So how about defaulting to 256 if TERM is xterm?

@richfitz
Copy link
Contributor Author

In emacs, when forcing 256 colours with:

crayon::make_style("hotpink", colors=256)

I get unstyled output, which doesn't seem too tragic a failing.

Looks like node is going with 8 colours with xterm. And apparently setting TERM is liable to cause unspecified things. What a mess.

@gaborcsardi
Copy link
Member

Please reopen if you have issues.

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

No branches or pull requests

2 participants