[][src]Struct crossterm::style::StyledContent

pub struct StyledContent<D: Display> { /* fields omitted */ }

The style with the content to be styled.

Examples

use crossterm::style::{style, Color, Attribute};

let styled = style("Hello there")
    .with(Color::Yellow)
    .on(Color::Blue)
    .attribute(Attribute::Bold);

println!("{}", styled);

Methods

impl<D: Display> StyledContent<D>[src]

pub fn new(style: ContentStyle, content: D) -> StyledContent<D>[src]

Creates a new StyledContent.

pub fn with(self, foreground_color: Color) -> StyledContent<D>[src]

Sets the foreground color.

pub fn on(self, background_color: Color) -> StyledContent<D>[src]

Sets the background color.

pub fn attribute(self, attr: Attribute) -> StyledContent<D>[src]

Adds the attribute.

You can add more attributes by calling this method multiple times.

pub fn content(&self) -> &D[src]

Returns the content.

pub fn style(&self) -> &ContentStyle[src]

Returns the style.

pub fn style_mut(&mut self) -> &mut ContentStyle[src]

Returns a mutable reference to the style, so that it can be futher manipulated

Trait Implementations

impl<D: Clone + Display> Clone for StyledContent<D>[src]

impl<D: Display + Clone> Colorize<D> for StyledContent<D>[src]

impl<D: Debug + Display> Debug for StyledContent<D>[src]

impl<D: Display> Display for StyledContent<D>[src]

impl<D: Display + Clone> Styler<D> for StyledContent<D>[src]

Auto Trait Implementations

impl<D> RefUnwindSafe for StyledContent<D> where
    D: RefUnwindSafe

impl<D> Send for StyledContent<D> where
    D: Send

impl<D> Sync for StyledContent<D> where
    D: Sync

impl<D> Unpin for StyledContent<D> where
    D: Unpin

impl<D> UnwindSafe for StyledContent<D> where
    D: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.