Skip to main content

write_sgr

Function write_sgr 

Source
pub fn write_sgr<W: Write>(w: &mut W, params: &[&[u16]]) -> Result<()>
Expand description

Write an SGR sequence using semicolon-separated groups and colon-separated subparameters.

The emitted format is ESC [ <params> m. The outer slice separates primary parameters with ;; each non-empty inner slice is joined with :. An empty outer slice emits ESC [ m (SGR reset), and empty inner slices are skipped.

§Examples

// ESC [ 1 ; 31 ; 4 m — bold, red, underline
write_sgr(w, &[&[1], &[31], &[4]])?;

// ESC [ 38 : 2 : 0 : 10 : 20 : 30 m — colon-form truecolor foreground
write_sgr(w, &[&[38, 2, 0, 10, 20, 30]])?;

// ESC [ 0 ; 38 : 2 : 10 : 20 : 30 ; 1 m — mixed groups
write_sgr(w, &[&[0], &[38, 2, 10, 20, 30], &[1]])?;