You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, one is already able to determine if colors are supported, but only through a "hack" what I'd like is a new function:
supports_color considers the override value and (might ?) mirror the API of the underlying supports-color crate. This is especially useful in cases where one would A) like to query the negative status, e.g. do something if colors are not supported and B) get more information, e.g. only execute X if truecolor is supported, but still take into account the globally set override.
What do you think? I'd be happy to draft up a PR and implement the functionality, but before that would like to know if this is something that the library should support.
How to currently get the status (sadly involves additional atomics, is cumbersome and requires alloc):
let supports_color = AtomicBool::new(false);
owo_colors::set_override(true);format!("{}", x.if_supports_color(Stream::Stdout, |x| {
supports_color.store(true, core::sync::atomic::Ordering::SeqCst);
x
}));
supports_color.load(core::sync::atomic::Ordering::SeqCst)
The text was updated successfully, but these errors were encountered:
indietyp
changed the title
[Feature Request]
[Feature Request] introspection if colors are supported
Jan 10, 2023
Ability to introspect the current override status.
(follow-up to #84)
Currently, one is already able to determine if colors are supported, but only through a "hack" what I'd like is a new function:
supports_color
considers the override value and (might ?) mirror the API of the underlyingsupports-color
crate. This is especially useful in cases where one would A) like to query the negative status, e.g. do something if colors are not supported and B) get more information, e.g. only executeX
if truecolor is supported, but still take into account the globally set override.What do you think? I'd be happy to draft up a PR and implement the functionality, but before that would like to know if this is something that the library should support.
How to currently get the status (sadly involves additional atomics, is cumbersome and requires alloc):
The text was updated successfully, but these errors were encountered: