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.c File Reference

Go to the source code of this file.

Data Structures

struct  sgr256_seq_t
 Pre-computed 256-color ANSI SGR sequence. More...

Macros

#define VIDEO_ASCII_SGR_SEQ_BUFFER_SIZE   12
#define VIDEO_ASCII_SGR_BUF_BUFFER_SIZE   32

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)
char * image_print_color_simd (image_t *image, bool background, bool indexed, const char *palette)
 Print image as ASCII with color using SIMD.

Detailed Description

Shared ANSI SGR encoders for scalar, SIMD, and compatibility entry points.

Definition in file sgr.c.

Macro Definition Documentation

◆ VIDEO_ASCII_SGR_BUF_BUFFER_SIZE

#define VIDEO_ASCII_SGR_BUF_BUFFER_SIZE   32

Definition at line 7 of file sgr.c.

Referenced by get_sgr256_fg_bg_string().

◆ VIDEO_ASCII_SGR_SEQ_BUFFER_SIZE

#define VIDEO_ASCII_SGR_SEQ_BUFFER_SIZE   12

Definition at line 6 of file sgr.c.

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().