Skip to content

Commit 555d4e1

Browse files
authoredMar 6, 2023
Enable ansi support for examples under windows (#20)
* Enable ansi support for examples under windows * Run the `256_colors` example in the build jobs
1 parent 2a7ffde commit 555d4e1

File tree

5 files changed

+13
-0
lines changed

5 files changed

+13
-0
lines changed
 

‎.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ jobs:
2323
- run: cargo test
2424
- run: cargo fmt --check --all
2525
- run: cargo clippy -- -D warnings
26+
- run: cargo run --example 256_colors

‎examples/256_colors.rs

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ use nu_ansi_term::Color;
1010
// - 232 to 255 are shades of grey.
1111

1212
fn main() {
13+
#[cfg(windows)]
14+
nu_ansi_term::enable_ansi_support().unwrap();
15+
1316
// First two lines
1417
for c in 0..8 {
1518
glow(c, c != 0);

‎examples/basic_colors.rs

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ use nu_ansi_term::{Color::*, Style};
44
// This example prints out the 16 basic colors.
55

66
fn main() {
7+
#[cfg(windows)]
8+
nu_ansi_term::enable_ansi_support().unwrap();
9+
710
let normal = Style::default();
811

912
println!("{} {}", normal.paint("Normal"), normal.bold().paint("bold"));

‎examples/gradient_colors.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use nu_ansi_term::{build_all_gradient_text, Color, Gradient, Rgb, TargetGround};
22

33
fn main() {
4+
#[cfg(windows)]
5+
nu_ansi_term::enable_ansi_support().unwrap();
6+
47
let text = "lorem ipsum quia dolor sit amet, consectetur, adipisci velit";
58

69
// a gradient from hex colors

‎examples/rgb_colors.rs

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const WIDTH: i32 = 80;
99
const HEIGHT: i32 = 24;
1010

1111
fn main() {
12+
#[cfg(windows)]
13+
nu_ansi_term::enable_ansi_support().unwrap();
14+
1215
for row in 0..HEIGHT {
1316
for col in 0..WIDTH {
1417
let r = (row * 255 / HEIGHT) as u8;

0 commit comments

Comments
 (0)
Please sign in to comment.