prettytty

Trait Sgr

Source
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§

Source

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.

Source§

fn write_param(&self, out: &mut Formatter<'_>) -> Result

Source§

impl<S: Sgr + ?Sized> Sgr for Box<S>

A boxed SGR is an SGR.

Source§

fn write_param(&self, out: &mut Formatter<'_>) -> Result

Implementors§

Source§

impl Sgr for Format

Source§

impl Sgr for DynSetBackground8

Source§

impl Sgr for DynSetBackground24

Source§

impl Sgr for DynSetForeground8

Source§

impl Sgr for DynSetForeground24

Source§

impl Sgr for SetDefaultBackground

Source§

impl Sgr for SetDefaultForeground

Source§

impl<const COLOR: u8> Sgr for SetBackground8<COLOR>

Source§

impl<const COLOR: u8> Sgr for SetForeground8<COLOR>

Source§

impl<const R: u8, const G: u8, const B: u8> Sgr for SetBackground24<R, G, B>

Source§

impl<const R: u8, const G: u8, const B: u8> Sgr for SetForeground24<R, G, B>