term: Introduce `PaintTarget`

This introduces a `PaintTarget`, that defines the stream an operation
uses to draw to (`stdout`, `stderr`, `sink`). It will be used in
subsequent commits to configure the new spinner.
This commit is contained in:
Erik Kundt 2025-09-10 23:48:47 +02:00 committed by Lorenz Leutgeb
parent 379037956a
commit 11a109ef41
1 changed files with 20 additions and 0 deletions

View File

@ -46,6 +46,26 @@ pub static CONFIG: LazyLock<RenderConfig> = LazyLock::new(|| RenderConfig {
..RenderConfig::default_colored()
});
/// Target for paint operations.
///
/// This tells a [`Spinner`] object where to paint to.
#[derive(Clone)]
pub enum PaintTarget {
Stdout,
Stderr,
Hidden,
}
impl PaintTarget {
pub fn writer(&self) -> Box<dyn io::Write> {
match self {
PaintTarget::Stdout => Box::new(io::stdout()),
PaintTarget::Stderr => Box::new(io::stderr()),
PaintTarget::Hidden => Box::new(io::sink()),
}
}
}
#[macro_export]
macro_rules! info {
($writer:expr; $($arg:tt)*) => ({