Struct crossterm::style::TerminalColor[][src]

pub struct TerminalColor<'stdout> { /* fields omitted */ }

Struct that stores an specific platform implementation for color related actions.

For styling text use the ::crossterm::style() function. TerminalColor will set the colors of the screen permanently and the style() will only style the text given.

Check /examples/color in the library for more specific examples.

use crossterm::{Screen}
use crossterm::style::color;

let screen = Screen::default();
let colored_terminal = color(&screen);

// set foreground color
colored_terminal.set_fg(Color::Red);
// set background color
colored_terminal.set_bg(Color::Red);
// reset color to default
colored_terminal.reset();

Methods

impl<'stdout> TerminalColor<'stdout>
[src]

Create new instance whereon color related actions can be performed.

Set the foreground color to the given color.

let screen = Screen::default();
let colored_terminal = color(&screen);

// Set foreground color of the font
colored_terminal.set_fg(Color::Red);
// crossterm provides to set the background from &str or String
colored_terminal.set_fg(Color::from("Red"));

Set the background color to the given color.

let screen = Screen::default();
let colored_terminal = color(&screen);

// Set background color of the font
colored_terminal.set_bg(Color::Red);
// crossterm provides to set the background from &str or String
colored_terminal.set_bg(Color::from("Red"));

Reset the terminal colors and attributes to default.

let screen = Screen::default();
let colored_terminal = color(&screen);
colored_terminal.reset();

Get available color count.

Auto Trait Implementations

impl<'stdout> Send for TerminalColor<'stdout>

impl<'stdout> Sync for TerminalColor<'stdout>