Library · Virtual Terminal Engine

Coffer

A virtual terminal engine in C — parser, UAX-aware grid, scrollback, reflow, sixel, Lottie, and kitty keyboard, with zero external dependencies.

#c #library #scrollback #terminal #vt-parser #vte

What is Coffer?

Coffer is a standalone virtual terminal engine extracted from portty, where it replaces libvterm. It implements a full VT parser, a UAX #29 grapheme-cluster-aware grid, scrollback, reflow, charsets, sixel and iTerm2/kitty inline images, Lottie graphics, ambiguous-width rendering, and the kitty keyboard protocol — all with no external libraries (libc only; ThorVG optional for Lottie rasterization).

Features

  • VT parser (CSI, ESC, OSC, DCS) with a pending-cluster flush pattern
  • UAX #29 grapheme-cluster-aware grid with paged allocation
  • Paged ring-buffer scrollback; at most two pages live
  • Reflow on resize; altscreen swaps the grid pointer (no copy)
  • Sixel, iTerm2 inline, and kitty graphics protocols
  • Lottie APC protocol (OSC 5555 carrier on Windows ConPTY)
  • Kitty keyboard protocol and damage tracking
  • Pluggable CfrAllocator — all heap traffic goes through it
  • Zero-allocation input write hot path in steady state

Build & install

Coffer is a zero-dependency library — no PKG_CONFIG_PATH needed:

git clone https://github.com/chestso/coffer
cd coffer
./autogen.sh
mkdir -p build && cd build
../configure --prefix=$HOME/.local
make -j"$(nproc)"
make install

Consumed via pkg-config. It ships a static library and headers; portty links it for terminal emulation.

The coffer CLI

make also builds coffer, a headless PTY inspector: it spawns a child on a PTY, pipes output through the engine, and renders the grid as text, with scripted assert-contains / assert-not-contains assertions for CI. make install installs it with its man page. Works on POSIX (forkpty) and Windows (ConPTY).