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
Stream
s 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§
sourcefn escapes_recognized(&self) -> bool
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§
sourcefn set_color(&mut self, color: ColorCode) -> IoResult<()>
fn set_color(&mut self, color: ColorCode) -> IoResult<()>
Write a “foreground color” escape code (\x1B[3???m
)
Object Safety§
This trait is not object safe.