diff --git a/src/build/UnicodeTables.zig b/src/build/UnicodeTables.zig index 5c6d6e1a4..9972c851a 100644 --- a/src/build/UnicodeTables.zig +++ b/src/build/UnicodeTables.zig @@ -15,7 +15,7 @@ pub fn init(b: *std.Build, uucode_tables: std.Build.LazyPath) !UnicodeTables { const props_exe = b.addExecutable(.{ .name = "props-unigen", .root_module = b.createModule(.{ - .root_source_file = b.path("src/unicode/props_ziglyph.zig"), + .root_source_file = b.path("src/unicode/props_uucode.zig"), .target = b.graph.host, .strip = false, .omit_frame_pointer = false, @@ -26,7 +26,7 @@ pub fn init(b: *std.Build, uucode_tables: std.Build.LazyPath) !UnicodeTables { const symbols_exe = b.addExecutable(.{ .name = "symbols-unigen", .root_module = b.createModule(.{ - .root_source_file = b.path("src/unicode/symbols_ziglyph.zig"), + .root_source_file = b.path("src/unicode/symbols_uucode.zig"), .target = b.graph.host, .strip = false, .omit_frame_pointer = false, diff --git a/src/main_ghostty.zig b/src/main_ghostty.zig index 555dd16bf..9c121b950 100644 --- a/src/main_ghostty.zig +++ b/src/main_ghostty.zig @@ -191,8 +191,8 @@ test { _ = @import("simd/main.zig"); _ = @import("synthetic/main.zig"); _ = @import("unicode/main.zig"); - _ = @import("unicode/props_ziglyph.zig"); - _ = @import("unicode/symbols_ziglyph.zig"); + _ = @import("unicode/props_uucode.zig"); + _ = @import("unicode/symbols_uucode.zig"); // Extra _ = @import("extra/bash.zig"); diff --git a/src/unicode/props_table.zig b/src/unicode/props_table.zig index d4ddfebbb..cac0a38b3 100644 --- a/src/unicode/props_table.zig +++ b/src/unicode/props_table.zig @@ -8,7 +8,7 @@ pub const table = table: { // build.zig process, but due to Zig's lazy analysis we can still reference // it here. // - // An example process is the `main` in `props_ziglyph.zig` + // An example process is the `main` in `props_uucode.zig` const generated = @import("unicode_tables").Tables(Properties); const Tables = lut.Tables(Properties); break :table Tables{ diff --git a/src/unicode/props_uucode.zig b/src/unicode/props_uucode.zig index 449c04ddf..fe9de37ab 100644 --- a/src/unicode/props_uucode.zig +++ b/src/unicode/props_uucode.zig @@ -55,7 +55,7 @@ pub fn get(cp: u21) Properties { return .{ .width = width, - .grapheme_boundary_class = .init(cp), + .grapheme_boundary_class = graphemeBoundaryClass(cp), }; } diff --git a/src/unicode/symbols_table.zig b/src/unicode/symbols_table.zig index af77d88fd..da2614cae 100644 --- a/src/unicode/symbols_table.zig +++ b/src/unicode/symbols_table.zig @@ -7,7 +7,7 @@ pub const table = table: { // build.zig process, but due to Zig's lazy analysis we can still reference // it here. // - // An example process is the `main` in `symbols_ziglyph.zig` + // An example process is the `main` in `symbols_uucode.zig` const generated = @import("symbols_tables").Tables(bool); const Tables = lut.Tables(bool); break :table Tables{ diff --git a/src/unicode/symbols_uucode.zig b/src/unicode/symbols_uucode.zig new file mode 100644 index 000000000..d78a2b234 --- /dev/null +++ b/src/unicode/symbols_uucode.zig @@ -0,0 +1,41 @@ +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); + try t.writeZig(std.io.getStdOut().writer()); + + // Uncomment when manually debugging to see our table sizes. + // std.log.warn("stage1={} stage2={} stage3={}", .{ + // t.stage1.len, + // t.stage2.len, + // t.stage3.len, + // }); +}