ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
Loading...
Searching...
No Matches
sgr.h File Reference

ANSI SGR (Select Graphic Rendition) color sequence generation. More...

Go to the source code of this file.

Functions

void prewarm_sgr256_fg_cache (void)
 Prewarm 256-color foreground cache for benchmarks.
void prewarm_sgr256_cache (void)
 Prewarm 256-color foreground/background cache for benchmarks.
char * get_sgr256_fg_string (uint8_t fg, uint8_t *len_out)
 Get 256-color foreground ANSI sequence string.
char * get_sgr256_bg_string (uint8_t bg, uint8_t *len_out)
 Get 256-color background ANSI sequence string.
char * get_sgr256_fg_bg_string (uint8_t fg, uint8_t bg, uint8_t *len_out)
 Get 256-color foreground/background ANSI sequence string.
char * append_sgr_reset (char *dst)
char * append_sgr_truecolor_fg (char *dst, uint8_t r, uint8_t g, uint8_t b)
char * append_sgr_truecolor_bg (char *dst, uint8_t r, uint8_t g, uint8_t b)
char * append_sgr_truecolor_fg_bg (char *dst, uint8_t fr, uint8_t fg, uint8_t fb, uint8_t br, uint8_t bg, uint8_t bb)

Detailed Description

ANSI SGR (Select Graphic Rendition) color sequence generation.

Definition in file sgr.h.

Function Documentation

◆ append_sgr_reset()

char * append_sgr_reset ( char * dst)

Definition at line 122 of file sgr.c.

122 {
123 memcpy(dst, "\033[0m", 4);
124 return dst + 4;
125}

Referenced by emit_reset().

◆ append_sgr_truecolor_bg()

char * append_sgr_truecolor_bg ( char * dst,
uint8_t r,
uint8_t g,
uint8_t b )

Definition at line 146 of file sgr.c.

146 {
147 return append_rgb_sgr(dst, true, r, g, b);
148}

Referenced by append_truecolor_bg().

◆ append_sgr_truecolor_fg()

char * append_sgr_truecolor_fg ( char * dst,
uint8_t r,
uint8_t g,
uint8_t b )

Definition at line 142 of file sgr.c.

142 {
143 return append_rgb_sgr(dst, false, r, g, b);
144}

Referenced by append_truecolor_fg().

◆ append_sgr_truecolor_fg_bg()

char * append_sgr_truecolor_fg_bg ( char * dst,
uint8_t fr,
uint8_t fg,
uint8_t fb,
uint8_t br,
uint8_t bg,
uint8_t bb )

Definition at line 150 of file sgr.c.

150 {
151 memcpy(dst, "\033[38;2;", 7);
152 dst = append_rgb_components(dst + 7, fr, fg, fb);
153 memcpy(dst, ";48;2;", 6);
154 dst = append_rgb_components(dst + 6, br, bg, bb);
155 *dst++ = 'm';
156 return dst;
157}

Referenced by append_truecolor_fg_bg().