terminal: add lib.zig to centralize lib target and re-exports

Previously every file in the terminal package independently imported
build_options and ../lib/main.zig, then computed the same
lib_target constant. This was repetitive and meant each file needed
both imports just to get the target.

Introduce src/terminal/lib.zig which computes the target once and
re-exports the commonly used lib types (Enum, TaggedUnion, Struct,
String, checkGhosttyHEnum, structSizedFieldFits). All terminal
package files now import lib.zig and use lib.target instead of the
local lib_target constant, removing the per-file boilerplate.
This commit is contained in:
Mitchell Hashimoto
2026-03-25 07:22:02 -07:00
parent bebca84668
commit f50aa90ced
19 changed files with 69 additions and 78 deletions

View File

@@ -9,16 +9,13 @@ const ScreenSet = @This();
const std = @import("std");
const assert = @import("../quirks.zig").inlineAssert;
const build_options = @import("terminal_options");
const lib = @import("../lib/main.zig");
const lib = @import("lib.zig");
const testing = std.testing;
const Allocator = std.mem.Allocator;
const Screen = @import("Screen.zig");
const lib_target: lib.Target = if (build_options.c_abi) .c else .zig;
/// The possible keys for screens in the screen set.
pub const Key = lib.Enum(lib_target, &.{
pub const Key = lib.Enum(lib.target, &.{
"primary",
"alternate",
});