summaryrefslogtreecommitdiff
path: root/src/display_width.zig
diff options
context:
space:
mode:
authorGravatar Jose Colon Rodriguez2024-02-18 11:14:43 -0400
committerGravatar Jose Colon Rodriguez2024-02-18 11:14:43 -0400
commit6c7da0b526959840240177c0defb680e76fecad6 (patch)
tree78c426747ebd23f1e0034798f29c37d1a5893826 /src/display_width.zig
parentRename to zg (diff)
downloadzg-6c7da0b526959840240177c0defb680e76fecad6.tar.gz
zg-6c7da0b526959840240177c0defb680e76fecad6.tar.xz
zg-6c7da0b526959840240177c0defb680e76fecad6.zip
Testing Ghostty's Utf8Decoder. A bit slower
Diffstat (limited to 'src/display_width.zig')
-rw-r--r--src/display_width.zig7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/display_width.zig b/src/display_width.zig
index 7f39566..71483ca 100644
--- a/src/display_width.zig
+++ b/src/display_width.zig
@@ -52,18 +52,17 @@ pub fn strWidth(str: []const u8) usize {
52 var giter = GraphemeIterator.init(str); 52 var giter = GraphemeIterator.init(str);
53 53
54 while (giter.next()) |gc| { 54 while (giter.next()) |gc| {
55 const gc_bytes = gc.bytes(str); 55 var cp_iter = CodePointIterator{ .bytes = gc.bytes(str) };
56 var cp_iter = CodePointIterator{ .bytes = gc_bytes };
57 var gc_total: isize = 0; 56 var gc_total: isize = 0;
58 57
59 while (cp_iter.next()) |cp| { 58 while (cp_iter.next()) |cp| {
60 var w = codePointWidth(cp.code(gc_bytes)); 59 var w = codePointWidth(cp.code);
61 60
62 if (w != 0) { 61 if (w != 0) {
63 // Handle text emoji sequence. 62 // Handle text emoji sequence.
64 if (cp_iter.next()) |ncp| { 63 if (cp_iter.next()) |ncp| {
65 // emoji text sequence. 64 // emoji text sequence.
66 if (ncp.code(gc_bytes) == 0xFE0E) w = 1; 65 if (ncp.code == 0xFE0E) w = 1;
67 } 66 }
68 67
69 // Only adding width of first non-zero-width code point. 68 // Only adding width of first non-zero-width code point.