$ show nsf/termbox-go
termbox-go is a minimalistic Go library for building text-based user interfaces (TUIs). It provides a clean API for cell-based screen manipulation, keyboard and mouse input, and multiple output modes (normal, 256, 216, grayscale, RGB). The library abstracts over Unix terminals (via terminfo and ANSI escape codes) and the Windows console (via Win32 API). Architecture uses double-buffering: a back buffer is modified by the user, then flushed to a front buffer and rendered to the terminal. Input events are processed asynchronously via a goroutine and channel. The library is stable and widely used (godit, termui, gocui, etc.) but the README explicitly states it is no longer actively maintained; users may consider gdamore/tcell as a more modern alternative. The codebase is well-organized with platform-specific files using Go build tags, though it exhibits some global state and sparse test coverage.
The LLM identified 2 files worth highlighting for reuse:
Provides pure functions AttributeToRGB and RGBToAttribute for converting between termbox attributes and RGB triplets. These functions are self-contained, have no internal dependencies, and can be extracted and reused in any Go project requiring similar color encoding/decoding logic. They demonstrate careful bit manipulation to pack RGB values into an Attribute type, handling alignment with the max_attr constant.
Implements the cellbuf structure, a simple 2D cell buffer with init, resize, and clear methods. This is a reusable pattern for any terminal or grid-based rendering system. The resize method intelligently copies overlapping cells when the buffer dimensions change, preserving existing content. The code is clean, small, and has no external dependencies beyond the core Cell type defined in the same package.