Skip to content

Rowobin/zterm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zterm

A single-file low-level terminal manipulation library written in Zig. Built as a learning exercise.

If you find any bugs or other issues, please let me know. If you think there's features that I should add, suggestions and PRs are always appreciated!

Tested with zig 0.15.2

Tested on MacOS, Linux and Windows

Features

  • Style (bold, italic, underline, etc)
  • 8-16 colors
  • True Color (24-bit RGB)
  • Cursor manipulation (position, hide, show)
  • Enable/disable raw mode
  • Clear screen
  • Alternate Screen Support
  • Abstractions for mouse and keyboard input handling

How to use

Because this is a single-file library, you can just add the file "zterm.zig" to your project. You can also use zig fetch.

Zig fetch

Add library as a dependency in build.zig.zon file with the following command:

zig fetch --save git+https://github.com/Rowobin/zterm

Add the following to thebuild.zig file:

const zterm_dep = b.dependency("zterm", .{
    .target = target,
    .optimize = optimize,
});

exe.root_module.addImport("zterm", zterm_dep.module("zterm"));

Now the library can be used:

const std = @import("std");
const zterm = @import("zterm");

pub fn main() void {
    std.debug.print("{s}Hello World in red!\n", .{
        zterm.color.fg(.red)
    });
}

Building examples

You can build any example with:

> zig build example_name

List of examples:

  • text_effects
  • cursor
  • raw_mode
  • clear_screen
  • game_base
  • alt_screen
  • mouse_input

Credits

I got the idea to build this library from mibu.

About

A terminal manipulation library written in Zig.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages