summaryrefslogtreecommitdiff
path: root/src/tui
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-16 22:46:21 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commitb2163c0a53a6276bc8e1211e9a7c9584bb1ccb2e (patch)
treeb24a6c5991f6d79e8baecb24f2ad50e3a8e8035d /src/tui
parentf2b02c455f2bcdfb905a015eefbb630a28b4b12e (diff)
downloadpardes-b2163c0a53a6276bc8e1211e9a7c9584bb1ccb2e.tar.gz
pardes-b2163c0a53a6276bc8e1211e9a7c9584bb1ccb2e.zip
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
Diffstat (limited to 'src/tui')
-rw-r--r--src/tui/tui.zig14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/tui/tui.zig b/src/tui/tui.zig
index 0daac14b..77c8ce2b 100644
--- a/src/tui/tui.zig
+++ b/src/tui/tui.zig
@@ -3344,3 +3344,17 @@ test "the tty draws a glide at whole rows: once a flick or a spin slows, its ste
try std.testing.expectEqual(row, (shown.cursor orelse return error.NoCursor).y);
}
}
+
+test "the tui's vaxis measures a grapheme as wide as the core lays it out" {
+ // vaxis renders a cell at gwidth(.unicode) in mode 2027; the core's
+ // File.utf8Width is that function over the same uucode tables. A vaxis
+ // that measures otherwise would draw past or short of the core's cells.
+ for ([_][]const u8{
+ "a", "\u{4e16}", "e\u{301}", "\u{301}",
+ "\u{1f642}", "\u{1f44b}\u{1f3ff}", "\u{1f469}\u{200d}\u{1f680}", "\u{1f1fa}\u{1f1f8}",
+ "\u{1f1fa}", "\u{2764}\u{fe0e}", "\u{2764}\u{fe0f}", "1\u{fe0f}\u{20e3}",
+ "\u{1100}\u{1161}", "\u{ff21}", "\u{b1}", "\u{200b}",
+ "\u{ad}", "\u{fffd}", "\u{85}", "\x7f",
+ "a\u{4e16}\u{1f642}", "\u{e0100}", "\u{231a}", "\u{2600}",
+ }) |g| try std.testing.expectEqual(vaxis.gwidth.gwidth(g, .unicode), pardes.panes.File.utf8Width(g));
+}