Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
use nu_ansi_term::Color;
// This example prints out the 256 colors.
// They're arranged like this:
//
// - 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() {
#[cfg(windows)]
nu_ansi_term::enable_ansi_support().unwrap();
// First two lines
for c in 0..8 {
glow(c, c != 0);
print!(" ");
}
println!();
for c in 8..16 {
glow(c, c != 8);
print!(" ");
}
println!("\n");
// Six lines of the first three squares
for row in 0..6 {
for square in 0..3 {
for column in 0..6 {
glow(16 + square * 36 + row * 6 + column, row >= 3);
print!(" ");
}
print!(" ");
}
println!();
}
println!();
// Six more lines of the other three squares
for row in 0..6 {
for square in 0..3 {
for column in 0..6 {
glow(124 + square * 36 + row * 6 + column, row >= 3);
print!(" ");
}
print!(" ");
}
println!();
}
println!();
// The last greyscale lines
for c in 232..=243 {
glow(c, false);
print!(" ");
}
println!();
for c in 244..=255 {
glow(c, true);
print!(" ");
}
println!();
}
fn glow(c: u8, light_bg: bool) {
let base = if light_bg { Color::Black } else { Color::White };
let style = base.on(Color::Fixed(c));
print!("{}", style.paint(&format!(" {:3} ", c)));
}

View File

@@ -0,0 +1,34 @@
use nu_ansi_term::{Color::*, Style};
// This example prints out the 16 basic colors.
fn main() {
#[cfg(windows)]
nu_ansi_term::enable_ansi_support().unwrap();
let normal = Style::default();
println!("{} {}", normal.paint("Normal"), normal.bold().paint("bold"));
println!("{} {}", Black.paint("Black"), Black.bold().paint("bold"));
println!("{} {}", Red.paint("Red"), Red.bold().paint("bold"));
println!("{} {}", Green.paint("Green"), Green.bold().paint("bold"));
println!("{} {}", Yellow.paint("Yellow"), Yellow.bold().paint("bold"));
println!("{} {}", Blue.paint("Blue"), Blue.bold().paint("bold"));
println!("{} {}", Purple.paint("Purple"), Purple.bold().paint("bold"));
println!("{} {}", Cyan.paint("Cyan"), Cyan.bold().paint("bold"));
println!("{} {}", White.paint("White"), White.bold().paint("bold"));
println!("\nreset_before_style at work:");
println!(
"\x1b[33mReset {} \x1b[33mand {}\x1b[0m",
Style::new().reset_before_style().bold().paint("bold"),
Style::new()
.reset_before_style()
.underline()
.paint("underline")
);
println!(
"\x1b[33mDo not reset {} \x1b[33mand {}\x1b[0m",
Style::new().bold().paint("bold"),
Style::new().underline().paint("underline")
);
}

View File

@@ -0,0 +1,40 @@
use nu_ansi_term::{build_all_gradient_text, Color, Gradient, Rgb, TargetGround};
fn main() {
#[cfg(windows)]
nu_ansi_term::enable_ansi_support().unwrap();
let text = "lorem ipsum quia dolor sit amet, consectetur, adipisci velit";
// a gradient from hex colors
let start = Rgb::from_hex(0x40c9ff);
let end = Rgb::from_hex(0xe81cff);
let grad0 = Gradient::new(start, end);
// a gradient from color::rgb()
let start = Color::Rgb(64, 201, 255);
let end = Color::Rgb(232, 28, 255);
let gradient = Gradient::from_color_rgb(start, end);
// a slightly different gradient
let start2 = Color::Rgb(128, 64, 255);
let end2 = Color::Rgb(0, 28, 255);
let gradient2 = Gradient::from_color_rgb(start2, end2);
// reverse the gradient
let gradient3 = gradient.reverse();
let build_fg = gradient.build(text, TargetGround::Foreground);
println!("{}", build_fg);
let build_bg = gradient.build(text, TargetGround::Background);
println!("{}", build_bg);
let bgt = build_all_gradient_text(text, gradient, gradient2);
println!("{}", bgt);
let bgt2 = build_all_gradient_text(text, gradient, gradient3);
println!("{}", bgt2);
println!(
"{}",
grad0.build("nushell is awesome", TargetGround::Foreground)
);
}

View File

@@ -0,0 +1,17 @@
use nu_ansi_term::Color;
mod may_sleep;
use may_sleep::{parse_cmd_args, sleep};
fn main() {
#[cfg(windows)]
nu_ansi_term::enable_ansi_support().unwrap();
let sleep_ms = parse_cmd_args();
let link = Color::Blue
.underline()
.paint("Link to example.com")
.hyperlink("https://example.com");
println!("{}", link);
sleep(sleep_ms);
}

View File

@@ -0,0 +1,35 @@
pub fn parse_cmd_args() -> Option<u16> {
let mut sleep_ms: Option<u16> = None;
let mut skip_next = false;
for (i, arg) in std::env::args().skip(1).enumerate() {
if skip_next {
skip_next = false;
continue;
}
match &arg[..] {
"-s" | "--sleep" => {
sleep_ms = std::env::args()
.nth(i + 2) // next is +2 because .skip(1)
.unwrap_or(String::from("5000u16"))
.parse::<u16>()
.ok()
.and_then(|parsed| {
skip_next = true;
Some(parsed)
});
}
_ => {}
}
}
sleep_ms
}
pub fn sleep(sleep_ms: Option<u16>) {
if let Some(sleep_ms) = sleep_ms {
let sleep_ms = std::time::Duration::from_millis(sleep_ms as u64);
std::thread::sleep(sleep_ms);
}
}

View File

@@ -0,0 +1,25 @@
use nu_ansi_term::{Color, Style};
// This example prints out a color gradient in a grid by calculating each
// characters red, green, and blue components, and using 24-bit color codes
// to display them.
const WIDTH: i32 = 80;
const HEIGHT: i32 = 24;
fn main() {
#[cfg(windows)]
nu_ansi_term::enable_ansi_support().unwrap();
for row in 0..HEIGHT {
for col in 0..WIDTH {
let r = (row * 255 / HEIGHT) as u8;
let g = (col * 255 / WIDTH) as u8;
let b = 128;
print!("{}", Style::default().on(Color::Rgb(r, g, b)).paint(" "));
}
println!();
}
}

19
vendor/nu-ansi-term/examples/title.rs vendored Normal file
View File

@@ -0,0 +1,19 @@
use nu_ansi_term::AnsiGenericString;
mod may_sleep;
use may_sleep::{parse_cmd_args, sleep};
fn main() {
#[cfg(windows)]
nu_ansi_term::enable_ansi_support().unwrap();
let sleep_ms = parse_cmd_args();
let title = AnsiGenericString::title("My Title");
println!(
"{}Terminal title set for the next {:?} milliseconds",
title, sleep_ms
);
// sleep because often prompts change this before you can see
// the results
sleep(sleep_ms);
}