![]() |
libghostty
|
Utilities for encoding color scheme reports into terminal escape sequences for color scheme reporting mode (mode 2031).
Use ghostty_color_scheme_report_encode() to encode a color scheme report into a caller-provided buffer. If the buffer is too small, the function returns GHOSTTY_OUT_OF_SPACE and sets the required size in the output parameter.
Functions | |
| GHOSTTY_API GhosttyResult | ghostty_color_scheme_report_encode (GhosttyColorScheme scheme, char *buf, size_t buf_len, size_t *out_written) |
| GHOSTTY_API GhosttyResult ghostty_color_scheme_report_encode | ( | GhosttyColorScheme | scheme, |
| char * | buf, | ||
| size_t | buf_len, | ||
| size_t * | out_written ) |
Encode a color scheme report into an escape sequence.
Encodes a color scheme report into the provided buffer. Dark color schemes emit ESC [ ? 997 ; 1 n, and light color schemes emit ESC [ ? 997 ; 2 n. The encoded bytes are identical to the terminal's internal CSI ? 996 n query response.
Hosts should gate unsolicited sends on GHOSTTY_MODE_COLOR_SCHEME_REPORT (mode 2031) being set, which can be checked via the mode getters.
If the buffer is too small, the function returns GHOSTTY_OUT_OF_SPACE and writes the required buffer size to out_written. The caller can then retry with a sufficiently sized buffer.
| scheme | The color scheme to encode | |
| buf | Output buffer to write the encoded sequence into (may be NULL) | |
| buf_len | Size of the output buffer in bytes | |
| [out] | out_written | On success, the number of bytes written. On GHOSTTY_OUT_OF_SPACE, the required buffer size. |