aboutsummaryrefslogtreecommitdiff
path: root/vendor/anstream/src/lib.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
committerValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
commit1b6a04ca5504955c571d1c97504fb45ea0befee4 (patch)
tree7579f518b23313e8a9748a88ab6173d5e030b227 /vendor/anstream/src/lib.rs
parent5ecd8cf2cba827454317368b68571df0d13d7842 (diff)
downloadfparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.tar.xz
fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.zip
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
Diffstat (limited to 'vendor/anstream/src/lib.rs')
-rw-r--r--vendor/anstream/src/lib.rs79
1 files changed, 79 insertions, 0 deletions
diff --git a/vendor/anstream/src/lib.rs b/vendor/anstream/src/lib.rs
new file mode 100644
index 0000000..9721139
--- /dev/null
+++ b/vendor/anstream/src/lib.rs
@@ -0,0 +1,79 @@
+//! **Auto-adapting [`stdout`] / [`stderr`] streams**
+//!
+//! *A portmanteau of "ansi stream"*
+//!
+//! [`AutoStream`] always accepts [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code),
+//! adapting to the user's terminal's capabilities.
+//!
+//! Benefits
+//! - Allows the caller to not be concerned with the terminal's capabilities
+//! - Semver safe way of passing styled text between crates as ANSI escape codes offer more
+//! compatibility than most crate APIs.
+//!
+//! Available styling crates:
+//! - [anstyle](https://docs.rs/anstyle) for minimal runtime styling, designed to go in public APIs
+//! (once it hits 1.0)
+//! - [owo-colors](https://docs.rs/owo-colors) for feature-rich runtime styling
+//! - [color-print](https://docs.rs/color-print) for feature-rich compile-time styling
+//!
+//! # Example
+//!
+//! ```
+//! # #[cfg(feature = "auto")] {
+//! use anstream::println;
+//! use owo_colors::OwoColorize as _;
+//!
+//! // Foreground colors
+//! println!("My number is {:#x}!", 10.green());
+//! // Background colors
+//! println!("My number is not {}!", 4.on_red());
+//! # }
+//! ```
+//!
+//! And this will correctly handle piping to a file, etc
+
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
+
+pub mod adapter;
+pub mod stream;
+
+mod buffer;
+#[macro_use]
+mod macros;
+mod auto;
+mod fmt;
+mod strip;
+#[cfg(all(windows, feature = "wincon"))]
+mod wincon;
+
+pub use auto::AutoStream;
+pub use strip::StripStream;
+#[cfg(all(windows, feature = "wincon"))]
+pub use wincon::WinconStream;
+
+#[allow(deprecated)]
+pub use buffer::Buffer;
+
+/// Create an ANSI escape code compatible stdout
+///
+/// **Note:** Call [`AutoStream::lock`] in loops to avoid the performance hit of acquiring/releasing
+/// from the implicit locking in each [`std::io::Write`] call
+#[cfg(feature = "auto")]
+pub fn stdout() -> AutoStream<std::io::Stdout> {
+ let stdout = std::io::stdout();
+ AutoStream::auto(stdout)
+}
+
+/// Create an ANSI escape code compatible stderr
+///
+/// **Note:** Call [`AutoStream::lock`] in loops to avoid the performance hit of acquiring/releasing
+/// from the implicit locking in each [`std::io::Write`] call
+#[cfg(feature = "auto")]
+pub fn stderr() -> AutoStream<std::io::Stderr> {
+ let stderr = std::io::stderr();
+ AutoStream::auto(stderr)
+}
+
+/// Selection for overriding color output
+#[cfg(feature = "auto")]
+pub use colorchoice::ColorChoice;