mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-31 22:07:33 +03:00
partial changes. forgot about the stash
This commit is contained in:
@ -42,8 +42,8 @@
|
||||
.lazy = true,
|
||||
},
|
||||
.zg = .{
|
||||
.url = "https://codeberg.org/jacobsandlund/zg/archive/1ff1fc206db017444e80db4ccfc24378c16735e0.tar.gz",
|
||||
.hash = "zg-0.14.0-oGqU3DAwswKPRCEJKlJpPKA8mlMb_1iX6vFqK-c6BenW",
|
||||
.url = "https://codeberg.org/jacobsandlund/zg/archive/bfb71988dbef3d11e54637fa7f99a84a2c7c9d1f.tar.gz",
|
||||
.hash = "zg-0.14.0-oGqU3A-9sgKPomBsiqZsVKUayWJ2oIwolsb_6PwM7PnX",
|
||||
.lazy = true,
|
||||
},
|
||||
.zig_wayland = .{
|
||||
|
@ -64,10 +64,6 @@ pub fn main() !void {
|
||||
// We want to use the c allocator because it is much faster than GPA.
|
||||
const alloc = std.heap.c_allocator;
|
||||
|
||||
// Initialize DisplayWidth for zg
|
||||
const display_width = try DisplayWidth.init(alloc);
|
||||
display_width.deinit(alloc);
|
||||
|
||||
// Parse our args
|
||||
var args: Args = .{};
|
||||
defer args.deinit();
|
||||
@ -84,7 +80,7 @@ pub fn main() !void {
|
||||
switch (args.mode) {
|
||||
.noop => try benchNoop(reader, buf),
|
||||
.wcwidth => try benchWcwidth(reader, buf),
|
||||
.zg => try benchZg(display_width, reader, buf),
|
||||
.zg => try benchZg(reader, buf),
|
||||
.simd => try benchSimd(reader, buf),
|
||||
.table => try benchTable(reader, buf),
|
||||
}
|
||||
@ -160,7 +156,6 @@ noinline fn benchTable(
|
||||
}
|
||||
|
||||
noinline fn benchZg(
|
||||
display_width: DisplayWidth,
|
||||
reader: anytype,
|
||||
buf: []u8,
|
||||
) !void {
|
||||
@ -175,7 +170,7 @@ noinline fn benchZg(
|
||||
const cp_, const consumed = d.next(c);
|
||||
assert(consumed);
|
||||
if (cp_) |cp| {
|
||||
const width = DisplayWidth.codePointWidth(display_width, cp);
|
||||
const width = DisplayWidth.codePointWidth(cp);
|
||||
|
||||
// Write the width to the buffer to avoid it being compiled away
|
||||
buf[0] = @intCast(width);
|
||||
|
@ -56,10 +56,6 @@ pub fn main() !void {
|
||||
// We want to use the c allocator because it is much faster than GPA.
|
||||
const alloc = std.heap.c_allocator;
|
||||
|
||||
// Initialize Graphemes for zg
|
||||
const graphemes = try Graphemes.init(alloc);
|
||||
graphemes.deinit(alloc);
|
||||
|
||||
// Parse our args
|
||||
var args: Args = .{};
|
||||
defer args.deinit();
|
||||
@ -75,7 +71,7 @@ pub fn main() !void {
|
||||
// Handle the modes that do not depend on terminal state first.
|
||||
switch (args.mode) {
|
||||
.noop => try benchNoop(reader, buf),
|
||||
.zg => try benchZg(&graphemes, reader, buf),
|
||||
.zg => try benchZg(reader, buf),
|
||||
.table => try benchTable(reader, buf),
|
||||
}
|
||||
}
|
||||
@ -123,7 +119,6 @@ noinline fn benchTable(
|
||||
}
|
||||
|
||||
noinline fn benchZg(
|
||||
graphemes: *const Graphemes,
|
||||
reader: anytype,
|
||||
buf: []u8,
|
||||
) !void {
|
||||
@ -140,7 +135,7 @@ noinline fn benchZg(
|
||||
const cp_, const consumed = d.next(c);
|
||||
assert(consumed);
|
||||
if (cp_) |cp2| {
|
||||
const v = Graphemes.graphemeBreak(cp1, @intCast(cp2), graphemes, &state);
|
||||
const v = Graphemes.graphemeBreak(cp1, @intCast(cp2), &state);
|
||||
buf[0] = @intCast(@intFromBool(v));
|
||||
cp1 = cp2;
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ pub const GhosttyFrameData = @import("GhosttyFrameData.zig");
|
||||
pub const GhosttyLib = @import("GhosttyLib.zig");
|
||||
pub const GhosttyResources = @import("GhosttyResources.zig");
|
||||
pub const GhosttyI18n = @import("GhosttyI18n.zig");
|
||||
pub const GhosttyUnicodeTest = @import("GhosttyUnicodeTest.zig");
|
||||
pub const GhosttyXcodebuild = @import("GhosttyXcodebuild.zig");
|
||||
pub const GhosttyXCFramework = @import("GhosttyXCFramework.zig");
|
||||
pub const GhosttyWebdata = @import("GhosttyWebdata.zig");
|
||||
pub const HelpStrings = @import("HelpStrings.zig");
|
||||
|
@ -16,6 +16,7 @@ const build_config = @import("../build_config.zig");
|
||||
const assert = std.debug.assert;
|
||||
const Allocator = std.mem.Allocator;
|
||||
const ArenaAllocator = std.heap.ArenaAllocator;
|
||||
const global_state = &@import("../global.zig").state;
|
||||
const fontpkg = @import("../font/main.zig");
|
||||
const inputpkg = @import("../input.zig");
|
||||
const terminal = @import("../terminal/main.zig");
|
||||
@ -5991,8 +5992,6 @@ pub const Keybinds = struct {
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var set: Keybinds = .{};
|
||||
try set.parseCLI(alloc, "shift+a=copy_to_clipboard");
|
||||
@ -6007,8 +6006,6 @@ pub const Keybinds = struct {
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var list: Keybinds = .{};
|
||||
try list.parseCLI(alloc, "shift+a=csi:hello");
|
||||
@ -6025,8 +6022,6 @@ pub const Keybinds = struct {
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var list: Keybinds = .{};
|
||||
try list.parseCLI(alloc, "ctrl+z>1=goto_tab:1");
|
||||
@ -6051,8 +6046,6 @@ pub const Keybinds = struct {
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var list: Keybinds = .{};
|
||||
try list.parseCLI(alloc, "ctrl+a>ctrl+b>n=new_window");
|
||||
@ -6264,8 +6257,6 @@ pub const RepeatableCodepointMap = struct {
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var list: Self = .{};
|
||||
try list.parseCLI(alloc, "U+ABCD=Comic Sans");
|
||||
@ -6303,8 +6294,6 @@ pub const RepeatableCodepointMap = struct {
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var list: Self = .{};
|
||||
try list.parseCLI(alloc, "U+ABCD=Comic Sans");
|
||||
@ -6320,8 +6309,6 @@ pub const RepeatableCodepointMap = struct {
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var list: Self = .{};
|
||||
try list.parseCLI(alloc, "U+0001 - U+0005=Verdana");
|
||||
@ -6337,8 +6324,6 @@ pub const RepeatableCodepointMap = struct {
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var list: Self = .{};
|
||||
try list.parseCLI(alloc, "U+0006-U+0009, U+ABCD=Courier");
|
||||
@ -6417,8 +6402,6 @@ pub const FontStyle = union(enum) {
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var p: Self = .{ .default = {} };
|
||||
try p.parseCLI(alloc, "default");
|
||||
@ -6439,8 +6422,6 @@ pub const FontStyle = union(enum) {
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var p: Self = .{ .default = {} };
|
||||
try p.parseCLI(alloc, "default");
|
||||
@ -6456,8 +6437,6 @@ pub const FontStyle = union(enum) {
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var p: Self = .{ .default = {} };
|
||||
try p.parseCLI(alloc, "false");
|
||||
@ -6473,8 +6452,6 @@ pub const FontStyle = union(enum) {
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var p: Self = .{ .default = {} };
|
||||
try p.parseCLI(alloc, "bold");
|
||||
@ -6652,8 +6629,6 @@ pub const RepeatableCommand = struct {
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var list: RepeatableCommand = .{};
|
||||
try list.parseCLI(alloc, "title:Foo,action:ignore");
|
||||
@ -6707,8 +6682,6 @@ pub const RepeatableCommand = struct {
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var list: RepeatableCommand = .{};
|
||||
try list.parseCLI(alloc, "title:Bobr, action:text:Bober");
|
||||
@ -6724,8 +6697,6 @@ pub const RepeatableCommand = struct {
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var list: RepeatableCommand = .{};
|
||||
try list.parseCLI(alloc, "title:Bobr, action:text:kurwa");
|
||||
@ -7444,8 +7415,6 @@ pub const Theme = struct {
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
// Single
|
||||
{
|
||||
@ -7863,8 +7832,6 @@ const TestIterator = struct {
|
||||
|
||||
test "parse hook: invalid command" {
|
||||
const testing = std.testing;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
var cfg = try Config.default(testing.allocator);
|
||||
defer cfg.deinit();
|
||||
const alloc = cfg._arena.?.allocator();
|
||||
@ -7876,8 +7843,6 @@ test "parse hook: invalid command" {
|
||||
|
||||
test "parse e: command only" {
|
||||
const testing = std.testing;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
var cfg = try Config.default(testing.allocator);
|
||||
defer cfg.deinit();
|
||||
const alloc = cfg._arena.?.allocator();
|
||||
@ -7893,8 +7858,6 @@ test "parse e: command only" {
|
||||
|
||||
test "parse e: command and args" {
|
||||
const testing = std.testing;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
var cfg = try Config.default(testing.allocator);
|
||||
defer cfg.deinit();
|
||||
const alloc = cfg._arena.?.allocator();
|
||||
@ -7913,8 +7876,6 @@ test "parse e: command and args" {
|
||||
test "clone default" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var source = try Config.default(alloc);
|
||||
defer source.deinit();
|
||||
@ -7932,8 +7893,6 @@ test "clone default" {
|
||||
test "clone preserves conditional state" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var a = try Config.default(alloc);
|
||||
defer a.deinit();
|
||||
@ -7962,8 +7921,6 @@ test "clone can then change conditional state" {
|
||||
var arena = ArenaAllocator.init(alloc);
|
||||
defer arena.deinit();
|
||||
const alloc_arena = arena.allocator();
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
// Setup our test theme
|
||||
var td = try internal_os.TempDir.init();
|
||||
@ -8024,8 +7981,6 @@ test "clone can then change conditional state" {
|
||||
test "clone preserves conditional set" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var cfg = try Config.default(alloc);
|
||||
defer cfg.deinit();
|
||||
@ -8045,8 +8000,6 @@ test "clone preserves conditional set" {
|
||||
test "changed" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var source = try Config.default(alloc);
|
||||
defer source.deinit();
|
||||
@ -8061,8 +8014,6 @@ test "changed" {
|
||||
test "changeConditionalState ignores irrelevant changes" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
{
|
||||
var cfg = try Config.default(alloc);
|
||||
@ -8082,8 +8033,6 @@ test "changeConditionalState ignores irrelevant changes" {
|
||||
test "changeConditionalState applies relevant changes" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
{
|
||||
var cfg = try Config.default(alloc);
|
||||
@ -8106,8 +8055,6 @@ test "theme loading" {
|
||||
var arena = ArenaAllocator.init(alloc);
|
||||
defer arena.deinit();
|
||||
const alloc_arena = arena.allocator();
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
// Setup our test theme
|
||||
var td = try internal_os.TempDir.init();
|
||||
@ -8144,8 +8091,6 @@ test "theme loading preserves conditional state" {
|
||||
var arena = ArenaAllocator.init(alloc);
|
||||
defer arena.deinit();
|
||||
const alloc_arena = arena.allocator();
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
// Setup our test theme
|
||||
var td = try internal_os.TempDir.init();
|
||||
@ -8176,8 +8121,6 @@ test "theme priority is lower than config" {
|
||||
var arena = ArenaAllocator.init(alloc);
|
||||
defer arena.deinit();
|
||||
const alloc_arena = arena.allocator();
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
// Setup our test theme
|
||||
var td = try internal_os.TempDir.init();
|
||||
@ -8212,8 +8155,6 @@ test "theme loading correct light/dark" {
|
||||
var arena = ArenaAllocator.init(alloc);
|
||||
defer arena.deinit();
|
||||
const alloc_arena = arena.allocator();
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
// Setup our test theme
|
||||
var td = try internal_os.TempDir.init();
|
||||
@ -8303,8 +8244,6 @@ test "theme loading correct light/dark" {
|
||||
test "theme specifying light/dark changes window-theme from auto" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
{
|
||||
var cfg = try Config.default(alloc);
|
||||
@ -8323,8 +8262,6 @@ test "theme specifying light/dark changes window-theme from auto" {
|
||||
test "theme specifying light/dark sets theme usage in conditional state" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
{
|
||||
var cfg = try Config.default(alloc);
|
||||
|
@ -121,8 +121,6 @@ fn fieldByKey(self: *const Config, comptime k: Key) Value(k) {
|
||||
test "c_get: u8" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var c = try Config.default(alloc);
|
||||
defer c.deinit();
|
||||
@ -136,8 +134,6 @@ test "c_get: u8" {
|
||||
test "c_get: enum" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var c = try Config.default(alloc);
|
||||
defer c.deinit();
|
||||
@ -153,8 +149,6 @@ test "c_get: enum" {
|
||||
test "c_get: color" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var c = try Config.default(alloc);
|
||||
defer c.deinit();
|
||||
@ -170,8 +164,6 @@ test "c_get: color" {
|
||||
test "c_get: optional" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var c = try Config.default(alloc);
|
||||
defer c.deinit();
|
||||
@ -195,8 +187,6 @@ test "c_get: optional" {
|
||||
test "c_get: background-blur" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var c = try Config.default(alloc);
|
||||
defer c.deinit();
|
||||
|
@ -193,8 +193,6 @@ pub const FileFormatter = struct {
|
||||
test "format default config" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
var cfg = try Config.default(alloc);
|
||||
defer cfg.deinit();
|
||||
|
||||
@ -214,8 +212,6 @@ test "format default config" {
|
||||
test "format default config changed" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
var cfg = try Config.default(alloc);
|
||||
defer cfg.deinit();
|
||||
cfg.@"font-size" = 42;
|
||||
|
@ -15,7 +15,6 @@ const std = @import("std");
|
||||
const Allocator = std.mem.Allocator;
|
||||
const Emoji = @import("Emoji");
|
||||
const font = @import("main.zig");
|
||||
const zg = &@import("../global.zig").state.zg;
|
||||
const Atlas = font.Atlas;
|
||||
const CodepointMap = font.CodepointMap;
|
||||
const Collection = font.Collection;
|
||||
@ -151,7 +150,7 @@ pub fn getIndex(
|
||||
// we'll do this multiple times if we recurse, but this is a cached function
|
||||
// call higher up (GroupCache) so this should be rare.
|
||||
const p_mode: Collection.PresentationMode = if (p) |v| .{ .explicit = v } else .{
|
||||
.default = if (Emoji.isEmojiPresentation(zg.emoji, @intCast(cp)))
|
||||
.default = if (Emoji.isEmojiPresentation(@intCast(cp)))
|
||||
.emoji
|
||||
else
|
||||
.text,
|
||||
@ -380,8 +379,6 @@ test getIndex {
|
||||
const testFont = font.embedded.regular;
|
||||
const testEmoji = font.embedded.emoji;
|
||||
const testEmojiText = font.embedded.emoji_text;
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var lib = try Library.init(alloc);
|
||||
defer lib.deinit();
|
||||
@ -460,8 +457,6 @@ test "getIndex disabled font style" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const testFont = font.embedded.regular;
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var atlas_grayscale = try font.Atlas.init(alloc, 512, .grayscale);
|
||||
defer atlas_grayscale.deinit(alloc);
|
||||
@ -517,8 +512,6 @@ test "getIndex disabled font style" {
|
||||
test "getIndex box glyph" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var lib = try Library.init(alloc);
|
||||
defer lib.deinit();
|
||||
|
@ -393,8 +393,6 @@ fn testGrid(mode: TestMode, alloc: Allocator, lib: Library) !SharedGrid {
|
||||
test getIndex {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
// const testEmoji = @import("test.zig").fontEmoji;
|
||||
|
||||
var lib = try Library.init(alloc);
|
||||
|
@ -711,8 +711,6 @@ pub const Key = struct {
|
||||
test "Key" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
var cfg = try Config.default(alloc);
|
||||
defer cfg.deinit();
|
||||
|
||||
@ -732,8 +730,6 @@ test "Key" {
|
||||
test "Key different font points" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
var cfg = try Config.default(alloc);
|
||||
defer cfg.deinit();
|
||||
|
||||
@ -752,8 +748,6 @@ test "Key different font points" {
|
||||
test "Key different font DPI" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
var cfg = try Config.default(alloc);
|
||||
defer cfg.deinit();
|
||||
|
||||
@ -772,8 +766,6 @@ test "Key different font DPI" {
|
||||
test SharedGridSet {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var set = try SharedGridSet.init(alloc);
|
||||
defer set.deinit();
|
||||
|
@ -576,8 +576,6 @@ pub const Shaper = struct {
|
||||
test "run iterator" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var testdata = try testShaper(alloc);
|
||||
defer testdata.deinit();
|
||||
@ -658,8 +656,6 @@ test "run iterator" {
|
||||
test "run iterator: empty cells with background set" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var testdata = try testShaper(alloc);
|
||||
defer testdata.deinit();
|
||||
@ -708,8 +704,6 @@ test "run iterator: empty cells with background set" {
|
||||
test "shape" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var testdata = try testShaper(alloc);
|
||||
defer testdata.deinit();
|
||||
@ -743,8 +737,6 @@ test "shape" {
|
||||
test "shape nerd fonts" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var testdata = try testShaperWithFont(alloc, .nerd_font);
|
||||
defer testdata.deinit();
|
||||
@ -778,8 +770,6 @@ test "shape nerd fonts" {
|
||||
test "shape inconsolata ligs" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var testdata = try testShaper(alloc);
|
||||
defer testdata.deinit();
|
||||
@ -834,8 +824,6 @@ test "shape inconsolata ligs" {
|
||||
test "shape monaspace ligs" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var testdata = try testShaperWithFont(alloc, .monaspace_neon);
|
||||
defer testdata.deinit();
|
||||
@ -868,8 +856,6 @@ test "shape monaspace ligs" {
|
||||
test "shape left-replaced lig in last run" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var testdata = try testShaperWithFont(alloc, .geist_mono);
|
||||
defer testdata.deinit();
|
||||
@ -902,8 +888,6 @@ test "shape left-replaced lig in last run" {
|
||||
test "shape left-replaced lig in early run" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var testdata = try testShaperWithFont(alloc, .geist_mono);
|
||||
defer testdata.deinit();
|
||||
@ -933,8 +917,6 @@ test "shape left-replaced lig in early run" {
|
||||
test "shape U+3C9 with JB Mono" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var testdata = try testShaperWithFont(alloc, .jetbrains_mono);
|
||||
defer testdata.deinit();
|
||||
@ -966,8 +948,6 @@ test "shape U+3C9 with JB Mono" {
|
||||
test "shape emoji width" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var testdata = try testShaper(alloc);
|
||||
defer testdata.deinit();
|
||||
@ -997,8 +977,6 @@ test "shape emoji width" {
|
||||
test "shape emoji width long" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var testdata = try testShaper(alloc);
|
||||
defer testdata.deinit();
|
||||
@ -1046,8 +1024,6 @@ test "shape emoji width long" {
|
||||
test "shape variation selector VS15" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var testdata = try testShaper(alloc);
|
||||
defer testdata.deinit();
|
||||
@ -1081,8 +1057,6 @@ test "shape variation selector VS15" {
|
||||
test "shape variation selector VS16" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var testdata = try testShaper(alloc);
|
||||
defer testdata.deinit();
|
||||
@ -1116,8 +1090,6 @@ test "shape variation selector VS16" {
|
||||
test "shape with empty cells in between" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var testdata = try testShaper(alloc);
|
||||
defer testdata.deinit();
|
||||
@ -1149,8 +1121,6 @@ test "shape with empty cells in between" {
|
||||
test "shape Chinese characters" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var testdata = try testShaper(alloc);
|
||||
defer testdata.deinit();
|
||||
@ -1191,8 +1161,6 @@ test "shape Chinese characters" {
|
||||
test "shape box glyphs" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var testdata = try testShaper(alloc);
|
||||
defer testdata.deinit();
|
||||
@ -1230,8 +1198,6 @@ test "shape box glyphs" {
|
||||
test "shape selection boundary" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var testdata = try testShaper(alloc);
|
||||
defer testdata.deinit();
|
||||
@ -1355,8 +1321,6 @@ test "shape selection boundary" {
|
||||
test "shape cursor boundary" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var testdata = try testShaper(alloc);
|
||||
defer testdata.deinit();
|
||||
@ -1494,8 +1458,6 @@ test "shape cursor boundary" {
|
||||
test "shape cursor boundary and colored emoji" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var testdata = try testShaper(alloc);
|
||||
defer testdata.deinit();
|
||||
@ -1590,8 +1552,6 @@ test "shape cursor boundary and colored emoji" {
|
||||
test "shape cell attribute change" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var testdata = try testShaper(alloc);
|
||||
defer testdata.deinit();
|
||||
@ -1720,8 +1680,6 @@ test "shape high plane sprite font codepoint" {
|
||||
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
const zg = try @import("../../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var testdata = try testShaper(alloc);
|
||||
defer testdata.deinit();
|
||||
|
@ -1,7 +1,6 @@
|
||||
const std = @import("std");
|
||||
const assert = std.debug.assert;
|
||||
const Allocator = std.mem.Allocator;
|
||||
const Graphemes = @import("Graphemes");
|
||||
const font = @import("../main.zig");
|
||||
const terminal = @import("../../terminal/main.zig");
|
||||
const unicode = @import("../../unicode/main.zig");
|
||||
|
@ -10,11 +10,6 @@ const oni = @import("oniguruma");
|
||||
const crash = @import("crash/main.zig");
|
||||
const renderer = @import("renderer.zig");
|
||||
const apprt = @import("apprt.zig");
|
||||
const CaseFolding = @import("CaseFolding");
|
||||
const Emoji = @import("Emoji");
|
||||
const GeneralCategories = @import("GeneralCategories");
|
||||
const LetterCasing = @import("LetterCasing");
|
||||
const unicode = @import("unicode/main.zig");
|
||||
|
||||
/// We export the xev backend we want to use so that the rest of
|
||||
/// Ghostty can import this once and have access to the proper
|
||||
@ -38,7 +33,6 @@ pub const GlobalState = struct {
|
||||
action: ?cli.Action,
|
||||
logging: Logging,
|
||||
rlimits: ResourceLimits = .{},
|
||||
zg: Zg,
|
||||
|
||||
/// The app resources directory, equivalent to zig-out/share when we build
|
||||
/// from source. This is null if we can't detect it.
|
||||
@ -70,7 +64,6 @@ pub const GlobalState = struct {
|
||||
.logging = .{ .stderr = {} },
|
||||
.rlimits = .{},
|
||||
.resources_dir = .{},
|
||||
.zg = undefined,
|
||||
};
|
||||
errdefer self.deinit();
|
||||
|
||||
@ -157,8 +150,6 @@ pub const GlobalState = struct {
|
||||
);
|
||||
};
|
||||
|
||||
self.zg = try Zg.init(self.alloc);
|
||||
|
||||
// const sentrylib = @import("sentry");
|
||||
// if (sentrylib.captureEvent(sentrylib.Value.initMessageEvent(
|
||||
// .info,
|
||||
@ -197,8 +188,6 @@ pub const GlobalState = struct {
|
||||
// Flush our crash logs
|
||||
crash.deinit();
|
||||
|
||||
self.zg.deinit(self.alloc);
|
||||
|
||||
if (self.gpa) |*value| {
|
||||
// We want to ensure that we deinit the GPA because this is
|
||||
// the point at which it will output if there were safety violations.
|
||||
@ -227,39 +216,6 @@ pub const GlobalState = struct {
|
||||
}
|
||||
};
|
||||
|
||||
pub const Zg = struct {
|
||||
case_folding: CaseFolding,
|
||||
emoji: Emoji,
|
||||
general_categories: GeneralCategories,
|
||||
letter_casing: LetterCasing,
|
||||
|
||||
pub fn init(alloc: std.mem.Allocator) !Zg {
|
||||
return .{
|
||||
.case_folding = try CaseFolding.init(alloc),
|
||||
.emoji = try Emoji.init(alloc),
|
||||
.general_categories = try GeneralCategories.init(alloc),
|
||||
.letter_casing = try LetterCasing.init(alloc),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn deinit(self: *Zg, alloc: std.mem.Allocator) void {
|
||||
self.case_folding.deinit(alloc);
|
||||
self.emoji.deinit(alloc);
|
||||
self.general_categories.deinit(alloc);
|
||||
self.letter_casing.deinit(alloc);
|
||||
}
|
||||
|
||||
pub fn initForTesting() !*Zg {
|
||||
const zg = &state.zg;
|
||||
zg.* = try Zg.init(std.testing.allocator);
|
||||
return zg;
|
||||
}
|
||||
|
||||
pub fn deinitForTesting(self: *Zg) void {
|
||||
self.deinit(std.testing.allocator);
|
||||
}
|
||||
};
|
||||
|
||||
/// Maintains the Unix resource limits that we set for our process. This
|
||||
/// can be used to restore the limits to their original values.
|
||||
pub const ResourceLimits = struct {
|
||||
|
@ -9,7 +9,6 @@ const LetterCasing = @import("LetterCasing");
|
||||
const CaseFolding = @import("CaseFolding");
|
||||
const key = @import("key.zig");
|
||||
const KeyEvent = key.KeyEvent;
|
||||
const zg = &@import("../global.zig").state.zg;
|
||||
|
||||
/// The trigger that needs to be performed to execute the action.
|
||||
trigger: Trigger,
|
||||
@ -1566,7 +1565,7 @@ pub const Trigger = struct {
|
||||
fn foldedCodepoint(cp: u21) [3]u21 {
|
||||
// ASCII fast path
|
||||
if (('A' <= cp and cp <= 'Z') or ('a' <= cp and cp <= 'z')) {
|
||||
return .{ LetterCasing.toLower(zg.letter_casing, cp), 0, 0 };
|
||||
return .{ LetterCasing.toLower(cp), 0, 0 };
|
||||
}
|
||||
|
||||
// Unicode slow path. Case folding can result in more codepoints.
|
||||
@ -1574,7 +1573,7 @@ pub const Trigger = struct {
|
||||
// as-is which isn't correct but until we have a failing test
|
||||
// then I don't want to handle this.
|
||||
var buf: [3]u21 = .{ 0, 0, 0 };
|
||||
_ = CaseFolding.caseFold(&zg.case_folding, cp, &buf);
|
||||
_ = CaseFolding.caseFold(cp, &buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@ -2628,8 +2627,6 @@ test "parse: sequences" {
|
||||
test "set: parseAndPut typical binding" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var s: Set = .{};
|
||||
defer s.deinit(alloc);
|
||||
@ -2653,8 +2650,6 @@ test "set: parseAndPut typical binding" {
|
||||
test "set: parseAndPut unconsumed binding" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var s: Set = .{};
|
||||
defer s.deinit(alloc);
|
||||
@ -2679,8 +2674,6 @@ test "set: parseAndPut unconsumed binding" {
|
||||
test "set: parseAndPut removed binding" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var s: Set = .{};
|
||||
defer s.deinit(alloc);
|
||||
@ -2699,8 +2692,6 @@ test "set: parseAndPut removed binding" {
|
||||
test "set: parseAndPut sequence" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var s: Set = .{};
|
||||
defer s.deinit(alloc);
|
||||
@ -2725,8 +2716,6 @@ test "set: parseAndPut sequence" {
|
||||
test "set: parseAndPut sequence with two actions" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var s: Set = .{};
|
||||
defer s.deinit(alloc);
|
||||
@ -2759,8 +2748,6 @@ test "set: parseAndPut sequence with two actions" {
|
||||
test "set: parseAndPut overwrite sequence" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var s: Set = .{};
|
||||
defer s.deinit(alloc);
|
||||
@ -2786,8 +2773,6 @@ test "set: parseAndPut overwrite sequence" {
|
||||
test "set: parseAndPut overwrite leader" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var s: Set = .{};
|
||||
defer s.deinit(alloc);
|
||||
@ -2813,8 +2798,6 @@ test "set: parseAndPut overwrite leader" {
|
||||
test "set: parseAndPut unbind sequence unbinds leader" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var s: Set = .{};
|
||||
defer s.deinit(alloc);
|
||||
@ -2831,8 +2814,6 @@ test "set: parseAndPut unbind sequence unbinds leader" {
|
||||
test "set: parseAndPut unbind sequence unbinds leader if not set" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var s: Set = .{};
|
||||
defer s.deinit(alloc);
|
||||
@ -2848,8 +2829,6 @@ test "set: parseAndPut unbind sequence unbinds leader if not set" {
|
||||
test "set: parseAndPut sequence preserves reverse mapping" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var s: Set = .{};
|
||||
defer s.deinit(alloc);
|
||||
@ -2867,8 +2846,6 @@ test "set: parseAndPut sequence preserves reverse mapping" {
|
||||
test "set: put overwrites sequence" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var s: Set = .{};
|
||||
defer s.deinit(alloc);
|
||||
@ -2889,8 +2866,6 @@ test "set: put overwrites sequence" {
|
||||
test "set: maintains reverse mapping" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var s: Set = .{};
|
||||
defer s.deinit(alloc);
|
||||
@ -2919,8 +2894,6 @@ test "set: maintains reverse mapping" {
|
||||
test "set: performable is not part of reverse mappings" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var s: Set = .{};
|
||||
defer s.deinit(alloc);
|
||||
@ -2954,8 +2927,6 @@ test "set: performable is not part of reverse mappings" {
|
||||
test "set: overriding a mapping updates reverse" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var s: Set = .{};
|
||||
defer s.deinit(alloc);
|
||||
@ -2977,8 +2948,6 @@ test "set: overriding a mapping updates reverse" {
|
||||
test "set: consumed state" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var s: Set = .{};
|
||||
defer s.deinit(alloc);
|
||||
@ -3004,8 +2973,6 @@ test "set: consumed state" {
|
||||
test "set: getEvent physical" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var s: Set = .{};
|
||||
defer s.deinit(alloc);
|
||||
@ -3036,8 +3003,6 @@ test "set: getEvent physical" {
|
||||
test "set: getEvent codepoint" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var s: Set = .{};
|
||||
defer s.deinit(alloc);
|
||||
@ -3078,8 +3043,6 @@ test "set: getEvent codepoint" {
|
||||
test "set: getEvent codepoint case folding" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
var s: Set = .{};
|
||||
defer s.deinit(alloc);
|
||||
@ -3123,8 +3086,6 @@ test "Action: clone" {
|
||||
var arena = std.heap.ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
_ = try @import("../global.zig").Zg.initForTesting();
|
||||
defer zg.deinitForTesting();
|
||||
|
||||
{
|
||||
var a: Action = .ignore;
|
||||
|
@ -224,9 +224,9 @@ pub fn constraintWidth(cell_pin: terminal.Pin) u2 {
|
||||
const cell = cell_pin.rowAndCell().cell;
|
||||
const cp = cell.codepoint();
|
||||
|
||||
if (!ziglyph.general_category.isPrivateUse(cp) and
|
||||
!ziglyph.blocks.isDingbats(cp))
|
||||
{
|
||||
// If it's not Private Use (Co) or Dingbats (0x2700-0x27bf), use grid
|
||||
// width.
|
||||
if (GeneralCategories.gc(cp) != .Co and !(cp >= 0x2700 and cp <= 0x27bf)) {
|
||||
return cell.gridWidth();
|
||||
}
|
||||
|
||||
|
@ -8,10 +8,6 @@ pub const Properties = props.Properties;
|
||||
pub const graphemeBreak = grapheme.graphemeBreak;
|
||||
pub const GraphemeBreakState = grapheme.BreakState;
|
||||
|
||||
test {
|
||||
@import("std").testing.refAllDecls(@This());
|
||||
}
|
||||
|
||||
/// Build Ghostty with `zig build -Doptimize=ReleaseFast -Demit-unicode-test`.
|
||||
///
|
||||
/// Usage: ./zig-out/bin/unicode-test [width|class|break|all] [old|zg|ziglyph|all]
|
||||
@ -41,9 +37,6 @@ pub fn main() !void {
|
||||
const args = try std.process.argsAlloc(alloc);
|
||||
defer std.process.argsFree(alloc, args);
|
||||
|
||||
var zg = try props.Context.init(alloc);
|
||||
defer zg.deinit(alloc);
|
||||
|
||||
const ziglyph = @import("ziglyph");
|
||||
const Graphemes = @import("Graphemes");
|
||||
const DisplayWidth = @import("DisplayWidth");
|
||||
@ -74,14 +67,14 @@ pub fn main() !void {
|
||||
}
|
||||
|
||||
if (compareZg) {
|
||||
const zg_width = @min(2, @max(0, DisplayWidth.codePointWidth(zg.display_width, @intCast(cp))));
|
||||
const zg_width = @min(2, @max(0, DisplayWidth.codePointWidth(@intCast(cp))));
|
||||
if (t.width != zg_width) {
|
||||
std.log.warn("[zg mismatch] cp={x} t={} zg={}", .{ cp, t.width, zg_width });
|
||||
}
|
||||
}
|
||||
|
||||
if (compareZiglyph) {
|
||||
const ziglyph_width = @min(2, @max(0, DisplayWidth.codePointWidth(zg.display_width, @intCast(cp))));
|
||||
const ziglyph_width = @min(2, @max(0, DisplayWidth.codePointWidth(@intCast(cp))));
|
||||
if (t.width != ziglyph_width) {
|
||||
std.log.warn("[ziglyph mismatch] cp={x} t={} zg={}", .{ cp, t.width, ziglyph_width });
|
||||
}
|
||||
@ -105,7 +98,7 @@ pub fn main() !void {
|
||||
}
|
||||
|
||||
if (compareZg) {
|
||||
const gbp = Graphemes.gbp(zg.graphemes, @intCast(cp));
|
||||
const gbp = Graphemes.gbp(@intCast(cp));
|
||||
const matches = switch (t.grapheme_boundary_class) {
|
||||
.extended_pictographic_base => gbp == .Emoji_Modifier_Base,
|
||||
.emoji_modifier => gbp == .Emoji_Modifier,
|
||||
@ -179,11 +172,11 @@ pub fn main() !void {
|
||||
if (cp1 % 0x100 == 0) std.log.info("progress: cp1={x}", .{cp1});
|
||||
|
||||
if (cp1 == '\r' or cp1 == '\n' or
|
||||
Graphemes.gbp(zg.graphemes, @intCast(cp1)) == .Control) continue;
|
||||
Graphemes.gbp(@intCast(cp1)) == .Control) continue;
|
||||
|
||||
for (min..max) |cp2| {
|
||||
if (cp2 == '\r' or cp2 == '\n' or
|
||||
Graphemes.gbp(zg.graphemes, @intCast(cp1)) == .Control) continue;
|
||||
Graphemes.gbp(@intCast(cp1)) == .Control) continue;
|
||||
|
||||
const gb = graphemeBreak(@intCast(cp1), @intCast(cp2), &state);
|
||||
|
||||
@ -202,7 +195,7 @@ pub fn main() !void {
|
||||
}
|
||||
|
||||
if (compareZg) {
|
||||
const zg_gb = Graphemes.graphemeBreak(@intCast(cp1), @intCast(cp2), &zg.graphemes, &zg_state);
|
||||
const zg_gb = Graphemes.graphemeBreak(@intCast(cp1), @intCast(cp2), &zg_state);
|
||||
if (gb != zg_gb) {
|
||||
std.log.warn("[zg mismatch] cp1={x} cp2={x} gb={} zg_gb={} state={} zg_state={}", .{
|
||||
cp1,
|
||||
|
@ -1,33 +1,15 @@
|
||||
const std = @import("std");
|
||||
const assert = std.debug.assert;
|
||||
const lut = @import("lut.zig");
|
||||
const Graphemes = @import("Graphemes");
|
||||
|
||||
/// The context needed for lut generation.
|
||||
pub const Context = struct {
|
||||
graphemes: Graphemes,
|
||||
display_width: DisplayWidth,
|
||||
|
||||
// Whether to use the old implementation based on ziglyph.
|
||||
old: bool = false,
|
||||
|
||||
const Graphemes = @import("Graphemes");
|
||||
const DisplayWidth = @import("DisplayWidth");
|
||||
|
||||
// Public only for unicode-test
|
||||
pub fn init(alloc: std.mem.Allocator) !Context {
|
||||
const graphemes = try Graphemes.init(alloc);
|
||||
return .{
|
||||
.graphemes = graphemes,
|
||||
.display_width = try DisplayWidth.initWithGraphemes(alloc, graphemes),
|
||||
};
|
||||
}
|
||||
|
||||
// Public only for unicode-test
|
||||
pub fn deinit(self: *Context, alloc: std.mem.Allocator) void {
|
||||
self.graphemes.deinit(alloc);
|
||||
self.display_width.deinit(alloc);
|
||||
}
|
||||
|
||||
pub fn get(self: Context, cp: u21) !Properties {
|
||||
if (cp > 0x10FFFF) {
|
||||
return .{
|
||||
@ -35,12 +17,12 @@ pub const Context = struct {
|
||||
.grapheme_boundary_class = .invalid,
|
||||
};
|
||||
} else {
|
||||
const zg_width = DisplayWidth.codePointWidth(self.display_width, cp);
|
||||
const zg_width = DisplayWidth.codePointWidth(cp);
|
||||
|
||||
return .{
|
||||
.width = @intCast(@min(2, @max(0, zg_width))),
|
||||
//.grapheme_boundary_class = .init(self, cp),
|
||||
.grapheme_boundary_class = if (self.old) .initOld(cp) else .init(self, cp),
|
||||
.grapheme_boundary_class = if (self.old) .initOld(cp) else .init(cp),
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -137,10 +119,12 @@ pub const GraphemeBoundaryClass = enum(u4) {
|
||||
extended_pictographic_base, // \p{Extended_Pictographic} & \p{Emoji_Modifier_Base}
|
||||
emoji_modifier, // \p{Emoji_Modifier}
|
||||
|
||||
const Graphemes = @import("Graphemes");
|
||||
|
||||
/// Gets the grapheme boundary class for a codepoint. This is VERY
|
||||
/// SLOW. The use case for this is only in generating lookup tables.
|
||||
pub fn init(ctx: Context, cp: u21) GraphemeBoundaryClass {
|
||||
return switch (Graphemes.gbp(ctx.graphemes, cp)) {
|
||||
pub fn init(cp: u21) GraphemeBoundaryClass {
|
||||
return switch (Graphemes.gbp(cp)) {
|
||||
.Emoji_Modifier_Base => .extended_pictographic_base,
|
||||
.Emoji_Modifier => .emoji_modifier,
|
||||
.Extended_Pictographic => .extended_pictographic,
|
||||
@ -214,8 +198,7 @@ pub fn main() !void {
|
||||
const args = try std.process.argsAlloc(alloc);
|
||||
defer std.process.argsFree(alloc, args);
|
||||
|
||||
var ctx = try Context.init(alloc);
|
||||
defer ctx.deinit(alloc);
|
||||
var ctx = Context{};
|
||||
|
||||
if (args.len > 1 and std.mem.eql(u8, args[1], "old")) {
|
||||
ctx.old = true;
|
||||
|
Reference in New Issue
Block a user