ZVTerm terminal emulator library

A Zig wrapper for libvterm, exposing a small subset in a native Zig API. Just enough to build a working terminal emulator.

ZVTerm is fed ANSI escape codes and produces a grid of coloured, styled characters representing the display.

    // setup an 80x24 terminal
    var term = try ZVTerm.init(80, 24);
    // get a writer to send data to the terminal
    var writer = term.getWriter();
    // write terminal escape codes
    try writer.print("\x1b[10;10HHello world", .{});

    // read back the screen state for each x,y position
    for (0..term.height) |y| {
        for (0..term.width) |x| {
            const cell = term.getCell(x, y);
            // paint cell.char:u8 using cell.fgRGBA:u32 and cell.bgRGBA:u32 colours
            ...
        }
    }

I’m using this as part of a project porting terminal games to WASM to run in the browser.

3 Likes

PoC SDL terminal. Does the basics, but doesn’t map ctrl keys, page up/down etc.

1 Like