Comments (10)
Beautiful, thanks!
from crayon.
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?
from crayon.
from crayon.
I am not sure if this is a regression. But it could be. What does crayon::num_colors()
say? Sys.getenv()
? (Remove authentication tokens!)
from crayon.
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 😄
from crayon.
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.
from crayon.
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.
from crayon.
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
?
from crayon.
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.
from crayon.
Please reopen if you have issues.
from crayon.
Related Issues (20)
- Detection of color-capable output broken inside an RStudio Job run as a script HOT 1
- win10_build: argument is of length 0 HOT 1
- Backport palette support from cli
- Move `master` branch to `main` HOT 1
- Ns in DNAstringset greys out all text in console that follows HOT 2
- Force all warnings to use crayon? HOT 3
- Release crayon 1.4.2
- red$bold(X) results in : Error in gsub: input string 1 is invalid UTF-8 HOT 3
- Color detection Github Actions HOT 5
- Does not install on R 3.4 and R 3.5, on Windows HOT 1
- Release crayon 1.5.0
- Potential NAMESPACE/import issue? HOT 1
- Release crayon 1.5.1
- Partial argument name: read.table(..., comment = ";")
- crayon doesn't mark encoding on UTF-8 strings in some cases HOT 3
- num_ansi_colors ignores stream parameter HOT 1
- strip_style() returns garbled output in non-UTF-8 locale when UTF-8 characters are present HOT 2
- Release crayon 1.5.2
- Upkeep for crayon (2023)
- crayon update from CRAN
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crayon.