mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-06-07 12:24:24 +00:00
This fixes the VS16 issues found in this test: https://ucs-detect.readthedocs.io/sw_results/ghostty.html#ghostty This is also a more robust way to handle VS15/16 in general. This commit also changes our propeties to be a packed struct which reduces its size from 4 bytes to 1 and likewise drops our unicode table size 4x.
100 lines
2.5 KiB
Zig
100 lines
2.5 KiB
Zig
const std = @import("std");
|
|
const assert = std.debug.assert;
|
|
const config = @import("config.zig");
|
|
const config_x = @import("config.x.zig");
|
|
const d = config.default;
|
|
const wcwidth = config_x.wcwidth;
|
|
|
|
const Allocator = std.mem.Allocator;
|
|
|
|
fn computeWidth(
|
|
alloc: std.mem.Allocator,
|
|
cp: u21,
|
|
data: anytype,
|
|
backing: anytype,
|
|
tracking: anytype,
|
|
) Allocator.Error!void {
|
|
_ = alloc;
|
|
_ = cp;
|
|
_ = backing;
|
|
_ = tracking;
|
|
|
|
// Emoji modifiers are technically width 0 because they're joining
|
|
// points. But we handle joining via grapheme break and don't use width
|
|
// there. If a emoji modifier is standalone, we want it to take up
|
|
// two columns.
|
|
if (data.is_emoji_modifier) {
|
|
assert(data.wcwidth == 0);
|
|
data.wcwidth = 2;
|
|
return;
|
|
}
|
|
|
|
data.width = @intCast(@min(2, @max(0, data.wcwidth)));
|
|
}
|
|
|
|
const width = config.Extension{
|
|
.inputs = &.{
|
|
"is_emoji_modifier",
|
|
"wcwidth",
|
|
},
|
|
.compute = &computeWidth,
|
|
.fields = &.{
|
|
.{ .name = "width", .type = u2 },
|
|
},
|
|
};
|
|
|
|
fn computeIsSymbol(
|
|
alloc: Allocator,
|
|
cp: u21,
|
|
data: anytype,
|
|
backing: anytype,
|
|
tracking: anytype,
|
|
) Allocator.Error!void {
|
|
_ = alloc;
|
|
_ = cp;
|
|
_ = backing;
|
|
_ = tracking;
|
|
const block = data.block;
|
|
data.is_symbol = data.general_category == .other_private_use or
|
|
block == .arrows or
|
|
block == .dingbats or
|
|
block == .emoticons or
|
|
block == .miscellaneous_symbols or
|
|
block == .enclosed_alphanumerics or
|
|
block == .enclosed_alphanumeric_supplement or
|
|
block == .miscellaneous_symbols_and_pictographs or
|
|
block == .transport_and_map_symbols;
|
|
}
|
|
|
|
const is_symbol = config.Extension{
|
|
.inputs = &.{ "block", "general_category" },
|
|
.compute = &computeIsSymbol,
|
|
.fields = &.{
|
|
.{ .name = "is_symbol", .type = bool },
|
|
},
|
|
};
|
|
|
|
pub const tables = [_]config.Table{
|
|
.{
|
|
.name = "runtime",
|
|
.extensions = &.{},
|
|
.fields = &.{
|
|
d.field("is_emoji_presentation"),
|
|
d.field("case_folding_full"),
|
|
},
|
|
},
|
|
.{
|
|
.name = "buildtime",
|
|
.extensions = &.{ wcwidth, width, is_symbol },
|
|
.fields = &.{
|
|
width.field("width"),
|
|
d.field("grapheme_break"),
|
|
is_symbol.field("is_symbol"),
|
|
d.field("is_emoji_modifier"),
|
|
d.field("is_emoji_modifier_base"),
|
|
d.field("is_emoji_vs_text"),
|
|
d.field("is_emoji_vs_emoji"),
|
|
},
|
|
},
|
|
};
|