Enum nu_ansi_term::Color [−][src]
pub enum Color { }
Expand description
A color is one specific type of ANSI escape code, and can refer to either the foreground or background color.
These use the standard numeric sequences. See http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
Variants
Color #0 (foreground code 30
, background code 40
).
This is not necessarily the background color, and using it as one may render the text hard to read on terminals with dark backgrounds.
Color #0 (foreground code 90
, background code 100
).
Color #1 (foreground code 31
, background code 41
).
Color #1 (foreground code 91
, background code 101
).
Color #2 (foreground code 32
, background code 42
).
Color #2 (foreground code 92
, background code 102
).
Color #3 (foreground code 33
, background code 43
).
Color #3 (foreground code 93
, background code 103
).
Color #4 (foreground code 34
, background code 44
).
Color #4 (foreground code 94
, background code 104
).
Color #5 (foreground code 35
, background code 45
).
Color #5 (foreground code 95
, background code 105
).
Color #5 (foreground code 35
, background code 45
).
Color #5 (foreground code 95
, background code 105
).
Color #6 (foreground code 36
, background code 46
).
Color #6 (foreground code 96
, background code 106
).
Color #7 (foreground code 37
, background code 47
).
As above, this is not necessarily the foreground color, and may be hard to read on terminals with light backgrounds.
Color #7 (foreground code 97
, background code 107
).
Fixed(u8)
A color number from 0 to 255, for use in 256-color terminal environments.
- colors 0 to 7 are the
Black
toWhite
variants respectively. These colors can usually be changed in the terminal emulator. - colors 8 to 15 are brighter versions of the eight colors above. These can also usually be changed in the terminal emulator, or it could be configured to use the original colors and show the text in bold instead. It varies depending on the program.
- colors 16 to 231 contain several palettes of bright colors, arranged in six squares measuring six by six each.
- colors 232 to 255 are shades of grey from black to white.
It might make more sense to look at a color chart.
A 24-bit RGB color, as specified by ISO-8613-3.
Implementations
impl Color
[src]
impl Color
[src]pub fn prefix(self) -> Prefix
[src]
pub fn prefix(self) -> Prefix
[src]The prefix bytes for this color as a Style
. These are the bytes
that tell the terminal to use a different color or font style.
See also Style::prefix
.
Examples
use nu_ansi_term::Color::Green; assert_eq!("\x1b[0m", Green.suffix().to_string());
pub fn infix(self, next: Color) -> Infix
[src]
pub fn infix(self, next: Color) -> Infix
[src]The infix bytes between this color and next
color. These are the bytes
that tell the terminal to use the next
color, or to do nothing if
the two colors are equal.
See also Style::infix
.
Examples
use nu_ansi_term::Color::{Red, Yellow}; assert_eq!("\x1b[33m", Red.infix(Yellow).to_string());
pub fn suffix(self) -> Suffix
[src]
pub fn suffix(self) -> Suffix
[src]The suffix for this color as a Style
. These are the bytes that
tell the terminal to reset back to its normal color and font style.
See also Style::suffix
.
Examples
use nu_ansi_term::Color::Purple; assert_eq!("\x1b[0m", Purple.suffix().to_string());
impl Color
[src]
impl Color
[src]pub fn normal(self) -> Style
[src]
pub fn normal(self) -> Style
[src]Returns a Style
with the foreground color set to this color.
Examples
use nu_ansi_term::Color; let style = Color::Red.normal(); println!("{}", style.paint("hi"));
pub fn bold(self) -> Style
[src]
pub fn bold(self) -> Style
[src]Returns a Style
with the foreground color set to this color and the
bold property set.
Examples
use nu_ansi_term::Color; let style = Color::Green.bold(); println!("{}", style.paint("hey"));
pub fn dimmed(self) -> Style
[src]
pub fn dimmed(self) -> Style
[src]Returns a Style
with the foreground color set to this color and the
dimmed property set.
Examples
use nu_ansi_term::Color; let style = Color::Yellow.dimmed(); println!("{}", style.paint("sup"));
pub fn italic(self) -> Style
[src]
pub fn italic(self) -> Style
[src]Returns a Style
with the foreground color set to this color and the
italic property set.
Examples
use nu_ansi_term::Color; let style = Color::Blue.italic(); println!("{}", style.paint("greetings"));
pub fn underline(self) -> Style
[src]
pub fn underline(self) -> Style
[src]Returns a Style
with the foreground color set to this color and the
underline property set.
Examples
use nu_ansi_term::Color; let style = Color::Purple.underline(); println!("{}", style.paint("salutations"));
pub fn blink(self) -> Style
[src]
pub fn blink(self) -> Style
[src]Returns a Style
with the foreground color set to this color and the
blink property set.
Examples
use nu_ansi_term::Color; let style = Color::Cyan.blink(); println!("{}", style.paint("wazzup"));
pub fn reverse(self) -> Style
[src]
pub fn reverse(self) -> Style
[src]Returns a Style
with the foreground color set to this color and the
reverse property set.
Examples
use nu_ansi_term::Color; let style = Color::Black.reverse(); println!("{}", style.paint("aloha"));
pub fn hidden(self) -> Style
[src]
pub fn hidden(self) -> Style
[src]Returns a Style
with the foreground color set to this color and the
hidden property set.
Examples
use nu_ansi_term::Color; let style = Color::White.hidden(); println!("{}", style.paint("ahoy"));
pub fn strikethrough(self) -> Style
[src]
pub fn strikethrough(self) -> Style
[src]Returns a Style
with the foreground color set to this color and the
strikethrough property set.
Examples
use nu_ansi_term::Color; let style = Color::Fixed(244).strikethrough(); println!("{}", style.paint("yo"));
impl Color
[src]
impl Color
[src]#[must_use]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,
[src]
#[must_use]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,
[src]Paints the given text with this color, returning an ANSI string.
This is a short-cut so you don’t have to use Blue.normal()
just
to get blue text.
use nu_ansi_term::Color::Blue; println!("{}", Blue.paint("da ba dee"));
Trait Implementations
impl From<Color> for Style
[src]
impl From<Color> for Style
[src]fn from(color: Color) -> Style
[src]
fn from(color: Color) -> Style
[src]You can turn a Color
into a Style
with the foreground color set
with the From
trait.
use nu_ansi_term::{Style, Color}; let green_foreground = Style::default().fg(Color::Green); assert_eq!(green_foreground, Color::Green.normal()); assert_eq!(green_foreground, Color::Green.into()); assert_eq!(green_foreground, Style::from(Color::Green));
impl Copy for Color
[src]
impl StructuralPartialEq for Color
[src]
Auto Trait Implementations
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnwindSafe for Color
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more