crossterm::style

Struct StyledContent

Source
pub struct StyledContent<D: Display> { /* private fields */ }
Expand description

The style with the content to be styled.

§Examples

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

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

println!("{}", styled);

Implementations§

Source§

impl<D: Display> StyledContent<D>

Source

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

Creates a new StyledContent.

Source

pub fn content(&self) -> &D

Returns the content.

Source

pub fn style(&self) -> &ContentStyle

Returns the style.

Source

pub fn style_mut(&mut self) -> &mut ContentStyle

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

Trait Implementations§

Source§

impl<D: Display> AsMut<ContentStyle> for StyledContent<D>

Source§

fn as_mut(&mut self) -> &mut ContentStyle

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<D: Display> AsRef<ContentStyle> for StyledContent<D>

Source§

fn as_ref(&self) -> &ContentStyle

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<D: Clone + Display> Clone for StyledContent<D>

Source§

fn clone(&self) -> StyledContent<D>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<D: Debug + Display> Debug for StyledContent<D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<D: Display> Display for StyledContent<D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<D: PartialEq + Display> PartialEq for StyledContent<D>

Source§

fn eq(&self, other: &StyledContent<D>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<D: Display> Stylize for StyledContent<D>

Source§

type Styled = StyledContent<D>

This type with styles applied.
Source§

fn stylize(self) -> Self::Styled

Styles this type.
Source§

fn with(self, color: Color) -> Self::Styled

Sets the foreground color.
Source§

fn on(self, color: Color) -> Self::Styled

Sets the background color.
Source§

fn underline(self, color: Color) -> Self::Styled

Sets the underline color.
Source§

fn attribute(self, attr: Attribute) -> Self::Styled

Styles the content with the attribute.
Source§

fn reset(self) -> Self::Styled

Applies the Reset attribute to the text.
Source§

fn bold(self) -> Self::Styled

Applies the Bold attribute to the text.
Source§

fn underlined(self) -> Self::Styled

Applies the Underlined attribute to the text.
Source§

fn reverse(self) -> Self::Styled

Applies the Reverse attribute to the text.
Source§

fn dim(self) -> Self::Styled

Applies the Dim attribute to the text.
Source§

fn italic(self) -> Self::Styled

Applies the Italic attribute to the text.
Source§

fn negative(self) -> Self::Styled

Applies the Reverse attribute to the text.
Applies the SlowBlink attribute to the text.
Applies the RapidBlink attribute to the text.
Source§

fn hidden(self) -> Self::Styled

Applies the Hidden attribute to the text.
Source§

fn crossed_out(self) -> Self::Styled

Applies the CrossedOut attribute to the text.
Source§

fn black(self) -> Self::Styled

Sets the foreground color to Black.
Source§

fn on_black(self) -> Self::Styled

Sets the background color to Black.
Source§

fn underline_black(self) -> Self::Styled

Sets the underline color to Black.
Source§

fn dark_grey(self) -> Self::Styled

Sets the foreground color to DarkGrey.
Source§

fn on_dark_grey(self) -> Self::Styled

Sets the background color to DarkGrey.
Source§

fn underline_dark_grey(self) -> Self::Styled

Sets the underline color to DarkGrey.
Source§

fn red(self) -> Self::Styled

Sets the foreground color to Red.
Source§

fn on_red(self) -> Self::Styled

Sets the background color to Red.
Source§

fn underline_red(self) -> Self::Styled

Sets the underline color to Red.
Source§

fn dark_red(self) -> Self::Styled

Sets the foreground color to DarkRed.
Source§

fn on_dark_red(self) -> Self::Styled

Sets the background color to DarkRed.
Source§

fn underline_dark_red(self) -> Self::Styled

Sets the underline color to DarkRed.
Source§

fn green(self) -> Self::Styled

Sets the foreground color to Green.
Source§

fn on_green(self) -> Self::Styled

Sets the background color to Green.
Source§

fn underline_green(self) -> Self::Styled

Sets the underline color to Green.
Source§

fn dark_green(self) -> Self::Styled

Sets the foreground color to DarkGreen.
Source§

fn on_dark_green(self) -> Self::Styled

Sets the background color to DarkGreen.
Source§

fn underline_dark_green(self) -> Self::Styled

Sets the underline color to DarkGreen.
Source§

fn yellow(self) -> Self::Styled

Sets the foreground color to Yellow.
Source§

fn on_yellow(self) -> Self::Styled

Sets the background color to Yellow.
Source§

fn underline_yellow(self) -> Self::Styled

Sets the underline color to Yellow.
Source§

fn dark_yellow(self) -> Self::Styled

Sets the foreground color to DarkYellow.
Source§

fn on_dark_yellow(self) -> Self::Styled

Sets the background color to DarkYellow.
Source§

fn underline_dark_yellow(self) -> Self::Styled

Sets the underline color to DarkYellow.
Source§

fn blue(self) -> Self::Styled

Sets the foreground color to Blue.
Source§

fn on_blue(self) -> Self::Styled

Sets the background color to Blue.
Source§

fn underline_blue(self) -> Self::Styled

Sets the underline color to Blue.
Source§

fn dark_blue(self) -> Self::Styled

Sets the foreground color to DarkBlue.
Source§

fn on_dark_blue(self) -> Self::Styled

Sets the background color to DarkBlue.
Source§

fn underline_dark_blue(self) -> Self::Styled

Sets the underline color to DarkBlue.
Source§

fn magenta(self) -> Self::Styled

Sets the foreground color to Magenta.
Source§

fn on_magenta(self) -> Self::Styled

Sets the background color to Magenta.
Source§

fn underline_magenta(self) -> Self::Styled

Sets the underline color to Magenta.
Source§

fn dark_magenta(self) -> Self::Styled

Sets the foreground color to DarkMagenta.
Source§

fn on_dark_magenta(self) -> Self::Styled

Sets the background color to DarkMagenta.
Source§

fn underline_dark_magenta(self) -> Self::Styled

Sets the underline color to DarkMagenta.
Source§

fn cyan(self) -> Self::Styled

Sets the foreground color to Cyan.
Source§

fn on_cyan(self) -> Self::Styled

Sets the background color to Cyan.
Source§

fn underline_cyan(self) -> Self::Styled

Sets the underline color to Cyan.
Source§

fn dark_cyan(self) -> Self::Styled

Sets the foreground color to DarkCyan.
Source§

fn on_dark_cyan(self) -> Self::Styled

Sets the background color to DarkCyan.
Source§

fn underline_dark_cyan(self) -> Self::Styled

Sets the underline color to DarkCyan.
Source§

fn white(self) -> Self::Styled

Sets the foreground color to White.
Source§

fn on_white(self) -> Self::Styled

Sets the background color to White.
Source§

fn underline_white(self) -> Self::Styled

Sets the underline color to White.
Source§

fn grey(self) -> Self::Styled

Sets the foreground color to Grey.
Source§

fn on_grey(self) -> Self::Styled

Sets the background color to Grey.
Source§

fn underline_grey(self) -> Self::Styled

Sets the underline color to Grey.
Source§

impl<D: Copy + Display> Copy for StyledContent<D>

Source§

impl<D: Eq + Display> Eq for StyledContent<D>

Source§

impl<D: Display> StructuralPartialEq for StyledContent<D>

Auto Trait Implementations§

§

impl<D> Freeze for StyledContent<D>
where D: Freeze,

§

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§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.