35 lines
876 B
Rust

fn main() {
const COLORS: &[(usize, &str)] = &[
(1, "Red"),
(2, "Green"),
(3, "Yellow"),
(4, "Blue"),
(5, "Magenta"),
(6, "Cyan"),
(7, "White"),
];
println!(
"{:<8} \x1B[1m{:<8}\x1B[22m \x1B[3m{:<8} \x1B[1m{:<8}\x1B[0m",
"Normal", "Bold", "Italic", "Bold/it"
);
for &(color, text) in COLORS {
print!("\x1B[3{color}m");
// Normal
print!("{text:<8} ");
// Bold
print!("\x1B[1m");
print!("{text:<8} ");
print!("\x1B[22m");
// Italic
print!("\x1B[3m");
print!("{text:<8} ");
// Bold/italic
print!("\x1B[1m");
print!("{text:<8}");
println!("\x1B[0m");
}
println!("\x1B[4m\x1B[1mUnderlined\x1B[0m, \x1B[9m\x1B[3mStrikethrough\x1B[0m? \x1B[4m\x1B[9mBOTH!!!\x1B[0m");
}