-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
tty: improve tty color detection #19730
Conversation
This adds attributions for the getColorDepth function as it got inspired by https://github.com/chalk/supports-color and more sources.
This adds support for a couple more terminals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine to me, if @sindresorhus is okay with it too.
Also, fyi: http://no-color.org/
@addaleax I actually know that site, I just did not come up with the idea to use the information properly. So thanks a lot 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This adds attributions for the getColorDepth function as it got inspired by https://github.com/chalk/supports-color and more sources. PR-URL: nodejs#19730 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This adds support for a couple more terminals. PR-URL: nodejs#19730 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This adds attributions for the getColorDepth function as it got inspired by https://github.com/chalk/supports-color and more sources. PR-URL: #19730 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This adds support for a couple more terminals. PR-URL: #19730 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This moves the
getColorDepth
function to the newinternal/tty
file. This is important to properly give attributions to @sindresorhus.I also improved the detection by adding new values that should be checked. I am currently playing around with
ncurses
has_colors function. It does seem to work fine, I am just not sure where I should expose the function and how this should work on e.g. Windows. Somewhat similar:tput colors
. Adding that would allow to detect simple color support. A couple of the terminals that support colors actually support more colors than currently returned, but I did not yet find a good way to always detect the version (as I have to install the terminal etc...). If anyone has a idea how to detect color support without checking environment variables: please let me know.printf
andread
can be used in combination, I am just not sure how to make use of that information for Node.js.This definitely needs a backport to 9.x.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes