Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ringtailsoftware/zvterm
Zig binding for libvterm, a terminal emulator core
https://github.com/ringtailsoftware/zvterm
libvterm terminal terminal-emulator zig zig-package
Last synced: 5 days ago
JSON representation
Zig binding for libvterm, a terminal emulator core
- Host: GitHub
- URL: https://github.com/ringtailsoftware/zvterm
- Owner: ringtailsoftware
- License: other
- Created: 2024-12-08T19:36:46.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2025-01-01T23:10:30.000Z (about 1 month ago)
- Last Synced: 2025-01-30T00:31:59.282Z (11 days ago)
- Topics: libvterm, terminal, terminal-emulator, zig, zig-package
- Language: C
- Homepage:
- Size: 1.54 MB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ZVTerm
A Zig wrapper for [libvterm](https://www.leonerd.org.uk/code/libvterm/), exposing a small subset in a native Zig API.
Build with zig 0.14.0
(Just enough to build a working toy terminal emulator)
![](sdlzvterm/demo.gif)
See `examples/helloworld.zig` for usage.
See `sdlzvterm/` for a janky terminal implementation in SDL.
```zig
// setup an 80x24 terminal
var term = try ZVTerm.init(allocator, 80, 24);
defer term.deinit();
// 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.fg and cell.bg colours
...
}
}
```To build and run the simple demo,
zig build helloworld
To build and run the SDL demo terminal,
cd sdlzvterm
zig build run# Use
First we add the library as a dependency in our `build.zig.zon` file.
`zig fetch --save git+https://github.com/ringtailsoftware/zvterm.git`
And add it to `build.zig` file.
```zig
const zvterm_dep = b.dependency("zvterm", .{
.target = target,
.optimize = optimize,
});exe.root_module.addImport("zvterm", zvterm_dep.module("zvterm"));
```# Status
There's plenty to add in order to make a real terminal emulator. libvterm is capable, but the zig API needs extending to do more
- unicode
- bell
- more selective damage callbacks to know which areas of screen to redraw