From f37875c6c4e42055735f1cda9fdbcb7ab11b80bc Mon Sep 17 00:00:00 2001 From: Sam Atman Date: Fri, 13 Dec 2024 15:14:15 -0500 Subject: Add c0 and c1 control width options This allows a build of DisplayWidth to give characters in those classes a width, for cases where they'll be printed with a substitute in the final display. It also raises the size of possible characters from an i3 to an i4, to accommodate printing C1s as e.g. <80> or \u{80}. --- build.zig | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'build.zig') diff --git a/build.zig b/build.zig index 4c4a35a..ce362ea 100644 --- a/build.zig +++ b/build.zig @@ -16,10 +16,24 @@ pub fn build(b: *std.Build) void { const gbp_gen_out = run_gbp_gen_exe.addOutputFileArg("gbp.bin.z"); // Display width - const cjk = b.option(bool, "cjk", "Ambiguouse code points are wide (display width: 2).") orelse false; + const cjk = b.option(bool, "cjk", "Ambiguous code points are wide (display width: 2).") orelse false; const options = b.addOptions(); options.addOption(bool, "cjk", cjk); + // Visible Controls + const c0_width = b.option( + i4, + "c0_width", + "C0 controls have this width (default: 0, default -1)", + ); + options.addOption(?i4, "c0_width", c0_width); + const c1_width = b.option( + i4, + "c1_width", + "C1 controls have this width (default: 0)", + ); + options.addOption(?i4, "c1_width", c1_width); + const dwp_gen_exe = b.addExecutable(.{ .name = "dwp", .root_source_file = b.path("codegen/dwp.zig"), @@ -210,6 +224,7 @@ pub fn build(b: *std.Build) void { display_width.addImport("code_point", code_point); display_width.addImport("grapheme", grapheme); display_width.addImport("DisplayWidthData", width_data); + display_width.addOptions("options", options); // For testing // Normalization const ccc_data = b.createModule(.{ -- cgit v1.2.3