[−]Struct pretty_exec::logger::Style
A style is a collection of properties that can format a string using ANSI escape codes.
Examples
use ansi_term::{Style, Colour}; let style = Style::new().bold().on(Colour::Black); println!("{}", style.paint("Bold on black"));
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.
Implementations
impl Style
pub fn prefix(self) -> Prefix
The prefix bytes for this style. These are the bytes that tell the terminal to use a different colour or font style.
Examples
use ansi_term::{Style, Colour::Blue}; let style = Style::default().bold(); assert_eq!("\x1b[1m", style.prefix().to_string()); let style = Blue.bold(); assert_eq!("\x1b[1;34m", style.prefix().to_string()); let style = Style::default(); assert_eq!("", style.prefix().to_string());
pub fn infix(self, next: Style) -> Infix
The infix bytes between this style and next
style. These are the bytes
that tell the terminal to change the style to next
. These may include
a reset followed by the next colour and style, depending on the two styles.
Examples
use ansi_term::{Style, Colour::Green}; let style = Style::default().bold(); assert_eq!("\x1b[32m", style.infix(Green.bold()).to_string()); let style = Green.normal(); assert_eq!("\x1b[1m", style.infix(Green.bold()).to_string()); let style = Style::default(); assert_eq!("", style.infix(style).to_string());
pub fn suffix(self) -> Suffix
The suffix for this style. These are the bytes that tell the terminal to reset back to its normal colour and font style.
Examples
use ansi_term::{Style, Colour::Green}; let style = Style::default().bold(); assert_eq!("\x1b[0m", style.suffix().to_string()); let style = Green.normal().bold(); assert_eq!("\x1b[0m", style.suffix().to_string()); let style = Style::default(); assert_eq!("", style.suffix().to_string());
impl Style
pub fn new() -> Style
Creates a new Style with no properties set.
Examples
use ansi_term::Style; let style = Style::new(); println!("{}", style.paint("hi"));
pub fn bold(&self) -> Style
Returns a Style
with the bold property set.
Examples
use ansi_term::Style; let style = Style::new().bold(); println!("{}", style.paint("hey"));
pub fn dimmed(&self) -> Style
Returns a Style
with the dimmed property set.
Examples
use ansi_term::Style; let style = Style::new().dimmed(); println!("{}", style.paint("sup"));
pub fn italic(&self) -> Style
Returns a Style
with the italic property set.
Examples
use ansi_term::Style; let style = Style::new().italic(); println!("{}", style.paint("greetings"));
pub fn underline(&self) -> Style
Returns a Style
with the underline property set.
Examples
use ansi_term::Style; let style = Style::new().underline(); println!("{}", style.paint("salutations"));
pub fn blink(&self) -> Style
Returns a Style
with the blink property set.
Examples
use ansi_term::Style; let style = Style::new().blink(); println!("{}", style.paint("wazzup"));
pub fn reverse(&self) -> Style
Returns a Style
with the reverse property set.
Examples
use ansi_term::Style; let style = Style::new().reverse(); println!("{}", style.paint("aloha"));
pub fn hidden(&self) -> Style
Returns a Style
with the hidden property set.
Examples
use ansi_term::Style; let style = Style::new().hidden(); println!("{}", style.paint("ahoy"));
pub fn strikethrough(&self) -> Style
Returns a Style
with the strikethrough property set.
Examples
use ansi_term::Style; let style = Style::new().strikethrough(); println!("{}", style.paint("yo"));
pub fn fg(&self, foreground: Colour) -> Style
Returns a Style
with the foreground colour property set.
Examples
use ansi_term::{Style, Colour}; let style = Style::new().fg(Colour::Yellow); println!("{}", style.paint("hi"));
pub fn on(&self, background: Colour) -> Style
Returns a Style
with the background colour property set.
Examples
use ansi_term::{Style, Colour}; let style = Style::new().on(Colour::Blue); println!("{}", style.paint("eyyyy"));
pub fn is_plain(self) -> bool
Return true if this Style
has no actual styles, and can be written
without any control characters.
Examples
use ansi_term::Style; assert_eq!(true, Style::default().is_plain()); assert_eq!(false, Style::default().bold().is_plain());
impl Style
#[must_use]pub 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,
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 Clone for Style
pub fn clone(&self) -> Style
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Style
impl Debug for Style
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()));
impl Default for Style
pub fn default() -> Style
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());
impl From<Colour> for Style
pub fn from(colour: Colour) -> Style
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
impl StructuralPartialEq for Style
Auto Trait Implementations
impl RefUnwindSafe for Style
[src]
impl Send for Style
[src]
impl Sync for Style
[src]
impl Unpin for Style
[src]
impl UnwindSafe for Style
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<X> Pipe for X
pub fn pipe<Return, Function>(self, f: Function) -> Return where
Function: FnOnce(Self) -> Return,
Function: FnOnce(Self) -> Return,
pub fn pipe_ref<'a, Return, Function>(&'a self, f: Function) -> Return where
Function: FnOnce(&'a Self) -> Return,
Function: FnOnce(&'a Self) -> Return,
pub fn pipe_mut<'a, Return, Function>(&'a mut self, f: Function) -> Return where
Function: FnOnce(&'a mut Self) -> Return,
Function: FnOnce(&'a mut Self) -> Return,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,