diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
commit | 4f9fe856a25ab29345b90e7725509e9ee38a37be (patch) | |
tree | e4ffd8a9374cae7b21f7cbfb352927e0e074aff6 /vendor/nu-ansi-term/examples/256_colors.rs | |
parent | Adding upstream version 1.68.2+dfsg1. (diff) | |
download | rustc-5cd5bd4daf55da04d2c8e7c06c3067a027cfbfc2.tar.xz rustc-5cd5bd4daf55da04d2c8e7c06c3067a027cfbfc2.zip |
Adding upstream version 1.69.0+dfsg1.upstream/1.69.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | vendor/nu-ansi-term/examples/256_colors.rs (renamed from vendor/ansi_term/examples/256_colours.rs) | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/vendor/ansi_term/examples/256_colours.rs b/vendor/nu-ansi-term/examples/256_colors.rs index 92fe2f1c1..4766dcdb6 100644 --- a/vendor/ansi_term/examples/256_colours.rs +++ b/vendor/nu-ansi-term/examples/256_colors.rs @@ -1,27 +1,26 @@ -extern crate ansi_term; -use ansi_term::Colour; +extern crate nu_ansi_term; +use nu_ansi_term::Color; -// This example prints out the 256 colours. +// This example prints out the 256 colors. // They're arranged like this: // -// - 0 to 8 are the eight standard colours. -// - 9 to 15 are the eight bold colours. -// - 16 to 231 are six blocks of six-by-six colour squares. +// - 0 to 8 are the eight standard colors. +// - 9 to 15 are the eight bold colors. +// - 16 to 231 are six blocks of six-by-six color squares. // - 232 to 255 are shades of grey. fn main() { - // First two lines for c in 0..8 { glow(c, c != 0); print!(" "); } - print!("\n"); + println!(); for c in 8..16 { glow(c, c != 8); print!(" "); } - print!("\n\n"); + println!("\n"); // Six lines of the first three squares for row in 0..6 { @@ -34,9 +33,9 @@ fn main() { print!(" "); } - print!("\n"); + println!(); } - print!("\n"); + println!(); // Six more lines of the other three squares for row in 0..6 { @@ -49,25 +48,25 @@ fn main() { print!(" "); } - print!("\n"); + println!(); } - print!("\n"); + println!(); // The last greyscale lines for c in 232..=243 { glow(c, false); print!(" "); } - print!("\n"); + println!(); for c in 244..=255 { glow(c, true); print!(" "); } - print!("\n"); + println!(); } fn glow(c: u8, light_bg: bool) { - let base = if light_bg { Colour::Black } else { Colour::White }; - let style = base.on(Colour::Fixed(c)); + let base = if light_bg { Color::Black } else { Color::White }; + let style = base.on(Color::Fixed(c)); print!("{}", style.paint(&format!(" {:3} ", c))); } |