Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hterm

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.

Layout

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.

Build

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

Configuration

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.

What works

  • 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

Deliberately not (yet) implemented

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).

About

c99, sdl2 based suckless terminal emulator

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages