Files
ghostty/src/build/uucode_config.zig
2025-09-19 01:24:13 -04:00

89 lines
2.0 KiB
Zig

const std = @import("std");
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;
data.width = @intCast(@min(2, @max(0, data.wcwidth)));
}
const width = config.Extension{
.inputs = &.{"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 == .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{
.{
.extensions = &.{wcwidth},
.fields = &.{
d.field("is_emoji_presentation"),
d.field("case_folding_full"),
d.field("is_emoji_modifier"),
d.field("is_emoji_modifier_base"),
},
},
.{
.extensions = &.{ wcwidth, width },
.fields = &.{
width.field("width"),
},
},
.{
.fields = &.{
d.field("grapheme_break"),
},
},
.{
.extensions = &.{is_symbol},
.fields = &.{
is_symbol.field("is_symbol"),
},
},
};