An open API service indexing awesome lists of open source software.

https://github.com/chardoncs/zig-ansi-parse

Comptime-proof ANSI format parsing library for Zig
https://github.com/chardoncs/zig-ansi-parse

ansi-code ansi-colors ansi-terminal colorization parser zig ziglang

Last synced: 3 months ago
JSON representation

Comptime-proof ANSI format parsing library for Zig

Awesome Lists containing this project

README

        

# zig-ansi-parse

Comptime-proof ANSI format parsing library for Zig.

[How it works?](https://github.com/chardoncs/zig-ansi-parse/wiki/Syntax)

## Install

1. Fetch it in your project, `` is the version you want

```bash
zig fetch --save https://github.com/chardoncs/zig-ansi-parse/archive/refs/tags/v.tar.gz
```

Or fetch the git repo for latest updates

```bash
zig fetch --save git+https://github.com/chardoncs/zig-ansi-parse
```

2. Configure your `build.zig`.

```zig
const ansi_parse = b.dependency("ansi-parse", .{});
exe.root_module.addImport("ansi-parse", ansi_parse.module("ansi-parse"));
```

## At a glance

```zig
const std = @import("std");
const parseComptime = @import("ansi-parse").parseComptime;

const demo_text = parseComptime(
\\Greetings!> I'm bold> and blue>
\\Ignore this>
\\\
\\tabbedOllalHello
\\Three tabs
\\
, .{} // Options
);

pub fn main() !void {
std.debug.print(demo_text, .{});
}
```

## Options

| Name | Default value | Description |
|--------------|-----------------|-------------------------|
| branch_quota | 200,000 | (Comptime only) Evaluation branch quota. A larger quota can prevent the compiler from giving up caused by loops |
| out_size | `input.len * 4` | (Comptime only) Capacity of the output string, set a larger value if the output is truncated |