Struct crossterm::StyledObject[][src]

pub struct StyledObject<D: Display> {
    pub object_style: ObjectStyle,
    pub content: D,
}

Struct that contains both the style and the content wits can be styled.

Fields

Methods

impl<'a, D: Display + 'a> StyledObject<D>
[src]

Set the foreground of the styled object to the passed Color

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

// create an styled object with the foreground color red.
let styledobject =  style("Some colored text").with(Color::Blue);
// create an styled object with the foreground color blue.
let styledobject1 = style("Some colored text").with(Color::Blue);

let screen = Screen::default();

// print the styledobject to see the result
styledobject.paint(&screen);
styledobject1.paint(&screen);

// print an styled object directly.
style("Some colored text").with(Color::Blue).paint(&screen);

Set the background of the styled object to the passed Color

#Example

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

// create an styled object with the background color red.
let styledobject =  style("Some colored text").on(Color::Blue);
// create an styled object with the foreground color blue.
let styledobject1 = style("Some colored text").on(Color::Blue);

let screen = Screen::default();

// print the styledobject to see the result
styledobject.paint(&screen);
styledobject1.paint(&screen);

// print an styled object directly.
style("Some colored text").on(Color::Blue).paint(&screen);

This could be used to paint the styled object on the screen. Pass a reference to the screen whereon you want to perform the painting.

style("Some colored text")
    .with(Color::Blue)
    .on(Color::Black)
    .paint(&screen);

this converts an styled object into an DisplayableObject witch implements: Display and could be used inside the write function of the standard library's.

  let screen = Screen::default();

Auto Trait Implementations

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

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