Struct crossterm::color::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]
impl<'stdout> TerminalColor<'stdout>
pub fn new(stdout: &'stdout Arc<TerminalOutput>) -> TerminalColor<'stdout>
[src]
pub fn new(stdout: &'stdout Arc<TerminalOutput>) -> TerminalColor<'stdout>
Create new instance whereon color related actions can be performed.
pub fn set_fg(&self, color: Color)
[src]
pub fn set_fg(&self, color: Color)
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"));
pub fn set_bg(&self, color: Color)
[src]
pub fn set_bg(&self, color: Color)
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"));
pub fn reset(&self)
[src]
pub fn reset(&self)
Reset the terminal colors and attributes to default.
let screen = Screen::default(); let colored_terminal = color(&screen); colored_terminal.reset();
pub fn get_available_color_count(&self) -> Result<u16>
[src]
pub fn get_available_color_count(&self) -> Result<u16>
Get available color count.
Auto Trait Implementations
impl<'stdout> Send for TerminalColor<'stdout>
impl<'stdout> Send for TerminalColor<'stdout>
impl<'stdout> Sync for TerminalColor<'stdout>
impl<'stdout> Sync for TerminalColor<'stdout>