aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/unicode/symbols_uucode.zig
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-04-04 19:22:04 +0300
committerCan Celik <ogulcancelik@gmail.com>2026-04-05 01:23:06 +0300
commit41dd733ca7123c9ac4bfc6c781697a660e95b052 (patch)
tree3fc91815ca139ef2e0b281bba0abda4ef15175f4 /vendor/libghostty-vt/src/unicode/symbols_uucode.zig
parent55c138263e190a1e79d4b997bfb9397306c0ec1f (diff)
feat: finish ghostty pane backend integration
Diffstat (limited to 'vendor/libghostty-vt/src/unicode/symbols_uucode.zig')
-rw-r--r--vendor/libghostty-vt/src/unicode/symbols_uucode.zig68
1 files changed, 68 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/src/unicode/symbols_uucode.zig b/vendor/libghostty-vt/src/unicode/symbols_uucode.zig
new file mode 100644
index 00000000..794ca5ba
--- /dev/null
+++ b/vendor/libghostty-vt/src/unicode/symbols_uucode.zig
@@ -0,0 +1,68 @@
+const std = @import("std");
+const uucode = @import("uucode");
+const lut = @import("lut.zig");
+
+/// Runnable binary to generate the lookup tables and output to stdout.
+pub fn main() !void {
+ var arena_state = std.heap.ArenaAllocator.init(std.heap.page_allocator);
+ defer arena_state.deinit();
+ const alloc = arena_state.allocator();
+
+ const gen: lut.Generator(
+ bool,
+ struct {
+ pub fn get(ctx: @This(), cp: u21) !bool {
+ _ = ctx;
+ return if (cp > uucode.config.max_code_point)
+ false
+ else
+ uucode.get(.is_symbol, @intCast(cp));
+ }
+
+ pub fn eql(ctx: @This(), a: bool, b: bool) bool {
+ _ = ctx;
+ return a == b;
+ }
+ },
+ ) = .{};
+
+ const t = try gen.generate(alloc);
+ defer alloc.free(t.stage1);
+ defer alloc.free(t.stage2);
+ defer alloc.free(t.stage3);
+
+ var buf: [4096]u8 = undefined;
+ var stdout = std.fs.File.stdout().writer(&buf);
+ try t.writeZig(&stdout.interface);
+ // Use flush instead of end because stdout is a pipe when captured by
+ // the build system, and pipes cannot be truncated (Windows returns
+ // INVALID_PARAMETER, Linux returns EINVAL).
+ try stdout.interface.flush();
+
+ // Uncomment when manually debugging to see our table sizes.
+ // std.log.warn("stage1={} stage2={} stage3={}", .{
+ // t.stage1.len,
+ // t.stage2.len,
+ // t.stage3.len,
+ // });
+}
+
+test "unicode symbols: tables match uucode" {
+ if (std.valgrind.runningOnValgrind() > 0) return error.SkipZigTest;
+
+ const testing = std.testing;
+ const table = @import("symbols_table.zig").table;
+
+ for (0..std.math.maxInt(u21)) |cp| {
+ const t = table.get(@intCast(cp));
+ const uu = if (cp > uucode.config.max_code_point)
+ false
+ else
+ uucode.get(.is_symbol, @intCast(cp));
+
+ if (t != uu) {
+ std.log.warn("mismatch cp=U+{x} t={} uu={}", .{ cp, t, uu });
+ try testing.expect(false);
+ }
+ }
+}