Trait conciliator::term::EmitEscapes

source ·
pub trait EmitEscapes: Write + Sized {
    // Required method
    fn escapes_recognized(&self) -> bool;

    // Provided methods
    fn set_color(&mut self, color: ColorCode) -> IoResult<()> { ... }
    fn set_bold(&mut self) -> IoResult<()> { ... }
    fn reset(&mut self) -> IoResult<()> { ... }
    fn write_with_color<T: Display + ?Sized>(
        &mut self,
        color: ColorCode,
        thing: &T,
    ) { ... }
    fn write_with_color_bold<T: Display + ?Sized>(
        &mut self,
        color: ColorCode,
        thing: &T,
    ) { ... }
}
Expand description

Write for colors: emit terminal color & style escape sequences when possible

Implementors like stdout and stderr Streams have the ability to prevent any escape codes from being emitted depending on whether a TTY is attached, the capabilites of that TTY, or simply user choice.

Not intended to be used directly, use Paint instead (it is implemented for any T: EmitEscapes).

Currently supports only foreground colors and bold styling.

Required Methods§

source

fn escapes_recognized(&self) -> bool

If this returns true, escape codes will be emitted.

Otherwise, all calls to set_color, set_bold and reset are silently ignored. Further, write_with_color and write_with_color_bold will write only what the Display implementor chooses to.

Provided Methods§

source

fn set_color(&mut self, color: ColorCode) -> IoResult<()>

Write a “foreground color” escape code (\x1B[3???m)

source

fn set_bold(&mut self) -> IoResult<()>

Write a “bold text” escape code (\x1B[1m)

source

fn reset(&mut self) -> IoResult<()>

Write a “reset style and color” escape code (\x1B[0m)

source

fn write_with_color<T: Display + ?Sized>(&mut self, color: ColorCode, thing: &T)

set_color, then write! and then reset, provided for convenience

source

fn write_with_color_bold<T: Display + ?Sized>( &mut self, color: ColorCode, thing: &T, )

set_bold & set_color, then write! and then reset, provided for convenience

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<E: EmitEscapes> EmitEscapes for &mut E

Implementors§

source§

impl EmitEscapes for Buffer

source§

impl<'s> EmitEscapes for conciliator::core::Line<'s>

source§

impl<'s> EmitEscapes for conciliator::spin::Line<'s>

source§

impl<'s> EmitEscapes for Message<'s>