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
object_style: ObjectStyle
content: D
Methods
impl<'a, D: Display + 'a> StyledObject<D>
[src]
impl<'a, D: Display + 'a> StyledObject<D>
pub fn with(self, foreground_color: Color) -> StyledObject<D>
[src]
pub fn with(self, foreground_color: Color) -> StyledObject<D>
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);
pub fn on(self, background_color: Color) -> StyledObject<D>
[src]
pub fn on(self, background_color: Color) -> StyledObject<D>
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);
pub fn paint(&self, screen: &Screen)
[src]
pub fn paint(&self, screen: &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);
pub fn into_displayable(self, screen: &'a Screen) -> DisplayableObject<'a, D>
[src]
pub fn into_displayable(self, screen: &'a Screen) -> DisplayableObject<'a, D>
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> Send for StyledObject<D> where
D: Send,
impl<D> Sync for StyledObject<D> where
D: Sync,
impl<D> Sync for StyledObject<D> where
D: Sync,