ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
output_buffer.h
Go to the documentation of this file.
1#pragma once
2
53
54#include <stdio.h>
55#include <string.h>
56#include <stdbool.h>
57#include <stddef.h>
58#include <stdint.h>
60
61#ifdef __cplusplus
62extern "C" {
63#endif
64
65/* ============================================================================
66 * Data Structures
67 * ============================================================================
68 */
69
88typedef struct {
89 char *buf;
90 size_t len;
91 size_t cap;
94} outbuf_t;
95
96/* ============================================================================
97 * Buffer Management Functions
98 * @{
99 */
100
117void ob_reserve(outbuf_t *ob, size_t need);
118
133void ob_putc(outbuf_t *ob, char c);
134
151void ob_write(outbuf_t *ob, const void *s, size_t n);
152
166void ob_term(outbuf_t *ob);
167
169
170/* ============================================================================
171 * Integer Formatting Functions
172 * @{
173 */
174
189void ob_u8(outbuf_t *ob, uint8_t v);
190
205void ob_u32(outbuf_t *ob, uint32_t v);
206
208
209/* ============================================================================
210 * ANSI Escape Sequence Emission Functions
211 * @{
212 */
213
231
249
266void emit_set_256_color_fg(outbuf_t *ob, uint8_t color_idx);
267
284void emit_set_256_color_bg(outbuf_t *ob, uint8_t color_idx);
285
300void emit_reset(outbuf_t *ob);
301
303
304/* ============================================================================
305 * Run-Length Encoding (RLE) Functions
306 * @{
307 */
308
329bool rep_is_profitable(uint32_t runlen);
330
354void emit_rep(outbuf_t *ob, uint32_t extra);
355
357
358/* ============================================================================
359 * Auto-Select Color Mode Functions
360 * @{
361 */
362
382void emit_set_fg(outbuf_t *ob, uint8_t r, uint8_t g, uint8_t b);
383
403void emit_set_bg(outbuf_t *ob, uint8_t r, uint8_t g, uint8_t b);
404
406
407/* ============================================================================
408 * Utility Functions
409 * ============================================================================
410 */
411
412/* digits_u32() is now in util/number.h - include above for access */
413
417void emit_glyph_run(outbuf_t *out, const void *glyph, size_t bytes, uint32_t count);
419void emit_row_end(outbuf_t *out, bool colored, bool newline);
420
421#ifdef __cplusplus
422}
423#endif
unsigned int uint32_t
unsigned char uint8_t
void emit_set_256_color_bg(outbuf_t *ob, uint8_t color_idx)
Emit 256-color background ANSI sequence.
void emit_set_bg(outbuf_t *ob, uint8_t r, uint8_t g, uint8_t b)
Emit background color sequence (auto-select mode).
void ob_u32(outbuf_t *ob, uint32_t v)
Append unsigned 32-bit integer as decimal string.
void ob_u8(outbuf_t *ob, uint8_t v)
Append unsigned 8-bit integer as decimal string.
void emit_set_256_color_fg(outbuf_t *ob, uint8_t color_idx)
Emit 256-color foreground ANSI sequence.
void ob_term(outbuf_t *ob)
Append null terminator to buffer.
void ob_putc(outbuf_t *ob, char c)
Append a character to buffer.
bool rep_is_profitable(uint32_t runlen)
Check if run-length encoding is profitable.
void ob_reserve(outbuf_t *ob, size_t need)
Dynamic output buffer (auto-expanding).
void emit_set_truecolor_fg(outbuf_t *ob, uint8_t r, uint8_t g, uint8_t b)
Emit truecolor foreground ANSI sequence.
void emit_rep(outbuf_t *ob, uint32_t extra)
Emit run-length encoded sequence.
void emit_reset(outbuf_t *ob)
Emit ANSI reset sequence.
void emit_set_truecolor_bg(outbuf_t *ob, uint8_t r, uint8_t g, uint8_t b)
Emit truecolor background ANSI sequence.
void emit_set_fg(outbuf_t *ob, uint8_t r, uint8_t g, uint8_t b)
Emit foreground color sequence (auto-select mode).
void ob_write(outbuf_t *ob, const void *s, size_t n)
Append a string to buffer.
🔢 Number Formatting and Conversion Utilities
void emit_glyph_run(outbuf_t *out, const void *glyph, size_t bytes, uint32_t count)
void emit_row_end(outbuf_t *out, bool colored, bool newline)
static bool size_t gotel_query_t * out
Definition queries.h:10
🔤 String Manipulation and Shell Escaping Utilities
Dynamic output buffer (auto-expanding).
size_t cap
Buffer capacity in bytes (maximum length before reallocation).
size_t len
Current length in bytes (excluding null terminator).
char * buf
Buffer pointer (allocated, owned by caller, must be freed).