From b2163c0a53a6276bc8e1211e9a7c9584bb1ccb2e Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 16 Nov 2026 22:46:21 -0300 Subject: width: the core measures a grapheme's cells over uucode itself, File.utf8Width beside graphemeDisplayWidth, so libvaxis leaves the core module (build.zig gives it to main.zig's roots alone, the tui's and the gui's); it is libvaxis's gwidth(.unicode) over the same uucode tables in one pass (a grapheme as wide as its widest code point, the text selector, the emoji selector, emoji presentation and a flag's pair as there), and returned the same width on every Unicode scalar value (1,112,064), 76 multi-codepoint graphemes and 2,000,000 random sequences of joiners, selectors, marks, jamo, regional indicators and any scalar, and graphemeDisplayWidth the same on 6,260,096 byte strings, invalid UTF-8 included (a test run once, then removed); 204 instructions a non-ASCII grapheme against vaxis's 309 (ReleaseFast), a render of perf's small file 11,679,818 instructions against 11,685,276; surface.zig and draw.zig's test call it; tui.zig's test holds vaxis's width to it on a corpus, as vaxis renders the cells the core lays out; the changelog says so --- src/surface.zig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/surface.zig') diff --git a/src/surface.zig b/src/surface.zig index a5dbea8e..46b6c664 100644 --- a/src/surface.zig +++ b/src/surface.zig @@ -4,7 +4,6 @@ const pardes = @import("pardes.zig"); const std = @import("std"); const layout = @import("layout.zig"); const uucode = @import("uucode"); -const vaxis = @import("vaxis"); const panes = @import("panes.zig"); const config = @import("config.zig"); const MAX_PANES = pardes.MAX_PANES; @@ -425,7 +424,7 @@ pub const Surface = struct { const width: u16 = if (decoded == null or (cp < 0x80 and cp_slice.len == 1)) 1 else - @max(1, vaxis.gwidth.gwidth(cp_slice, .unicode)); + @max(1, panes.File.utf8Width(cp_slice)); if (width == 2 and col + 1 >= end) return null; var shown = cp_slice; if (shown.len > @typeInfo(@FieldType(Cell, "text")).array.len) { -- cgit v1.3