diff --git a/build.zig b/build.zig index 32f1846..c508451 100644 --- a/build.zig +++ b/build.zig @@ -353,7 +353,7 @@ pub fn build_exe( .imports = &.{ .{ .name = "cbor", .module = cbor_mod }, .{ .name = "thespian", .module = thespian_mod }, - .{ .name = "CaseData", .module = zg_dep.module("CaseData") }, + .{ .name = "LetterCasing", .module = zg_dep.module("LetterCasing") }, }, }); diff --git a/build.zig.zon b/build.zig.zon index fd712e2..feb6ad0 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -27,8 +27,8 @@ .hash = "fuzzig-0.1.1-AAAAALNIAQBmbHr-MPalGuR393Vem2pTQXI7_LXeNJgX", }, .vaxis = .{ - .url = "https://github.com/neurocyte/libvaxis/archive/9787035bd1a895355380bcca217e86293f8d6c07.tar.gz", - .hash = "vaxis-0.1.0-BWNV_I4QCQD6KmxhhplZGLIBVqxkVJPRdI3PbcfRh7_W", + .url = "https://github.com/neurocyte/libvaxis/archive/6137cb4c44a7350996f0946a069739e5075d1f23.tar.gz", + .hash = "vaxis-0.1.0-BWNV_HwOCQCw5wTV63hQGSc1QJzsNcytH6sGf1GBc0hP", }, .zeit = .{ .url = "https://github.com/rockorager/zeit/archive/8fd203f85f597f16e0a525c1f1ca1e0bffded809.tar.gz", diff --git a/src/buffer/unicode.zig b/src/buffer/unicode.zig index 5cd4986..a2747a8 100644 --- a/src/buffer/unicode.zig +++ b/src/buffer/unicode.zig @@ -72,12 +72,12 @@ pub fn utf8_sanitize(allocator: std.mem.Allocator, input: []const u8) error{ return output.toOwnedSlice(allocator); } -pub const CaseData = @import("CaseData"); -var case_data: ?CaseData = null; -var case_data_arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); +pub const LetterCasing = @import("LetterCasing"); +var letter_casing: ?LetterCasing = null; +var letter_casing_arena = std.heap.ArenaAllocator.init(std.heap.c_allocator); -pub fn get_case_data() *CaseData { - if (case_data) |*cd| return cd; - case_data = CaseData.init(case_data_arena.allocator()) catch @panic("CaseData.init"); - return &case_data.?; +pub fn get_letter_casing() *LetterCasing { + if (letter_casing) |*cd| return cd; + letter_casing = LetterCasing.init(letter_casing_arena.allocator()) catch @panic("LetterCasing.init"); + return &letter_casing.?; } diff --git a/src/main.zig b/src/main.zig index 21a9677..a3b9931 100644 --- a/src/main.zig +++ b/src/main.zig @@ -48,8 +48,8 @@ pub fn main() anyerror!void { } const a = std.heap.c_allocator; - const case_data = @import("Buffer").unicode.get_case_data(); - _ = case_data; // no need to free case_data as it is globally static + const letter_casing = @import("Buffer").unicode.get_letter_casing(); + _ = letter_casing; // no need to free letter_casing as it is globally static const Flags = struct { pub const description = diff --git a/src/renderer/vaxis/renderer.zig b/src/renderer/vaxis/renderer.zig index 11b99dd..016738b 100644 --- a/src/renderer/vaxis/renderer.zig +++ b/src/renderer/vaxis/renderer.zig @@ -579,7 +579,7 @@ const Loop = struct { switch (builtin.os.tag) { .windows => { var parser: vaxis.Parser = .{ - .grapheme_data = &self.vaxis.unicode.width_data.g_data, + .graphemes = &self.vaxis.unicode.graphemes, }; const a = self.vaxis.opts.system_clipboard_allocator orelse @panic("no tty allocator"); while (!self.should_quit) { @@ -588,7 +588,7 @@ const Loop = struct { }, else => { var parser: vaxis.Parser = .{ - .grapheme_data = &self.vaxis.unicode.width_data.g_data, + .graphemes = &self.vaxis.unicode.graphemes, }; const a = self.vaxis.opts.system_clipboard_allocator orelse @panic("no tty allocator"); diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 134d938..e067208 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -5672,7 +5672,7 @@ pub const Editor = struct { var sfa = std.heap.stackFallback(4096, self.allocator); const cut_text = copy_selection(root, sel.*, sfa.get(), self.metrics) catch return error.Stop; defer allocator.free(cut_text); - const ucased = Buffer.unicode.get_case_data().toUpperStr(allocator, cut_text) catch return error.Stop; + const ucased = Buffer.unicode.get_letter_casing().toUpperStr(allocator, cut_text) catch return error.Stop; defer allocator.free(ucased); root = try self.delete_selection(root, cursel, allocator); root = self.insert(root, cursel, ucased, allocator) catch return error.Stop; @@ -5700,7 +5700,7 @@ pub const Editor = struct { var sfa = std.heap.stackFallback(4096, self.allocator); const cut_text = copy_selection(root, sel.*, sfa.get(), self.metrics) catch return error.Stop; defer allocator.free(cut_text); - const ucased = Buffer.unicode.get_case_data().toLowerStr(allocator, cut_text) catch return error.Stop; + const ucased = Buffer.unicode.get_letter_casing().toLowerStr(allocator, cut_text) catch return error.Stop; defer allocator.free(ucased); root = try self.delete_selection(root, cursel, allocator); root = self.insert(root, cursel, ucased, allocator) catch return error.Stop; @@ -5732,13 +5732,13 @@ pub const Editor = struct { result: *std.ArrayListUnmanaged(u8), allocator: std.mem.Allocator, - const Error = @typeInfo(@typeInfo(@TypeOf(Buffer.unicode.CaseData.toUpperStr)).@"fn".return_type.?).error_union.error_set; + const Error = @typeInfo(@typeInfo(@TypeOf(Buffer.unicode.LetterCasing.toUpperStr)).@"fn".return_type.?).error_union.error_set; pub fn write(writer: *@This(), bytes: []const u8) Error!void { - const cd = Buffer.unicode.get_case_data(); - const flipped = if (cd.isLowerStr(bytes)) - try cd.toUpperStr(writer.self_.allocator, bytes) + const letter_casing = Buffer.unicode.get_letter_casing(); + const flipped = if (letter_casing.isLowerStr(bytes)) + try letter_casing.toUpperStr(writer.self_.allocator, bytes) else - try cd.toLowerStr(writer.self_.allocator, bytes); + try letter_casing.toLowerStr(writer.self_.allocator, bytes); defer writer.self_.allocator.free(flipped); return writer.result.appendSlice(writer.allocator, flipped); }