Lots of 0.14 changes

This commit is contained in:
Mitchell Hashimoto
2025-03-12 09:55:46 -07:00
parent 86d3f18707
commit 0f4d2bb237
67 changed files with 326 additions and 316 deletions

View File

@@ -291,7 +291,7 @@ pub const Action = union(Key) {
/// Sync with: ghostty_action_u /// Sync with: ghostty_action_u
pub const CValue = cvalue: { pub const CValue = cvalue: {
const key_fields = @typeInfo(Key).Enum.fields; const key_fields = @typeInfo(Key).@"enum".fields;
var union_fields: [key_fields.len]std.builtin.Type.UnionField = undefined; var union_fields: [key_fields.len]std.builtin.Type.UnionField = undefined;
for (key_fields, 0..) |field, i| { for (key_fields, 0..) |field, i| {
const action = @unionInit(Action, field.name, undefined); const action = @unionInit(Action, field.name, undefined);
@@ -309,7 +309,7 @@ pub const Action = union(Key) {
}; };
} }
break :cvalue @Type(.{ .Union = .{ break :cvalue @Type(.{ .@"union" = .{
.layout = .@"extern", .layout = .@"extern",
.tag_type = Key, .tag_type = Key,
.fields = &union_fields, .fields = &union_fields,
@@ -325,7 +325,7 @@ pub const Action = union(Key) {
/// Returns the value type for the given key. /// Returns the value type for the given key.
pub fn Value(comptime key: Key) type { pub fn Value(comptime key: Key) type {
inline for (@typeInfo(Action).Union.fields) |field| { inline for (@typeInfo(Action).@"union".fields) |field| {
const field_key = @field(Key, field.name); const field_key = @field(Key, field.name);
if (field_key == key) return field.type; if (field_key == key) return field.type;
} }

View File

@@ -165,7 +165,7 @@ pub const App = struct {
// then we strip the alt modifier from the mods for translation. // then we strip the alt modifier from the mods for translation.
const translate_mods = translate_mods: { const translate_mods = translate_mods: {
var translate_mods = mods; var translate_mods = mods;
if ((comptime builtin.target.isDarwin()) and translate_mods.alt) { if ((comptime builtin.target.os.tag.isDarwin()) and translate_mods.alt) {
// Note: the keyboardLayout() function is not super cheap // Note: the keyboardLayout() function is not super cheap
// so we only want to run it if alt is already pressed hence // so we only want to run it if alt is already pressed hence
// the above condition. // the above condition.
@@ -184,7 +184,7 @@ pub const App = struct {
// We strip super on macOS because its not used for translation // We strip super on macOS because its not used for translation
// it results in a bad translation. // it results in a bad translation.
if (comptime builtin.target.isDarwin()) { if (comptime builtin.target.os.tag.isDarwin()) {
translate_mods.super = false; translate_mods.super = false;
} }
@@ -538,12 +538,12 @@ pub const Platform = union(PlatformTag) {
// If our build target for libghostty is not darwin then we do // If our build target for libghostty is not darwin then we do
// not include macos support at all. // not include macos support at all.
pub const MacOS = if (builtin.target.isDarwin()) struct { pub const MacOS = if (builtin.target.os.tag.isDarwin()) struct {
/// The view to render the surface on. /// The view to render the surface on.
nsview: objc.Object, nsview: objc.Object,
} else void; } else void;
pub const IOS = if (builtin.target.isDarwin()) struct { pub const IOS = if (builtin.target.os.tag.isDarwin()) struct {
/// The view to render the surface on. /// The view to render the surface on.
uiview: objc.Object, uiview: objc.Object,
} else void; } else void;
@@ -1025,7 +1025,7 @@ pub const Surface = struct {
var env = try internal_os.getEnvMap(alloc); var env = try internal_os.getEnvMap(alloc);
errdefer env.deinit(); errdefer env.deinit();
if (comptime builtin.target.isDarwin()) { if (comptime builtin.target.os.tag.isDarwin()) {
if (env.get("__XCODE_BUILT_PRODUCTS_DIR_PATHS") != null) { if (env.get("__XCODE_BUILT_PRODUCTS_DIR_PATHS") != null) {
env.remove("__XCODE_BUILT_PRODUCTS_DIR_PATHS"); env.remove("__XCODE_BUILT_PRODUCTS_DIR_PATHS");
env.remove("__XPC_DYLD_LIBRARY_PATH"); env.remove("__XPC_DYLD_LIBRARY_PATH");
@@ -1078,7 +1078,7 @@ pub const Inspector = struct {
pub fn deinit(self: Backend) void { pub fn deinit(self: Backend) void {
switch (self) { switch (self) {
.metal => if (builtin.target.isDarwin()) cimgui.ImGui_ImplMetal_Shutdown(), .metal => if (builtin.target.os.tag.isDarwin()) cimgui.ImGui_ImplMetal_Shutdown(),
} }
} }
}; };
@@ -1351,7 +1351,7 @@ pub const CAPI = struct {
// Reference the conditional exports based on target platform // Reference the conditional exports based on target platform
// so they're included in the C API. // so they're included in the C API.
comptime { comptime {
if (builtin.target.isDarwin()) { if (builtin.target.os.tag.isDarwin()) {
_ = Darwin; _ = Darwin;
} }
} }

View File

@@ -25,7 +25,7 @@ const Config = @import("../config.zig").Config;
// Get native API access on certain platforms so we can do more customization. // Get native API access on certain platforms so we can do more customization.
const glfwNative = glfw.Native(.{ const glfwNative = glfw.Native(.{
.cocoa = builtin.target.isDarwin(), .cocoa = builtin.target.os.tag.isDarwin(),
.x11 = builtin.os.tag == .linux, .x11 = builtin.os.tag == .linux,
}); });
@@ -45,7 +45,7 @@ pub const App = struct {
pub const Options = struct {}; pub const Options = struct {};
pub fn init(core_app: *CoreApp, _: Options) !App { pub fn init(core_app: *CoreApp, _: Options) !App {
if (comptime builtin.target.isDarwin()) { if (comptime builtin.target.os.tag.isDarwin()) {
log.warn("WARNING WARNING WARNING: GLFW ON MAC HAS BUGS.", .{}); log.warn("WARNING WARNING WARNING: GLFW ON MAC HAS BUGS.", .{});
log.warn("You should use the AppKit-based app instead. The official download", .{}); log.warn("You should use the AppKit-based app instead. The official download", .{});
log.warn("is properly built and available from GitHub. If you're building from", .{}); log.warn("is properly built and available from GitHub. If you're building from", .{});
@@ -439,7 +439,7 @@ pub const App = struct {
/// Mac and the artifact is a standalone exe. We don't target libs because /// Mac and the artifact is a standalone exe. We don't target libs because
/// the embedded API doesn't do windowing. /// the embedded API doesn't do windowing.
const Darwin = struct { const Darwin = struct {
const enabled = builtin.target.isDarwin() and build_config.artifact == .exe; const enabled = builtin.target.os.tag.isDarwin() and build_config.artifact == .exe;
tabbing_id: *macos.foundation.String, tabbing_id: *macos.foundation.String,
@@ -767,7 +767,7 @@ pub const Surface = struct {
/// Set the shape of the cursor. /// Set the shape of the cursor.
fn setMouseShape(self: *Surface, shape: terminal.MouseShape) !void { fn setMouseShape(self: *Surface, shape: terminal.MouseShape) !void {
if ((comptime builtin.target.isDarwin()) and if ((comptime builtin.target.os.tag.isDarwin()) and
!internal_os.macos.isAtLeastVersion(13, 0, 0)) !internal_os.macos.isAtLeastVersion(13, 0, 0))
{ {
// We only set our cursor if we're NOT on Mac, or if we are then the // We only set our cursor if we're NOT on Mac, or if we are then the
@@ -925,7 +925,7 @@ pub const Surface = struct {
// On macOS we need to also disable some modifiers because // On macOS we need to also disable some modifiers because
// alt+key consumes the alt. // alt+key consumes the alt.
if (comptime builtin.target.isDarwin()) { if (comptime builtin.target.os.tag.isDarwin()) {
// For GLFW, we say we always consume alt because // For GLFW, we say we always consume alt because
// GLFW doesn't have a way to disable the alt key. // GLFW doesn't have a way to disable the alt key.
key_event.consumed_mods.alt = true; key_event.consumed_mods.alt = true;

View File

@@ -226,7 +226,7 @@ pub fn init(core_app: *CoreApp, opts: Options) !App {
var fmt = std.io.fixedBufferStream(&buf); var fmt = std.io.fixedBufferStream(&buf);
const writer = fmt.writer(); const writer = fmt.writer();
var first: bool = true; var first: bool = true;
inline for (@typeInfo(@TypeOf(gdk_debug)).Struct.fields) |field| { inline for (@typeInfo(@TypeOf(gdk_debug)).@"struct".fields) |field| {
if (@field(gdk_debug, field.name)) { if (@field(gdk_debug, field.name)) {
if (!first) try writer.writeAll(","); if (!first) try writer.writeAll(",");
try writer.writeAll(field.name); try writer.writeAll(field.name);
@@ -244,7 +244,7 @@ pub fn init(core_app: *CoreApp, opts: Options) !App {
var fmt = std.io.fixedBufferStream(&buf); var fmt = std.io.fixedBufferStream(&buf);
const writer = fmt.writer(); const writer = fmt.writer();
var first: bool = true; var first: bool = true;
inline for (@typeInfo(@TypeOf(gdk_disable)).Struct.fields) |field| { inline for (@typeInfo(@TypeOf(gdk_disable)).@"struct".fields) |field| {
if (@field(gdk_disable, field.name)) { if (@field(gdk_disable, field.name)) {
if (!first) try writer.writeAll(","); if (!first) try writer.writeAll(",");
try writer.writeAll(field.name); try writer.writeAll(field.name);

View File

@@ -30,7 +30,7 @@ pub const App = union(Protocol) {
app_id: [:0]const u8, app_id: [:0]const u8,
config: *const Config, config: *const Config,
) !App { ) !App {
inline for (@typeInfo(App).Union.fields) |field| { inline for (@typeInfo(App).@"union".fields) |field| {
if (try field.type.init( if (try field.type.init(
alloc, alloc,
gdk_display, gdk_display,
@@ -96,7 +96,7 @@ pub const Window = union(Protocol) {
) !Window { ) !Window {
return switch (app.*) { return switch (app.*) {
inline else => |*v, tag| { inline else => |*v, tag| {
inline for (@typeInfo(Window).Union.fields) |field| { inline for (@typeInfo(Window).@"union".fields) |field| {
if (comptime std.mem.eql( if (comptime std.mem.eql(
u8, u8,
field.name, field.name,

View File

@@ -24,7 +24,7 @@ pub fn genActions(writer: anytype) !void {
\\ \\
); );
inline for (@typeInfo(Action).Enum.fields) |field| { inline for (@typeInfo(Action).@"enum".fields) |field| {
const action = std.meta.stringToEnum(Action, field.name).?; const action = std.meta.stringToEnum(Action, field.name).?;
switch (action) { switch (action) {

View File

@@ -29,7 +29,7 @@ pub fn genConfig(writer: anytype) !void {
); );
@setEvalBranchQuota(50_000); @setEvalBranchQuota(50_000);
const fields = @typeInfo(Config).Struct.fields; const fields = @typeInfo(Config).@"struct".fields;
inline for (fields, 0..) |field, i| { inline for (fields, 0..) |field, i| {
if (field.name[0] == '_') continue; if (field.name[0] == '_') continue;
if (!@hasDecl(help_strings.Config, field.name)) continue; if (!@hasDecl(help_strings.Config, field.name)) continue;

View File

@@ -119,7 +119,7 @@ pub const Action = enum {
// If help is requested, then we use some comptime trickery // If help is requested, then we use some comptime trickery
// to find this action in the help strings and output that. // to find this action in the help strings and output that.
help_error => err: { help_error => err: {
inline for (@typeInfo(Action).Enum.fields) |field| { inline for (@typeInfo(Action).@"enum".fields) |field| {
// Future note: for now we just output the help text directly // Future note: for now we just output the help text directly
// to stdout. In the future we can style this much prettier // to stdout. In the future we can style this much prettier
// for all commands by just changing this one place. // for all commands by just changing this one place.

View File

@@ -55,7 +55,7 @@ pub fn parse(
iter: anytype, iter: anytype,
) !void { ) !void {
const info = @typeInfo(T); const info = @typeInfo(T);
assert(info == .Struct); assert(info == .@"struct");
comptime { comptime {
// Verify all renamed fields are valid (source does not exist, // Verify all renamed fields are valid (source does not exist,
@@ -208,10 +208,10 @@ fn formatInvalidValue(
fn formatValues(comptime T: type, key: []const u8, writer: anytype) std.mem.Allocator.Error!void { fn formatValues(comptime T: type, key: []const u8, writer: anytype) std.mem.Allocator.Error!void {
const typeinfo = @typeInfo(T); const typeinfo = @typeInfo(T);
inline for (typeinfo.Struct.fields) |f| { inline for (typeinfo.@"struct".fields) |f| {
if (std.mem.eql(u8, key, f.name)) { if (std.mem.eql(u8, key, f.name)) {
switch (@typeInfo(f.type)) { switch (@typeInfo(f.type)) {
.Enum => |e| { .@"enum" => |e| {
try writer.print(", valid values are: ", .{}); try writer.print(", valid values are: ", .{});
inline for (e.fields, 0..) |field, i| { inline for (e.fields, 0..) |field, i| {
if (i != 0) try writer.print(", ", .{}); if (i != 0) try writer.print(", ", .{});
@@ -243,19 +243,21 @@ pub fn parseIntoField(
value: ?[]const u8, value: ?[]const u8,
) !void { ) !void {
const info = @typeInfo(T); const info = @typeInfo(T);
assert(info == .Struct); assert(info == .@"struct");
inline for (info.Struct.fields) |field| { inline for (info.@"struct".fields) |field| {
if (field.name[0] != '_' and mem.eql(u8, field.name, key)) { if (field.name[0] != '_' and mem.eql(u8, field.name, key)) {
// For optional fields, we just treat it as the child type. // For optional fields, we just treat it as the child type.
// This lets optional fields default to null but get set by // This lets optional fields default to null but get set by
// the CLI. // the CLI.
const Field = switch (@typeInfo(field.type)) { const Field = switch (@typeInfo(field.type)) {
.Optional => |opt| opt.child, .optional => |opt| opt.child,
else => field.type, else => field.type,
}; };
const fieldInfo = @typeInfo(Field); const fieldInfo = @typeInfo(Field);
const canHaveDecls = fieldInfo == .Struct or fieldInfo == .Union or fieldInfo == .Enum; const canHaveDecls = fieldInfo == .@"struct" or
fieldInfo == .@"union" or
fieldInfo == .@"enum";
// If the value is empty string (set but empty string), // If the value is empty string (set but empty string),
// then we reset the value to the default. // then we reset the value to the default.
@@ -266,7 +268,7 @@ pub fn parseIntoField(
try @field(dst, field.name).init(alloc); try @field(dst, field.name).init(alloc);
return; return;
} }
const raw = field.default_value orelse break :default; const raw = field.default_value_ptr orelse break :default;
const ptr: *const field.type = @alignCast(@ptrCast(raw)); const ptr: *const field.type = @alignCast(@ptrCast(raw));
@field(dst, field.name) = ptr.*; @field(dst, field.name) = ptr.*;
return; return;
@@ -276,22 +278,22 @@ pub fn parseIntoField(
// we call that and use that to set the value. // we call that and use that to set the value.
if (canHaveDecls) { if (canHaveDecls) {
if (@hasDecl(Field, "parseCLI")) { if (@hasDecl(Field, "parseCLI")) {
const fnInfo = @typeInfo(@TypeOf(Field.parseCLI)).Fn; const fnInfo = @typeInfo(@TypeOf(Field.parseCLI)).@"fn";
switch (fnInfo.params.len) { switch (fnInfo.params.len) {
// 1 arg = (input) => output // 1 arg = (input) => output
1 => @field(dst, field.name) = try Field.parseCLI(value), 1 => @field(dst, field.name) = try Field.parseCLI(value),
// 2 arg = (self, input) => void // 2 arg = (self, input) => void
2 => switch (@typeInfo(field.type)) { 2 => switch (@typeInfo(field.type)) {
.Struct, .@"struct",
.Union, .@"union",
.Enum, .@"enum",
=> try @field(dst, field.name).parseCLI(value), => try @field(dst, field.name).parseCLI(value),
// If the field is optional and set, then we use // If the field is optional and set, then we use
// the pointer value directly into it. If its not // the pointer value directly into it. If its not
// set we need to create a new instance. // set we need to create a new instance.
.Optional => if (@field(dst, field.name)) |*v| { .optional => if (@field(dst, field.name)) |*v| {
try v.parseCLI(value); try v.parseCLI(value);
} else { } else {
// Note: you cannot do @field(dst, name) = undefined // Note: you cannot do @field(dst, name) = undefined
@@ -307,12 +309,12 @@ pub fn parseIntoField(
// 3 arg = (self, alloc, input) => void // 3 arg = (self, alloc, input) => void
3 => switch (@typeInfo(field.type)) { 3 => switch (@typeInfo(field.type)) {
.Struct, .@"struct",
.Union, .@"union",
.Enum, .@"enum",
=> try @field(dst, field.name).parseCLI(alloc, value), => try @field(dst, field.name).parseCLI(alloc, value),
.Optional => if (@field(dst, field.name)) |*v| { .optional => if (@field(dst, field.name)) |*v| {
try v.parseCLI(alloc, value); try v.parseCLI(alloc, value);
} else { } else {
var tmp: Field = undefined; var tmp: Field = undefined;
@@ -374,18 +376,18 @@ pub fn parseIntoField(
) catch return error.InvalidValue, ) catch return error.InvalidValue,
else => switch (fieldInfo) { else => switch (fieldInfo) {
.Enum => std.meta.stringToEnum( .@"enum" => std.meta.stringToEnum(
Field, Field,
value orelse return error.ValueRequired, value orelse return error.ValueRequired,
) orelse return error.InvalidValue, ) orelse return error.InvalidValue,
.Struct => try parseStruct( .@"struct" => try parseStruct(
Field, Field,
alloc, alloc,
value orelse return error.ValueRequired, value orelse return error.ValueRequired,
), ),
.Union => try parseTaggedUnion( .@"union" => try parseTaggedUnion(
Field, Field,
alloc, alloc,
value orelse return error.ValueRequired, value orelse return error.ValueRequired,
@@ -413,8 +415,8 @@ pub fn parseIntoField(
} }
fn parseTaggedUnion(comptime T: type, alloc: Allocator, v: []const u8) !T { fn parseTaggedUnion(comptime T: type, alloc: Allocator, v: []const u8) !T {
const info = @typeInfo(T).Union; const info = @typeInfo(T).@"union";
assert(@typeInfo(info.tag_type.?) == .Enum); assert(@typeInfo(info.tag_type.?) == .@"enum");
// Get the union tag that is being set. We support values with no colon // Get the union tag that is being set. We support values with no colon
// if the value is void so its not an error to have no colon. // if the value is void so its not an error to have no colon.
@@ -433,12 +435,12 @@ fn parseTaggedUnion(comptime T: type, alloc: Allocator, v: []const u8) !T {
// We need to create a struct that looks like this union field. // We need to create a struct that looks like this union field.
// This lets us use parseIntoField as if its a dedicated struct. // This lets us use parseIntoField as if its a dedicated struct.
const Target = @Type(.{ .Struct = .{ const Target = @Type(.{ .@"struct" = .{
.layout = .auto, .layout = .auto,
.fields = &.{.{ .fields = &.{.{
.name = field.name, .name = field.name,
.type = field.type, .type = field.type,
.default_value = null, .default_value_ptr = null,
.is_comptime = false, .is_comptime = false,
.alignment = @alignOf(field.type), .alignment = @alignOf(field.type),
}}, }},
@@ -459,7 +461,7 @@ fn parseTaggedUnion(comptime T: type, alloc: Allocator, v: []const u8) !T {
} }
fn parseStruct(comptime T: type, alloc: Allocator, v: []const u8) !T { fn parseStruct(comptime T: type, alloc: Allocator, v: []const u8) !T {
return switch (@typeInfo(T).Struct.layout) { return switch (@typeInfo(T).@"struct".layout) {
.auto => parseAutoStruct(T, alloc, v), .auto => parseAutoStruct(T, alloc, v),
.@"packed" => parsePackedStruct(T, v), .@"packed" => parsePackedStruct(T, v),
else => @compileError("unsupported struct layout"), else => @compileError("unsupported struct layout"),
@@ -467,7 +469,7 @@ fn parseStruct(comptime T: type, alloc: Allocator, v: []const u8) !T {
} }
pub fn parseAutoStruct(comptime T: type, alloc: Allocator, v: []const u8) !T { pub fn parseAutoStruct(comptime T: type, alloc: Allocator, v: []const u8) !T {
const info = @typeInfo(T).Struct; const info = @typeInfo(T).@"struct";
comptime assert(info.layout == .auto); comptime assert(info.layout == .auto);
// We start our result as undefined so we don't get an error for required // We start our result as undefined so we don't get an error for required
@@ -519,7 +521,7 @@ pub fn parseAutoStruct(comptime T: type, alloc: Allocator, v: []const u8) !T {
// Ensure all required fields are set // Ensure all required fields are set
inline for (info.fields, 0..) |field, i| { inline for (info.fields, 0..) |field, i| {
if (!fields_set.isSet(i)) { if (!fields_set.isSet(i)) {
const default_ptr = field.default_value orelse return error.InvalidValue; const default_ptr = field.default_value_ptr orelse return error.InvalidValue;
const typed_ptr: *const field.type = @alignCast(@ptrCast(default_ptr)); const typed_ptr: *const field.type = @alignCast(@ptrCast(default_ptr));
@field(result, field.name) = typed_ptr.*; @field(result, field.name) = typed_ptr.*;
} }
@@ -529,7 +531,7 @@ pub fn parseAutoStruct(comptime T: type, alloc: Allocator, v: []const u8) !T {
} }
fn parsePackedStruct(comptime T: type, v: []const u8) !T { fn parsePackedStruct(comptime T: type, v: []const u8) !T {
const info = @typeInfo(T).Struct; const info = @typeInfo(T).@"struct";
comptime assert(info.layout == .@"packed"); comptime assert(info.layout == .@"packed");
var result: T = .{}; var result: T = .{};

View File

@@ -54,14 +54,14 @@ pub const Location = union(enum) {
line: usize, line: usize,
}, },
pub const Key = @typeInfo(Location).Union.tag_type.?; pub const Key = @typeInfo(Location).@"union".tag_type.?;
pub fn fromIter(iter: anytype, alloc: Allocator) Allocator.Error!Location { pub fn fromIter(iter: anytype, alloc: Allocator) Allocator.Error!Location {
const Iter = t: { const Iter = t: {
const T = @TypeOf(iter); const T = @TypeOf(iter);
break :t switch (@typeInfo(T)) { break :t switch (@typeInfo(T)) {
.Pointer => |v| v.child, .pointer => |v| v.child,
.Struct => T, .@"struct" => T,
else => return .none, else => return .none,
}; };
}; };

View File

@@ -58,7 +58,7 @@ pub fn run(alloc: Allocator) !u8 {
\\ \\
); );
inline for (@typeInfo(Action).Enum.fields) |field| { inline for (@typeInfo(Action).@"enum".fields) |field| {
try stdout.print(" +{s}\n", .{field.name}); try stdout.print(" +{s}\n", .{field.name});
} }

View File

@@ -101,7 +101,7 @@ fn runArgs(alloc_gpa: Allocator, argsIter: anytype) !u8 {
var exit: bool = false; var exit: bool = false;
outer: for (opts._diagnostics.items()) |diagnostic| { outer: for (opts._diagnostics.items()) |diagnostic| {
if (diagnostic.location != .cli) continue :outer; if (diagnostic.location != .cli) continue :outer;
inner: inline for (@typeInfo(Options).Struct.fields) |field| { inner: inline for (@typeInfo(Options).@"struct".fields) |field| {
if (field.name[0] == '_') continue :inner; if (field.name[0] == '_') continue :inner;
if (std.mem.eql(u8, field.name, diagnostic.key)) { if (std.mem.eql(u8, field.name, diagnostic.key)) {
try stderr.writeAll("config error: "); try stderr.writeAll("config error: ");
@@ -134,7 +134,7 @@ fn runArgs(alloc_gpa: Allocator, argsIter: anytype) !u8 {
// action-specific argument. // action-specific argument.
if (!config._diagnostics.empty()) { if (!config._diagnostics.empty()) {
outer: for (config._diagnostics.items()) |diagnostic| { outer: for (config._diagnostics.items()) |diagnostic| {
inner: inline for (@typeInfo(Options).Struct.fields) |field| { inner: inline for (@typeInfo(Options).@"struct".fields) |field| {
if (field.name[0] == '_') continue :inner; if (field.name[0] == '_') continue :inner;
if (std.mem.eql(u8, field.name, diagnostic.key) and (diagnostic.location == .none or diagnostic.location == .cli)) continue :outer; if (std.mem.eql(u8, field.name, diagnostic.key) and (diagnostic.location == .none or diagnostic.location == .cli)) continue :outer;
} }

View File

@@ -2801,7 +2801,7 @@ pub fn changeConditionalState(
// If the conditional state between the old and new is the same, // If the conditional state between the old and new is the same,
// then we don't need to do anything. // then we don't need to do anything.
relevant: { relevant: {
inline for (@typeInfo(conditional.Key).Enum.fields) |field| { inline for (@typeInfo(conditional.Key).@"enum".fields) |field| {
const key: conditional.Key = @field(conditional.Key, field.name); const key: conditional.Key = @field(conditional.Key, field.name);
// Conditional set contains the keys that this config uses. So we // Conditional set contains the keys that this config uses. So we
@@ -2849,7 +2849,7 @@ fn expandPaths(self: *Config, base: []const u8) !void {
); );
// Expand all of our paths // Expand all of our paths
inline for (@typeInfo(Config).Struct.fields) |field| { inline for (@typeInfo(Config).@"struct".fields) |field| {
switch (field.type) { switch (field.type) {
RepeatablePath, Path => { RepeatablePath, Path => {
try @field(self, field.name).expand( try @field(self, field.name).expand(
@@ -3023,7 +3023,7 @@ pub fn finalize(self: *Config) !void {
// to look up defaults which is kind of expensive. We only do this // to look up defaults which is kind of expensive. We only do this
// on desktop. // on desktop.
const wd_home = std.mem.eql(u8, "home", wd); const wd_home = std.mem.eql(u8, "home", wd);
if ((comptime !builtin.target.isWasm()) and if ((comptime !builtin.target.cpu.arch.isWasm()) and
(comptime !builtin.is_test)) (comptime !builtin.is_test))
{ {
if (self.command == null or wd_home) command: { if (self.command == null or wd_home) command: {
@@ -3239,7 +3239,7 @@ pub fn clone(
const alloc_arena = result._arena.?.allocator(); const alloc_arena = result._arena.?.allocator();
// Copy our values // Copy our values
inline for (@typeInfo(Config).Struct.fields) |field| { inline for (@typeInfo(Config).@"struct".fields) |field| {
if (!@hasField(Key, field.name)) continue; if (!@hasField(Key, field.name)) continue;
@field(result, field.name) = try cloneValue( @field(result, field.name) = try cloneValue(
alloc_arena, alloc_arena,
@@ -3286,26 +3286,26 @@ fn cloneValue(
// If we're a type that can have decls and we have clone, then // If we're a type that can have decls and we have clone, then
// call clone and be done. // call clone and be done.
const t = @typeInfo(T); const t = @typeInfo(T);
if (t == .Struct or t == .Enum or t == .Union) { if (t == .@"struct" or t == .@"enum" or t == .@"union") {
if (@hasDecl(T, "clone")) return try src.clone(alloc); if (@hasDecl(T, "clone")) return try src.clone(alloc);
} }
// Back into types of types // Back into types of types
switch (t) { switch (t) {
inline .Bool, inline .bool,
.Int, .int,
.Float, .float,
.Enum, .@"enum",
.Union, .@"union",
=> return src, => return src,
.Optional => |info| return try cloneValue( .optional => |info| return try cloneValue(
alloc, alloc,
info.child, info.child,
src orelse return null, src orelse return null,
), ),
.Struct => |info| { .@"struct" => |info| {
// Packed structs we can return directly as copies. // Packed structs we can return directly as copies.
assert(info.layout == .@"packed"); assert(info.layout == .@"packed");
return src; return src;
@@ -3390,21 +3390,21 @@ fn equalField(comptime T: type, old: T, new: T) bool {
// Back into types of types // Back into types of types
switch (@typeInfo(T)) { switch (@typeInfo(T)) {
.Void => return true, .void => return true,
inline .Bool, inline .bool,
.Int, .int,
.Float, .float,
.Enum, .@"enum",
=> return old == new, => return old == new,
.Optional => |info| { .optional => |info| {
if (old == null and new == null) return true; if (old == null and new == null) return true;
if (old == null or new == null) return false; if (old == null or new == null) return false;
return equalField(info.child, old.?, new.?); return equalField(info.child, old.?, new.?);
}, },
.Struct => |info| { .@"struct" => |info| {
if (@hasDecl(T, "equal")) return old.equal(new); if (@hasDecl(T, "equal")) return old.equal(new);
// If a struct doesn't declare an "equal" function, we fall back // If a struct doesn't declare an "equal" function, we fall back
@@ -3419,7 +3419,7 @@ fn equalField(comptime T: type, old: T, new: T) bool {
return true; return true;
}, },
.Union => |info| { .@"union" => |info| {
const tag_type = info.tag_type.?; const tag_type = info.tag_type.?;
const old_tag = std.meta.activeTag(old); const old_tag = std.meta.activeTag(old);
const new_tag = std.meta.activeTag(new); const new_tag = std.meta.activeTag(new);
@@ -4293,7 +4293,7 @@ pub const Keybinds = struct {
// The order of these blocks is important. The *last* added keybind for a given action is // The order of these blocks is important. The *last* added keybind for a given action is
// what will display in the menu. We want the more typical keybinds after this block to be // what will display in the menu. We want the more typical keybinds after this block to be
// the standard // the standard
if (!builtin.target.isDarwin()) { if (!builtin.target.os.tag.isDarwin()) {
try self.set.put( try self.set.put(
alloc, alloc,
.{ .key = .{ .translated = .insert }, .mods = .{ .ctrl = true } }, .{ .key = .{ .translated = .insert }, .mods = .{ .ctrl = true } },
@@ -4308,7 +4308,7 @@ pub const Keybinds = struct {
// On macOS we default to super but Linux ctrl+shift since // On macOS we default to super but Linux ctrl+shift since
// ctrl+c is to kill the process. // ctrl+c is to kill the process.
const mods: inputpkg.Mods = if (builtin.target.isDarwin()) const mods: inputpkg.Mods = if (builtin.target.os.tag.isDarwin())
.{ .super = true } .{ .super = true }
else else
.{ .ctrl = true, .shift = true }; .{ .ctrl = true, .shift = true };
@@ -4426,7 +4426,7 @@ pub const Keybinds = struct {
); );
// Windowing // Windowing
if (comptime !builtin.target.isDarwin()) { if (comptime !builtin.target.os.tag.isDarwin()) {
try self.set.put( try self.set.put(
alloc, alloc,
.{ .key = .{ .translated = .n }, .mods = .{ .ctrl = true, .shift = true } }, .{ .key = .{ .translated = .n }, .mods = .{ .ctrl = true, .shift = true } },
@@ -4603,7 +4603,7 @@ pub const Keybinds = struct {
{ {
// On macOS we default to super but everywhere else // On macOS we default to super but everywhere else
// is alt. // is alt.
const mods: inputpkg.Mods = if (builtin.target.isDarwin()) const mods: inputpkg.Mods = if (builtin.target.os.tag.isDarwin())
.{ .super = true } .{ .super = true }
else else
.{ .alt = true }; .{ .alt = true };
@@ -4621,7 +4621,7 @@ pub const Keybinds = struct {
// want to be true on other platforms as well but this // want to be true on other platforms as well but this
// is definitely true on macOS so we just do it here for // is definitely true on macOS so we just do it here for
// now (#817) // now (#817)
.key = if (comptime builtin.target.isDarwin()) .key = if (comptime builtin.target.os.tag.isDarwin())
.{ .physical = @enumFromInt(i) } .{ .physical = @enumFromInt(i) }
else else
.{ .translated = @enumFromInt(i) }, .{ .translated = @enumFromInt(i) },
@@ -4634,7 +4634,7 @@ pub const Keybinds = struct {
try self.set.put( try self.set.put(
alloc, alloc,
.{ .{
.key = if (comptime builtin.target.isDarwin()) .key = if (comptime builtin.target.os.tag.isDarwin())
.{ .physical = .nine } .{ .physical = .nine }
else else
.{ .translated = .nine }, .{ .translated = .nine },
@@ -4659,7 +4659,7 @@ pub const Keybinds = struct {
); );
// Mac-specific keyboard bindings. // Mac-specific keyboard bindings.
if (comptime builtin.target.isDarwin()) { if (comptime builtin.target.os.tag.isDarwin()) {
try self.set.put( try self.set.put(
alloc, alloc,
.{ .key = .{ .translated = .q }, .mods = .{ .super = true } }, .{ .key = .{ .translated = .q }, .mods = .{ .super = true } },
@@ -4995,7 +4995,7 @@ pub const Keybinds = struct {
if (docs) { if (docs) {
try formatter.writer.writeAll("\n"); try formatter.writer.writeAll("\n");
const name = @tagName(v); const name = @tagName(v);
inline for (@typeInfo(help_strings.KeybindAction).Struct.decls) |decl| { inline for (@typeInfo(help_strings.KeybindAction).@"struct".decls) |decl| {
if (std.mem.eql(u8, decl.name, name)) { if (std.mem.eql(u8, decl.name, name)) {
const help = @field(help_strings.KeybindAction, decl.name); const help = @field(help_strings.KeybindAction, decl.name);
try formatter.writer.writeAll("# " ++ decl.name ++ "\n"); try formatter.writer.writeAll("# " ++ decl.name ++ "\n");

View File

@@ -53,21 +53,21 @@ fn getValue(ptr_raw: *anyopaque, value: anytype) bool {
}, },
else => |T| switch (@typeInfo(T)) { else => |T| switch (@typeInfo(T)) {
.Optional => { .optional => {
// If an optional has no value we return false. // If an optional has no value we return false.
const unwrapped = value orelse return false; const unwrapped = value orelse return false;
return getValue(ptr_raw, unwrapped); return getValue(ptr_raw, unwrapped);
}, },
.Enum => { .@"enum" => {
const ptr: *[*:0]const u8 = @ptrCast(@alignCast(ptr_raw)); const ptr: *[*:0]const u8 = @ptrCast(@alignCast(ptr_raw));
ptr.* = @tagName(value); ptr.* = @tagName(value);
}, },
.Struct => |info| { .@"struct" => |info| {
// If the struct implements cval then we call then. // If the struct implements cval then we call then.
if (@hasDecl(T, "cval")) { if (@hasDecl(T, "cval")) {
const PtrT = @typeInfo(@TypeOf(T.cval)).Fn.return_type.?; const PtrT = @typeInfo(@TypeOf(T.cval)).@"fn".return_type.?;
const ptr: *PtrT = @ptrCast(@alignCast(ptr_raw)); const ptr: *PtrT = @ptrCast(@alignCast(ptr_raw));
ptr.* = value.cval(); ptr.* = value.cval();
return true; return true;
@@ -84,9 +84,9 @@ fn getValue(ptr_raw: *anyopaque, value: anytype) bool {
ptr.* = @intCast(@as(Backing, @bitCast(value))); ptr.* = @intCast(@as(Backing, @bitCast(value)));
}, },
.Union => |_| { .@"union" => |_| {
if (@hasDecl(T, "cval")) { if (@hasDecl(T, "cval")) {
const PtrT = @typeInfo(@TypeOf(T.cval)).Fn.return_type.?; const PtrT = @typeInfo(@TypeOf(T.cval)).@"fn".return_type.?;
const ptr: *PtrT = @ptrCast(@alignCast(ptr_raw)); const ptr: *PtrT = @ptrCast(@alignCast(ptr_raw));
ptr.* = value.cval(); ptr.* = value.cval();
return true; return true;

View File

@@ -42,27 +42,27 @@ pub fn formatEntry(
writer: anytype, writer: anytype,
) !void { ) !void {
switch (@typeInfo(T)) { switch (@typeInfo(T)) {
.Bool, .Int => { .bool, .int => {
try writer.print("{s} = {}\n", .{ name, value }); try writer.print("{s} = {}\n", .{ name, value });
return; return;
}, },
.Float => { .float => {
try writer.print("{s} = {d}\n", .{ name, value }); try writer.print("{s} = {d}\n", .{ name, value });
return; return;
}, },
.Enum => { .@"enum" => {
try writer.print("{s} = {s}\n", .{ name, @tagName(value) }); try writer.print("{s} = {s}\n", .{ name, @tagName(value) });
return; return;
}, },
.Void => { .void => {
try writer.print("{s} = \n", .{name}); try writer.print("{s} = \n", .{name});
return; return;
}, },
.Optional => |info| { .optional => |info| {
if (value) |inner| { if (value) |inner| {
try formatEntry( try formatEntry(
info.child, info.child,
@@ -77,7 +77,7 @@ pub fn formatEntry(
return; return;
}, },
.Pointer => switch (T) { .pointer => switch (T) {
[]const u8, []const u8,
[:0]const u8, [:0]const u8,
=> { => {
@@ -93,7 +93,7 @@ pub fn formatEntry(
// This is given the formatter in use so that they can // This is given the formatter in use so that they can
// call BACK to our formatEntry to write each primitive // call BACK to our formatEntry to write each primitive
// value. // value.
.Struct => |info| if (@hasDecl(T, "formatEntry")) { .@"struct" => |info| if (@hasDecl(T, "formatEntry")) {
try value.formatEntry(entryFormatter(name, writer)); try value.formatEntry(entryFormatter(name, writer));
return; return;
} else switch (info.layout) { } else switch (info.layout) {
@@ -114,7 +114,7 @@ pub fn formatEntry(
else => {}, else => {},
}, },
.Union => if (@hasDecl(T, "formatEntry")) { .@"union" => if (@hasDecl(T, "formatEntry")) {
try value.formatEntry(entryFormatter(name, writer)); try value.formatEntry(entryFormatter(name, writer));
return; return;
}, },
@@ -158,7 +158,7 @@ pub const FileFormatter = struct {
null; null;
defer if (default) |*v| v.deinit(); defer if (default) |*v| v.deinit();
inline for (@typeInfo(Config).Struct.fields) |field| { inline for (@typeInfo(Config).@"struct".fields) |field| {
if (field.name[0] == '_') continue; if (field.name[0] == '_') continue;
const value = @field(self.config, field.name); const value = @field(self.config, field.name);

View File

@@ -22,7 +22,7 @@ pub const Key = key: {
var decls = [_]std.builtin.Type.Declaration{}; var decls = [_]std.builtin.Type.Declaration{};
break :key @Type(.{ break :key @Type(.{
.Enum = .{ .@"enum" = .{
.tag_type = std.math.IntFittingRange(0, field_infos.len - 1), .tag_type = std.math.IntFittingRange(0, field_infos.len - 1),
.fields = enumFields[0..i], .fields = enumFields[0..i],
.decls = &decls, .decls = &decls,

View File

@@ -76,7 +76,7 @@ pub const LocationIterator = struct {
location: Location, location: Location,
dir: []const u8, dir: []const u8,
} { } {
const max = @typeInfo(Location).Enum.fields.len; const max = @typeInfo(Location).@"enum".fields.len;
while (self.i < max) { while (self.i < max) {
const location: Location = @enumFromInt(self.i); const location: Location = @enumFromInt(self.i);
self.i += 1; self.i += 1;

View File

@@ -46,13 +46,13 @@ pub fn Reader(comptime S: type) type {
stream_directory_rva: u32, stream_directory_rva: u32,
const SourceCallable = switch (@typeInfo(Source)) { const SourceCallable = switch (@typeInfo(Source)) {
.Pointer => |v| v.child, .pointer => |v| v.child,
.Struct => Source, .@"struct" => Source,
else => @compileError("Source type must be a pointer or struct"), else => @compileError("Source type must be a pointer or struct"),
}; };
const SourceReader = @typeInfo(@TypeOf(SourceCallable.reader)).Fn.return_type.?; const SourceReader = @typeInfo(@TypeOf(SourceCallable.reader)).@"fn".return_type.?;
const SourceSeeker = @typeInfo(@TypeOf(SourceCallable.seekableStream)).Fn.return_type.?; const SourceSeeker = @typeInfo(@TypeOf(SourceCallable.seekableStream)).@"fn".return_type.?;
/// A limited reader for reading data from the source. /// A limited reader for reading data from the source.
pub const LimitedReader = std.io.LimitedReader(SourceReader); pub const LimitedReader = std.io.LimitedReader(SourceReader);

View File

@@ -639,11 +639,11 @@ pub const PresentationMode = union(enum) {
/// the Backing type and everything should just work fine. /// the Backing type and everything should just work fine.
pub const Index = packed struct(Index.Backing) { pub const Index = packed struct(Index.Backing) {
const Backing = u16; const Backing = u16;
const backing_bits = @typeInfo(Backing).Int.bits; const backing_bits = @typeInfo(Backing).int.bits;
/// The number of bits we use for the index. /// The number of bits we use for the index.
const idx_bits = backing_bits - @typeInfo(@typeInfo(Style).Enum.tag_type).Int.bits; const idx_bits = backing_bits - @typeInfo(@typeInfo(Style).@"enum".tag_type).int.bits;
pub const IndexInt = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = idx_bits } }); pub const IndexInt = @Type(.{ .int = .{ .signedness = .unsigned, .bits = idx_bits } });
/// The special-case fonts that we support. /// The special-case fonts that we support.
pub const Special = enum(IndexInt) { pub const Special = enum(IndexInt) {

View File

@@ -324,7 +324,7 @@ pub const Modifier = union(enum) {
/// Apply a modifier to a numeric value. /// Apply a modifier to a numeric value.
pub fn apply(self: Modifier, v: anytype) @TypeOf(v) { pub fn apply(self: Modifier, v: anytype) @TypeOf(v) {
const T = @TypeOf(v); const T = @TypeOf(v);
const signed = @typeInfo(T).Int.signedness == .signed; const signed = @typeInfo(T).int.signedness == .signed;
return switch (self) { return switch (self) {
.percent => |p| percent: { .percent => |p| percent: {
const p_clamped: f64 = @max(0, p); const p_clamped: f64 = @max(0, p);
@@ -395,7 +395,7 @@ pub const Key = key: {
var decls = [_]std.builtin.Type.Declaration{}; var decls = [_]std.builtin.Type.Declaration{};
break :key @Type(.{ break :key @Type(.{
.Enum = .{ .@"enum" = .{
.tag_type = std.math.IntFittingRange(0, count - 1), .tag_type = std.math.IntFittingRange(0, count - 1),
.fields = enumFields[0..count], .fields = enumFields[0..count],
.decls = &decls, .decls = &decls,

View File

@@ -188,7 +188,7 @@ fn collection(
// A buffer we use to store the font names for logging. // A buffer we use to store the font names for logging.
var name_buf: [256]u8 = undefined; var name_buf: [256]u8 = undefined;
inline for (@typeInfo(Style).Enum.fields) |field| { inline for (@typeInfo(Style).@"enum".fields) |field| {
const style = @field(Style, field.name); const style = @field(Style, field.name);
for (key.descriptorsForStyle(style)) |desc| { for (key.descriptorsForStyle(style)) |desc| {
{ {
@@ -297,7 +297,7 @@ fn collection(
// people add other emoji fonts to their system, we always want to // people add other emoji fonts to their system, we always want to
// prefer the official one. Users can override this by explicitly // prefer the official one. Users can override this by explicitly
// specifying a font-family for emoji. // specifying a font-family for emoji.
if (comptime builtin.target.isDarwin() and Discover != void) apple_emoji: { if (comptime builtin.target.os.tag.isDarwin() and Discover != void) apple_emoji: {
const disco = try self.discover() orelse break :apple_emoji; const disco = try self.discover() orelse break :apple_emoji;
var disco_it = try disco.discover(self.alloc, .{ var disco_it = try disco.discover(self.alloc, .{
.family = "Apple Color Emoji", .family = "Apple Color Emoji",
@@ -314,7 +314,7 @@ fn collection(
// Emoji fallback. We don't include this on Mac since Mac is expected // Emoji fallback. We don't include this on Mac since Mac is expected
// to always have the Apple Emoji available on the system. // to always have the Apple Emoji available on the system.
if (comptime !builtin.target.isDarwin() or Discover == void) { if (comptime !builtin.target.os.tag.isDarwin() or Discover == void) {
_ = try c.add( _ = try c.add(
self.alloc, self.alloc,
.regular, .regular,
@@ -672,7 +672,7 @@ pub const Key = struct {
autoHash(hasher, self.metric_modifiers.count()); autoHash(hasher, self.metric_modifiers.count());
autoHash(hasher, self.freetype_load_flags); autoHash(hasher, self.freetype_load_flags);
if (self.metric_modifiers.count() > 0) { if (self.metric_modifiers.count() > 0) {
inline for (@typeInfo(Metrics.Key).Enum.fields) |field| { inline for (@typeInfo(Metrics.Key).@"enum".fields) |field| {
const key = @field(Metrics.Key, field.name); const key = @field(Metrics.Key, field.name);
if (self.metric_modifiers.get(key)) |value| { if (self.metric_modifiers.get(key)) |value| {
autoHash(hasher, key); autoHash(hasher, key);

View File

@@ -597,7 +597,7 @@ pub const CoreText = struct {
/// We represent our sorting score as a packed struct so that we can /// We represent our sorting score as a packed struct so that we can
/// compare scores numerically but build scores symbolically. /// compare scores numerically but build scores symbolically.
const Score = packed struct { const Score = packed struct {
const Backing = @typeInfo(@This()).Struct.backing_integer.?; const Backing = @typeInfo(@This()).@"struct".backing_integer.?;
glyph_count: u16 = 0, // clamped if > intmax glyph_count: u16 = 0, // clamped if > intmax
traits: Traits = .unmatched, traits: Traits = .unmatched,

View File

@@ -64,7 +64,7 @@ pub const Version16Dot16 = packed struct(u32) {
pub const F26Dot6 = FixedPoint(i32, 26, 6); pub const F26Dot6 = FixedPoint(i32, 26, 6);
fn FixedPoint(comptime T: type, int_bits: u64, frac_bits: u64) type { fn FixedPoint(comptime T: type, int_bits: u64, frac_bits: u64) type {
const type_info: std.builtin.Type.Int = @typeInfo(T).Int; const type_info: std.builtin.Type.Int = @typeInfo(T).int;
comptime assert(int_bits + frac_bits == type_info.bits); comptime assert(int_bits + frac_bits == type_info.bits);
return packed struct(T) { return packed struct(T) {

View File

@@ -67,14 +67,13 @@ pub const SVG = struct {
// Slow path: binary search our records // Slow path: binary search our records
return std.sort.binarySearch( return std.sort.binarySearch(
[12]u8, [12]u8,
glyph_id,
self.records, self.records,
{}, glyph_id,
compareGlyphId, compareGlyphId,
) != null; ) != null;
} }
fn compareGlyphId(_: void, glyph_id: u16, record: [12]u8) std.math.Order { fn compareGlyphId(glyph_id: u16, record: [12]u8) std.math.Order {
const start, const end = glyphRange(&record) catch return .lt; const start, const end = glyphRange(&record) catch return .lt;
if (glyph_id < start) { if (glyph_id < start) {
return .lt; return .lt;

View File

@@ -2241,7 +2241,9 @@ fn draw_branch_node(
var ctx = canvas.getContext() catch return; var ctx = canvas.getContext() catch return;
defer ctx.deinit(); defer ctx.deinit();
ctx.setSource(.{ .alpha8 = .{ .a = @intFromEnum(Shade.on) } }); ctx.setSource(.{ .opaque_pattern = .{
.pixel = .{ .alpha8 = .{ .a = @intFromEnum(Shade.on) } },
} });
ctx.setLineWidth(float_thick); ctx.setLineWidth(float_thick);
// These @intFromFloat casts shouldn't ever fail since r can never // These @intFromFloat casts shouldn't ever fail since r can never
@@ -2290,7 +2292,9 @@ fn draw_circle(
var ctx = canvas.getContext() catch return; var ctx = canvas.getContext() catch return;
defer ctx.deinit(); defer ctx.deinit();
ctx.setSource(.{ .alpha8 = .{ .a = @intFromEnum(Shade.on) } }); ctx.setSource(.{ .opaque_pattern = .{
.pixel = .{ .alpha8 = .{ .a = @intFromEnum(Shade.on) } },
} });
ctx.setLineWidth( ctx.setLineWidth(
@floatFromInt(Thickness.light.height(self.metrics.box_thickness)), @floatFromInt(Thickness.light.height(self.metrics.box_thickness)),
); );
@@ -2513,7 +2517,7 @@ fn draw_octant(self: Box, canvas: *font.sprite.Canvas, cp: u32) void {
const octants: [octants_len]Octant = comptime octants: { const octants: [octants_len]Octant = comptime octants: {
@setEvalBranchQuota(10_000); @setEvalBranchQuota(10_000);
var result: [octants_len]Octant = .{.{}} ** octants_len; var result: [octants_len]Octant = .{Octant{}} ** octants_len;
var i: usize = 0; var i: usize = 0;
const data = @embedFile("octants.txt"); const data = @embedFile("octants.txt");
@@ -2678,7 +2682,9 @@ fn draw_arc(
var ctx = try canvas.getContext(); var ctx = try canvas.getContext();
defer ctx.deinit(); defer ctx.deinit();
ctx.setSource(.{ .alpha8 = .{ .a = @intFromEnum(Shade.on) } }); ctx.setSource(.{ .opaque_pattern = .{
.pixel = .{ .alpha8 = .{ .a = @intFromEnum(Shade.on) } },
} });
ctx.setLineWidth(float_thick); ctx.setLineWidth(float_thick);
ctx.setLineCapMode(.round); ctx.setLineCapMode(.round);
@@ -2970,8 +2976,9 @@ fn draw_separated_block_quadrant(self: Box, canvas: *font.sprite.Canvas, comptim
var ctx = try canvas.getContext(); var ctx = try canvas.getContext();
defer ctx.deinit(); defer ctx.deinit();
ctx.setSource(.{ .alpha8 = .{ .a = @intFromEnum(Shade.on) } }); ctx.setSource(.{ .opaque_pattern = .{
.pixel = .{ .alpha8 = .{ .a = @intFromEnum(Shade.on) } },
} });
const gap: f64 = @max(1.0, @as(f64, @floatFromInt(self.metrics.cell_width)) * 0.10) / 2.0; const gap: f64 = @max(1.0, @as(f64, @floatFromInt(self.metrics.cell_width)) * 0.10) / 2.0;
const left: f64 = gap; const left: f64 = gap;
const right = @as(f64, @floatFromInt(self.metrics.cell_width)) - gap; const right = @as(f64, @floatFromInt(self.metrics.cell_width)) - gap;

View File

@@ -211,9 +211,7 @@ pub const GlobalState = struct {
// often write to a broken pipe to exit the read thread. This should // often write to a broken pipe to exit the read thread. This should
// be fixed one day but for now this helps make this a bit more // be fixed one day but for now this helps make this a bit more
// robust. // robust.
p.sigaction(p.SIG.PIPE, &sa, null) catch |err| { p.sigaction(p.SIG.PIPE, &sa, null);
std.log.warn("failed to ignore SIGPIPE err={}", .{err});
};
} }
}; };

View File

@@ -510,7 +510,7 @@ pub const Action = union(enum) {
/// ///
crash: CrashThread, crash: CrashThread,
pub const Key = @typeInfo(Action).Union.tag_type.?; pub const Key = @typeInfo(Action).@"union".tag_type.?;
pub const CrashThread = enum { pub const CrashThread = enum {
main, main,
@@ -638,17 +638,22 @@ pub const Action = union(enum) {
const field_info = @typeInfo(field.type); const field_info = @typeInfo(field.type);
// Fields can provide a custom "parse" function // Fields can provide a custom "parse" function
if (field_info == .Struct or field_info == .Union or field_info == .Enum) { if (field_info == .@"struct" or
if (@hasDecl(field.type, "parse") and @typeInfo(@TypeOf(field.type.parse)) == .Fn) { field_info == .@"union" or
field_info == .@"enum")
{
if (@hasDecl(field.type, "parse") and
@typeInfo(@TypeOf(field.type.parse)) == .@"fn")
{
return field.type.parse(param); return field.type.parse(param);
} }
} }
return switch (field_info) { return switch (field_info) {
.Enum => try parseEnum(field.type, param), .@"enum" => try parseEnum(field.type, param),
.Int => try parseInt(field.type, param), .int => try parseInt(field.type, param),
.Float => try parseFloat(field.type, param), .float => try parseFloat(field.type, param),
.Struct => |info| blk: { .@"struct" => |info| blk: {
// Only tuples are supported to avoid ambiguity with field // Only tuples are supported to avoid ambiguity with field
// ordering // ordering
comptime assert(info.is_tuple); comptime assert(info.is_tuple);
@@ -658,9 +663,9 @@ pub const Action = union(enum) {
inline for (info.fields) |field_| { inline for (info.fields) |field_| {
const next = it.next() orelse return Error.InvalidFormat; const next = it.next() orelse return Error.InvalidFormat;
@field(value, field_.name) = switch (@typeInfo(field_.type)) { @field(value, field_.name) = switch (@typeInfo(field_.type)) {
.Enum => try parseEnum(field_.type, next), .@"enum" => try parseEnum(field_.type, next),
.Int => try parseInt(field_.type, next), .int => try parseInt(field_.type, next),
.Float => try parseFloat(field_.type, next), .float => try parseFloat(field_.type, next),
else => unreachable, else => unreachable,
}; };
} }
@@ -688,7 +693,7 @@ pub const Action = union(enum) {
// An action name is always required // An action name is always required
if (action.len == 0) return Error.InvalidFormat; if (action.len == 0) return Error.InvalidFormat;
const actionInfo = @typeInfo(Action).Union; const actionInfo = @typeInfo(Action).@"union";
inline for (actionInfo.fields) |field| { inline for (actionInfo.fields) |field| {
if (std.mem.eql(u8, action, field.name)) { if (std.mem.eql(u8, action, field.name)) {
// If the field type is void we expect no value // If the field type is void we expect no value
@@ -813,7 +818,9 @@ pub const Action = union(enum) {
/// Returns a union type that only contains actions that are scoped to /// Returns a union type that only contains actions that are scoped to
/// the given scope. /// the given scope.
pub fn Scoped(comptime s: Scope) type { pub fn Scoped(comptime s: Scope) type {
const all_fields = @typeInfo(Action).Union.fields; @setEvalBranchQuota(100_000);
const all_fields = @typeInfo(Action).@"union".fields;
// Find all fields that are app-scoped // Find all fields that are app-scoped
var i: usize = 0; var i: usize = 0;
@@ -829,9 +836,9 @@ pub const Action = union(enum) {
} }
// Build our union // Build our union
return @Type(.{ .Union = .{ return @Type(.{ .@"union" = .{
.layout = .auto, .layout = .auto,
.tag_type = @Type(.{ .Enum = .{ .tag_type = @Type(.{ .@"enum" = .{
.tag_type = std.math.IntFittingRange(0, i), .tag_type = std.math.IntFittingRange(0, i),
.fields = enum_fields[0..i], .fields = enum_fields[0..i],
.decls = &.{}, .decls = &.{},
@@ -903,10 +910,10 @@ pub const Action = union(enum) {
void => {}, void => {},
[]const u8 => try writer.print("{s}", .{value}), []const u8 => try writer.print("{s}", .{value}),
else => switch (value_info) { else => switch (value_info) {
.Enum => try writer.print("{s}", .{@tagName(value)}), .@"enum" => try writer.print("{s}", .{@tagName(value)}),
.Float => try writer.print("{d}", .{value}), .float => try writer.print("{d}", .{value}),
.Int => try writer.print("{d}", .{value}), .int => try writer.print("{d}", .{value}),
.Struct => |info| if (!info.is_tuple) { .@"struct" => |info| if (!info.is_tuple) {
try writer.print("{} (not configurable)", .{value}); try writer.print("{} (not configurable)", .{value});
} else { } else {
inline for (info.fields, 0..) |field, i| { inline for (info.fields, 0..) |field, i| {
@@ -937,21 +944,21 @@ pub const Action = union(enum) {
value: anytype, value: anytype,
) Allocator.Error!@TypeOf(value) { ) Allocator.Error!@TypeOf(value) {
return switch (@typeInfo(@TypeOf(value))) { return switch (@typeInfo(@TypeOf(value))) {
.Void, .void,
.Int, .int,
.Float, .float,
.Enum, .@"enum",
=> value, => value,
.Pointer => |info| slice: { .pointer => |info| slice: {
comptime assert(info.size == .Slice); comptime assert(info.size == .slice);
break :slice try alloc.dupe( break :slice try alloc.dupe(
info.child, info.child,
value, value,
); );
}, },
.Struct => |info| if (info.is_tuple) .@"struct" => |info| if (info.is_tuple)
value value
else else
try value.clone(alloc), try value.clone(alloc),
@@ -974,7 +981,7 @@ pub const Action = union(enum) {
/// Hash the action into the given hasher. /// Hash the action into the given hasher.
fn hashIncremental(self: Action, hasher: anytype) void { fn hashIncremental(self: Action, hasher: anytype) void {
// Always has the active tag. // Always has the active tag.
const Tag = @typeInfo(Action).Union.tag_type.?; const Tag = @typeInfo(Action).@"union".tag_type.?;
std.hash.autoHash(hasher, @as(Tag, self)); std.hash.autoHash(hasher, @as(Tag, self));
// Hash the value of the field. // Hash the value of the field.
@@ -1081,7 +1088,7 @@ pub const Trigger = struct {
if (part.len == 0) return Error.InvalidFormat; if (part.len == 0) return Error.InvalidFormat;
// Check if its a modifier // Check if its a modifier
const modsInfo = @typeInfo(key.Mods).Struct; const modsInfo = @typeInfo(key.Mods).@"struct";
inline for (modsInfo.fields) |field| { inline for (modsInfo.fields) |field| {
if (field.type == bool) { if (field.type == bool) {
if (std.mem.eql(u8, part, field.name)) { if (std.mem.eql(u8, part, field.name)) {
@@ -1116,7 +1123,7 @@ pub const Trigger = struct {
const key_part = if (physical) part[physical_prefix.len..] else part; const key_part = if (physical) part[physical_prefix.len..] else part;
// Check if its a key // Check if its a key
const keysInfo = @typeInfo(key.Key).Enum; const keysInfo = @typeInfo(key.Key).@"enum";
inline for (keysInfo.fields) |field| { inline for (keysInfo.fields) |field| {
if (!std.mem.eql(u8, field.name, "invalid")) { if (!std.mem.eql(u8, field.name, "invalid")) {
if (std.mem.eql(u8, key_part, field.name)) { if (std.mem.eql(u8, key_part, field.name)) {

View File

@@ -1531,7 +1531,7 @@ test "kitty: left shift with report all" {
} }
test "kitty: report associated with alt text on macOS with option" { test "kitty: report associated with alt text on macOS with option" {
if (comptime !builtin.target.isDarwin()) return error.SkipZigTest; if (comptime !builtin.target.os.tag.isDarwin()) return error.SkipZigTest;
var buf: [128]u8 = undefined; var buf: [128]u8 = undefined;
var enc: KeyEncoder = .{ var enc: KeyEncoder = .{
@@ -1555,7 +1555,7 @@ test "kitty: report associated with alt text on macOS with option" {
} }
test "kitty: report associated with alt text on macOS with alt" { test "kitty: report associated with alt text on macOS with alt" {
if (comptime !builtin.target.isDarwin()) return error.SkipZigTest; if (comptime !builtin.target.os.tag.isDarwin()) return error.SkipZigTest;
{ {
// With Alt modifier // With Alt modifier
@@ -1826,7 +1826,7 @@ test "legacy: alt+e only unshifted" {
} }
test "legacy: alt+x macos" { test "legacy: alt+x macos" {
if (comptime !builtin.target.isDarwin()) return error.SkipZigTest; if (comptime !builtin.target.os.tag.isDarwin()) return error.SkipZigTest;
var buf: [128]u8 = undefined; var buf: [128]u8 = undefined;
var enc: KeyEncoder = .{ var enc: KeyEncoder = .{
@@ -1845,7 +1845,7 @@ test "legacy: alt+x macos" {
} }
test "legacy: shift+alt+. macos" { test "legacy: shift+alt+. macos" {
if (comptime !builtin.target.isDarwin()) return error.SkipZigTest; if (comptime !builtin.target.os.tag.isDarwin()) return error.SkipZigTest;
var buf: [128]u8 = undefined; var buf: [128]u8 = undefined;
var enc: KeyEncoder = .{ var enc: KeyEncoder = .{

View File

@@ -81,24 +81,24 @@ pub const keys = keys: {
result.set(.left, pcStyle("\x1b[1;{}D") ++ cursorKey("\x1b[D", "\x1bOD")); result.set(.left, pcStyle("\x1b[1;{}D") ++ cursorKey("\x1b[D", "\x1bOD"));
result.set(.home, pcStyle("\x1b[1;{}H") ++ cursorKey("\x1b[H", "\x1bOH")); result.set(.home, pcStyle("\x1b[1;{}H") ++ cursorKey("\x1b[H", "\x1bOH"));
result.set(.end, pcStyle("\x1b[1;{}F") ++ cursorKey("\x1b[F", "\x1bOF")); result.set(.end, pcStyle("\x1b[1;{}F") ++ cursorKey("\x1b[F", "\x1bOF"));
result.set(.insert, pcStyle("\x1b[2;{}~") ++ .{.{ .sequence = "\x1B[2~" }}); result.set(.insert, pcStyle("\x1b[2;{}~") ++ .{Entry{ .sequence = "\x1B[2~" }});
result.set(.delete, pcStyle("\x1b[3;{}~") ++ .{.{ .sequence = "\x1B[3~" }}); result.set(.delete, pcStyle("\x1b[3;{}~") ++ .{Entry{ .sequence = "\x1B[3~" }});
result.set(.page_up, pcStyle("\x1b[5;{}~") ++ .{.{ .sequence = "\x1B[5~" }}); result.set(.page_up, pcStyle("\x1b[5;{}~") ++ .{Entry{ .sequence = "\x1B[5~" }});
result.set(.page_down, pcStyle("\x1b[6;{}~") ++ .{.{ .sequence = "\x1B[6~" }}); result.set(.page_down, pcStyle("\x1b[6;{}~") ++ .{Entry{ .sequence = "\x1B[6~" }});
// Function Keys. todo: f13-f35 but we need to add to input.Key // Function Keys. todo: f13-f35 but we need to add to input.Key
result.set(.f1, pcStyle("\x1b[1;{}P") ++ .{.{ .sequence = "\x1BOP" }}); result.set(.f1, pcStyle("\x1b[1;{}P") ++ .{Entry{ .sequence = "\x1BOP" }});
result.set(.f2, pcStyle("\x1b[1;{}Q") ++ .{.{ .sequence = "\x1BOQ" }}); result.set(.f2, pcStyle("\x1b[1;{}Q") ++ .{Entry{ .sequence = "\x1BOQ" }});
result.set(.f3, pcStyle("\x1b[13;{}~") ++ .{.{ .sequence = "\x1BOR" }}); result.set(.f3, pcStyle("\x1b[13;{}~") ++ .{Entry{ .sequence = "\x1BOR" }});
result.set(.f4, pcStyle("\x1b[1;{}S") ++ .{.{ .sequence = "\x1BOS" }}); result.set(.f4, pcStyle("\x1b[1;{}S") ++ .{Entry{ .sequence = "\x1BOS" }});
result.set(.f5, pcStyle("\x1b[15;{}~") ++ .{.{ .sequence = "\x1B[15~" }}); result.set(.f5, pcStyle("\x1b[15;{}~") ++ .{Entry{ .sequence = "\x1B[15~" }});
result.set(.f6, pcStyle("\x1b[17;{}~") ++ .{.{ .sequence = "\x1B[17~" }}); result.set(.f6, pcStyle("\x1b[17;{}~") ++ .{Entry{ .sequence = "\x1B[17~" }});
result.set(.f7, pcStyle("\x1b[18;{}~") ++ .{.{ .sequence = "\x1B[18~" }}); result.set(.f7, pcStyle("\x1b[18;{}~") ++ .{Entry{ .sequence = "\x1B[18~" }});
result.set(.f8, pcStyle("\x1b[19;{}~") ++ .{.{ .sequence = "\x1B[19~" }}); result.set(.f8, pcStyle("\x1b[19;{}~") ++ .{Entry{ .sequence = "\x1B[19~" }});
result.set(.f9, pcStyle("\x1b[20;{}~") ++ .{.{ .sequence = "\x1B[20~" }}); result.set(.f9, pcStyle("\x1b[20;{}~") ++ .{Entry{ .sequence = "\x1B[20~" }});
result.set(.f10, pcStyle("\x1b[21;{}~") ++ .{.{ .sequence = "\x1B[21~" }}); result.set(.f10, pcStyle("\x1b[21;{}~") ++ .{Entry{ .sequence = "\x1B[21~" }});
result.set(.f11, pcStyle("\x1b[23;{}~") ++ .{.{ .sequence = "\x1B[23~" }}); result.set(.f11, pcStyle("\x1b[23;{}~") ++ .{Entry{ .sequence = "\x1B[23~" }});
result.set(.f12, pcStyle("\x1b[24;{}~") ++ .{.{ .sequence = "\x1B[24~" }}); result.set(.f12, pcStyle("\x1b[24;{}~") ++ .{Entry{ .sequence = "\x1B[24~" }});
// Keypad keys // Keypad keys
result.set(.kp_0, kpKeys("p")); result.set(.kp_0, kpKeys("p"));
@@ -116,7 +116,7 @@ pub const keys = keys: {
result.set(.kp_multiply, kpKeys("j")); result.set(.kp_multiply, kpKeys("j"));
result.set(.kp_subtract, kpKeys("m")); result.set(.kp_subtract, kpKeys("m"));
result.set(.kp_add, kpKeys("k")); result.set(.kp_add, kpKeys("k"));
result.set(.kp_enter, kpKeys("M") ++ .{.{ .sequence = "\r" }}); result.set(.kp_enter, kpKeys("M") ++ .{Entry{ .sequence = "\r" }});
result.set(.kp_up, pcStyle("\x1b[1;{}A") ++ cursorKey("\x1b[A", "\x1bOA")); result.set(.kp_up, pcStyle("\x1b[1;{}A") ++ cursorKey("\x1b[A", "\x1bOA"));
result.set(.kp_down, pcStyle("\x1b[1;{}B") ++ cursorKey("\x1b[B", "\x1bOB")); result.set(.kp_down, pcStyle("\x1b[1;{}B") ++ cursorKey("\x1b[B", "\x1bOB"));
result.set(.kp_right, pcStyle("\x1b[1;{}C") ++ cursorKey("\x1b[C", "\x1bOC")); result.set(.kp_right, pcStyle("\x1b[1;{}C") ++ cursorKey("\x1b[C", "\x1bOC"));
@@ -124,10 +124,10 @@ pub const keys = keys: {
result.set(.kp_begin, pcStyle("\x1b[1;{}E") ++ cursorKey("\x1b[E", "\x1bOE")); result.set(.kp_begin, pcStyle("\x1b[1;{}E") ++ cursorKey("\x1b[E", "\x1bOE"));
result.set(.kp_home, pcStyle("\x1b[1;{}H") ++ cursorKey("\x1b[H", "\x1bOH")); result.set(.kp_home, pcStyle("\x1b[1;{}H") ++ cursorKey("\x1b[H", "\x1bOH"));
result.set(.kp_end, pcStyle("\x1b[1;{}F") ++ cursorKey("\x1b[F", "\x1bOF")); result.set(.kp_end, pcStyle("\x1b[1;{}F") ++ cursorKey("\x1b[F", "\x1bOF"));
result.set(.kp_insert, pcStyle("\x1b[2;{}~") ++ .{.{ .sequence = "\x1B[2~" }}); result.set(.kp_insert, pcStyle("\x1b[2;{}~") ++ .{Entry{ .sequence = "\x1B[2~" }});
result.set(.kp_delete, pcStyle("\x1b[3;{}~") ++ .{.{ .sequence = "\x1B[3~" }}); result.set(.kp_delete, pcStyle("\x1b[3;{}~") ++ .{Entry{ .sequence = "\x1B[3~" }});
result.set(.kp_page_up, pcStyle("\x1b[5;{}~") ++ .{.{ .sequence = "\x1B[5~" }}); result.set(.kp_page_up, pcStyle("\x1b[5;{}~") ++ .{Entry{ .sequence = "\x1B[5~" }});
result.set(.kp_page_down, pcStyle("\x1b[6;{}~") ++ .{.{ .sequence = "\x1B[6~" }}); result.set(.kp_page_down, pcStyle("\x1b[6;{}~") ++ .{Entry{ .sequence = "\x1B[6~" }});
result.set(.backspace, &.{ result.set(.backspace, &.{
// Modify Keys Normal // Modify Keys Normal

View File

@@ -73,7 +73,7 @@ pub fn generate(
var buffer = std.ArrayList(u8).init(page_allocator); var buffer = std.ArrayList(u8).init(page_allocator);
defer buffer.deinit(); defer buffer.deinit();
const fields = @typeInfo(KeybindAction).Union.fields; const fields = @typeInfo(KeybindAction).@"union".fields;
inline for (fields) |field| { inline for (fields) |field| {
if (field.name[0] == '_') continue; if (field.name[0] == '_') continue;

View File

@@ -152,7 +152,7 @@ pub const Mods = packed struct(Mods.Backing) {
pub fn translation(self: Mods, option_as_alt: config.OptionAsAlt) Mods { pub fn translation(self: Mods, option_as_alt: config.OptionAsAlt) Mods {
// We currently only process macos-option-as-alt so other // We currently only process macos-option-as-alt so other
// platforms don't need to do anything. // platforms don't need to do anything.
if (comptime !builtin.target.isDarwin()) return self; if (comptime !builtin.target.os.tag.isDarwin()) return self;
// Alt has to be set only on the correct side // Alt has to be set only on the correct side
switch (option_as_alt) { switch (option_as_alt) {
@@ -170,7 +170,7 @@ pub const Mods = packed struct(Mods.Backing) {
/// Checks to see if super is on (MacOS) or ctrl. /// Checks to see if super is on (MacOS) or ctrl.
pub fn ctrlOrSuper(self: Mods) bool { pub fn ctrlOrSuper(self: Mods) bool {
if (comptime builtin.target.isDarwin()) { if (comptime builtin.target.os.tag.isDarwin()) {
return self.super; return self.super;
} }
return self.ctrl; return self.ctrl;
@@ -187,7 +187,7 @@ pub const Mods = packed struct(Mods.Backing) {
} }
test "translation macos-option-as-alt" { test "translation macos-option-as-alt" {
if (comptime !builtin.target.isDarwin()) return error.SkipZigTest; if (comptime !builtin.target.os.tag.isDarwin()) return error.SkipZigTest;
const testing = std.testing; const testing = std.testing;
@@ -646,7 +646,7 @@ pub const Key = enum(c_int) {
/// true if this key is one of the left or right versions of super (MacOS) /// true if this key is one of the left or right versions of super (MacOS)
/// or ctrl. /// or ctrl.
pub fn ctrlOrSuper(self: Key) bool { pub fn ctrlOrSuper(self: Key) bool {
if (comptime builtin.target.isDarwin()) { if (comptime builtin.target.os.tag.isDarwin()) {
return self == .left_super or self == .right_super; return self == .left_super or self == .right_super;
} }
return self == .left_control or self == .right_control; return self == .left_control or self == .right_control;
@@ -757,7 +757,7 @@ pub const Key = enum(c_int) {
/// non-Mac we default to ctrl (i.e. ctrl+c for copy). /// non-Mac we default to ctrl (i.e. ctrl+c for copy).
pub fn ctrlOrSuper(mods: Mods) Mods { pub fn ctrlOrSuper(mods: Mods) Mods {
var copy = mods; var copy = mods;
if (comptime builtin.target.isDarwin()) { if (comptime builtin.target.os.tag.isDarwin()) {
copy.super = true; copy.super = true;
} else { } else {
copy.ctrl = true; copy.ctrl = true;

View File

@@ -27,7 +27,7 @@ pub const Button = enum(c_int) {
/// packed array, for example. /// packed array, for example.
pub const max = max: { pub const max = max: {
var cur = 0; var cur = 0;
for (@typeInfo(Self).Enum.fields) |field| { for (@typeInfo(Self).@"enum".fields) |field| {
if (field.value > cur) cur = field.value; if (field.value > cur) cur = field.value;
} }

View File

@@ -602,7 +602,7 @@ fn renderModesWindow(self: *Inspector) void {
} }
const t = self.surface.renderer_state.terminal; const t = self.surface.renderer_state.terminal;
inline for (@typeInfo(terminal.Mode).Enum.fields) |field| { inline for (@typeInfo(terminal.Mode).@"enum".fields) |field| {
const tag: terminal.modes.ModeTag = @bitCast(@as(terminal.modes.ModeTag.Backing, field.value)); const tag: terminal.modes.ModeTag = @bitCast(@as(terminal.modes.ModeTag.Backing, field.value));
cimgui.c.igTableNextRow(cimgui.c.ImGuiTableRowFlags_None, 0); cimgui.c.igTableNextRow(cimgui.c.ImGuiTableRowFlags_None, 0);
@@ -1298,7 +1298,7 @@ fn renderTermioWindow(self: *Inspector) void {
); );
defer cimgui.c.igEndTable(); defer cimgui.c.igEndTable();
inline for (@typeInfo(terminal.Parser.Action.Tag).Enum.fields) |field| { inline for (@typeInfo(terminal.Parser.Action.Tag).@"enum".fields) |field| {
const tag = @field(terminal.Parser.Action.Tag, field.name); const tag = @field(terminal.Parser.Action.Tag, field.name);
if (tag == .apc_put or tag == .dcs_put) continue; if (tag == .apc_put or tag == .dcs_put) continue;

View File

@@ -199,7 +199,7 @@ pub const VTEvent = struct {
void => {}, void => {},
[]const u8 => try md.put("data", try alloc.dupeZ(u8, v)), []const u8 => try md.put("data", try alloc.dupeZ(u8, v)),
else => |T| switch (@typeInfo(T)) { else => |T| switch (@typeInfo(T)) {
.Struct => |info| inline for (info.fields) |field| { .@"struct" => |info| inline for (info.fields) |field| {
try encodeMetadataSingle( try encodeMetadataSingle(
alloc, alloc,
md, md,
@@ -208,7 +208,7 @@ pub const VTEvent = struct {
); );
}, },
.Union => |info| { .@"union" => |info| {
const Tag = info.tag_type orelse @compileError("Unions must have a tag"); const Tag = info.tag_type orelse @compileError("Unions must have a tag");
const tag_name = @tagName(@as(Tag, v)); const tag_name = @tagName(@as(Tag, v));
inline for (info.fields) |field| { inline for (info.fields) |field| {
@@ -239,23 +239,23 @@ pub const VTEvent = struct {
const Value = @TypeOf(value); const Value = @TypeOf(value);
const info = @typeInfo(Value); const info = @typeInfo(Value);
switch (info) { switch (info) {
.Optional => if (value) |unwrapped| { .optional => if (value) |unwrapped| {
try encodeMetadataSingle(alloc, md, key, unwrapped); try encodeMetadataSingle(alloc, md, key, unwrapped);
} else { } else {
try md.put(key, try alloc.dupeZ(u8, "(unset)")); try md.put(key, try alloc.dupeZ(u8, "(unset)"));
}, },
.Bool => try md.put( .bool => try md.put(
key, key,
try alloc.dupeZ(u8, if (value) "true" else "false"), try alloc.dupeZ(u8, if (value) "true" else "false"),
), ),
.Enum => try md.put( .@"enum" => try md.put(
key, key,
try alloc.dupeZ(u8, @tagName(value)), try alloc.dupeZ(u8, @tagName(value)),
), ),
.Union => |u| { .@"union" => |u| {
const Tag = u.tag_type orelse @compileError("Unions must have a tag"); const Tag = u.tag_type orelse @compileError("Unions must have a tag");
const tag_name = @tagName(@as(Tag, value)); const tag_name = @tagName(@as(Tag, value));
inline for (u.fields) |field| { inline for (u.fields) |field| {
@@ -273,7 +273,7 @@ pub const VTEvent = struct {
} }
}, },
.Struct => try md.put( .@"struct" => try md.put(
key, key,
try alloc.dupeZ(u8, @typeName(Value)), try alloc.dupeZ(u8, @typeName(Value)),
), ),

View File

@@ -130,7 +130,7 @@ fn logFn(
// //
// sudo log stream --level debug --predicate 'subsystem=="com.mitchellh.ghostty"' // sudo log stream --level debug --predicate 'subsystem=="com.mitchellh.ghostty"'
// //
if (builtin.target.isDarwin()) { if (builtin.target.os.tag.isDarwin()) {
// Convert our levels to Mac levels // Convert our levels to Mac levels
const mac_level: macos.os.LogType = switch (level) { const mac_level: macos.os.LogType = switch (level) {
.debug => .debug, .debug => .debug,

View File

@@ -147,7 +147,7 @@ extern fn dgettext(domainname: [*:0]const u8, msgid: [*:0]const u8) [*:0]const u
extern fn _libintl_locale_name_canonicalize(name: [*:0]u8) void; extern fn _libintl_locale_name_canonicalize(name: [*:0]u8) void;
test "canonicalizeLocale darwin" { test "canonicalizeLocale darwin" {
if (!builtin.target.isDarwin()) return error.SkipZigTest; if (!builtin.target.os.tag.isDarwin()) return error.SkipZigTest;
const testing = std.testing; const testing = std.testing;
var buf: [256]u8 = undefined; var buf: [256]u8 = undefined;

View File

@@ -21,7 +21,7 @@ pub fn ensureLocale(alloc: std.mem.Allocator) !void {
// When launching the .app, LANG is not set so we must query it from the // When launching the .app, LANG is not set so we must query it from the
// OS. When launching from the CLI, LANG is usually set by the parent // OS. When launching from the CLI, LANG is usually set by the parent
// process. // process.
if (comptime builtin.target.isDarwin()) { if (comptime builtin.target.os.tag.isDarwin()) {
// Set the lang if it is not set or if its empty. // Set the lang if it is not set or if its empty.
if (lang == null or lang.?.value.len == 0) { if (lang == null or lang.?.value.len == 0) {
setLangFromCocoa(); setLangFromCocoa();

View File

@@ -7,7 +7,7 @@ const Allocator = std.mem.Allocator;
/// Verifies that the running macOS system version is at least the given version. /// Verifies that the running macOS system version is at least the given version.
pub fn isAtLeastVersion(major: i64, minor: i64, patch: i64) bool { pub fn isAtLeastVersion(major: i64, minor: i64, patch: i64) bool {
comptime assert(builtin.target.isDarwin()); comptime assert(builtin.target.os.tag.isDarwin());
const NSProcessInfo = objc.getClass("NSProcessInfo").?; const NSProcessInfo = objc.getClass("NSProcessInfo").?;
const info = NSProcessInfo.msgSend(objc.Object, objc.sel("processInfo"), .{}); const info = NSProcessInfo.msgSend(objc.Object, objc.sel("processInfo"), .{});
@@ -108,7 +108,7 @@ fn commonDir(
directory: NSSearchPathDirectory, directory: NSSearchPathDirectory,
sub_paths: []const []const u8, sub_paths: []const []const u8,
) (error{AppleAPIFailed} || Allocator.Error)![]const u8 { ) (error{AppleAPIFailed} || Allocator.Error)![]const u8 {
comptime assert(builtin.target.isDarwin()); comptime assert(builtin.target.os.tag.isDarwin());
const NSFileManager = objc.getClass("NSFileManager").?; const NSFileManager = objc.getClass("NSFileManager").?;
const manager = NSFileManager.msgSend( const manager = NSFileManager.msgSend(
@@ -146,7 +146,7 @@ fn commonDir(
} }
test "cacheDir paths" { test "cacheDir paths" {
if (!builtin.target.isDarwin()) return; if (!builtin.target.os.tag.isDarwin()) return;
const testing = std.testing; const testing = std.testing;
const alloc = testing.allocator; const alloc = testing.allocator;

View File

@@ -57,14 +57,14 @@ pub fn open(
// 50 KiB is the default value used by std.process.Child.run // 50 KiB is the default value used by std.process.Child.run
const output_max_size = 50 * 1024; const output_max_size = 50 * 1024;
var stdout = std.ArrayList(u8).init(alloc); var stdout: std.ArrayListUnmanaged(u8) = .{};
var stderr = std.ArrayList(u8).init(alloc); var stderr: std.ArrayListUnmanaged(u8) = .{};
defer { defer {
stdout.deinit(); stdout.deinit(alloc);
stderr.deinit(); stderr.deinit(alloc);
} }
try exe.collectOutput(&stdout, &stderr, output_max_size); try exe.collectOutput(alloc, &stdout, &stderr, output_max_size);
_ = try exe.wait(); _ = try exe.wait();
// If we have any stderr output we log it. This makes it easier for // If we have any stderr output we log it. This makes it easier for

View File

@@ -10,7 +10,7 @@ const log = std.log.scoped(.passwd);
// We want to be extra sure since this will force bad symbols into our import table // We want to be extra sure since this will force bad symbols into our import table
comptime { comptime {
if (builtin.target.isWasm()) { if (builtin.target.cpu.arch.isWasm()) {
@compileError("passwd is not available for wasm"); @compileError("passwd is not available for wasm");
} }
} }

View File

@@ -46,7 +46,7 @@ pub fn resourcesDir(alloc: std.mem.Allocator) !?[]const u8 {
exe = dir; exe = dir;
// On MacOS, we look for the app bundle path. // On MacOS, we look for the app bundle path.
if (comptime builtin.target.isDarwin()) { if (comptime builtin.target.os.tag.isDarwin()) {
if (try maybeDir(&dir_buf, dir, "Contents/Resources", sentinel)) |v| { if (try maybeDir(&dir_buf, dir, "Contents/Resources", sentinel)) |v| {
return try std.fs.path.join(alloc, &.{ v, "ghostty" }); return try std.fs.path.join(alloc, &.{ v, "ghostty" });
} }

View File

@@ -67,7 +67,7 @@ pub export fn free(ptr: ?[*]u8) void {
/// to the host. /// to the host.
pub fn toHostOwned(ptr: anytype) ![*]u8 { pub fn toHostOwned(ptr: anytype) ![*]u8 {
// Convert our pointer to a byte array // Convert our pointer to a byte array
const info = @typeInfo(@TypeOf(ptr)).Pointer; const info = @typeInfo(@TypeOf(ptr)).pointer;
const T = info.child; const T = info.child;
const size = @sizeOf(T); const size = @sizeOf(T);
const casted = @as([*]u8, @ptrFromInt(@intFromPtr(ptr))); const casted = @as([*]u8, @ptrFromInt(@intFromPtr(ptr)));

View File

@@ -215,19 +215,19 @@ const PosixPty = struct {
.mask = posix.empty_sigset, .mask = posix.empty_sigset,
.flags = 0, .flags = 0,
}; };
try posix.sigaction(posix.SIG.ABRT, &sa, null); posix.sigaction(posix.SIG.ABRT, &sa, null);
try posix.sigaction(posix.SIG.ALRM, &sa, null); posix.sigaction(posix.SIG.ALRM, &sa, null);
try posix.sigaction(posix.SIG.BUS, &sa, null); posix.sigaction(posix.SIG.BUS, &sa, null);
try posix.sigaction(posix.SIG.CHLD, &sa, null); posix.sigaction(posix.SIG.CHLD, &sa, null);
try posix.sigaction(posix.SIG.FPE, &sa, null); posix.sigaction(posix.SIG.FPE, &sa, null);
try posix.sigaction(posix.SIG.HUP, &sa, null); posix.sigaction(posix.SIG.HUP, &sa, null);
try posix.sigaction(posix.SIG.ILL, &sa, null); posix.sigaction(posix.SIG.ILL, &sa, null);
try posix.sigaction(posix.SIG.INT, &sa, null); posix.sigaction(posix.SIG.INT, &sa, null);
try posix.sigaction(posix.SIG.PIPE, &sa, null); posix.sigaction(posix.SIG.PIPE, &sa, null);
try posix.sigaction(posix.SIG.SEGV, &sa, null); posix.sigaction(posix.SIG.SEGV, &sa, null);
try posix.sigaction(posix.SIG.TRAP, &sa, null); posix.sigaction(posix.SIG.TRAP, &sa, null);
try posix.sigaction(posix.SIG.TERM, &sa, null); posix.sigaction(posix.SIG.TERM, &sa, null);
try posix.sigaction(posix.SIG.QUIT, &sa, null); posix.sigaction(posix.SIG.QUIT, &sa, null);
// Create a new process group // Create a new process group
if (setsid() < 0) return error.ProcessGroupFailed; if (setsid() < 0) return error.ProcessGroupFailed;

View File

@@ -1147,12 +1147,12 @@ pub fn updateFrame(
// the entire screen. This can be optimized in the future. // the entire screen. This can be optimized in the future.
const full_rebuild: bool = rebuild: { const full_rebuild: bool = rebuild: {
{ {
const Int = @typeInfo(terminal.Terminal.Dirty).Struct.backing_integer.?; const Int = @typeInfo(terminal.Terminal.Dirty).@"struct".backing_integer.?;
const v: Int = @bitCast(state.terminal.flags.dirty); const v: Int = @bitCast(state.terminal.flags.dirty);
if (v > 0) break :rebuild true; if (v > 0) break :rebuild true;
} }
{ {
const Int = @typeInfo(terminal.Screen.Dirty).Struct.backing_integer.?; const Int = @typeInfo(terminal.Screen.Dirty).@"struct".backing_integer.?;
const v: Int = @bitCast(state.terminal.screen.dirty); const v: Int = @bitCast(state.terminal.screen.dirty);
if (v > 0) break :rebuild true; if (v > 0) break :rebuild true;
} }

View File

@@ -799,12 +799,12 @@ pub fn updateFrame(
// the entire screen. This can be optimized in the future. // the entire screen. This can be optimized in the future.
const full_rebuild: bool = rebuild: { const full_rebuild: bool = rebuild: {
{ {
const Int = @typeInfo(terminal.Terminal.Dirty).Struct.backing_integer.?; const Int = @typeInfo(terminal.Terminal.Dirty).@"struct".backing_integer.?;
const v: Int = @bitCast(state.terminal.flags.dirty); const v: Int = @bitCast(state.terminal.flags.dirty);
if (v > 0) break :rebuild true; if (v > 0) break :rebuild true;
} }
{ {
const Int = @typeInfo(terminal.Screen.Dirty).Struct.backing_integer.?; const Int = @typeInfo(terminal.Screen.Dirty).@"struct".backing_integer.?;
const v: Int = @bitCast(state.terminal.screen.dirty); const v: Int = @bitCast(state.terminal.screen.dirty);
if (v > 0) break :rebuild true; if (v > 0) break :rebuild true;
} }
@@ -2327,7 +2327,7 @@ pub fn drawFrame(self: *OpenGL, surface: *apprt.Surface) !void {
// This locks the context and avoids crashes that can happen due to // This locks the context and avoids crashes that can happen due to
// races with the underlying Metal layer that Apple is using to // races with the underlying Metal layer that Apple is using to
// implement OpenGL. // implement OpenGL.
const is_darwin = builtin.target.isDarwin(); const is_darwin = builtin.target.os.tag.isDarwin();
const ogl = if (comptime is_darwin) @cImport({ const ogl = if (comptime is_darwin) @cImport({
@cInclude("OpenGL/OpenGL.h"); @cInclude("OpenGL/OpenGL.h");
}) else {}; }) else {};

View File

@@ -248,7 +248,7 @@ fn threadMain_(self: *Thread) !void {
fn setQosClass(self: *const Thread) void { fn setQosClass(self: *const Thread) void {
// Thread QoS classes are only relevant on macOS. // Thread QoS classes are only relevant on macOS.
if (comptime !builtin.target.isDarwin()) return; if (comptime !builtin.target.os.tag.isDarwin()) return;
const class: internal_os.macos.QosClass = class: { const class: internal_os.macos.QosClass = class: {
// If we aren't visible (our view is fully occluded) then we // If we aren't visible (our view is fully occluded) then we

View File

@@ -34,7 +34,7 @@ pub const MTLResourceOptions = packed struct(c_ulong) {
hazard_tracking_mode: HazardTrackingMode = .default, hazard_tracking_mode: HazardTrackingMode = .default,
_pad: @Type(.{ _pad: @Type(.{
.Int = .{ .signedness = .unsigned, .bits = @bitSizeOf(c_ulong) - 10 }, .int = .{ .signedness = .unsigned, .bits = @bitSizeOf(c_ulong) - 10 },
}) = 0, }) = 0,
pub const CPUCacheMode = enum(u4) { pub const CPUCacheMode = enum(u4) {

View File

@@ -681,11 +681,11 @@ fn initImagePipeline(
} }
fn autoAttribute(T: type, attrs: objc.Object) void { fn autoAttribute(T: type, attrs: objc.Object) void {
inline for (@typeInfo(T).Struct.fields, 0..) |field, i| { inline for (@typeInfo(T).@"struct".fields, 0..) |field, i| {
const offset = @offsetOf(T, field.name); const offset = @offsetOf(T, field.name);
const FT = switch (@typeInfo(field.type)) { const FT = switch (@typeInfo(field.type)) {
.Enum => |e| e.tag_type, .@"enum" => |e| e.tag_type,
else => field.type, else => field.type,
}; };

View File

@@ -67,7 +67,7 @@ pub const CellMode = enum(u8) {
// Since we use bit tricks below, we want to ensure the enum // Since we use bit tricks below, we want to ensure the enum
// doesn't change without us looking at this logic again. // doesn't change without us looking at this logic again.
comptime { comptime {
const info = @typeInfo(CellMode).Enum; const info = @typeInfo(CellMode).@"enum";
std.debug.assert(info.fields.len == 5); std.debug.assert(info.fields.len == 5);
} }

View File

@@ -75,7 +75,7 @@ pub const Coordinate = union(enum) {
terminal: Terminal, terminal: Terminal,
grid: Grid, grid: Grid,
pub const Tag = @typeInfo(Coordinate).Union.tag_type.?; pub const Tag = @typeInfo(Coordinate).@"union".tag_type.?;
pub const Surface = struct { x: f64, y: f64 }; pub const Surface = struct { x: f64, y: f64 };
pub const Terminal = struct { x: f64, y: f64 }; pub const Terminal = struct { x: f64, y: f64 };
pub const Grid = struct { x: GridSize.Unit, y: GridSize.Unit }; pub const Grid = struct { x: GridSize.Unit, y: GridSize.Unit };

View File

@@ -120,7 +120,7 @@ fn isMouseModeOverrideState(mods: input.Mods) bool {
/// Returns true if our modifiers put us in a state where dragging /// Returns true if our modifiers put us in a state where dragging
/// should cause a rectangle select. /// should cause a rectangle select.
pub fn isRectangleSelectState(mods: input.Mods) bool { pub fn isRectangleSelectState(mods: input.Mods) bool {
return if (comptime builtin.target.isDarwin()) return if (comptime builtin.target.os.tag.isDarwin())
mods.alt mods.alt
else else
mods.ctrlOrSuper() and mods.alt; mods.ctrlOrSuper() and mods.alt;

View File

@@ -148,7 +148,7 @@ pub const Action = union(enum) {
) !void { ) !void {
_ = layout; _ = layout;
const T = Action; const T = Action;
const info = @typeInfo(T).Union; const info = @typeInfo(T).@"union";
try writer.writeAll(@typeName(T)); try writer.writeAll(@typeName(T));
if (info.tag_type) |TagType| { if (info.tag_type) |TagType| {

View File

@@ -77,7 +77,7 @@ default_palette: color.Palette = color.default,
/// The color palette to use. The mask indicates which palette indices have been /// The color palette to use. The mask indicates which palette indices have been
/// modified with OSC 4 /// modified with OSC 4
color_palette: struct { color_palette: struct {
const Mask = std.StaticBitSet(@typeInfo(color.Palette).Array.len); const Mask = std.StaticBitSet(@typeInfo(color.Palette).array.len);
colors: color.Palette = color.default, colors: color.Palette = color.default,
mask: Mask = Mask.initEmpty(), mask: Mask = Mask.initEmpty(),
} = .{}, } = .{},

View File

@@ -99,7 +99,7 @@ fn initTable() [table_len]u16 {
test { test {
const testing = std.testing; const testing = std.testing;
const info = @typeInfo(Charset).Enum; const info = @typeInfo(Charset).@"enum";
inline for (info.fields) |field| { inline for (info.fields) |field| {
// utf8 has no table // utf8 has no table
if (@field(Charset, field.name) == .utf8) continue; if (@field(Charset, field.name) == .utf8) continue;

View File

@@ -14,7 +14,7 @@ pub const Request = dsr_enum: {
}; };
} }
break :dsr_enum @Type(.{ .Enum = .{ break :dsr_enum @Type(.{ .@"enum" = .{
.tag_type = Tag.Backing, .tag_type = Tag.Backing,
.fields = &fields, .fields = &fields,
.decls = &.{}, .decls = &.{},
@@ -27,7 +27,7 @@ pub const Request = dsr_enum: {
/// chosen somewhat arbitrarily to match the largest expected size /// chosen somewhat arbitrarily to match the largest expected size
/// we see as a multiple of 8 bits. /// we see as a multiple of 8 bits.
pub const Tag = packed struct(u16) { pub const Tag = packed struct(u16) {
pub const Backing = @typeInfo(@This()).Struct.backing_integer.?; pub const Backing = @typeInfo(@This()).@"struct".backing_integer.?;
value: u15, value: u15,
question: bool = false, question: bool = false,

View File

@@ -204,8 +204,8 @@ fn HashMapUnmanaged(
} }
pub fn takeFingerprint(hash: Hash) FingerPrint { pub fn takeFingerprint(hash: Hash) FingerPrint {
const hash_bits = @typeInfo(Hash).Int.bits; const hash_bits = @typeInfo(Hash).int.bits;
const fp_bits = @typeInfo(FingerPrint).Int.bits; const fp_bits = @typeInfo(FingerPrint).int.bits;
return @as(FingerPrint, @truncate(hash >> (hash_bits - fp_bits))); return @as(FingerPrint, @truncate(hash >> (hash_bits - fp_bits)));
} }
@@ -688,8 +688,6 @@ fn HashMapUnmanaged(
return result; return result;
} }
pub fn getOrPutAssumeCapacityAdapted(self: *Self, key: anytype, ctx: anytype) GetOrPutResult { pub fn getOrPutAssumeCapacityAdapted(self: *Self, key: anytype, ctx: anytype) GetOrPutResult {
comptime std.hash_map.verifyContext(@TypeOf(ctx), @TypeOf(key), K, Hash, false);
// If you get a compile error on this line, it means that your generic hash // If you get a compile error on this line, it means that your generic hash
// function is invalid for these parameters. // function is invalid for these parameters.
const hash = ctx.hash(key); const hash = ctx.hash(key);

View File

@@ -30,7 +30,7 @@ pub const Special = enum {
}; };
pub const Kind = union(enum) { pub const Kind = union(enum) {
pub const max: usize = std.math.maxInt(u8) + @typeInfo(Special).Enum.fields.len; pub const max: usize = std.math.maxInt(u8) + @typeInfo(Special).@"enum".fields.len;
palette: u8, palette: u8,
special: Special, special: Special,

View File

@@ -553,12 +553,11 @@ const IncompletePlacement = struct {
/// Get the row/col index for a diacritic codepoint. These are 0-indexed. /// Get the row/col index for a diacritic codepoint. These are 0-indexed.
fn getIndex(cp: u21) ?u32 { fn getIndex(cp: u21) ?u32 {
const idx = std.sort.binarySearch(u21, cp, diacritics, {}, (struct { const idx = std.sort.binarySearch(u21, diacritics, cp, (struct {
fn order(context: void, lhs: u21, rhs: u21) std.math.Order { fn compare(context: u21, item: u21) std.math.Order {
_ = context; return std.math.order(context, item);
return std.math.order(lhs, rhs);
} }
}).order) orelse return null; }).compare) orelse return null;
return @intCast(idx); return @intCast(idx);
} }

View File

@@ -93,13 +93,13 @@ pub const ModePacked = packed_struct: {
fields[i] = .{ fields[i] = .{
.name = entry.name, .name = entry.name,
.type = bool, .type = bool,
.default_value = &entry.default, .default_value_ptr = &entry.default,
.is_comptime = false, .is_comptime = false,
.alignment = 0, .alignment = 0,
}; };
} }
break :packed_struct @Type(.{ .Struct = .{ break :packed_struct @Type(.{ .@"struct" = .{
.layout = .@"packed", .layout = .@"packed",
.fields = &fields, .fields = &fields,
.decls = &.{}, .decls = &.{},
@@ -121,7 +121,7 @@ pub const Mode = mode_enum: {
}; };
} }
break :mode_enum @Type(.{ .Enum = .{ break :mode_enum @Type(.{ .@"enum" = .{
.tag_type = ModeTag.Backing, .tag_type = ModeTag.Backing,
.fields = &fields, .fields = &fields,
.decls = &.{}, .decls = &.{},
@@ -132,7 +132,7 @@ pub const Mode = mode_enum: {
/// The tag type for our enum is a u16 but we use a packed struct /// The tag type for our enum is a u16 but we use a packed struct
/// in order to pack the ansi bit into the tag. /// in order to pack the ansi bit into the tag.
pub const ModeTag = packed struct(u16) { pub const ModeTag = packed struct(u16) {
pub const Backing = @typeInfo(@This()).Struct.backing_integer.?; pub const Backing = @typeInfo(@This()).@"struct".backing_integer.?;
value: u15, value: u15,
ansi: bool = false, ansi: bool = false,

View File

@@ -37,7 +37,7 @@ pub const Transition = struct {
fn genTableType(comptime optional: bool) type { fn genTableType(comptime optional: bool) type {
const max_u8 = std.math.maxInt(u8); const max_u8 = std.math.maxInt(u8);
const stateInfo = @typeInfo(State); const stateInfo = @typeInfo(State);
const max_state = stateInfo.Enum.fields.len; const max_state = stateInfo.@"enum".fields.len;
const Elem = if (optional) ?Transition else Transition; const Elem = if (optional) ?Transition else Transition;
return [max_u8 + 1][max_state]Elem; return [max_u8 + 1][max_state]Elem;
} }
@@ -56,7 +56,7 @@ fn genTable() Table {
// anywhere transitions // anywhere transitions
const stateInfo = @typeInfo(State); const stateInfo = @typeInfo(State);
inline for (stateInfo.Enum.fields) |field| { inline for (stateInfo.@"enum".fields) |field| {
const source: State = @enumFromInt(field.value); const source: State = @enumFromInt(field.value);
// anywhere => ground // anywhere => ground

View File

@@ -132,13 +132,13 @@ pub fn getOffset(
fn intFromBase(base: anytype) usize { fn intFromBase(base: anytype) usize {
const T = @TypeOf(base); const T = @TypeOf(base);
return switch (@typeInfo(T)) { return switch (@typeInfo(T)) {
.Pointer => |v| switch (v.size) { .pointer => |v| switch (v.size) {
.One, .one,
.Many, .many,
.C, .c,
=> @intFromPtr(base), => @intFromPtr(base),
.Slice => @intFromPtr(base.ptr), .slice => @intFromPtr(base.ptr),
}, },
else => switch (T) { else => switch (T) {

View File

@@ -42,7 +42,7 @@ pub fn Stream(comptime Handler: type) type {
// We use T with @hasDecl so it needs to be a struct. Unwrap the // We use T with @hasDecl so it needs to be a struct. Unwrap the
// pointer if we were given one. // pointer if we were given one.
const T = switch (@typeInfo(Handler)) { const T = switch (@typeInfo(Handler)) {
.Pointer => |p| p.child, .pointer => |p| p.child,
else => Handler, else => Handler,
}; };

View File

@@ -8,7 +8,7 @@ pub const map = colorMap() catch @compileError("failed to parse rgb.txt");
pub const ColorMap = std.StaticStringMapWithEql(RGB, std.static_string_map.eqlAsciiIgnoreCase); pub const ColorMap = std.StaticStringMapWithEql(RGB, std.static_string_map.eqlAsciiIgnoreCase);
fn colorMap() !ColorMap { fn colorMap() !ColorMap {
@setEvalBranchQuota(100_000); @setEvalBranchQuota(500_000);
const KV = struct { []const u8, RGB }; const KV = struct { []const u8, RGB };

View File

@@ -301,7 +301,7 @@ pub fn childExitedAbnormally(
// We don't print this on macOS because the exit code is always 0 // We don't print this on macOS because the exit code is always 0
// due to the way we launch the process. // due to the way we launch the process.
if (comptime !builtin.target.isDarwin()) { if (comptime !builtin.target.os.tag.isDarwin()) {
const exit_code_str = try std.fmt.allocPrint(alloc, "{d}", .{exit_code}); const exit_code_str = try std.fmt.allocPrint(alloc, "{d}", .{exit_code});
t.carriageReturn(); t.carriageReturn();
try t.linefeed(); try t.linefeed();
@@ -369,7 +369,7 @@ fn processExit(
if (runtime_ms) |runtime| runtime: { if (runtime_ms) |runtime| runtime: {
// On macOS, our exit code detection doesn't work, possibly // On macOS, our exit code detection doesn't work, possibly
// because of our `login` wrapper. More investigation required. // because of our `login` wrapper. More investigation required.
if (comptime !builtin.target.isDarwin()) { if (comptime !builtin.target.os.tag.isDarwin()) {
// If our exit code is zero, then the command was successful // If our exit code is zero, then the command was successful
// and we don't ever consider it abnormal. // and we don't ever consider it abnormal.
if (exit_code == 0) break :runtime; if (exit_code == 0) break :runtime;
@@ -751,7 +751,7 @@ const Subprocess = struct {
}); });
try env.put("TERMINFO", dir); try env.put("TERMINFO", dir);
} else { } else {
if (comptime builtin.target.isDarwin()) { if (comptime builtin.target.os.tag.isDarwin()) {
log.warn("ghostty terminfo not found, using xterm-256color", .{}); log.warn("ghostty terminfo not found, using xterm-256color", .{});
log.warn("the terminfo SHOULD exist on macos, please ensure", .{}); log.warn("the terminfo SHOULD exist on macos, please ensure", .{});
log.warn("you're using a valid app bundle.", .{}); log.warn("you're using a valid app bundle.", .{});
@@ -797,7 +797,7 @@ const Subprocess = struct {
// On macOS, export additional data directories from our // On macOS, export additional data directories from our
// application bundle. // application bundle.
if (comptime builtin.target.isDarwin()) darwin: { if (comptime builtin.target.os.tag.isDarwin()) darwin: {
const resources_dir = cfg.resources_dir orelse break :darwin; const resources_dir = cfg.resources_dir orelse break :darwin;
var buf: [std.fs.max_path_bytes]u8 = undefined; var buf: [std.fs.max_path_bytes]u8 = undefined;
@@ -908,7 +908,7 @@ const Subprocess = struct {
// If we're on macOS, we have to use `login(1)` to get all of // If we're on macOS, we have to use `login(1)` to get all of
// the proper environment variables set, a login shell, and proper // the proper environment variables set, a login shell, and proper
// hushlogin behavior. // hushlogin behavior.
if (comptime builtin.target.isDarwin()) darwin: { if (comptime builtin.target.os.tag.isDarwin()) darwin: {
const passwd = internal_os.passwd.get(alloc) catch |err| { const passwd = internal_os.passwd.get(alloc) catch |err| {
log.warn("failed to read passwd, not using a login shell err={}", .{err}); log.warn("failed to read passwd, not using a login shell err={}", .{err});
break :darwin; break :darwin;
@@ -1289,7 +1289,7 @@ const Subprocess = struct {
switch (posix.errno(c.killpg(pgid, c.SIGHUP))) { switch (posix.errno(c.killpg(pgid, c.SIGHUP))) {
.SUCCESS => log.debug("process group killed pgid={}", .{pgid}), .SUCCESS => log.debug("process group killed pgid={}", .{pgid}),
else => |err| killpg: { else => |err| killpg: {
if ((comptime builtin.target.isDarwin()) and if ((comptime builtin.target.os.tag.isDarwin()) and
err == .PERM) err == .PERM)
{ {
log.debug("killpg failed with EPERM, expected on Darwin and ignoring", .{}); log.debug("killpg failed with EPERM, expected on Darwin and ignoring", .{});

View File

@@ -139,8 +139,8 @@ pub fn MessageData(comptime Elem: type, comptime small_size: comptime_int) type
/// This can't and will never detect stable pointers. /// This can't and will never detect stable pointers.
pub fn init(alloc: Allocator, data: anytype) !Self { pub fn init(alloc: Allocator, data: anytype) !Self {
switch (@typeInfo(@TypeOf(data))) { switch (@typeInfo(@TypeOf(data))) {
.Pointer => |info| { .pointer => |info| {
assert(info.size == .Slice); assert(info.size == .slice);
assert(info.child == Elem); assert(info.child == Elem);
// If it fits in our small request, do that. // If it fits in our small request, do that.

View File

@@ -82,7 +82,7 @@ fn setupShell(
// If we're running "/bin/bash" on Darwin, we can assume // If we're running "/bin/bash" on Darwin, we can assume
// we're using Apple's Bash because /bin is non-writable // we're using Apple's Bash because /bin is non-writable
// on modern macOS due to System Integrity Protection. // on modern macOS due to System Integrity Protection.
if (comptime builtin.target.isDarwin()) { if (comptime builtin.target.os.tag.isDarwin()) {
if (std.mem.eql(u8, "/bin/bash", command)) { if (std.mem.eql(u8, "/bin/bash", command)) {
return null; return null;
} }
@@ -137,7 +137,7 @@ test "force shell" {
var env = EnvMap.init(alloc); var env = EnvMap.init(alloc);
defer env.deinit(); defer env.deinit();
inline for (@typeInfo(Shell).Enum.fields) |field| { inline for (@typeInfo(Shell).@"enum".fields) |field| {
const shell = @field(Shell, field.name); const shell = @field(Shell, field.name);
const result = try setup(alloc, ".", "sh", &env, shell, .{}); const result = try setup(alloc, ".", "sh", &env, shell, .{});
try testing.expectEqual(shell, result.?.shell); try testing.expectEqual(shell, result.?.shell);

View File

@@ -52,7 +52,7 @@ const Precompute = struct {
var result: [std.math.maxInt(u10)]Value = undefined; var result: [std.math.maxInt(u10)]Value = undefined;
@setEvalBranchQuota(3_000); @setEvalBranchQuota(3_000);
const info = @typeInfo(GraphemeBoundaryClass).Enum; const info = @typeInfo(GraphemeBoundaryClass).@"enum";
for (0..std.math.maxInt(u2) + 1) |state_init| { for (0..std.math.maxInt(u2) + 1) |state_init| {
for (info.fields) |field1| { for (info.fields) |field1| {
for (info.fields) |field2| { for (info.fields) |field2| {