This example demonstrates how to schedule incremental scrollback compression after compression-relevant terminal activity becomes idle.
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
terminal,
&compression_result);
switch (compression_result) {
return true;
return false;
default:
assert(false);
return false;
}
}
int main(void) {
size_t max_scrollback_bytes = 10 * 1024 * 1024;
terminal,
&max_scrollback_bytes);
uint64_t compression_activity;
terminal,
&compression_activity);
const char *line = "repeated and compressible terminal history\r\n";
for (size_t i = 0; i < 4000; i++) {
terminal,
(const uint8_t *)line,
strlen(line));
}
uint64_t new_activity;
if (new_activity != compression_activity) {
compression_activity = new_activity;
}
while (compression_idle_step(terminal)) {}
return 0;
}
GHOSTTY_API GhosttyResult ghostty_terminal_set(GhosttyTerminal terminal, GhosttyTerminalOption option, const void *value)
GHOSTTY_API GhosttyResult ghostty_terminal_compression_activity(GhosttyTerminal terminal, uint64_t *out_activity)
GhosttyTerminalCompressionResult
struct GhosttyTerminalImpl * GhosttyTerminal
GHOSTTY_API void ghostty_terminal_free(GhosttyTerminal terminal)
GHOSTTY_API void ghostty_terminal_vt_write(GhosttyTerminal terminal, const uint8_t *data, size_t len)
GHOSTTY_API GhosttyResult ghostty_terminal_new(const GhosttyAllocator *allocator, GhosttyTerminal *terminal, uint16_t cols, uint16_t rows)
GHOSTTY_API GhosttyResult ghostty_terminal_compress(GhosttyTerminal terminal, GhosttyTerminalCompressionMode mode, GhosttyTerminalCompressionResult *out_result)
@ GHOSTTY_TERMINAL_COMPRESSION_MODE_INCREMENTAL
@ GHOSTTY_TERMINAL_COMPRESSION_RESULT_UNSUPPORTED
@ GHOSTTY_TERMINAL_COMPRESSION_RESULT_COMPLETE
@ GHOSTTY_TERMINAL_COMPRESSION_RESULT_PENDING
@ GHOSTTY_TERMINAL_OPT_SCROLLBACK_MAX_BYTES