Struct yansi::Paint [] [src]

pub struct Paint<T> { /* fields omitted */ }

A structure encapsulating all of the styling for a given item.

See the crate level documentation for usage information.

Methods

impl<T> Paint<T>
[src]

Constructs a new Paint structure that encapsulates item. No styling is applied.

use yansi::Paint;

assert_eq!(Paint::new("hello!").to_string(), "hello!".to_string());

Constructs a new Paint structure that encapsulates item and masks it. No styling is applied. A masked item is not written out when painting is disabled during Display or Debug invocations. When painting is enabled, masking has no effect.

use yansi::Paint;

println!("{}Sprout!", Paint::masked("🌱 "));

Constructs a new Paint structure that encapsulates item with the foreground color set to the name of this method.

use yansi::Paint;

println!("This is going to be blue: {}", Paint::blue("yay!"));

Constructs a new Paint structure that encapsulates item with the foreground color set to the name of this method.

use yansi::Paint;

println!("This is going to be blue: {}", Paint::blue("yay!"));

Constructs a new Paint structure that encapsulates item with the foreground color set to the name of this method.

use yansi::Paint;

println!("This is going to be blue: {}", Paint::blue("yay!"));

Constructs a new Paint structure that encapsulates item with the foreground color set to the name of this method.

use yansi::Paint;

println!("This is going to be blue: {}", Paint::blue("yay!"));

Constructs a new Paint structure that encapsulates item with the foreground color set to the name of this method.

use yansi::Paint;

println!("This is going to be blue: {}", Paint::blue("yay!"));

Constructs a new Paint structure that encapsulates item with the foreground color set to the name of this method.

use yansi::Paint;

println!("This is going to be blue: {}", Paint::blue("yay!"));

Constructs a new Paint structure that encapsulates item with the foreground color set to the name of this method.

use yansi::Paint;

println!("This is going to be blue: {}", Paint::blue("yay!"));

Constructs a new Paint structure that encapsulates item with the foreground color set to the name of this method.

use yansi::Paint;

println!("This is going to be blue: {}", Paint::blue("yay!"));

Constructs a new Paint structure that encapsulates item with the foreground color set RGB color corresponding to r, g, b.

use yansi::Paint;

println!("This is going to be funky: {}", Paint::rgb(70, 130, 122, "hi!"));

Constructs a new Paint structure that encapsulates item with the foreground color set to the fixed color corresponding to color.

use yansi::Paint;

println!("This is going to be funky: {}", Paint::fixed(100, "hi!"));

Sets the foreground to color.

use yansi::Paint;
use yansi::Color::Red;

println!("Red foreground: {}", Paint::new("hi!").fg(Red));

Sets the background to color.

use yansi::Paint;
use yansi::Color::Yellow;

println!("Yellow background: {}", Paint::new("hi!").bg(Yellow));

Masks self. A masked item is not written out when painting is disabled during Display or Debug invocations. When painting is enabled, masking has no effect.

use yansi::Paint;

println!("{}Something happened.", Paint::red("Whoops! ").mask());

Enables the styling corresponding to the name of this method.

use yansi::Paint;

println!("Red, underlined: {}", Paint::red("beep.").underline());

Enables the styling corresponding to the name of this method.

use yansi::Paint;

println!("Red, underlined: {}", Paint::red("beep.").underline());

Enables the styling corresponding to the name of this method.

use yansi::Paint;

println!("Red, underlined: {}", Paint::red("beep.").underline());

Enables the styling corresponding to the name of this method.

use yansi::Paint;

println!("Red, underlined: {}", Paint::red("beep.").underline());

Enables the styling corresponding to the name of this method.

use yansi::Paint;

println!("Red, underlined: {}", Paint::red("beep.").underline());

Enables the styling corresponding to the name of this method.

use yansi::Paint;

println!("Red, underlined: {}", Paint::red("beep.").underline());

Enables the styling corresponding to the name of this method.

use yansi::Paint;

println!("Red, underlined: {}", Paint::red("beep.").underline());

Enables the styling corresponding to the name of this method.

use yansi::Paint;

println!("Red, underlined: {}", Paint::red("beep.").underline());

impl Paint<()>
[src]

Disables coloring globally.

This method is only available when the "nightly" feature is enabled.

Example

use yansi::Paint;

// With coloring enabled, ANSI color codes are emitted.
assert_ne!(Paint::green("go").to_string(), "go".to_string());

// With coloring disabled, ANSI color codes are _not_ emitted.
Paint::disable();
assert_eq!(Paint::green("go").to_string(), "go".to_string());

Enables coloring globally. Coloring is enabled by default, so this method should only be called to re enable coloring.

This method is only available when the "nightly" feature is enabled.

Example

use yansi::Paint;

// With coloring disabled, ANSI color codes are _not_ emitted.
Paint::disable();
assert_eq!(Paint::green("go").to_string(), "go".to_string());

// Reenabling causes color code to be emitted.
Paint::enable();
assert_ne!(Paint::green("go").to_string(), "go".to_string());

Enables ASCII terminal escape sequences on Windows consoles when possible. Returns true if escape sequence support was successfully enabled and false otherwise. On non-Windows targets, this method always returns true.

Support for escape sequences in Windows consoles was added in the Windows 10 anniversary update. For targets with older Windows installations, this method is expected to return false.

Example

use yansi::Paint;

// A best-effort Windows ASCII terminal support enabling.
Paint::enable_windows_ascii();

Trait Implementations

impl<T: Default> Default for Paint<T>
[src]

Returns the "default value" for a type. Read more

impl<T: Eq> Eq for Paint<T>
[src]

impl<T: PartialEq> PartialEq for Paint<T>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<T: Ord> Ord for Paint<T>
[src]

This method returns an Ordering between self and other. Read more

🔬 This is a nightly-only experimental API. (ord_max_min)

Compares and returns the maximum of two values. Read more

🔬 This is a nightly-only experimental API. (ord_max_min)

Compares and returns the minimum of two values. Read more

impl<T: PartialOrd> PartialOrd for Paint<T>
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<T: Hash> Hash for Paint<T>
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl<T: Copy> Copy for Paint<T>
[src]

impl<T: Clone> Clone for Paint<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: Display> Display for Paint<T>
[src]

Formats the value using the given formatter. Read more

impl<T: Debug> Debug for Paint<T>
[src]

Formats the value using the given formatter.