diff options
Diffstat (limited to 'rola-cli/src/output/ansi_control.rs')
| -rw-r--r-- | rola-cli/src/output/ansi_control.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/rola-cli/src/output/ansi_control.rs b/rola-cli/src/output/ansi_control.rs new file mode 100644 index 0000000..5db8c2a --- /dev/null +++ b/rola-cli/src/output/ansi_control.rs @@ -0,0 +1,32 @@ +use std::sync::atomic::{AtomicBool, Ordering}; + +mod colorize_wrapper; +pub use colorize_wrapper::*; + +/// Global flag controlling whether ANSI color output is enabled. +static ANSI_ENABLED: AtomicBool = AtomicBool::new(true); + +/// Enable ANSI color codes in output. +pub fn enable_ansi() { + ANSI_ENABLED.store(true, Ordering::Relaxed); +} + +/// Disable ANSI color codes in output. +pub fn disable_ansi() { + ANSI_ENABLED.store(false, Ordering::Relaxed); +} + +/// Set ANSI color output to the specified state (`true` to enable, `false` to disable). +pub fn set_ansi(enabled: bool) { + ANSI_ENABLED.store(enabled, Ordering::Relaxed); +} + +/// Check whether ANSI color output is currently enabled. +pub fn is_ansi_enabled() -> bool { + ANSI_ENABLED.load(Ordering::Relaxed) +} + +/// Returns `true` if ANSI is enabled, `false` otherwise. +pub fn is_enabled() -> bool { + is_ansi_enabled() +} |
