[−][src]Struct yansi_term::Style
A style is a collection of properties that can format a string using ANSI escape codes.
Examples
use yansi_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.
Methods
impl Style
[src]
pub fn new() -> Style
[src]
Creates a new Style with no properties set.
Examples
use yansi_term::Style; let style = Style::new(); println!("{}", style.paint("hi"));
pub fn bold(self) -> Self
[src]
Returns a Style
with the bold property set.
Examples
use yansi_term::Style; let style = Style::new().bold(); println!("{}", style.paint("hey"));
pub fn dimmed(self) -> Self
[src]
Returns a Style
with the dimmed property set.
Examples
use yansi_term::Style; let style = Style::new().dimmed(); println!("{}", style.paint("sup"));
pub fn italic(self) -> Self
[src]
Returns a Style
with the italic property set.
Examples
use yansi_term::Style; let style = Style::new().italic(); println!("{}", style.paint("greetings"));
pub fn underline(self) -> Self
[src]
Returns a Style
with the underline property set.
Examples
use yansi_term::Style; let style = Style::new().underline(); println!("{}", style.paint("salutations"));
pub fn blink(self) -> Self
[src]
Returns a Style
with the blink property set.
Examples
use yansi_term::Style; let style = Style::new().blink(); println!("{}", style.paint("wazzup"));
pub fn reverse(self) -> Self
[src]
Returns a Style
with the reverse property set.
Examples
use yansi_term::Style; let style = Style::new().reverse(); println!("{}", style.paint("aloha"));
[src]
Returns a Style
with the hidden property set.
Examples
use yansi_term::Style; let style = Style::new().hidden(); println!("{}", style.paint("ahoy"));
pub fn strikethrough(self) -> Self
[src]
Returns a Style
with the strikethrough property set.
Examples
use yansi_term::Style; let style = Style::new().strikethrough(); println!("{}", style.paint("yo"));
pub fn fg(self, foreground: Colour) -> Self
[src]
Returns a Style
with the foreground colour property set.
Examples
use yansi_term::{Style, Colour}; let style = Style::new().fg(Colour::Yellow); println!("{}", style.paint("hi"));
pub fn on(self, background: Colour) -> Self
[src]
Returns a Style
with the background colour property set.
Examples
use yansi_term::{Style, Colour}; let style = Style::new().on(Colour::Blue); println!("{}", style.paint("eyyyy"));
pub fn is_plain(self) -> bool
[src]
Return true if this Style
has no actual styles, and can be written
without any control characters.
Examples
use yansi_term::Style; assert_eq!(true, Style::default().is_plain()); assert_eq!(false, Style::default().bold().is_plain());
impl Style
[src]
pub fn paint<'a>(self, input: &'a str) -> impl Display + 'a
[src]
Paints the given text with this style
pub fn paint_fn<F: FnOnce(&mut Formatter) -> Result>(self, f: F) -> impl Display
[src]
Paints the given format function with this style
Trait Implementations
impl Clone for Style
[src]
impl Copy for Style
[src]
impl Debug for Style
[src]
impl Default 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 yansi_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 StructuralPartialEq for Style
[src]
Auto Trait Implementations
impl RefUnwindSafe for Style
impl Send for Style
impl Sync for Style
impl Unpin for Style
impl UnwindSafe for Style
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,
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<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
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.
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>,