blob: 5db8c2a972f86a6bd2a1294f92cca7d56a6d7749 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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()
}
|