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 attr(self, attr: Attribute) -> StyledObject<D>
[src]
pub fn attr(self, attr: Attribute) -> StyledObject<D>
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);
pub fn bold(self) -> StyledObject<D>
[src]
pub fn bold(self) -> StyledObject<D>
Increase the font intensity.
pub fn dim(self) -> StyledObject<D>
[src]
pub fn dim(self) -> StyledObject<D>
Faint (decreased intensity) (Not widely supported).
pub fn italic(self) -> StyledObject<D>
[src]
pub fn italic(self) -> StyledObject<D>
Make the font italic (Not widely supported; Sometimes treated as inverse).
pub fn underlined(self) -> StyledObject<D>
[src]
pub fn underlined(self) -> StyledObject<D>
Underline font.
pub fn slow_blink(self) -> StyledObject<D>
[src]
pub fn slow_blink(self) -> StyledObject<D>
Slow Blink (less than 150 per minute; not widely supported).
pub fn rapid_blink(self) -> StyledObject<D>
[src]
pub fn rapid_blink(self) -> StyledObject<D>
Rapid Blink (MS-DOS ANSI.SYS; 150+ per minute; not widely supported).
pub fn reverse(self) -> StyledObject<D>
[src]
pub fn reverse(self) -> StyledObject<D>
Swap foreground and background colors.
Hide text (Not widely supported).
pub fn crossed_out(self) -> StyledObject<D>
[src]
pub fn crossed_out(self) -> StyledObject<D>
Characters legible, but marked for deletion. Not widely supported.
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,