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);

Set the attribute of an styled object to the passed Attribute

#Example

extern crate crossterm;
use self::crossterm::style::{style,Attribute};

style("Some colored text").attr(Attribute::Bold).paint(&screen);

Increase the font intensity.

Faint (decreased intensity) (Not widely supported).

Make the font italic (Not widely supported; Sometimes treated as inverse).

Underline font.

Slow Blink (less than 150 per minute; not widely supported).

Rapid Blink (MS-DOS ANSI.SYS; 150+ per minute; not widely supported).

Swap foreground and background colors.

Hide text (Not widely supported).

Characters legible, but marked for deletion. Not widely supported.

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