Struct pretty_assertions::Style
[−]
[src]
pub struct Style { pub foreground: Option<Colour>, pub background: Option<Colour>, pub is_bold: bool, pub is_dimmed: bool, pub is_italic: bool, pub is_underline: bool, pub is_blink: bool, pub is_reverse: bool, pub is_hidden: bool, pub is_strikethrough: bool, }
A style is a collection of properties that can format a string using ANSI escape codes.
Fields
foreground: Option<Colour>
The style's foreground colour, if it has one.
background: Option<Colour>
The style's background colour, if it has one.
is_bold: bool
Whether this style is bold.
is_dimmed: bool
Whether this style is dimmed.
is_italic: bool
Whether this style is italic.
is_underline: bool
Whether this style is underlined.
is_blink: bool
Whether this style is blinking.
is_reverse: bool
Whether this style has reverse colours.
Whether this style is hidden.
is_strikethrough: bool
Whether this style is struckthrough.
Methods
impl Style
[src]
fn prefix(self) -> Prefix
[src]
The prefix for this style.
fn infix(self, other: Style) -> Infix
[src]
The infix between this style and another.
fn suffix(self) -> Suffix
[src]
The suffix for this style.
impl Style
[src]
fn new() -> Style
[src]
Creates a new Style with no differences.
fn bold(&self) -> Style
[src]
Returns a Style
with the bold property set.
fn dimmed(&self) -> Style
[src]
Returns a Style
with the dimmed property set.
fn italic(&self) -> Style
[src]
Returns a Style
with the italic property set.
fn underline(&self) -> Style
[src]
Returns a Style
with the underline property set.
fn blink(&self) -> Style
[src]
Returns a Style
with the blink property set.
fn reverse(&self) -> Style
[src]
Returns a Style
with the reverse property set.
[src]
Returns a Style
with the hidden property set.
fn strikethrough(&self) -> Style
[src]
Returns a Style
with the hidden property set.
fn fg(&self, foreground: Colour) -> Style
[src]
Returns a Style
with the foreground colour property set.
fn on(&self, background: Colour) -> Style
[src]
Returns a Style
with the background colour property set.
fn is_plain(self) -> bool
[src]
Return true if this Style
has no actual styles, and can be written
without any control characters.
impl Style
[src]
fn paint<'a, I, S>(self, input: I) -> ANSIGenericString<'a, S> where
I: Into<Cow<'a, S>>,
S: 'a + ToOwned + ?Sized,
<S as ToOwned>::Owned: Debug,
[src]
I: Into<Cow<'a, S>>,
S: 'a + ToOwned + ?Sized,
<S as ToOwned>::Owned: Debug,
Paints the given text with this colour, returning an ANSI string.
Trait Implementations
impl Copy for Style
[src]
impl Clone for Style
[src]
impl From<Colour> for Style
[src]
fn from(colour: Colour) -> 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<Style> for Style
[src]
impl Debug for Style
[src]
Styles have a special Debug
implementation that only shows the fields that
are set. Fields that haven’t been touched aren’t included in the output.
This behaviour gets bypassed when using the alternate formatting mode
format!("{:#?}")
.
use ansi_term::Colour::{Red, Blue}; assert_eq!("Style { fg(Red), on(Blue), bold, italic }", format!("{:?}", Red.on(Blue).bold().italic()));
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter.
impl Default for Style
[src]
fn default() -> Style
[src]
Returns a style with no properties set. Formatting text using this style returns the exact same text.
use ansi_term::Style; assert_eq!(None, Style::default().foreground); assert_eq!(None, Style::default().background); assert_eq!(false, Style::default().is_bold); assert_eq!("txt", Style::default().paint("txt").to_string());