Single-header C library for simple terminal UIs with colored cell rendering and keyboard input.
- Single-header distribution in
term.h - Colored cell-based rendering with diffed screen updates
- Keyboard input helpers for arrows, home/end, insert/delete, page keys, function keys, and modifier-aware input
- Terminal resize event support via
TKEY_RESIZE - Works on Win32 consoles and Unix-like terminals
term.h: library interface and implementationterm_example.c: small demo programbuild.bat: builds the Windows example withgccbuild_wsl.bat: builds the example inside WSL (testing unix backend)
In exactly one .c file:
#define TIMPLEMENTATION
#include "term.h"In other translation units:
#include "term.h"- Text APIs use
wchar_tand wide string literals likeL"text". - Colors are packed with
TRGBA(r, g, b, a)as0xRRGGBBAA. Alpha is preserved in the color value and currently ignored by terminal rendering. - Use
tdefaultfg()andtdefaultbg()when you want to render with the terminal's current default colors. - The terminal backend expects a real console/TTY, not redirected stdin/stdout.
twait()andtpoll()return the base key code. Calltkeymods()after each returned key to inspectTKEY_MOD_SHIFT,TKEY_MOD_ALT, andTKEY_MOD_CTRL.
MIT. See LICENSE.
