pub trait Sgr: Command {
// Required method
fn write_param(&self, out: &mut Formatter<'_>) -> Result;
}
Expand description
A command using select-graphic-rendition ANSI escape sequences.
To facilitate composition, SGR commands implement Sgr::write_param
,
which writes the parameter(s) with the leading CSI
and the trailing m
.
Technically, an impl &mut core::fmt::Write
would suffice for out
, but
that would make the method generic and hence also prevent the trait from
being object-safe. Declaring out
to be a formatter instead doesn’t
restrict the trait by much, since write_param()
is most likely invoked
inside an implementation of Display::fmt
anyways, while also ensuring that
the trait is object-safe.
Required Methods§
Sourcefn write_param(&self, out: &mut Formatter<'_>) -> Result
fn write_param(&self, out: &mut Formatter<'_>) -> Result
Write the parameter(s) for this SGR command.
Implementations on Foreign Types§
Source§impl<S: Sgr + ?Sized> Sgr for &S
A borrowed SGR is an SGR.
impl<S: Sgr + ?Sized> Sgr for &S
A borrowed SGR is an SGR.
fn write_param(&self, out: &mut Formatter<'_>) -> Result
Source§impl<S: Sgr + ?Sized> Sgr for Box<S>
A boxed SGR is an SGR.
impl<S: Sgr + ?Sized> Sgr for Box<S>
A boxed SGR is an SGR.