From 341137ce2eca23e3ba082b5f6ee9350f342aea4f Mon Sep 17 00:00:00 2001 From: Jacob Sandlund Date: Wed, 13 Aug 2025 09:56:05 -0400 Subject: [PATCH] case folding --- build.zig.zon | 4 ++-- src/build/uucode_config.zig | 5 ++++- src/input/Binding.zig | 11 +++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index de0faac18..4110effd4 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -42,8 +42,8 @@ .lazy = true, }, .uucode = .{ - .url = "https://github.com/jacobsandlund/uucode/archive/96dd05cb9df893293fffe35321eb0aeb36379b48.tar.gz", - .hash = "uucode-0.0.0-ZZjBPuZ1PAB3TAPIR1yzwyGZbAZ4AqYEtfQ81lsdBL67", + .url = "https://github.com/jacobsandlund/uucode/archive/c7421d97dbdaa8aa176a87eb6dd7dcc3baab12d1.tar.gz", + .hash = "uucode-0.0.0-ZZjBPkh9PAAR34asa24LSw5i5TNKE1B3hohDkZL5iT8J", }, .uucode_x = .{ .url = "https://github.com/jacobsandlund/uucode.x/archive/ca9a9a4560307a30319d206b1ac68a7fc2f2fce9.tar.gz", diff --git a/src/build/uucode_config.zig b/src/build/uucode_config.zig index 943928c3f..bc6ff7eb7 100644 --- a/src/build/uucode_config.zig +++ b/src/build/uucode_config.zig @@ -9,8 +9,11 @@ pub const tables = [_]config.Table{ .fields = &.{ wcwidth.field("wcwidth"), d.field("general_category"), - d.field("has_emoji_presentation"), d.field("block"), + d.field("has_emoji_presentation"), + d.field("case_folding_full"), + // Alternative: + // d.field("case_folding_simple"), }, }, }; diff --git a/src/input/Binding.zig b/src/input/Binding.zig index 3d2d71fe7..6c7870f06 100644 --- a/src/input/Binding.zig +++ b/src/input/Binding.zig @@ -6,7 +6,6 @@ const std = @import("std"); const Allocator = std.mem.Allocator; const assert = std.debug.assert; const build_config = @import("../build_config.zig"); -const ziglyph = @import("ziglyph"); const uucode = @import("uucode"); const key = @import("key.zig"); const KeyEvent = key.KeyEvent; @@ -1566,6 +1565,8 @@ pub const Trigger = struct { .unicode => |cp| std.hash.autoHash( hasher, foldedCodepoint(cp), + // Alternative, just use simple case folding: + // uucode.get(.case_folding_simple, cp), ), } std.hash.autoHash(hasher, self.mods.binding()); @@ -1576,14 +1577,16 @@ pub const Trigger = struct { fn foldedCodepoint(cp: u21) [3]u21 { // ASCII fast path if (uucode.ascii.isAlphabetic(cp)) { - return .{ ziglyph.letter.toLower(cp), 0, 0 }; + return .{ uucode.ascii.toLower(cp), 0, 0 }; } - // Unicode slow path. Case folding can resultin more codepoints. + // Unicode slow path. Case folding can result in more codepoints. // If more codepoints are produced then we return the codepoint // as-is which isn't correct but until we have a failing test // then I don't want to handle this. - return ziglyph.letter.toCaseFold(cp); + var folded: [3]u21 = .{ 0, 0, 0 }; + _ = uucode.get(.case_folding_full, cp).copy(&folded, cp); + return folded; } /// Convert the trigger to a C API compatible trigger.