[][src]Enum ansi_term::Colour

pub enum Colour {
    Black,
    Red,
    Green,
    Yellow,
    Blue,
    Purple,
    Cyan,
    White,
    Fixed(u8),
    RGB(u8u8u8),
}
[]

A colour is one specific type of ANSI escape code, and can refer to either the foreground or background colour.

These use the standard numeric sequences. See http://invisible-island.net/xterm/ctlseqs/ctlseqs.html

Variants

[]

Colour #0 (foreground code 30, background code 40).

This is not necessarily the background colour, and using it as one may render the text hard to read on terminals with dark backgrounds.

[]

Colour #1 (foreground code 31, background code 41).

[]

Colour #2 (foreground code 32, background code 42).

[]

Colour #3 (foreground code 33, background code 43).

[]

Colour #4 (foreground code 34, background code 44).

[]

Colour #5 (foreground code 35, background code 45).

[]

Colour #6 (foreground code 36, background code 46).

[]

Colour #7 (foreground code 37, background code 47).

As above, this is not necessarily the foreground colour, and may be hard to read on terminals with light backgrounds.

[]

A colour number from 0 to 255, for use in 256-colour terminal environments.

It might make more sense to look at a colour chart.

[]

A 24-bit RGB color, as specified by ISO-8613-3.

Methods

impl Colour
[src]
[]

[]

The prefix for this colour.

[]

The infix between this colour and another.

[]

The suffix for this colour.

impl Colour
[src]
[]

[]

Return a Style with the foreground colour set to this colour.

[]

Returns a Style with the bold property set.

[]

Returns a Style with the dimmed property set.

[]

Returns a Style with the italic property set.

[]

Returns a Style with the underline property set.

Returns a Style with the blink property set.

[]

Returns a Style with the reverse property set.

[]

Returns a Style with the hidden property set.

[]

Returns a Style with the strikethrough property set.

[]

Returns a Style with the background colour property set.

impl Colour
[src]
[]

[]

Paints the given text with this colour, returning an ANSI string. This is a short-cut so you don’t have to use Blue.normal() just to get blue text.

use ansi_term::Colour::Blue;
println!("{}", Blue.paint("da ba dee"));

Trait Implementations

impl Clone for Colour
[src]
[+]

[]

Returns a copy of the value. Read more

[]

Performs copy-assignment from source. Read more

impl Copy for Colour
[src]

impl From<Colour> for Style
[src]
[+]

[]

You can turn a Colour into a Style with the foreground colour set with the From trait.

use ansi_term::{Style, Colour};
let green_foreground = Style::default().fg(Colour::Green);
assert_eq!(green_foreground, Colour::Green.normal());
assert_eq!(green_foreground, Colour::Green.into());
assert_eq!(green_foreground, Style::from(Colour::Green));

impl PartialEq<Colour> for Colour
[src]
[+]

[]

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

[]

This method tests for !=.

impl Debug for Colour
[src]
[+]

[]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for Colour

impl Sync for Colour

Blanket Implementations

impl<T> From for T
[src]
[]

[]

Performs the conversion.

impl<T, U> Into for T where
    U: From<T>, 
[src]
[]

[]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]
[]

[]

Creates owned data from borrowed data, usually by cloning. Read more

[]

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

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]
[]

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

The type returned in the event of a conversion error.

[]

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

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]
[]

[]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut for T where
    T: ?Sized
[src]
[]

[]

Mutably borrows from an owned value. Read more

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]
[]

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

The type returned in the event of a conversion error.

[]

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

Performs the conversion.

impl<T> Any for T where
    T: 'static + ?Sized
[src]
[]

[]

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

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more