From c838bfc1c1d59e2497c5e613a4599176eb17a3bd Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 8 Feb 2024 21:17:30 -0800 Subject: [PATCH] terminal: swap to table implementatino --- src/terminal/Terminal.zig | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index 5110a8d2a..f9f55ae83 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -11,6 +11,7 @@ const testing = std.testing; const assert = std.debug.assert; const Allocator = std.mem.Allocator; const simd = @import("../simd/main.zig"); +const unicode = @import("../unicode/main.zig"); const ansi = @import("ansi.zig"); const modes = @import("modes.zig"); @@ -870,13 +871,7 @@ pub fn print(self: *Terminal, c: u21) !void { // Determine the width of this character so we can handle // non-single-width characters properly. - const width: usize = @intCast(simd.codepointWidth(c)); - - // Old implementation, 3x slower on ASCII, 2x slower on CJK, etc. - // const width: usize = @intCast(@min( - // @max(0, ziglyph.display_width.codePointWidth(c, .half)), - // 2, - // )); + const width: usize = @intCast(unicode.table.get(c).width); // Note: it is possible to have a width of "3" and a width of "-1" // from ziglyph. We should look into those cases and handle them