ascii-chat
Binary v0.16.50-198-g78f51665f
Library lib/v0.3.2-2240-g78f51665f
Video chat in your terminal
Loading...
Searching...
No Matches
ansi.c
Go to the documentation of this file.
1
6
7/* Existing buffer budgets in bytes, including NUL for text storage. */
8#define ANSI_16_SGR_BUFFER_SIZE 16
9
10#include <ascii-chat/common.h>
11#include <libplatform/lifecycle.h>
17#include <options/options.h>
18#include <string.h>
19#include <time.h>
20#ifndef _WIN32
21#include <unistd.h>
22#endif
23#include <limits.h>
24
25/* ===== BASIC ANSI UTILITIES ===== */
26
27char *ansi_strip_escapes(const char *input, size_t input_len) {
28 if (!input || input_len == 0) {
29 return NULL;
30 }
31
32 // Allocate buffer directly for output (at most input_len bytes)
33 char *output = SAFE_MALLOC(input_len + 1, char *);
34 if (!output) {
35 return NULL;
36 }
37
38 size_t out_pos = 0;
39 size_t i = 0;
40
41 while (i < input_len) {
42 // Check for ESC character (start of ANSI sequence)
43 if (input[i] == '\x1b' && i + 1 < input_len && input[i + 1] == '[') {
44 // Skip ESC[
45 i += 2;
46
47 // Skip parameter bytes (digits, semicolons, and intermediate bytes)
48 while (i < input_len) {
49 char c = input[i];
50 // Parameter bytes: 0x30-0x3F (digits, semicolon, etc.)
51 // Intermediate bytes: 0x20-0x2F (space, !, ", etc.)
52 if ((c >= 0x30 && c <= 0x3F) || (c >= 0x20 && c <= 0x2F)) {
53 i++;
54 } else {
55 break;
56 }
57 }
58
59 // Skip final byte (0x40-0x7E: @, A-Z, [, \, ], ^, _, `, a-z, {, |, }, ~)
60 if (i < input_len) {
61 char final = input[i];
62 if (final >= 0x40 && final <= 0x7E) {
63 i++;
64 }
65 }
66 } else {
67 // Regular character - copy to output
68 output[out_pos++] = input[i];
69 i++;
70 }
71 }
72
73 // Null-terminate the output
74 output[out_pos] = '\0';
75 return output;
76}
77
78const char *ansi_skip_escape(const char *ptr, const char *end) {
79 if (!ptr || ptr >= end || *ptr != '\x1b') {
80 return ptr ? ptr + 1 : ptr;
81 }
82
83 const char *p = ptr + 1;
84 if (p >= end || *p != '[') {
85 return p; // Not a CSI sequence, skip just the ESC byte
86 }
87 p++; // Skip '['
88
89 // Skip parameter bytes (0x30-0x3F) and intermediate bytes (0x20-0x2F)
90 while (p < end && ((*p >= 0x30 && *p <= 0x3F) || (*p >= 0x20 && *p <= 0x2F))) {
91 p++;
92 }
93
94 // Skip final byte (0x40-0x7E)
95 if (p < end && *p >= 0x40 && *p <= 0x7E) {
96 p++;
97 }
98
99 return p;
100}
101
102bool ansi_is_already_colorized(const char *message, size_t pos) {
103 if (!message) {
104 return false;
105 }
106
107 bool in_reset = true; // Start in reset state
108
109 // Scan from beginning to current position looking for ANSI codes
110 for (size_t i = 0; i < pos && message[i] != '\0'; i++) {
111 if (message[i] == '\x1b' && message[i + 1] == '[') {
112 // Found ANSI escape sequence start
113 // Look for the end marker 'm'
114 size_t j = i + 2;
115 while (message[j] != '\0' && message[j] != 'm') {
116 j++;
117 }
118
119 if (message[j] == 'm') {
120 // Extract the color code part (between [ and m)
121 // Check if it's a reset code: \x1b[0m or \x1b[m
122 in_reset = ((j == i + 3 && message[i + 2] == '0') || (j == i + 2));
123 }
124 }
125 }
126
127 // Return true if NOT in reset state (already colorized)
128 return !in_reset;
129}
130
131/* ===== 16-COLOR LOOKUP TABLES ===== */
132
133static char color16_fg_strings[16][ANSI_16_SGR_BUFFER_SIZE];
134static char color16_bg_strings[16][ANSI_16_SGR_BUFFER_SIZE];
135static lifecycle_t g_color16_lc = LIFECYCLE_INIT;
136
137/* ===== TRUECOLOR FUNCTIONS ===== */
138
139// Fast foreground color: \033[38;2;R;G;Bm
140// Maximum output: 19 bytes (\033[38;2;255;255;255m)
141char *append_truecolor_fg(char *dst, uint8_t r, uint8_t g, uint8_t b) {
142 return append_sgr_truecolor_fg(dst, r, g, b);
143}
144
145char *append_truecolor_bg(char *dst, uint8_t r, uint8_t g, uint8_t b) {
146 return append_sgr_truecolor_bg(dst, r, g, b);
147}
148
149char *append_truecolor_fg_bg(char *dst, uint8_t fr, uint8_t fg, uint8_t fb, uint8_t br, uint8_t bg, uint8_t bb) {
150 return append_sgr_truecolor_fg_bg(dst, fr, fg, fb, br, bg, bb);
151}
152
153/* ===== RUN-LENGTH ENCODING FUNCTIONS ===== */
154
155// Initialize run-length encoding context
156void ansi_rle_init(ansi_rle_context_t *ctx, char *buffer, size_t capacity, ansi_color_mode_t mode) {
157 ctx->buffer = buffer;
158 ctx->capacity = capacity;
159 ctx->length = 0;
160 ctx->mode = mode;
161 ctx->first_pixel = true;
162 // Initialize with impossible color values to force first SGR
163 ctx->last_r = 0xFF;
164 ctx->last_g = 0xFF;
165 ctx->last_b = 0xFF;
166}
167
168// Add pixel with run-length encoding - only emit SGR when color changes
169void ansi_rle_add_pixel(ansi_rle_context_t *ctx, uint8_t r, uint8_t g, uint8_t b, char ascii_char) {
170 // Check if we need to emit a new SGR sequence
171 bool color_changed = ctx->first_pixel || (r != ctx->last_r) || (g != ctx->last_g) || (b != ctx->last_b);
172
173 if (color_changed) {
174 if (ctx->length + 40 >= ctx->capacity) {
175 // Log when we can't add a color change due to buffer capacity
176 log_warn_every(US_PER_SEC_INT, "RLE_CAPACITY: Cannot add SGR at length=%zu, capacity=%zu (need 40 bytes)", ctx->length, ctx->capacity);
177 }
178 }
179
180 if (color_changed && (ctx->length + 40 < ctx->capacity)) { // Reserve 40 bytes for SGR (FG+BG max is 38)
181 char *pos = ctx->buffer + ctx->length;
182
183 switch (ctx->mode) {
185 pos = append_truecolor_fg(pos, r, g, b);
186 break;
188 pos = append_truecolor_bg(pos, r, g, b);
189 break;
191 // For FG+BG mode, use a default background (black) or implement dual-color logic
192 pos = append_truecolor_fg_bg(pos, r, g, b, 0, 0, 0);
193 break;
194 }
195
196 ctx->length = (size_t)(pos - ctx->buffer);
197 ctx->last_r = r;
198 ctx->last_g = g;
199 ctx->last_b = b;
200 ctx->first_pixel = false;
201 }
202
203 // Add the ASCII character
204 if (ctx->length < ctx->capacity - 1) {
205 ctx->buffer[ctx->length++] = ascii_char;
206 }
207}
208
209// Finish RLE sequence with reset and null terminator
211 // Add reset sequence (requires 4 bytes + 1 for null terminator = 5 bytes total)
212 if (ctx->length + 5 <= ctx->capacity) {
213 SAFE_MEMCPY(ctx->buffer + ctx->length, 4, "\033[0m", 4);
214 ctx->length += 4;
215 }
216
217 // Null terminate
218 if (ctx->length < ctx->capacity) {
219 ctx->buffer[ctx->length] = '\0';
220 }
221}
222
223/* ===== INITIALIZATION FUNCTIONS ===== */
224
225// Initialize the decimal lookup table (call once at startup)
226void ansi_fast_init(void) {
227 // Initialize the dec3 cache used by truecolor functions
229}
230
234
236 uint8_t length;
237 const char *sequence = get_sgr256_fg_string(index, &length);
238 memcpy(dst, sequence, length);
239 return dst + length;
240}
241
243 uint8_t length;
244 const char *sequence = get_sgr256_bg_string(index, &length);
245 memcpy(dst, sequence, length);
246 return dst + length;
247}
248
249// Convert RGB to closest 256-color palette index
251 // Xterm cube levels are nonuniform. Compare the nearest cube entry with
252 // the nearest gray, including cube black/white rather than clipping them.
253 static const int levels[] = {0, 95, 135, 175, 215, 255};
254 int values[] = {r, g, b}, cube[3], error = 0;
255 for (int c = 0; c < 3; c++) {
256 cube[c] = 0;
257 for (int i = 1; i < 6; i++)
258 if (abs(values[c] - levels[i]) < abs(values[c] - levels[cube[c]]))
259 cube[c] = i;
260 int delta = values[c] - levels[cube[c]];
261 error += delta * delta;
262 }
263 int gray = ((int)r + g + b - 9) / 30;
264 if (gray < 0)
265 gray = 0;
266 if (gray > 23)
267 gray = 23;
268 int level = 8 + 10 * gray;
269 int dr = r - level, dg = g - level, db = b - level;
270 if (dr * dr + dg * dg + db * db < error)
271 return (uint8_t)(232 + gray);
272 return (uint8_t)(16 + cube[0] * 36 + cube[1] * 6 + cube[2]);
273}
274
275// Expand a standard xterm palette index to truecolor. The first 16 entries
276// use the same reference palette as rgb_to_16color (terminal themes may vary).
278 if (!r || !g || !b) {
279 SET_ERRNO(ERROR_INVALID_PARAM, "Missing palette RGB output");
280 return;
281 }
282 if (index < 16) {
283 get_16color_rgb(index, r, g, b);
284 return;
285 }
286 if (index >= 232) {
287 *r = *g = *b = (uint8_t)(8 + (index - 232) * 10);
288 return;
289 }
290 static const uint8_t levels[] = {0, 95, 135, 175, 215, 255};
291 int cube = index - 16;
292 *r = levels[cube / 36];
293 *g = levels[(cube / 6) % 6];
294 *b = levels[cube % 6];
295}
296
297/* ===== 16-COLOR FUNCTIONS ===== */
298
299// Private initialization function (called exactly once via lifecycle)
300static void do_init_16color(void) {
301 // Standard ANSI color codes
302 const char *fg_codes[] = {"30", "31", "32", "33", "34", "35", "36", "37", // Normal colors (30-37)
303 "90", "91", "92", "93", "94", "95", "96", "97"}; // Bright colors (90-97)
304 const char *bg_codes[] = {"40", "41", "42", "43", "44", "45", "46", "47", // Normal colors (40-47)
305 "100", "101", "102", "103", "104", "105", "106", "107"}; // Bright colors (100-107)
306
307 for (int i = 0; i < 16; i++) {
308 SAFE_SNPRINTF(color16_fg_strings[i], sizeof(color16_fg_strings[i]), "\033[%sm", fg_codes[i]);
309 SAFE_SNPRINTF(color16_bg_strings[i], sizeof(color16_bg_strings[i]), "\033[%sm", bg_codes[i]);
310 }
311}
312
313// Public initialization wrapper - thread-safe using lifecycle API
315 if (!lifecycle_init(&g_color16_lc, "ansi_16color")) {
316 return; // Already initialized
317 }
318 do_init_16color();
319}
320
321char *append_16color_fg(char *dst, uint8_t color_index) {
322 // Ensure initialization before use
324
325 if (color_index >= 16) {
326 color_index = 7; // Default to white
327 }
328
329 const char *color_str = color16_fg_strings[color_index];
330 while (*color_str) {
331 *dst++ = *color_str++;
332 }
333
334 return dst;
335}
336
337char *append_16color_bg(char *dst, uint8_t color_index) {
338 // Ensure initialization before use
340
341 if (color_index >= 16) {
342 color_index = 0; // Default to black background
343 }
344
345 const char *color_str = color16_bg_strings[color_index];
346 while (*color_str) {
347 *dst++ = *color_str++;
348 }
349
350 return dst;
351}
352
354 // Convert RGB to the closest 16-color ANSI color
355 // This uses a simple distance-based approach
356
357 // Define the 16 ANSI colors in RGB
358 static const uint8_t ansi_colors[16][3] = {
359 {0, 0, 0}, // 0: Black
360 {128, 0, 0}, // 1: Dark Red
361 {0, 128, 0}, // 2: Dark Green
362 {128, 128, 0}, // 3: Dark Yellow (Brown)
363 {0, 0, 128}, // 4: Dark Blue
364 {128, 0, 128}, // 5: Dark Magenta
365 {0, 128, 128}, // 6: Dark Cyan
366 {192, 192, 192}, // 7: Light Gray
367 {128, 128, 128}, // 8: Dark Gray
368 {255, 0, 0}, // 9: Bright Red
369 {0, 255, 0}, // 10: Bright Green
370 {255, 255, 0}, // 11: Bright Yellow
371 {0, 0, 255}, // 12: Bright Blue
372 {255, 0, 255}, // 13: Bright Magenta
373 {0, 255, 255}, // 14: Bright Cyan
374 {255, 255, 255} // 15: White
375 };
376
377 uint8_t best_match = 0;
378 int min_distance = INT_MAX;
379
380 for (int i = 0; i < 16; i++) {
381 int dr = (int)r - (int)ansi_colors[i][0];
382 int dg = (int)g - (int)ansi_colors[i][1];
383 int db = (int)b - (int)ansi_colors[i][2];
384 int distance = dr * dr + dg * dg + db * db;
385
386 if (distance < min_distance) {
387 min_distance = distance;
388 best_match = i;
389 }
390 }
391
392 return best_match;
393}
394
395// Get the actual RGB values for a 16-color ANSI index
396void get_16color_rgb(uint8_t color_index, uint8_t *r, uint8_t *g, uint8_t *b) {
397 // Same color table as rgb_to_16color()
398 static const uint8_t ansi_colors[16][3] = {
399 {0, 0, 0}, // 0: Black
400 {128, 0, 0}, // 1: Dark Red
401 {0, 128, 0}, // 2: Dark Green
402 {128, 128, 0}, // 3: Dark Yellow (Brown)
403 {0, 0, 128}, // 4: Dark Blue
404 {128, 0, 128}, // 5: Dark Magenta
405 {0, 128, 128}, // 6: Dark Cyan
406 {192, 192, 192}, // 7: Light Gray
407 {128, 128, 128}, // 8: Dark Gray
408 {255, 0, 0}, // 9: Bright Red
409 {0, 255, 0}, // 10: Bright Green
410 {255, 255, 0}, // 11: Bright Yellow
411 {0, 0, 255}, // 12: Bright Blue
412 {255, 0, 255}, // 13: Bright Magenta
413 {0, 255, 255}, // 14: Bright Cyan
414 {255, 255, 255} // 15: White
415 };
416
417 if (color_index >= 16) {
418 color_index = 7; // Default to light gray
419 }
420
421 *r = ansi_colors[color_index][0];
422 *g = ansi_colors[color_index][1];
423 *b = ansi_colors[color_index][2];
424}
425
426// Floyd-Steinberg dithering for 16-color terminals
427uint8_t rgb_to_16color_dithered(int r, int g, int b, int x, int y, int width, int height, rgb_error_t *error_buffer) {
428 // Add accumulated error from previous pixels
429 if (error_buffer) {
430 // Use size_t for index calculation to prevent integer overflow on large images
431 size_t error_idx = (size_t)y * (size_t)width + (size_t)x;
432 r += error_buffer[error_idx].r;
433 g += error_buffer[error_idx].g;
434 b += error_buffer[error_idx].b;
435
436 // Reset error for this pixel
437 error_buffer[error_idx].r = 0;
438 error_buffer[error_idx].g = 0;
439 error_buffer[error_idx].b = 0;
440 }
441
442 // Clamp values to [0, 255]
443 uint8_t r_clamped = clamp_rgb((int)r);
444 uint8_t g_clamped = clamp_rgb((int)g);
445 uint8_t b_clamped = clamp_rgb((int)b);
446
447 // Find the closest 16-color match
448 uint8_t closest_color = rgb_to_16color(r_clamped, g_clamped, b_clamped);
449
450 // Calculate quantization error if dithering is enabled
451 if (error_buffer) {
452 uint8_t actual_r, actual_g, actual_b;
453 get_16color_rgb(closest_color, &actual_r, &actual_g, &actual_b);
454
455 int error_r = r - (int)actual_r;
456 int error_g = g - (int)actual_g;
457 int error_b = b - (int)actual_b;
458
459 // Distribute error using Floyd-Steinberg weights:
460 // * 7/16
461 // 3/16 5/16 1/16
462
463 // Error to right pixel (x+1, y)
464 // Use size_t for all index calculations to prevent integer overflow
465 if (x + 1 < width) {
466 size_t right_idx = (size_t)y * (size_t)width + (size_t)(x + 1);
467 error_buffer[right_idx].r += (error_r * 7) / 16;
468 error_buffer[right_idx].g += (error_g * 7) / 16;
469 error_buffer[right_idx].b += (error_b * 7) / 16;
470 }
471
472 // Error to pixels on next row (y+1)
473 if (y + 1 < height) {
474 // Bottom-left pixel (x-1, y+1)
475 if (x - 1 >= 0) {
476 size_t bl_idx = (size_t)(y + 1) * (size_t)width + (size_t)(x - 1);
477 error_buffer[bl_idx].r += (error_r * 3) / 16;
478 error_buffer[bl_idx].g += (error_g * 3) / 16;
479 error_buffer[bl_idx].b += (error_b * 3) / 16;
480 }
481
482 // Bottom pixel (x, y+1)
483 size_t bottom_idx = (size_t)(y + 1) * (size_t)width + (size_t)x;
484 error_buffer[bottom_idx].r += (error_r * 5) / 16;
485 error_buffer[bottom_idx].g += (error_g * 5) / 16;
486 error_buffer[bottom_idx].b += (error_b * 5) / 16;
487
488 // Bottom-right pixel (x+1, y+1)
489 if (x + 1 < width) {
490 size_t br_idx = (size_t)(y + 1) * (size_t)width + (size_t)(x + 1);
491 error_buffer[br_idx].r += (error_r * 1) / 16;
492 error_buffer[br_idx].g += (error_g * 1) / 16;
493 error_buffer[br_idx].b += (error_b * 1) / 16;
494 }
495 }
496 }
497
498 return closest_color;
499}
500
501/* ===== MODE-AWARE COLOR FUNCTIONS ===== */
502
503// Terminal capability-aware color function
504char *append_color_fg_for_mode(char *dst, uint8_t r, uint8_t g, uint8_t b, terminal_color_mode_t mode) {
505 switch (mode) {
507 return append_truecolor_fg(dst, r, g, b);
508
510 uint8_t color_index = rgb_to_256color(r, g, b);
511 return append_256color_fg(dst, color_index);
512 }
513
514 case COLOR_MODE_16_COLOR: {
515 uint8_t color_index = rgb_to_16color(r, g, b);
516 return append_16color_fg(dst, color_index);
517 }
518
519 case COLOR_MODE_NONE:
520 case COLOR_MODE_AUTO:
521 default:
522 // No color output for monochrome mode or auto mode (fallback)
523 return dst;
524 }
525}
#define ANSI_16_SGR_BUFFER_SIZE
Definition ansi.c:8
ANSI escape sequence utilities and fast color code generation.
#define SET_ERRNO(code,...)
Platform initialization and static synchronization helpers.
unsigned int height
Definition fft.c:24
unsigned int width
Definition fft.c:24
char * append_16color_fg(char *dst, uint8_t color_index)
Definition ansi.c:321
char * append_16color_bg(char *dst, uint8_t color_index)
Definition ansi.c:337
char * append_256color_bg(char *dst, uint8_t index)
Definition ansi.c:242
char * append_truecolor_fg(char *dst, uint8_t r, uint8_t g, uint8_t b)
Definition ansi.c:141
void ansi_fast_init_256color(void)
Definition ansi.c:231
const char * ansi_skip_escape(const char *ptr, const char *end)
Find the end of an ANSI CSI escape sequence.
Definition ansi.c:78
uint8_t rgb_to_16color(uint8_t r, uint8_t g, uint8_t b)
Definition ansi.c:353
void get_256color_rgb(uint8_t index, uint8_t *r, uint8_t *g, uint8_t *b)
Definition ansi.c:277
uint8_t rgb_to_16color_dithered(int r, int g, int b, int x, int y, int width, int height, rgb_error_t *error_buffer)
Definition ansi.c:427
ansi_color_mode_t
Definition ansi.h:39
void ansi_rle_init(ansi_rle_context_t *ctx, char *buffer, size_t capacity, ansi_color_mode_t mode)
Definition ansi.c:156
char * ansi_strip_escapes(const char *input, size_t input_len)
When code needs to work with rgb error, it keeps r, g, b here instead of scattering it across globals...
Definition ansi.c:27
void ansi_fast_init(void)
Definition ansi.c:226
char * append_truecolor_fg_bg(char *dst, uint8_t fr, uint8_t fg, uint8_t fb, uint8_t br, uint8_t bg, uint8_t bb)
Definition ansi.c:149
void ansi_rle_finish(ansi_rle_context_t *ctx)
Definition ansi.c:210
void get_16color_rgb(uint8_t color_index, uint8_t *r, uint8_t *g, uint8_t *b)
Definition ansi.c:396
void ansi_rle_add_pixel(ansi_rle_context_t *ctx, uint8_t r, uint8_t g, uint8_t b, char ascii_char)
Definition ansi.c:169
bool ansi_is_already_colorized(const char *message, size_t pos)
Check if a position in text is already colored.
Definition ansi.c:102
char * append_256color_fg(char *dst, uint8_t index)
Definition ansi.c:235
char * append_color_fg_for_mode(char *dst, uint8_t r, uint8_t g, uint8_t b, terminal_color_mode_t mode)
Definition ansi.c:504
uint8_t rgb_to_256color(uint8_t r, uint8_t g, uint8_t b)
Definition ansi.c:250
void ansi_fast_init_16color(void)
Definition ansi.c:314
char * append_truecolor_bg(char *dst, uint8_t r, uint8_t g, uint8_t b)
Definition ansi.c:145
@ ANSI_MODE_FOREGROUND_BACKGROUND
Definition ansi.h:42
@ ANSI_MODE_FOREGROUND
Definition ansi.h:40
@ ANSI_MODE_BACKGROUND
Definition ansi.h:41
#define SAFE_MALLOC(size, cast)
#define SAFE_SNPRINTF(buffer, buffer_size,...)
unsigned char uint8_t
#define SAFE_MEMCPY(dest, dest_size, src, count)
@ ERROR_INVALID_PARAM
#define US_PER_SEC_INT
Definition time.h:177
#define COLOR_MODE_16_COLOR
16-color mode (full name)
Definition options.h:226
#define COLOR_MODE_256_COLOR
256-color mode (full name)
Definition options.h:228
#define COLOR_MODE_TRUECOLOR
24-bit truecolor mode
Definition options.h:229
#define COLOR_MODE_AUTO
Backward compatibility aliases for color mode enum values.
Definition options.h:223
#define COLOR_MODE_NONE
Monochrome mode.
Definition options.h:224
void prewarm_sgr256_cache(void)
Prewarm 256-color foreground/background cache for benchmarks.
Definition sgr.c:95
char * get_sgr256_bg_string(uint8_t bg, uint8_t *len_out)
Get 256-color background ANSI sequence string.
Definition sgr.c:108
char * get_sgr256_fg_string(uint8_t fg, uint8_t *len_out)
Get 256-color foreground ANSI sequence string.
Definition sgr.c:100
void ascii_simd_init(void)
Initialize SIMD subsystem.
⚙️ Common definitions, error codes, macros, and types shared throughout the application
SIMD-optimized ASCII conversion interface.
#define log_warn_every(interval_us, fmt,...)
Rate-limited WARN logging.
Definition log/log.h:749
🔢 Mathematical Utility Functions
⚙️ Unified options parsing system for ascii-chat with builder pattern and lock-free access
static bool size_t index
Definition queries.h:8
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 sgr.c:150
char * append_sgr_truecolor_bg(char *dst, uint8_t r, uint8_t g, uint8_t b)
Definition sgr.c:146
char * append_sgr_truecolor_fg(char *dst, uint8_t r, uint8_t g, uint8_t b)
Definition sgr.c:142
ANSI SGR (Select Graphic Rendition) color sequence generation.
🔤 String Manipulation and Shell Escaping Utilities
uint8_t last_b
Definition ansi.h:54
uint8_t last_g
Definition ansi.h:53
size_t capacity
Definition ansi.h:48
uint8_t last_r
Definition ansi.h:52
char * buffer
Definition ansi.h:47
bool first_pixel
Definition ansi.h:51
size_t length
Definition ansi.h:49
ansi_color_mode_t mode
Definition ansi.h:50
int b
Definition ansi.h:74
int g
Definition ansi.h:73
int r
Definition ansi.h:72
⏱️ High-precision timing utilities using sokol_time.h and uthash