ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
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/* ============================================================================
62 * Data Structures
63 * ============================================================================
64 */
65
84typedef struct {
85 char *buf;
86 size_t len;
87 size_t cap;
90} outbuf_t;
91
92/* ============================================================================
93 * Buffer Management Functions
94 * @{
95 */
96
113void ob_reserve(outbuf_t *ob, size_t need);
114
129void ob_putc(outbuf_t *ob, char c);
130
147void ob_write(outbuf_t *ob, const void *s, size_t n);
148
162void ob_term(outbuf_t *ob);
163
165
166/* ============================================================================
167 * Integer Formatting Functions
168 * @{
169 */
170
185void ob_u8(outbuf_t *ob, uint8_t v);
186
201void ob_u32(outbuf_t *ob, uint32_t v);
202
204
205/* ============================================================================
206 * ANSI Escape Sequence Emission Functions
207 * @{
208 */
209
227
245
262void emit_set_256_color_fg(outbuf_t *ob, uint8_t color_idx);
263
280void emit_set_256_color_bg(outbuf_t *ob, uint8_t color_idx);
281
296void emit_reset(outbuf_t *ob);
297
299
300/* ============================================================================
301 * Run-Length Encoding (RLE) Functions
302 * @{
303 */
304
325bool rep_is_profitable(uint32_t runlen);
326
350void emit_rep(outbuf_t *ob, uint32_t extra);
351
353
354/* ============================================================================
355 * Auto-Select Color Mode Functions
356 * @{
357 */
358
378void emit_set_fg(outbuf_t *ob, uint8_t r, uint8_t g, uint8_t b);
379
399void emit_set_bg(outbuf_t *ob, uint8_t r, uint8_t g, uint8_t b);
400
402
403/* ============================================================================
404 * Utility Functions
405 * ============================================================================
406 */
407
408/* digits_u32() is now in util/number.h - include above for access */
409
413void emit_glyph_run(outbuf_t *out, const void *glyph, size_t bytes, uint32_t count);
415void emit_row_end(outbuf_t *out, bool colored, bool newline);
unsigned int uint32_t
Definition common.h:62
unsigned char uint8_t
Definition common.h:60
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:8
🔤 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).