[−][src]Enum ansi_term::Color
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
BlackColour #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.
RedColour #1 (foreground code 31, background code 41).
GreenColour #2 (foreground code 32, background code 42).
YellowColour #3 (foreground code 33, background code 43).
BlueColour #4 (foreground code 34, background code 44).
PurpleColour #5 (foreground code 35, background code 45).
CyanColour #6 (foreground code 36, background code 46).
WhiteColour #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.
Fixed(u8)A colour number from 0 to 255, for use in 256-colour terminal environments.
- Colours 0 to 7 are the
BlacktoWhitevariants respectively. These colours can usually be changed in the terminal emulator. - Colours 8 to 15 are brighter versions of the eight colours above. These can also usually be changed in the terminal emulator, or it could be configured to use the original colours and show the text in bold instead. It varies depending on the program.
- Colours 16 to 231 contain several palettes of bright colours, arranged in six squares measuring six by six each.
- Colours 232 to 255 are shades of grey from black to white.
It might make more sense to look at a colour chart.
RGB(u8, u8, u8)A 24-bit RGB color, as specified by ISO-8613-3.
Methods
impl Colour[src]
impl Colourpub fn prefix(self) -> Prefix[src]
pub fn prefix(self) -> PrefixThe prefix for this colour.
pub fn infix(self, other: Colour) -> Infix[src]
pub fn infix(self, other: Colour) -> InfixThe infix between this colour and another.
pub fn suffix(self) -> Suffix[src]
pub fn suffix(self) -> SuffixThe suffix for this colour.
impl Colour[src]
impl Colourpub fn normal(self) -> Style[src]
pub fn normal(self) -> StyleReturn a Style with the foreground colour set to this colour.
pub fn bold(self) -> Style[src]
pub fn bold(self) -> StyleReturns a Style with the bold property set.
pub fn dimmed(self) -> Style[src]
pub fn dimmed(self) -> StyleReturns a Style with the dimmed property set.
pub fn italic(self) -> Style[src]
pub fn italic(self) -> StyleReturns a Style with the italic property set.
pub fn underline(self) -> Style[src]
pub fn underline(self) -> StyleReturns a Style with the underline property set.
pub fn blink(self) -> Style[src]
pub fn blink(self) -> StyleReturns a Style with the blink property set.
pub fn reverse(self) -> Style[src]
pub fn reverse(self) -> StyleReturns a Style with the reverse property set.
Returns a Style with the hidden property set.
pub fn strikethrough(self) -> Style[src]
pub fn strikethrough(self) -> StyleReturns a Style with the strikethrough property set.
pub fn on(self, background: Colour) -> Style[src]
pub fn on(self, background: Colour) -> StyleReturns a Style with the background colour property set.
impl Colour[src]
impl Colourpub fn paint<'a, I, S: 'a + ToOwned + ?Sized>(
self,
input: I
) -> ANSIGenericString<'a, S> where
I: Into<Cow<'a, S>>,
<S as ToOwned>::Owned: Debug, [src]
pub fn paint<'a, I, S: 'a + ToOwned + ?Sized>(
self,
input: I
) -> ANSIGenericString<'a, S> where
I: Into<Cow<'a, S>>,
<S as ToOwned>::Owned: Debug, 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]
impl Clone for Colourfn clone(&self) -> Colour[src]
fn clone(&self) -> ColourReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Copy for Colour[src]
impl Copy for Colourimpl From<Colour> for Style[src]
impl From<Colour> for Stylefn from(colour: Colour) -> Style[src]
fn from(colour: Colour) -> StyleYou 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]
impl PartialEq<Colour> for Colourfn eq(&self, other: &Colour) -> bool[src]
fn eq(&self, other: &Colour) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Colour) -> bool[src]
fn ne(&self, other: &Colour) -> boolThis method tests for !=.
impl Debug for Colour[src]
impl Debug for ColourAuto Trait Implementations
Blanket Implementations
impl<T> From for T[src]
impl<T> From for Timpl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, type Owned = T
fn to_owned(&self) -> T[src]
fn to_owned(&self) -> TCreates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)[src]
fn clone_into(&self, target: &mut T)🔬 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]
impl<T, U> TryFrom for T where
T: From<U>, type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>try_from)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, fn borrow_mut(&mut self) -> &mut T[src]
fn borrow_mut(&mut self) -> &mut TMutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>try_from)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeId🔬 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