google / ansicolor-dart

Apache License 2.0
104 stars 26 forks source link

Detect color support, default "color disabled" accordingly #6

Closed seaneagan closed 4 years ago

seaneagan commented 9 years ago

I created a package to detect color support:

https://github.com/seaneagan/supports_color

If #4 were fixed using Zones as suggested, then you just initialize the "color disabled" value in the root Zone to the value from the supports_color package, and if folks want to override it, they just use the API provided by #4 to do so.

MikeMitterer commented 7 years ago

I'm not sure why you would need a Zone for this but auto detection as the supports_colors suggest would be very nice to have.

pulyaevskiy commented 7 years ago

I tend to agree about Zones.

It seems like it would be a good idea to merge supports_color in this library, or just implement the same logic here.

pulyaevskiy commented 7 years ago

Looks like ansiSupported is coming in 1.23 on the Platform class in dart:io: https://github.com/google/platform.dart/pull/4

jtmcdole commented 4 years ago

Looks like ansiSupported was removed. ansicolor today requires nothing (dart:io or other). You can write this exact line of code in Chrome and it'll work - so this library is still useful for folks there.

console.log('\x1b[36m%s\x1b[34m%s\x1b[0m', 'I am cyan','i am blue');
jtmcdole commented 4 years ago

Stdout.supportsAnsiEscapes is the new variable. I can make this support browsers as well.