[][src]Trait term_painter::ToStyle

pub trait ToStyle: Sized {
    fn to_style(self) -> Style;

    fn to_mapped_style<F>(self, func: F) -> Style
    where
        F: FnOnce(&mut Style)
, { ... }
fn fg(self, c: Color) -> Style { ... }
fn bg(self, c: Color) -> Style { ... }
fn bold(self) -> Style { ... }
fn dim(self) -> Style { ... }
fn underline(self) -> Style { ... }
fn not_underline(self) -> Style { ... }
fn blink(self) -> Style { ... }
fn reverse(self) -> Style { ... }
fn secure(self) -> Style { ... }
fn paint<T>(&self, obj: T) -> Painted<T>
    where
        Self: Clone
, { ... }
fn with<F, R>(&self, f: F) -> R
    where
        F: FnOnce() -> R,
        Self: Clone
, { ... } }

Everything that can be seen as part of a style. This is the core of this crate. All functions ("style modifier") consume self and return a modified version of the style.

Required methods

fn to_style(self) -> Style

Loading content...

Provided methods

fn to_mapped_style<F>(self, func: F) -> Style where
    F: FnOnce(&mut Style), 

Convenience method for modifying the style before it's returned.

fn fg(self, c: Color) -> Style

Sets the foreground (text) color.

fn bg(self, c: Color) -> Style

Sets the background color.

fn bold(self) -> Style

Makes the text bold.

fn dim(self) -> Style

Dim mode.

fn underline(self) -> Style

Underlines the text.

fn not_underline(self) -> Style

Removes underline-attribute.

Underlines the text.

fn reverse(self) -> Style

Underlines the text.

fn secure(self) -> Style

Secure mode.

fn paint<T>(&self, obj: T) -> Painted<T> where
    Self: Clone

Wraps the style specified in self and something of arbitrary type into a Painted. When Painted is printed it will print the arbitrary something with the given style.

fn with<F, R>(&self, f: F) -> R where
    F: FnOnce() -> R,
    Self: Clone

Executes the given function, applying the style information before calling it and resetting after it finished.

Loading content...

Implementors

impl ToStyle for Attr[src]

fn to_style(self) -> Style[src]

Returns a Style with default values and the self attribute enabled.

impl ToStyle for Color[src]

fn to_style(self) -> Style[src]

Returns a Style with default values and the self color as foreground color.

impl ToStyle for Style[src]

fn to_style(self) -> Style[src]

Dummy implementation that just returns self.

Loading content...