terminal: swap to table implementatino

This commit is contained in:
Mitchell Hashimoto
2024-02-08 21:17:30 -08:00
parent 4834b8e925
commit c838bfc1c1

View File

@ -11,6 +11,7 @@ const testing = std.testing;
const assert = std.debug.assert; const assert = std.debug.assert;
const Allocator = std.mem.Allocator; const Allocator = std.mem.Allocator;
const simd = @import("../simd/main.zig"); const simd = @import("../simd/main.zig");
const unicode = @import("../unicode/main.zig");
const ansi = @import("ansi.zig"); const ansi = @import("ansi.zig");
const modes = @import("modes.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 // Determine the width of this character so we can handle
// non-single-width characters properly. // non-single-width characters properly.
const width: usize = @intCast(simd.codepointWidth(c)); const width: usize = @intCast(unicode.table.get(c).width);
// 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,
// ));
// Note: it is possible to have a width of "3" and a width of "-1" // 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 // from ziglyph. We should look into those cases and handle them