summaryrefslogtreecommitdiffstats
path: root/vendor/anstyle-wincon
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /vendor/anstyle-wincon
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz
rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/anstyle-wincon')
-rw-r--r--vendor/anstyle-wincon/.cargo-checksum.json1
-rw-r--r--vendor/anstyle-wincon/Cargo.lock90
-rw-r--r--vendor/anstyle-wincon/Cargo.toml93
-rw-r--r--vendor/anstyle-wincon/LICENSE-APACHE202
-rw-r--r--vendor/anstyle-wincon/LICENSE-MIT19
-rw-r--r--vendor/anstyle-wincon/README.md30
-rw-r--r--vendor/anstyle-wincon/examples/dump.rs143
-rw-r--r--vendor/anstyle-wincon/examples/set.rs57
-rw-r--r--vendor/anstyle-wincon/src/console.rs156
-rw-r--r--vendor/anstyle-wincon/src/lib.rs21
-rw-r--r--vendor/anstyle-wincon/src/lockable.rs31
-rw-r--r--vendor/anstyle-wincon/src/stream.rs139
-rw-r--r--vendor/anstyle-wincon/src/windows.rs147
13 files changed, 1129 insertions, 0 deletions
diff --git a/vendor/anstyle-wincon/.cargo-checksum.json b/vendor/anstyle-wincon/.cargo-checksum.json
new file mode 100644
index 000000000..67464ffc5
--- /dev/null
+++ b/vendor/anstyle-wincon/.cargo-checksum.json
@@ -0,0 +1 @@
+{"files":{"Cargo.lock":"86cb92ab6c8ebf447b7c7b7f7c66e7abe0e1075f02e604ce18aeadffdd39492c","Cargo.toml":"455d753c0e8ec901c91ac87b161d4a8cc583cb62d5b3ce9b295e79f9b8ec194c","LICENSE-APACHE":"c6596eb7be8581c18be736c846fb9173b69eccf6ef94c5135893ec56bd92ba08","LICENSE-MIT":"73b0d84e4b954ce904a00043379767ae2a5f8d4f40564639cee230f639fe4dae","README.md":"513a578c6c2ea39a811e2038358e512cbc0c709e3a7c18303871ec2c52ebbeec","examples/dump.rs":"529652b19ddc3ee16d36cd9d110d917a1a85f93e15c40118eca2bdec141ada11","examples/set.rs":"942ca48495fb50058ef7e39cf6e756eaafde7b2afc3f0af1281c85167f81648d","src/console.rs":"4c0b7d41fe738beaf85fcb30c68fdafce89deb0e10cec7e658fa970660c1cc6f","src/lib.rs":"3ad580df7729f21aeed60a1cef7b857852ee38640b48c4db3de234036742ae69","src/lockable.rs":"838c7652cde81ea19f8e62d64e9c552677b9602bec3c5593ce66e7b4b8b9fb01","src/stream.rs":"fbc8996017e8592d27aebf936a01a8333e8f15413c7283837dbdf5f5e010a528","src/windows.rs":"4bd4e2fc5a260bb5afed9df8a6e04051a47064f475a22001e22fbcebf9347b6d"},"package":"c3127af6145b149f3287bb9a0d10ad9c5692dba8c53ad48285e5bec4063834fa"} \ No newline at end of file
diff --git a/vendor/anstyle-wincon/Cargo.lock b/vendor/anstyle-wincon/Cargo.lock
new file mode 100644
index 000000000..90c4e5cfc
--- /dev/null
+++ b/vendor/anstyle-wincon/Cargo.lock
@@ -0,0 +1,90 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "anstyle"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "80c697cc33851b02ab0c26b2e8a211684fbe627ff1cc506131f35026dd7686dd"
+
+[[package]]
+name = "anstyle-wincon"
+version = "0.2.0"
+dependencies = [
+ "anstyle",
+ "lexopt",
+ "windows-sys",
+]
+
+[[package]]
+name = "lexopt"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baff4b617f7df3d896f97fe922b64817f6cd9a756bb81d40f8883f2f66dcb401"
+
+[[package]]
+name = "windows-sys"
+version = "0.45.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.42.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.42.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.42.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.42.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.42.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.42.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.42.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.42.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"
diff --git a/vendor/anstyle-wincon/Cargo.toml b/vendor/anstyle-wincon/Cargo.toml
new file mode 100644
index 000000000..daece8464
--- /dev/null
+++ b/vendor/anstyle-wincon/Cargo.toml
@@ -0,0 +1,93 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g., crates.io) dependencies.
+#
+# If you are reading this file be aware that the original Cargo.toml
+# will likely look very different (and much more reasonable).
+# See Cargo.toml.orig for the original contents.
+
+[package]
+edition = "2021"
+rust-version = "1.64.0"
+name = "anstyle-wincon"
+version = "0.2.0"
+include = [
+ "build.rs",
+ "src/**/*",
+ "Cargo.toml",
+ "LICENSE*",
+ "README.md",
+ "benches/**/*",
+ "examples/**/*",
+]
+description = "Styling legacy Windows terminals"
+homepage = "https://github.com/rust-cli/anstyle"
+readme = "README.md"
+keywords = [
+ "ansi",
+ "terminal",
+ "color",
+ "windows",
+]
+categories = ["command-line-interface"]
+license = "MIT OR Apache-2.0"
+repository = "https://github.com/rust-cli/anstyle.git"
+
+[package.metadata.docs.rs]
+rustdoc-args = [
+ "--cfg",
+ "docsrs",
+]
+features = ["unstable-doc"]
+targets = ["x86_64-pc-windows-msvc"]
+
+[[package.metadata.release.pre-release-replacements]]
+file = "CHANGELOG.md"
+search = "Unreleased"
+replace = "{{version}}"
+min = 1
+
+[[package.metadata.release.pre-release-replacements]]
+file = "CHANGELOG.md"
+search = '\.\.\.HEAD'
+replace = "...{{tag_name}}"
+exactly = 1
+
+[[package.metadata.release.pre-release-replacements]]
+file = "CHANGELOG.md"
+search = "ReleaseDate"
+replace = "{{date}}"
+min = 1
+
+[[package.metadata.release.pre-release-replacements]]
+file = "CHANGELOG.md"
+search = "<!-- next-header -->"
+replace = """
+<!-- next-header -->
+## [Unreleased] - ReleaseDate
+"""
+exactly = 1
+
+[[package.metadata.release.pre-release-replacements]]
+file = "CHANGELOG.md"
+search = "<!-- next-url -->"
+replace = """
+<!-- next-url -->
+[Unreleased]: https://github.com/rust-cli/anstyle/compare/{{tag_name}}...HEAD"""
+exactly = 1
+
+[dependencies.anstyle]
+version = "0.3.0"
+
+[dev-dependencies.lexopt]
+version = "0.3.0"
+
+[target."cfg(windows)".dependencies.windows-sys]
+version = "0.45.0"
+features = [
+ "Win32_System_Console",
+ "Win32_Foundation",
+]
diff --git a/vendor/anstyle-wincon/LICENSE-APACHE b/vendor/anstyle-wincon/LICENSE-APACHE
new file mode 100644
index 000000000..8f71f43fe
--- /dev/null
+++ b/vendor/anstyle-wincon/LICENSE-APACHE
@@ -0,0 +1,202 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright {yyyy} {name of copyright owner}
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
diff --git a/vendor/anstyle-wincon/LICENSE-MIT b/vendor/anstyle-wincon/LICENSE-MIT
new file mode 100644
index 000000000..fe451c946
--- /dev/null
+++ b/vendor/anstyle-wincon/LICENSE-MIT
@@ -0,0 +1,19 @@
+Copyright (c) 2015 Josh Triplett, 2022 The rust-cli Developers
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/anstyle-wincon/README.md b/vendor/anstyle-wincon/README.md
new file mode 100644
index 000000000..7df0db541
--- /dev/null
+++ b/vendor/anstyle-wincon/README.md
@@ -0,0 +1,30 @@
+# anstyle-wincon
+
+> Styling legacy Windows terminals
+
+[![Documentation](https://img.shields.io/badge/docs-master-blue.svg)][Documentation]
+![License](https://img.shields.io/crates/l/anstyle-wincon.svg)
+[![Crates Status](https://img.shields.io/crates/v/anstyle-wincon.svg)](https://crates.io/crates/anstyle-wincon)
+
+## License
+
+Licensed under either of
+
+ * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
+ * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
+
+at your option.
+
+### Contribution
+
+Unless you explicitly state otherwise, any contribution intentionally
+submitted for inclusion in the work by you, as defined in the Apache-2.0
+license, shall be dual licensed as above, without any additional terms or
+conditions.
+
+### Special Thanks
+
+[burntsushi](https://github.com/burntsushi) for [termcolor](https://github.com/burntsushi/termcolor) as I don't know Windows either :)
+
+[Crates.io]: https://crates.io/crates/anstyle-wincon
+[Documentation]: https://docs.rs/anstyle-wincon
diff --git a/vendor/anstyle-wincon/examples/dump.rs b/vendor/anstyle-wincon/examples/dump.rs
new file mode 100644
index 000000000..64070a0e6
--- /dev/null
+++ b/vendor/anstyle-wincon/examples/dump.rs
@@ -0,0 +1,143 @@
+fn main() -> Result<(), lexopt::Error> {
+ let args = Args::parse()?;
+ let stdout = std::io::stdout();
+ let mut stdout = anstyle_wincon::Console::new(stdout.lock())
+ .map_err(|_err| lexopt::Error::from("could not open `stdout` for color control"))?;
+
+ for fixed in 0..16 {
+ let style = style(fixed, args.layer, args.effects);
+ let _ = print_number(&mut stdout, fixed, style);
+ if fixed == 7 || fixed == 15 {
+ let _ = stdout.write(None, None, &b"\n"[..]);
+ }
+ }
+
+ for r in 0..6 {
+ let _ = stdout.write(None, None, &b"\n"[..]);
+ for g in 0..6 {
+ for b in 0..6 {
+ let fixed = r * 36 + g * 6 + b + 16;
+ let style = style(fixed, args.layer, args.effects);
+ let _ = print_number(&mut stdout, fixed, style);
+ }
+ let _ = stdout.write(None, None, &b"\n"[..]);
+ }
+ }
+
+ for c in 0..24 {
+ if 0 == c % 8 {
+ let _ = stdout.write(None, None, &b"\n"[..]);
+ }
+ let fixed = 232 + c;
+ let style = style(fixed, args.layer, args.effects);
+ let _ = print_number(&mut stdout, fixed, style);
+ }
+
+ Ok(())
+}
+
+fn style(fixed: u8, layer: Layer, effects: anstyle::Effects) -> anstyle::Style {
+ let color = anstyle::Ansi256Color(fixed).into();
+ (match layer {
+ Layer::Fg => anstyle::Style::new().fg_color(Some(color)),
+ Layer::Bg => anstyle::Style::new().bg_color(Some(color)),
+ Layer::Underline => anstyle::Style::new().underline_color(Some(color)),
+ }) | effects
+}
+
+fn print_number(
+ stdout: &mut anstyle_wincon::Console<std::io::StdoutLock<'_>>,
+ fixed: u8,
+ style: anstyle::Style,
+) -> std::io::Result<()> {
+ let fg = style.get_fg_color().and_then(|c| match c {
+ anstyle::Color::Ansi(c) => Some(c),
+ anstyle::Color::Ansi256(c) => c.into_ansi(),
+ anstyle::Color::Rgb(_) => None,
+ });
+ let bg = style.get_bg_color().and_then(|c| match c {
+ anstyle::Color::Ansi(c) => Some(c),
+ anstyle::Color::Ansi256(c) => c.into_ansi(),
+ anstyle::Color::Rgb(_) => None,
+ });
+
+ stdout
+ .write(fg, bg, format!("{:>4}", fixed).as_bytes())
+ .map(|_| ())
+}
+
+#[derive(Default)]
+struct Args {
+ effects: anstyle::Effects,
+ layer: Layer,
+}
+
+#[derive(Copy, Clone)]
+enum Layer {
+ Fg,
+ Bg,
+ Underline,
+}
+
+impl Default for Layer {
+ fn default() -> Self {
+ Layer::Fg
+ }
+}
+
+impl Args {
+ fn parse() -> Result<Self, lexopt::Error> {
+ use lexopt::prelude::*;
+
+ let mut res = Args::default();
+
+ let mut args = lexopt::Parser::from_env();
+ while let Some(arg) = args.next()? {
+ match arg {
+ Long("layer") => {
+ res.layer = args.value()?.parse_with(|s| match s {
+ "fg" => Ok(Layer::Fg),
+ "bg" => Ok(Layer::Bg),
+ "underline" => Ok(Layer::Underline),
+ _ => Err("expected values fg, bg, underline"),
+ })?;
+ }
+ Long("effect") => {
+ const EFFECTS: [(&str, anstyle::Effects); 12] = [
+ ("bold", anstyle::Effects::BOLD),
+ ("dimmed", anstyle::Effects::DIMMED),
+ ("italic", anstyle::Effects::ITALIC),
+ ("underline", anstyle::Effects::UNDERLINE),
+ ("double_underline", anstyle::Effects::UNDERLINE),
+ ("curly_underline", anstyle::Effects::CURLY_UNDERLINE),
+ ("dotted_underline", anstyle::Effects::DOTTED_UNDERLINE),
+ ("dashed_underline", anstyle::Effects::DASHED_UNDERLINE),
+ ("blink", anstyle::Effects::BLINK),
+ ("invert", anstyle::Effects::INVERT),
+ ("hidden", anstyle::Effects::HIDDEN),
+ ("strikethrough", anstyle::Effects::STRIKETHROUGH),
+ ];
+ let effect = args.value()?.parse_with(|s| {
+ EFFECTS
+ .into_iter()
+ .find(|(name, _)| *name == s)
+ .map(|(_, effect)| effect)
+ .ok_or_else(|| {
+ format!(
+ "expected one of {}",
+ EFFECTS
+ .into_iter()
+ .map(|(n, _)| n)
+ .collect::<Vec<_>>()
+ .join(", ")
+ )
+ })
+ })?;
+ res.effects = res.effects.insert(effect);
+ }
+ _ => return Err(arg.unexpected()),
+ }
+ }
+ Ok(res)
+ }
+}
diff --git a/vendor/anstyle-wincon/examples/set.rs b/vendor/anstyle-wincon/examples/set.rs
new file mode 100644
index 000000000..3b9f9093a
--- /dev/null
+++ b/vendor/anstyle-wincon/examples/set.rs
@@ -0,0 +1,57 @@
+#![cfg_attr(not(windows), allow(dead_code))]
+
+#[cfg(not(windows))]
+fn main() {
+ panic!("unsupported");
+}
+
+#[cfg(windows)]
+fn main() -> Result<(), lexopt::Error> {
+ let args = Args::parse()?;
+ let stdout = std::io::stdout();
+ let mut stdout = anstyle_wincon::Console::new(stdout.lock())
+ .map_err(|_err| lexopt::Error::from("could not open `stdout` for color control"))?;
+
+ let fg = args.fg.and_then(|c| c.into_ansi());
+ let bg = args.bg.and_then(|c| c.into_ansi());
+
+ let _ = stdout.write(fg, bg, "".as_bytes());
+
+ std::mem::forget(stdout);
+
+ Ok(())
+}
+
+#[derive(Default)]
+struct Args {
+ fg: Option<anstyle::Ansi256Color>,
+ bg: Option<anstyle::Ansi256Color>,
+}
+
+impl Args {
+ fn parse() -> Result<Self, lexopt::Error> {
+ use lexopt::prelude::*;
+
+ let mut res = Args::default();
+
+ let mut args = lexopt::Parser::from_env();
+ while let Some(arg) = args.next()? {
+ match arg {
+ Long("fg") => {
+ res.fg = Some(
+ args.value()?
+ .parse_with(|s| s.parse::<u8>().map(anstyle::Ansi256Color))?,
+ );
+ }
+ Long("bg") => {
+ res.fg = Some(
+ args.value()?
+ .parse_with(|s| s.parse::<u8>().map(anstyle::Ansi256Color))?,
+ );
+ }
+ _ => return Err(arg.unexpected()),
+ }
+ }
+ Ok(res)
+ }
+}
diff --git a/vendor/anstyle-wincon/src/console.rs b/vendor/anstyle-wincon/src/console.rs
new file mode 100644
index 000000000..6b89740cb
--- /dev/null
+++ b/vendor/anstyle-wincon/src/console.rs
@@ -0,0 +1,156 @@
+/// Write colored text to the screen
+#[derive(Debug)]
+pub struct Console<S>
+where
+ S: crate::WinconStream + std::io::Write,
+{
+ stream: Option<S>,
+ initial_fg: Option<anstyle::AnsiColor>,
+ initial_bg: Option<anstyle::AnsiColor>,
+ last_fg: Option<anstyle::AnsiColor>,
+ last_bg: Option<anstyle::AnsiColor>,
+}
+
+impl<S> Console<S>
+where
+ S: crate::WinconStream + std::io::Write,
+{
+ pub fn new(stream: S) -> Result<Self, S> {
+ // HACK: Assuming the error from `get_colors()` will be present on `write` and doing basic
+ // ops on the stream will cause the same result
+ let (initial_fg, initial_bg) = match stream.get_colors() {
+ Ok(ok) => ok,
+ Err(_) => {
+ return Err(stream);
+ }
+ };
+ Ok(Self {
+ stream: Some(stream),
+ initial_fg,
+ initial_bg,
+ last_fg: initial_fg,
+ last_bg: initial_bg,
+ })
+ }
+
+ /// Write colored text to the screen
+ pub fn write(
+ &mut self,
+ fg: Option<anstyle::AnsiColor>,
+ bg: Option<anstyle::AnsiColor>,
+ data: &[u8],
+ ) -> std::io::Result<usize> {
+ self.apply(fg, bg)?;
+ let written = self.as_stream_mut().write(data)?;
+ Ok(written)
+ }
+
+ pub fn flush(&mut self) -> std::io::Result<()> {
+ self.as_stream_mut().flush()
+ }
+
+ /// Change the terminal back to the initial colors
+ pub fn reset(&mut self) -> std::io::Result<()> {
+ self.apply(self.initial_fg, self.initial_bg)
+ }
+
+ /// Close the stream, reporting any errors
+ pub fn close(mut self) -> std::io::Result<()> {
+ self.reset()
+ }
+
+ /// Allow changing the stream
+ pub fn map<S1: crate::WinconStream + std::io::Write>(
+ mut self,
+ op: impl FnOnce(S) -> S1,
+ ) -> Console<S1> {
+ Console {
+ stream: Some(op(self.stream.take().unwrap())),
+ initial_fg: self.initial_fg,
+ initial_bg: self.initial_bg,
+ last_fg: self.last_fg,
+ last_bg: self.last_bg,
+ }
+ }
+
+ /// Get the inner writer
+ #[inline]
+ pub fn into_inner(mut self) -> S {
+ let _ = self.reset();
+ self.stream.take().unwrap()
+ }
+
+ fn apply(
+ &mut self,
+ fg: Option<anstyle::AnsiColor>,
+ bg: Option<anstyle::AnsiColor>,
+ ) -> std::io::Result<()> {
+ let fg = fg.or(self.initial_fg);
+ let bg = bg.or(self.initial_bg);
+ if fg == self.last_fg && bg == self.last_bg {
+ return Ok(());
+ }
+
+ // Ensure everything is written with the last set of colors before applying the next set
+ self.as_stream_mut().flush()?;
+
+ self.as_stream_mut().set_colors(fg, bg)?;
+ self.last_fg = fg;
+ self.last_bg = bg;
+
+ Ok(())
+ }
+
+ fn as_stream_mut(&mut self) -> &mut S {
+ self.stream.as_mut().unwrap()
+ }
+}
+
+impl<S> Console<S>
+where
+ S: crate::WinconStream + std::io::Write,
+ S: crate::Lockable,
+ <S as crate::Lockable>::Locked: crate::WinconStream + std::io::Write,
+{
+ /// Get exclusive access to the `Console`
+ ///
+ /// Why?
+ /// - Faster performance when writing in a loop
+ /// - Avoid other threads interleaving output with the current thread
+ #[inline]
+ pub fn lock(mut self) -> <Self as crate::Lockable>::Locked {
+ Console {
+ stream: Some(self.stream.take().unwrap().lock()),
+ initial_fg: self.initial_fg,
+ initial_bg: self.initial_bg,
+ last_fg: self.last_fg,
+ last_bg: self.last_bg,
+ }
+ }
+}
+
+impl<S> crate::Lockable for Console<S>
+where
+ S: crate::WinconStream + std::io::Write,
+ S: crate::Lockable,
+ <S as crate::Lockable>::Locked: crate::WinconStream + std::io::Write,
+{
+ type Locked = Console<<S as crate::Lockable>::Locked>;
+
+ #[inline]
+ fn lock(self) -> Self::Locked {
+ self.lock()
+ }
+}
+
+impl<S> Drop for Console<S>
+where
+ S: crate::WinconStream + std::io::Write,
+{
+ fn drop(&mut self) {
+ // Otherwise `Console::lock` took it
+ if self.stream.is_some() {
+ let _ = self.reset();
+ }
+ }
+}
diff --git a/vendor/anstyle-wincon/src/lib.rs b/vendor/anstyle-wincon/src/lib.rs
new file mode 100644
index 000000000..f61b6dc14
--- /dev/null
+++ b/vendor/anstyle-wincon/src/lib.rs
@@ -0,0 +1,21 @@
+//! Styling legacy Windows terminals
+//!
+//! See [`Console`]
+//!
+//! This fills a similar role as [`winapi-util`](https://crates.io/crates/winapi-util) does for
+//! [`termcolor`](https://crates.io/crates/termcolor) with the differences
+//! - Uses `windows-sys` rather than `winapi`
+//! - Uses [`anstyle`](https://crates.io/crates/termcolor) rather than defining its own types
+//! - More focused, smaller
+
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
+
+mod console;
+mod lockable;
+mod stream;
+#[cfg(windows)]
+mod windows;
+
+pub use console::Console;
+pub use lockable::Lockable;
+pub use stream::WinconStream;
diff --git a/vendor/anstyle-wincon/src/lockable.rs b/vendor/anstyle-wincon/src/lockable.rs
new file mode 100644
index 000000000..47f305e33
--- /dev/null
+++ b/vendor/anstyle-wincon/src/lockable.rs
@@ -0,0 +1,31 @@
+/// Explicitly lock a [`std::io::Write`]able
+pub trait Lockable {
+ type Locked;
+
+ /// Get exclusive access to the `Stream`
+ ///
+ /// Why?
+ /// - Faster performance when writing in a loop
+ /// - Avoid other threads interleaving output with the current thread
+ fn lock(self) -> Self::Locked;
+}
+
+impl Lockable for std::io::Stdout {
+ type Locked = std::io::StdoutLock<'static>;
+
+ #[inline]
+ fn lock(self) -> Self::Locked {
+ #[allow(clippy::needless_borrow)] // Its needed to avoid recursion
+ (&self).lock()
+ }
+}
+
+impl Lockable for std::io::Stderr {
+ type Locked = std::io::StderrLock<'static>;
+
+ #[inline]
+ fn lock(self) -> Self::Locked {
+ #[allow(clippy::needless_borrow)] // Its needed to avoid recursion
+ (&self).lock()
+ }
+}
diff --git a/vendor/anstyle-wincon/src/stream.rs b/vendor/anstyle-wincon/src/stream.rs
new file mode 100644
index 000000000..9638dd2e8
--- /dev/null
+++ b/vendor/anstyle-wincon/src/stream.rs
@@ -0,0 +1,139 @@
+/// Extend `std::io::Write` with wincon styling
+///
+/// Generally, you will want to use [`Console`][crate::Console] instead
+pub trait WinconStream {
+ /// Change the foreground/background
+ ///
+ /// A common pitfall is to forget to flush writes to
+ /// stdout before setting new text attributes.
+ fn set_colors(
+ &mut self,
+ fg: Option<anstyle::AnsiColor>,
+ bg: Option<anstyle::AnsiColor>,
+ ) -> std::io::Result<()>;
+
+ /// Get the current foreground/background colors
+ fn get_colors(
+ &self,
+ ) -> std::io::Result<(Option<anstyle::AnsiColor>, Option<anstyle::AnsiColor>)>;
+}
+
+impl WinconStream for std::io::Stdout {
+ fn set_colors(
+ &mut self,
+ fg: Option<anstyle::AnsiColor>,
+ bg: Option<anstyle::AnsiColor>,
+ ) -> std::io::Result<()> {
+ inner::set_colors(self, fg, bg)
+ }
+
+ fn get_colors(
+ &self,
+ ) -> std::io::Result<(Option<anstyle::AnsiColor>, Option<anstyle::AnsiColor>)> {
+ inner::get_colors(self)
+ }
+}
+
+impl<'s> WinconStream for std::io::StdoutLock<'s> {
+ fn set_colors(
+ &mut self,
+ fg: Option<anstyle::AnsiColor>,
+ bg: Option<anstyle::AnsiColor>,
+ ) -> std::io::Result<()> {
+ inner::set_colors(self, fg, bg)
+ }
+
+ fn get_colors(
+ &self,
+ ) -> std::io::Result<(Option<anstyle::AnsiColor>, Option<anstyle::AnsiColor>)> {
+ inner::get_colors(self)
+ }
+}
+
+impl WinconStream for std::io::Stderr {
+ fn set_colors(
+ &mut self,
+ fg: Option<anstyle::AnsiColor>,
+ bg: Option<anstyle::AnsiColor>,
+ ) -> std::io::Result<()> {
+ inner::set_colors(self, fg, bg)
+ }
+
+ fn get_colors(
+ &self,
+ ) -> std::io::Result<(Option<anstyle::AnsiColor>, Option<anstyle::AnsiColor>)> {
+ inner::get_colors(self)
+ }
+}
+
+impl<'s> WinconStream for std::io::StderrLock<'s> {
+ fn set_colors(
+ &mut self,
+ fg: Option<anstyle::AnsiColor>,
+ bg: Option<anstyle::AnsiColor>,
+ ) -> std::io::Result<()> {
+ inner::set_colors(self, fg, bg)
+ }
+
+ fn get_colors(
+ &self,
+ ) -> std::io::Result<(Option<anstyle::AnsiColor>, Option<anstyle::AnsiColor>)> {
+ inner::get_colors(self)
+ }
+}
+
+#[cfg(windows)]
+mod inner {
+ use std::os::windows::io::{AsHandle, AsRawHandle};
+
+ pub(super) fn set_colors<S: AsHandle>(
+ stream: &mut S,
+ fg: Option<anstyle::AnsiColor>,
+ bg: Option<anstyle::AnsiColor>,
+ ) -> std::io::Result<()> {
+ let handle = stream.as_handle();
+ let handle = handle.as_raw_handle();
+ if let (Some(fg), Some(bg)) = (fg, bg) {
+ let attributes = crate::windows::set_colors(fg, bg);
+ crate::windows::set_console_text_attributes(handle, attributes)
+ } else {
+ Ok(())
+ }
+ }
+
+ pub(super) fn get_colors<S: AsHandle>(
+ stream: &S,
+ ) -> std::io::Result<(Option<anstyle::AnsiColor>, Option<anstyle::AnsiColor>)> {
+ let handle = stream.as_handle();
+ let handle = handle.as_raw_handle();
+ let info = crate::windows::get_screen_buffer_info(handle)?;
+ let (fg, bg) = crate::windows::get_colors(&info);
+ Ok((Some(fg), Some(bg)))
+ }
+}
+
+#[cfg(not(windows))]
+mod inner {
+ pub(super) fn set_colors<S: std::io::Write>(
+ stream: &mut S,
+ fg: Option<anstyle::AnsiColor>,
+ bg: Option<anstyle::AnsiColor>,
+ ) -> std::io::Result<()> {
+ if let Some(fg) = fg {
+ write!(stream, "{}", fg.render_fg())?;
+ }
+ if let Some(bg) = bg {
+ write!(stream, "{}", bg.render_bg())?;
+ }
+ if fg.is_none() && bg.is_none() {
+ write!(stream, "{}", anstyle::Reset.render())?;
+ }
+ Ok(())
+ }
+
+ pub(super) fn get_colors<S>(
+ _stream: &S,
+ ) -> std::io::Result<(Option<anstyle::AnsiColor>, Option<anstyle::AnsiColor>)> {
+ Ok((None, None))
+ }
+}
diff --git a/vendor/anstyle-wincon/src/windows.rs b/vendor/anstyle-wincon/src/windows.rs
new file mode 100644
index 000000000..d2b9bc807
--- /dev/null
+++ b/vendor/anstyle-wincon/src/windows.rs
@@ -0,0 +1,147 @@
+use windows_sys::Win32::System::Console::CONSOLE_CHARACTER_ATTRIBUTES;
+use windows_sys::Win32::System::Console::CONSOLE_SCREEN_BUFFER_INFO;
+use windows_sys::Win32::System::Console::FOREGROUND_BLUE;
+use windows_sys::Win32::System::Console::FOREGROUND_GREEN;
+use windows_sys::Win32::System::Console::FOREGROUND_INTENSITY;
+use windows_sys::Win32::System::Console::FOREGROUND_RED;
+
+use std::os::windows::io::RawHandle;
+
+const FOREGROUND_CYAN: CONSOLE_CHARACTER_ATTRIBUTES = FOREGROUND_BLUE | FOREGROUND_GREEN;
+const FOREGROUND_MAGENTA: CONSOLE_CHARACTER_ATTRIBUTES = FOREGROUND_BLUE | FOREGROUND_RED;
+const FOREGROUND_YELLOW: CONSOLE_CHARACTER_ATTRIBUTES = FOREGROUND_GREEN | FOREGROUND_RED;
+const FOREGROUND_WHITE: CONSOLE_CHARACTER_ATTRIBUTES =
+ FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED;
+
+pub fn get_screen_buffer_info(handle: RawHandle) -> std::io::Result<CONSOLE_SCREEN_BUFFER_INFO> {
+ unsafe {
+ let handle = std::mem::transmute(handle);
+ if handle == 0 {
+ return Err(std::io::Error::new(
+ std::io::ErrorKind::BrokenPipe,
+ "console is detached",
+ ));
+ }
+
+ let mut info: CONSOLE_SCREEN_BUFFER_INFO = std::mem::zeroed();
+ if windows_sys::Win32::System::Console::GetConsoleScreenBufferInfo(handle, &mut info) != 0 {
+ Ok(info)
+ } else {
+ Err(std::io::Error::last_os_error())
+ }
+ }
+}
+
+pub fn set_console_text_attributes(
+ handle: RawHandle,
+ attributes: CONSOLE_CHARACTER_ATTRIBUTES,
+) -> std::io::Result<()> {
+ unsafe {
+ let handle = std::mem::transmute(handle);
+ if handle == 0 {
+ return Err(std::io::Error::new(
+ std::io::ErrorKind::BrokenPipe,
+ "console is detached",
+ ));
+ }
+
+ if windows_sys::Win32::System::Console::SetConsoleTextAttribute(handle, attributes) != 0 {
+ Ok(())
+ } else {
+ Err(std::io::Error::last_os_error())
+ }
+ }
+}
+
+pub fn get_colors(info: &CONSOLE_SCREEN_BUFFER_INFO) -> (anstyle::AnsiColor, anstyle::AnsiColor) {
+ let attributes = info.wAttributes;
+ let bg = from_nibble(attributes >> 4);
+ let fg = from_nibble(attributes);
+ (fg, bg)
+}
+
+pub fn set_colors(fg: anstyle::AnsiColor, bg: anstyle::AnsiColor) -> CONSOLE_CHARACTER_ATTRIBUTES {
+ to_nibble(bg) << 4 | to_nibble(fg)
+}
+
+fn from_nibble(color: CONSOLE_CHARACTER_ATTRIBUTES) -> anstyle::AnsiColor {
+ if color & FOREGROUND_WHITE == FOREGROUND_WHITE {
+ // 3 bits high
+ anstyle::AnsiColor::White
+ } else if color & FOREGROUND_CYAN == FOREGROUND_CYAN {
+ // 2 bits high
+ anstyle::AnsiColor::Cyan
+ } else if color & FOREGROUND_YELLOW == FOREGROUND_YELLOW {
+ // 2 bits high
+ anstyle::AnsiColor::Yellow
+ } else if color & FOREGROUND_MAGENTA == FOREGROUND_MAGENTA {
+ // 2 bits high
+ anstyle::AnsiColor::Magenta
+ } else if color & FOREGROUND_RED == FOREGROUND_RED {
+ // 1 bit high
+ anstyle::AnsiColor::Red
+ } else if color & FOREGROUND_GREEN == FOREGROUND_GREEN {
+ // 1 bit high
+ anstyle::AnsiColor::Green
+ } else if color & FOREGROUND_BLUE == FOREGROUND_BLUE {
+ // 1 bit high
+ anstyle::AnsiColor::Blue
+ } else {
+ // 0 bits high
+ anstyle::AnsiColor::Black
+ }
+ .bright(color & FOREGROUND_INTENSITY == FOREGROUND_INTENSITY)
+}
+
+fn to_nibble(color: anstyle::AnsiColor) -> CONSOLE_CHARACTER_ATTRIBUTES {
+ let mut attributes = 0;
+ attributes |= match color.bright(false) {
+ anstyle::AnsiColor::Black => 0,
+ anstyle::AnsiColor::Red => FOREGROUND_RED,
+ anstyle::AnsiColor::Green => FOREGROUND_GREEN,
+ anstyle::AnsiColor::Yellow => FOREGROUND_YELLOW,
+ anstyle::AnsiColor::Blue => FOREGROUND_BLUE,
+ anstyle::AnsiColor::Magenta => FOREGROUND_MAGENTA,
+ anstyle::AnsiColor::Cyan => FOREGROUND_CYAN,
+ anstyle::AnsiColor::White => FOREGROUND_WHITE,
+ anstyle::AnsiColor::BrightBlack
+ | anstyle::AnsiColor::BrightRed
+ | anstyle::AnsiColor::BrightGreen
+ | anstyle::AnsiColor::BrightYellow
+ | anstyle::AnsiColor::BrightBlue
+ | anstyle::AnsiColor::BrightMagenta
+ | anstyle::AnsiColor::BrightCyan
+ | anstyle::AnsiColor::BrightWhite => unreachable!("brights were toggled off"),
+ };
+ if color.is_bright() {
+ attributes |= FOREGROUND_INTENSITY;
+ }
+ attributes
+}
+
+#[test]
+fn to_from_nibble() {
+ const COLORS: [anstyle::AnsiColor; 16] = [
+ anstyle::AnsiColor::Black,
+ anstyle::AnsiColor::Red,
+ anstyle::AnsiColor::Green,
+ anstyle::AnsiColor::Yellow,
+ anstyle::AnsiColor::Blue,
+ anstyle::AnsiColor::Magenta,
+ anstyle::AnsiColor::Cyan,
+ anstyle::AnsiColor::White,
+ anstyle::AnsiColor::BrightBlack,
+ anstyle::AnsiColor::BrightRed,
+ anstyle::AnsiColor::BrightGreen,
+ anstyle::AnsiColor::BrightYellow,
+ anstyle::AnsiColor::BrightBlue,
+ anstyle::AnsiColor::BrightMagenta,
+ anstyle::AnsiColor::BrightCyan,
+ anstyle::AnsiColor::BrightWhite,
+ ];
+ for expected in COLORS {
+ let nibble = to_nibble(expected);
+ let actual = from_nibble(nibble);
+ assert_eq!(expected, actual, "Intermediate: {}", nibble);
+ }
+}