Terminal DrawingC • Zsh • Curses

zdraw

Build terminal interfaces directly in Zsh. zdraw supplies windows, borders, styled text, and input primitives while your application controls the layout, theme, and event loop.

Drawing Primitives for Your Next TUI

Custom borders

Draw ASCII, rounded, or double borders with eight configurable edge and corner characters. Unicode borders are available on wide curses builds.

Styled text in one call

Batch differently styled text across a row while preserving the window's cursor and drawing state. Refresh when your application is ready.

Cell-aware clipping

Measure text without opening a terminal session, then clip styled runs to a shared column budget using system character widths.

Optional truecolor

Use #RRGGBB colors when the curses build and terminal description support direct color. Query capabilities before enabling it.

Live terminal geometry

Read the controlling terminal's current rows and columns directly, without starting a subprocess or updating the screen.

Feature discovery

Inspect compiled features even in a headless process. Session color information reports usable limits and remaining color-pair capacity.

Built on Zsh's Curses Foundations

Derived from Zsh's zsh/curses module, zdraw has its own module name, builtin, and parameters. Its API develops independently, with general-purpose fixes and extensions remaining candidates for contribution to Zsh.

Screen output stays within curses. Applications choose when to refresh, how to handle events, and which fallback to use when an optional feature is unavailable.

Try the Native Geometry Query

Follow the repository's build instructions, then start the matching shell from the checkout in a terminal:

.build/zsh/Src/zsh -df

# Inside the newly built shell:
module_path=("$PWD/.build/modules")
zmodload zdraw
typeset -a size
zdraw geometry size && print -r -- "$size[1] rows, $size[2] columns"

The query works before curses initialization and leaves the screen untouched. The repository also includes standalone border, clipping, and truecolor examples.

Build and Platform Status

The build uses Zsh sources, a C compiler, GNU Make, Autoconf, and curses development libraries. Tests use Python and their own pseudo-terminals. Build products stay inside the checkout without installing or replacing your shell.

Zsh 5.9.2 on Linux is the tested baseline. BSD/macOS and alternative curses libraries still need testing. Loading the module into an existing Zsh requires a build that matches that shell's ABI.

Text clipping follows system cell widths; it does not promise complete grapheme boundaries for complex emoji sequences. Truecolor depends on both the build and the terminal description.