using just `get`

pull/8757/head
Jacob Sandlund 2025-08-05 23:59:30 -04:00
parent 8dec520b41
commit 0c393299b0
8 changed files with 29 additions and 31 deletions

View File

@ -42,12 +42,12 @@
.lazy = true,
},
.uucode = .{
.url = "https://github.com/jacobsandlund/uucode/archive/7d851864a21d1d700d41230762de66f7b7fa5941.tar.gz",
.hash = "uucode-0.0.0-ZZjBPqk4OwDcGSplCRYO-zLKcs3FZ-jQGj9rfSEf6VZr",
.url = "https://github.com/jacobsandlund/uucode/archive/c5300b75cf2a1f11fe00f492875a8db9f8d346f0.tar.gz",
.hash = "uucode-0.0.0-ZZjBPsGrOwBSzsufKmTo-bwSYyjogdt7HW0sBPkE24uc",
},
.uucode_x = .{
.url = "https://github.com/jacobsandlund/uucode.x/archive/779492c4565ed282a7c989ffc7f52cbe060f17a3.tar.gz",
.hash = "uucode_x-0.0.0-5_D0j-gIAAC4SzTTunb6O4sqwj0kojbjV0rm2bj9QgyA",
.url = "https://github.com/jacobsandlund/uucode.x/archive/db7678dd8af009971021f8479fb2ac07db00e698.tar.gz",
.hash = "uucode_x-0.0.0-5_D0jxkhAACi1yTMBn7Rat1telHy82oD65B7ywtj4W4j",
},
.zig_wayland = .{
// codeberg ifreund/zig-wayland

View File

@ -21,22 +21,21 @@ uucode_tables_zig: std.Build.LazyPath,
pub const LazyPathList = std.ArrayList(std.Build.LazyPath);
pub fn init(b: *std.Build, cfg: *const Config) !SharedDeps {
const uucode_x = b.dependency("uucode_x", .{});
const uucode_x_config = uucode_x.module("uucode.x.config");
const uucode_tables_zig = blk: {
const uucode = b.dependency("uucode", .{
.build_config_path = b.path("src/build/uucode_config.zig"),
});
@import("uucode_x").connectBuild(b.dependency("uucode_x", .{}), uucode);
const uucode = b.dependency("uucode", .{
.build_config_path = b.path("src/build/uucode_build_config.zig"),
});
uucode.module("build_config").addImport("uucode.x.config", uucode_x_config);
uucode_x_config.addImport("config.zig", uucode.module("config.zig"));
uucode_x_config.addImport("types.zig", uucode.module("types.zig"));
break :blk uucode.namedLazyPath("tables.zig");
};
var result: SharedDeps = .{
.config = cfg,
.help_strings = try .init(b, cfg),
.unicode_tables = try .init(b),
.unicode_tables = try .init(b, uucode_tables_zig),
.framedata = try .init(b),
.uucode_tables_zig = uucode.namedLazyPath("tables.zig"),
.uucode_tables_zig = uucode_tables_zig,
// Setup by retarget
.options = undefined,
@ -431,7 +430,6 @@ pub fn add(
.target = target,
.optimize = optimize,
.@"tables.zig" = self.uucode_tables_zig,
.x_root_path = b.path("src/build/uucode_x.zig"),
})) |dep| {
step.root_module.addImport("uucode", dep.module("uucode"));
}

View File

@ -9,7 +9,7 @@ exe: *std.Build.Step.Compile,
/// The output path for the unicode tables
output: std.Build.LazyPath,
pub fn init(b: *std.Build) !UnicodeTables {
pub fn init(b: *std.Build, uucode_tables_zig: std.Build.LazyPath) !UnicodeTables {
const exe = b.addExecutable(.{
.name = "unigen",
.root_module = b.createModule(.{
@ -30,6 +30,13 @@ pub fn init(b: *std.Build) !UnicodeTables {
);
}
if (b.lazyDependency("uucode", .{
.target = b.graph.host,
.@"tables.zig" = uucode_tables_zig,
})) |dep| {
exe.root_module.addImport("uucode", dep.module("uucode"));
}
const run = b.addRunArtifact(exe);
return .{
.exe = exe,

View File

@ -4,9 +4,9 @@ const d = config.default;
pub const tables = [_]config.Table{
.{
.extensions = &.{x.width},
.extensions = &.{x.wcwidth},
.fields = &.{
x.width.field("width"),
x.wcwidth.field("wcwidth"),
d.field("general_category"),
d.field("has_emoji_presentation"),
},

View File

@ -1,8 +0,0 @@
const get = @import("get.zig");
const tableFor = get.tableFor;
const data = get.data;
pub fn width(cp: u21) u2 {
const table = comptime tableFor("width");
return data(table, cp).width;
}

View File

@ -150,7 +150,7 @@ pub fn getIndex(
// we'll do this multiple times if we recurse, but this is a cached function
// call higher up (GroupCache) so this should be rare.
const p_mode: Collection.PresentationMode = if (p) |v| .{ .explicit = v } else .{
.default = if (uucode.hasEmojiPresentation(@intCast(cp)))
.default = if (uucode.get("has_emoji_presentation", @intCast(cp)))
.emoji
else
.text,

View File

@ -237,7 +237,7 @@ pub fn constraintWidth(cell_pin: terminal.Pin) u2 {
const cp = cell.codepoint();
// If not a Co (Private Use) and not a Dingbats, use grid width.
if (uucode.generalCategory(cp) != .Co and
if (uucode.get("general_category", cp) != .Co and
!ziglyph.blocks.isDingbats(cp))
{
return cell.gridWidth();
@ -262,7 +262,7 @@ pub fn constraintWidth(cell_pin: terminal.Pin) u2 {
if (isPowerline(prev_cp)) break :prev;
// If it's Private Use (Co) use 1 as the width.
if (uucode.generalCategory(prev_cp) == .Co) {
if (uucode.get("general_category", prev_cp) == .Co) {
return 1;
}
}

View File

@ -2,6 +2,7 @@ const props = @This();
const std = @import("std");
const assert = std.debug.assert;
const ziglyph = @import("ziglyph");
const uucode = @import("uucode");
const lut = @import("lut.zig");
/// The lookup tables for Ghostty.
@ -121,10 +122,10 @@ pub const GraphemeBoundaryClass = enum(u4) {
};
pub fn get(cp: u21) Properties {
const zg_width = ziglyph.display_width.codePointWidth(cp, .half);
const wcwidth = if (cp < 0x110000) uucode.get("wcwidth", cp) else 0;
return .{
.width = @intCast(@min(2, @max(0, zg_width))),
.width = @intCast(@min(2, @max(0, wcwidth))),
.grapheme_boundary_class = .init(cp),
};
}