Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
term: Introduce `DrawTarget`
Erik Kundt committed 7 months ago
commit 541471a1e09e75da1a1e4821d87e6af1cd1bd8b4
parent 646d4360e7d905f0a9ec87d32c6768c5390eabf3
1 file changed +21 -0
modified crates/radicle-term/src/io.rs
@@ -46,6 +46,27 @@ pub static CONFIG: LazyLock<RenderConfig> = LazyLock::new(|| RenderConfig {
    ..RenderConfig::default_colored()
});

+
/// Target for draw operations
+
///
+
/// This tells a [`Spinner`] object where to draw to.
+
/// The draw target is a stateful wrapper over a drawing destination.
+
#[derive(Clone)]
+
pub enum DrawTarget {
+
    Stdout,
+
    Stderr,
+
    Hidden,
+
}
+

+
impl DrawTarget {
+
    pub fn writer(&self) -> Box<dyn io::Write> {
+
        match self {
+
            DrawTarget::Stdout => Box::new(io::stdout()),
+
            DrawTarget::Stderr => Box::new(io::stderr()),
+
            DrawTarget::Hidden => Box::new(io::sink()),
+
        }
+
    }
+
}
+

#[macro_export]
macro_rules! info {
    ($writer:expr; $($arg:tt)*) => ({