A minimal terminal emulator in C99. SDL2 + SDL_ttf for display, everything else hand-rolled. The goal is small, readable code, not feature parity with xterm.
| file | role |
|---|---|
term.c/h |
backend-agnostic core: cell grid, UTF-8 decoder, VT parser |
pty.c/h |
forks $SHELL on a pseudo-terminal |
config.h |
compile-time configuration: font, colors, cursor |
main.c |
SDL2 shell: window, font, glyph cache, event loop, keyboard |
test_term.c |
headless checks for the core (make check) |
The core has no SDL dependency, so the renderer is swappable.
Needs sdl2 and SDL2_ttf development packages, e.g. on Void Linux:
sudo xbps-install SDL2-devel SDL2_ttf-devel
Then:
make # build ./hterm
make check # run core tests, no display needed
Compile-time, st-style: edit config.h and rebuild. It holds the font
path and size (empty path = autodetect via fc-match monospace), initial
geometry, default foreground/background, the 16-color ANSI palette, and
the cursor's color, shape (block / underline / beam) and blink.
- Full UTF-8: streaming decoder, invalid input → U+FFFD, double-width
(CJK, emoji) via
wcwidth - CSI: cursor movement, erase, insert/delete lines/chars, scroll regions, save/restore cursor, DSR/DA reports
- SGR: bold, italic, underline, reverse, 16/256/truecolor
- Autowrap with deferred wrap, window resize, Ctrl keys, Ctrl+Shift+V paste
Scrollback, selection/copy, alternate screen, mouse reporting, combining characters, font fallback (missing glyphs render as tofu), Alt-as-Meta, blinking text, OSC (title sequences are parsed and discarded).