From 0f4d2bb2375c707182dba8cf2dd7723a2e918e79 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 12 Mar 2025 09:55:46 -0700 Subject: [PATCH] Lots of 0.14 changes --- src/apprt/action.zig | 6 +- src/apprt/embedded.zig | 14 ++-- src/apprt/glfw.zig | 10 +-- src/apprt/gtk/App.zig | 4 +- src/apprt/gtk/winproto.zig | 4 +- src/build/webgen/main_commands.zig | 4 +- src/build/webgen/main_config.zig | 2 +- src/cli/action.zig | 2 +- src/cli/args.zig | 58 +++++++++-------- src/cli/diagnostics.zig | 6 +- src/cli/help.zig | 2 +- src/cli/show_face.zig | 4 +- src/config/Config.zig | 56 ++++++++-------- src/config/c_get.zig | 12 ++-- src/config/formatter.zig | 18 +++--- src/config/key.zig | 2 +- src/config/theme.zig | 2 +- src/crash/minidump/reader.zig | 8 +-- src/font/Collection.zig | 6 +- src/font/Metrics.zig | 4 +- src/font/SharedGridSet.zig | 8 +-- src/font/discovery.zig | 2 +- src/font/opentype/sfnt.zig | 2 +- src/font/opentype/svg.zig | 5 +- src/font/sprite/Box.zig | 19 ++++-- src/global.zig | 4 +- src/input/Binding.zig | 63 ++++++++++-------- src/input/KeyEncoder.zig | 8 +-- src/input/function_keys.zig | 42 ++++++------ src/input/helpgen_actions.zig | 2 +- src/input/key.zig | 10 +-- src/input/mouse.zig | 2 +- src/inspector/Inspector.zig | 4 +- src/inspector/termio.zig | 14 ++-- src/main_ghostty.zig | 2 +- src/os/i18n.zig | 2 +- src/os/locale.zig | 2 +- src/os/macos.zig | 6 +- src/os/open.zig | 10 +-- src/os/passwd.zig | 2 +- src/os/resourcesdir.zig | 2 +- src/os/wasm.zig | 2 +- src/pty.zig | 26 ++++---- src/renderer/Metal.zig | 4 +- src/renderer/OpenGL.zig | 86 ++++++++++++------------- src/renderer/Thread.zig | 2 +- src/renderer/metal/api.zig | 2 +- src/renderer/metal/shaders.zig | 4 +- src/renderer/opengl/CellProgram.zig | 2 +- src/renderer/size.zig | 2 +- src/surface_mouse.zig | 2 +- src/terminal/Parser.zig | 2 +- src/terminal/Terminal.zig | 2 +- src/terminal/charsets.zig | 2 +- src/terminal/device_status.zig | 4 +- src/terminal/hash_map.zig | 6 +- src/terminal/kitty/color.zig | 2 +- src/terminal/kitty/graphics_unicode.zig | 9 ++- src/terminal/modes.zig | 8 +-- src/terminal/parse_table.zig | 4 +- src/terminal/size.zig | 10 +-- src/terminal/stream.zig | 2 +- src/terminal/x11_color.zig | 2 +- src/termio/Exec.zig | 12 ++-- src/termio/message.zig | 4 +- src/termio/shell_integration.zig | 4 +- src/unicode/grapheme.zig | 2 +- 67 files changed, 326 insertions(+), 316 deletions(-) diff --git a/src/apprt/action.zig b/src/apprt/action.zig index 149118aa6..2ddbee524 100644 --- a/src/apprt/action.zig +++ b/src/apprt/action.zig @@ -291,7 +291,7 @@ pub const Action = union(Key) { /// Sync with: ghostty_action_u 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; for (key_fields, 0..) |field, i| { 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", .tag_type = Key, .fields = &union_fields, @@ -325,7 +325,7 @@ pub const Action = union(Key) { /// Returns the value type for the given key. 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); if (field_key == key) return field.type; } diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig index f7f67b270..4ad0390df 100644 --- a/src/apprt/embedded.zig +++ b/src/apprt/embedded.zig @@ -165,7 +165,7 @@ pub const App = struct { // then we strip the alt modifier from the mods for translation. const translate_mods = translate_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 // so we only want to run it if alt is already pressed hence // the above condition. @@ -184,7 +184,7 @@ pub const App = struct { // We strip super on macOS because its not used for translation // it results in a bad translation. - if (comptime builtin.target.isDarwin()) { + if (comptime builtin.target.os.tag.isDarwin()) { 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 // 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. nsview: objc.Object, } 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. uiview: objc.Object, } else void; @@ -1025,7 +1025,7 @@ pub const Surface = struct { var env = try internal_os.getEnvMap(alloc); errdefer env.deinit(); - if (comptime builtin.target.isDarwin()) { + if (comptime builtin.target.os.tag.isDarwin()) { if (env.get("__XCODE_BUILT_PRODUCTS_DIR_PATHS") != null) { env.remove("__XCODE_BUILT_PRODUCTS_DIR_PATHS"); env.remove("__XPC_DYLD_LIBRARY_PATH"); @@ -1078,7 +1078,7 @@ pub const Inspector = struct { pub fn deinit(self: Backend) void { 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 // so they're included in the C API. comptime { - if (builtin.target.isDarwin()) { + if (builtin.target.os.tag.isDarwin()) { _ = Darwin; } } diff --git a/src/apprt/glfw.zig b/src/apprt/glfw.zig index 935ca85ac..10835fb5f 100644 --- a/src/apprt/glfw.zig +++ b/src/apprt/glfw.zig @@ -25,7 +25,7 @@ const Config = @import("../config.zig").Config; // Get native API access on certain platforms so we can do more customization. const glfwNative = glfw.Native(.{ - .cocoa = builtin.target.isDarwin(), + .cocoa = builtin.target.os.tag.isDarwin(), .x11 = builtin.os.tag == .linux, }); @@ -45,7 +45,7 @@ pub const App = struct { pub const Options = struct {}; 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("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", .{}); @@ -439,7 +439,7 @@ pub const App = struct { /// Mac and the artifact is a standalone exe. We don't target libs because /// the embedded API doesn't do windowing. 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, @@ -767,7 +767,7 @@ pub const Surface = struct { /// Set the shape of the cursor. 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)) { // 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 // 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 // GLFW doesn't have a way to disable the alt key. key_event.consumed_mods.alt = true; diff --git a/src/apprt/gtk/App.zig b/src/apprt/gtk/App.zig index f84cf4319..2ed90eccf 100644 --- a/src/apprt/gtk/App.zig +++ b/src/apprt/gtk/App.zig @@ -226,7 +226,7 @@ pub fn init(core_app: *CoreApp, opts: Options) !App { var fmt = std.io.fixedBufferStream(&buf); const writer = fmt.writer(); 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 (!first) try writer.writeAll(","); try writer.writeAll(field.name); @@ -244,7 +244,7 @@ pub fn init(core_app: *CoreApp, opts: Options) !App { var fmt = std.io.fixedBufferStream(&buf); const writer = fmt.writer(); 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 (!first) try writer.writeAll(","); try writer.writeAll(field.name); diff --git a/src/apprt/gtk/winproto.zig b/src/apprt/gtk/winproto.zig index 01587a226..7fc7c0bd3 100644 --- a/src/apprt/gtk/winproto.zig +++ b/src/apprt/gtk/winproto.zig @@ -30,7 +30,7 @@ pub const App = union(Protocol) { app_id: [:0]const u8, config: *const Config, ) !App { - inline for (@typeInfo(App).Union.fields) |field| { + inline for (@typeInfo(App).@"union".fields) |field| { if (try field.type.init( alloc, gdk_display, @@ -96,7 +96,7 @@ pub const Window = union(Protocol) { ) !Window { return switch (app.*) { inline else => |*v, tag| { - inline for (@typeInfo(Window).Union.fields) |field| { + inline for (@typeInfo(Window).@"union".fields) |field| { if (comptime std.mem.eql( u8, field.name, diff --git a/src/build/webgen/main_commands.zig b/src/build/webgen/main_commands.zig index 6e6b00c5e..add8fc803 100644 --- a/src/build/webgen/main_commands.zig +++ b/src/build/webgen/main_commands.zig @@ -8,7 +8,7 @@ pub fn main() !void { } // Note: as a shortcut for defining inline editOnGithubLinks per cli action the user -// is directed to the folder view on Github. This includes a README pointing them to +// is directed to the folder view on Github. This includes a README pointing them to // the files to edit. pub fn genActions(writer: anytype) !void { // Write the header @@ -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).?; switch (action) { diff --git a/src/build/webgen/main_config.zig b/src/build/webgen/main_config.zig index 6cb55fcd3..1bde2f9cc 100644 --- a/src/build/webgen/main_config.zig +++ b/src/build/webgen/main_config.zig @@ -29,7 +29,7 @@ pub fn genConfig(writer: anytype) !void { ); @setEvalBranchQuota(50_000); - const fields = @typeInfo(Config).Struct.fields; + const fields = @typeInfo(Config).@"struct".fields; inline for (fields, 0..) |field, i| { if (field.name[0] == '_') continue; if (!@hasDecl(help_strings.Config, field.name)) continue; diff --git a/src/cli/action.zig b/src/cli/action.zig index f3da2e2ef..a53e55ef8 100644 --- a/src/cli/action.zig +++ b/src/cli/action.zig @@ -119,7 +119,7 @@ pub const Action = enum { // If help is requested, then we use some comptime trickery // to find this action in the help strings and output that. 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 // to stdout. In the future we can style this much prettier // for all commands by just changing this one place. diff --git a/src/cli/args.zig b/src/cli/args.zig index 5ff7de2d4..4860cdd74 100644 --- a/src/cli/args.zig +++ b/src/cli/args.zig @@ -55,7 +55,7 @@ pub fn parse( iter: anytype, ) !void { const info = @typeInfo(T); - assert(info == .Struct); + assert(info == .@"struct"); comptime { // 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 { const typeinfo = @typeInfo(T); - inline for (typeinfo.Struct.fields) |f| { + inline for (typeinfo.@"struct".fields) |f| { if (std.mem.eql(u8, key, f.name)) { switch (@typeInfo(f.type)) { - .Enum => |e| { + .@"enum" => |e| { try writer.print(", valid values are: ", .{}); inline for (e.fields, 0..) |field, i| { if (i != 0) try writer.print(", ", .{}); @@ -243,19 +243,21 @@ pub fn parseIntoField( value: ?[]const u8, ) !void { 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)) { // For optional fields, we just treat it as the child type. // This lets optional fields default to null but get set by // the CLI. const Field = switch (@typeInfo(field.type)) { - .Optional => |opt| opt.child, + .optional => |opt| opt.child, else => field.type, }; 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), // then we reset the value to the default. @@ -266,7 +268,7 @@ pub fn parseIntoField( try @field(dst, field.name).init(alloc); 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)); @field(dst, field.name) = ptr.*; return; @@ -276,22 +278,22 @@ pub fn parseIntoField( // we call that and use that to set the value. if (canHaveDecls) { if (@hasDecl(Field, "parseCLI")) { - const fnInfo = @typeInfo(@TypeOf(Field.parseCLI)).Fn; + const fnInfo = @typeInfo(@TypeOf(Field.parseCLI)).@"fn"; switch (fnInfo.params.len) { // 1 arg = (input) => output 1 => @field(dst, field.name) = try Field.parseCLI(value), // 2 arg = (self, input) => void 2 => switch (@typeInfo(field.type)) { - .Struct, - .Union, - .Enum, + .@"struct", + .@"union", + .@"enum", => try @field(dst, field.name).parseCLI(value), // If the field is optional and set, then we use // the pointer value directly into it. If its not // 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); } else { // Note: you cannot do @field(dst, name) = undefined @@ -307,12 +309,12 @@ pub fn parseIntoField( // 3 arg = (self, alloc, input) => void 3 => switch (@typeInfo(field.type)) { - .Struct, - .Union, - .Enum, + .@"struct", + .@"union", + .@"enum", => 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); } else { var tmp: Field = undefined; @@ -374,18 +376,18 @@ pub fn parseIntoField( ) catch return error.InvalidValue, else => switch (fieldInfo) { - .Enum => std.meta.stringToEnum( + .@"enum" => std.meta.stringToEnum( Field, value orelse return error.ValueRequired, ) orelse return error.InvalidValue, - .Struct => try parseStruct( + .@"struct" => try parseStruct( Field, alloc, value orelse return error.ValueRequired, ), - .Union => try parseTaggedUnion( + .@"union" => try parseTaggedUnion( Field, alloc, value orelse return error.ValueRequired, @@ -413,8 +415,8 @@ pub fn parseIntoField( } fn parseTaggedUnion(comptime T: type, alloc: Allocator, v: []const u8) !T { - const info = @typeInfo(T).Union; - assert(@typeInfo(info.tag_type.?) == .Enum); + const info = @typeInfo(T).@"union"; + assert(@typeInfo(info.tag_type.?) == .@"enum"); // 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. @@ -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. // This lets us use parseIntoField as if its a dedicated struct. - const Target = @Type(.{ .Struct = .{ + const Target = @Type(.{ .@"struct" = .{ .layout = .auto, .fields = &.{.{ .name = field.name, .type = field.type, - .default_value = null, + .default_value_ptr = null, .is_comptime = false, .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 { - return switch (@typeInfo(T).Struct.layout) { + return switch (@typeInfo(T).@"struct".layout) { .auto => parseAutoStruct(T, alloc, v), .@"packed" => parsePackedStruct(T, v), 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 { - const info = @typeInfo(T).Struct; + const info = @typeInfo(T).@"struct"; comptime assert(info.layout == .auto); // 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 inline for (info.fields, 0..) |field, 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)); @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 { - const info = @typeInfo(T).Struct; + const info = @typeInfo(T).@"struct"; comptime assert(info.layout == .@"packed"); var result: T = .{}; diff --git a/src/cli/diagnostics.zig b/src/cli/diagnostics.zig index 40fed3001..2c6cb3b30 100644 --- a/src/cli/diagnostics.zig +++ b/src/cli/diagnostics.zig @@ -54,14 +54,14 @@ pub const Location = union(enum) { 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 { const Iter = t: { const T = @TypeOf(iter); break :t switch (@typeInfo(T)) { - .Pointer => |v| v.child, - .Struct => T, + .pointer => |v| v.child, + .@"struct" => T, else => return .none, }; }; diff --git a/src/cli/help.zig b/src/cli/help.zig index 22fe27d8d..32cdfa303 100644 --- a/src/cli/help.zig +++ b/src/cli/help.zig @@ -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}); } diff --git a/src/cli/show_face.zig b/src/cli/show_face.zig index 8b460a623..b7f039dc8 100644 --- a/src/cli/show_face.zig +++ b/src/cli/show_face.zig @@ -101,7 +101,7 @@ fn runArgs(alloc_gpa: Allocator, argsIter: anytype) !u8 { var exit: bool = false; outer: for (opts._diagnostics.items()) |diagnostic| { 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 (std.mem.eql(u8, field.name, diagnostic.key)) { try stderr.writeAll("config error: "); @@ -134,7 +134,7 @@ fn runArgs(alloc_gpa: Allocator, argsIter: anytype) !u8 { // action-specific argument. if (!config._diagnostics.empty()) { 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 (std.mem.eql(u8, field.name, diagnostic.key) and (diagnostic.location == .none or diagnostic.location == .cli)) continue :outer; } diff --git a/src/config/Config.zig b/src/config/Config.zig index 1790d8b38..481e02a79 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -2801,7 +2801,7 @@ pub fn changeConditionalState( // If the conditional state between the old and new is the same, // then we don't need to do anything. 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); // 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 - inline for (@typeInfo(Config).Struct.fields) |field| { + inline for (@typeInfo(Config).@"struct".fields) |field| { switch (field.type) { RepeatablePath, Path => { 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 // on desktop. 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)) { if (self.command == null or wd_home) command: { @@ -3239,7 +3239,7 @@ pub fn clone( const alloc_arena = result._arena.?.allocator(); // Copy our values - inline for (@typeInfo(Config).Struct.fields) |field| { + inline for (@typeInfo(Config).@"struct".fields) |field| { if (!@hasField(Key, field.name)) continue; @field(result, field.name) = try cloneValue( alloc_arena, @@ -3286,26 +3286,26 @@ fn cloneValue( // If we're a type that can have decls and we have clone, then // call clone and be done. 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); } // Back into types of types switch (t) { - inline .Bool, - .Int, - .Float, - .Enum, - .Union, + inline .bool, + .int, + .float, + .@"enum", + .@"union", => return src, - .Optional => |info| return try cloneValue( + .optional => |info| return try cloneValue( alloc, info.child, src orelse return null, ), - .Struct => |info| { + .@"struct" => |info| { // Packed structs we can return directly as copies. assert(info.layout == .@"packed"); return src; @@ -3390,21 +3390,21 @@ fn equalField(comptime T: type, old: T, new: T) bool { // Back into types of types switch (@typeInfo(T)) { - .Void => return true, + .void => return true, - inline .Bool, - .Int, - .Float, - .Enum, + inline .bool, + .int, + .float, + .@"enum", => return old == new, - .Optional => |info| { + .optional => |info| { if (old == null and new == null) return true; if (old == null or new == null) return false; return equalField(info.child, old.?, new.?); }, - .Struct => |info| { + .@"struct" => |info| { if (@hasDecl(T, "equal")) return old.equal(new); // 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; }, - .Union => |info| { + .@"union" => |info| { const tag_type = info.tag_type.?; const old_tag = std.meta.activeTag(old); 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 // what will display in the menu. We want the more typical keybinds after this block to be // the standard - if (!builtin.target.isDarwin()) { + if (!builtin.target.os.tag.isDarwin()) { try self.set.put( alloc, .{ .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 // 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 } else .{ .ctrl = true, .shift = true }; @@ -4426,7 +4426,7 @@ pub const Keybinds = struct { ); // Windowing - if (comptime !builtin.target.isDarwin()) { + if (comptime !builtin.target.os.tag.isDarwin()) { try self.set.put( alloc, .{ .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 // is alt. - const mods: inputpkg.Mods = if (builtin.target.isDarwin()) + const mods: inputpkg.Mods = if (builtin.target.os.tag.isDarwin()) .{ .super = true } else .{ .alt = true }; @@ -4621,7 +4621,7 @@ pub const Keybinds = struct { // want to be true on other platforms as well but this // is definitely true on macOS so we just do it here for // now (#817) - .key = if (comptime builtin.target.isDarwin()) + .key = if (comptime builtin.target.os.tag.isDarwin()) .{ .physical = @enumFromInt(i) } else .{ .translated = @enumFromInt(i) }, @@ -4634,7 +4634,7 @@ pub const Keybinds = struct { try self.set.put( alloc, .{ - .key = if (comptime builtin.target.isDarwin()) + .key = if (comptime builtin.target.os.tag.isDarwin()) .{ .physical = .nine } else .{ .translated = .nine }, @@ -4659,7 +4659,7 @@ pub const Keybinds = struct { ); // Mac-specific keyboard bindings. - if (comptime builtin.target.isDarwin()) { + if (comptime builtin.target.os.tag.isDarwin()) { try self.set.put( alloc, .{ .key = .{ .translated = .q }, .mods = .{ .super = true } }, @@ -4995,7 +4995,7 @@ pub const Keybinds = struct { if (docs) { try formatter.writer.writeAll("\n"); 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)) { const help = @field(help_strings.KeybindAction, decl.name); try formatter.writer.writeAll("# " ++ decl.name ++ "\n"); diff --git a/src/config/c_get.zig b/src/config/c_get.zig index 251a95e77..f235f596a 100644 --- a/src/config/c_get.zig +++ b/src/config/c_get.zig @@ -53,21 +53,21 @@ fn getValue(ptr_raw: *anyopaque, value: anytype) bool { }, else => |T| switch (@typeInfo(T)) { - .Optional => { + .optional => { // If an optional has no value we return false. const unwrapped = value orelse return false; return getValue(ptr_raw, unwrapped); }, - .Enum => { + .@"enum" => { const ptr: *[*:0]const u8 = @ptrCast(@alignCast(ptr_raw)); ptr.* = @tagName(value); }, - .Struct => |info| { + .@"struct" => |info| { // If the struct implements cval then we call then. 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)); ptr.* = value.cval(); return true; @@ -84,9 +84,9 @@ fn getValue(ptr_raw: *anyopaque, value: anytype) bool { ptr.* = @intCast(@as(Backing, @bitCast(value))); }, - .Union => |_| { + .@"union" => |_| { 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)); ptr.* = value.cval(); return true; diff --git a/src/config/formatter.zig b/src/config/formatter.zig index aec7ead89..ca3da1d91 100644 --- a/src/config/formatter.zig +++ b/src/config/formatter.zig @@ -42,27 +42,27 @@ pub fn formatEntry( writer: anytype, ) !void { switch (@typeInfo(T)) { - .Bool, .Int => { + .bool, .int => { try writer.print("{s} = {}\n", .{ name, value }); return; }, - .Float => { + .float => { try writer.print("{s} = {d}\n", .{ name, value }); return; }, - .Enum => { + .@"enum" => { try writer.print("{s} = {s}\n", .{ name, @tagName(value) }); return; }, - .Void => { + .void => { try writer.print("{s} = \n", .{name}); return; }, - .Optional => |info| { + .optional => |info| { if (value) |inner| { try formatEntry( info.child, @@ -77,7 +77,7 @@ pub fn formatEntry( return; }, - .Pointer => switch (T) { + .pointer => switch (T) { []const u8, [:0]const u8, => { @@ -93,7 +93,7 @@ pub fn formatEntry( // This is given the formatter in use so that they can // call BACK to our formatEntry to write each primitive // value. - .Struct => |info| if (@hasDecl(T, "formatEntry")) { + .@"struct" => |info| if (@hasDecl(T, "formatEntry")) { try value.formatEntry(entryFormatter(name, writer)); return; } else switch (info.layout) { @@ -114,7 +114,7 @@ pub fn formatEntry( else => {}, }, - .Union => if (@hasDecl(T, "formatEntry")) { + .@"union" => if (@hasDecl(T, "formatEntry")) { try value.formatEntry(entryFormatter(name, writer)); return; }, @@ -158,7 +158,7 @@ pub const FileFormatter = struct { null; 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; const value = @field(self.config, field.name); diff --git a/src/config/key.zig b/src/config/key.zig index f56376238..781b7ec99 100644 --- a/src/config/key.zig +++ b/src/config/key.zig @@ -22,7 +22,7 @@ pub const Key = key: { var decls = [_]std.builtin.Type.Declaration{}; break :key @Type(.{ - .Enum = .{ + .@"enum" = .{ .tag_type = std.math.IntFittingRange(0, field_infos.len - 1), .fields = enumFields[0..i], .decls = &decls, diff --git a/src/config/theme.zig b/src/config/theme.zig index 2d206e1f6..21d6faf08 100644 --- a/src/config/theme.zig +++ b/src/config/theme.zig @@ -76,7 +76,7 @@ pub const LocationIterator = struct { location: Location, dir: []const u8, } { - const max = @typeInfo(Location).Enum.fields.len; + const max = @typeInfo(Location).@"enum".fields.len; while (self.i < max) { const location: Location = @enumFromInt(self.i); self.i += 1; diff --git a/src/crash/minidump/reader.zig b/src/crash/minidump/reader.zig index f792d6670..b7f5efe80 100644 --- a/src/crash/minidump/reader.zig +++ b/src/crash/minidump/reader.zig @@ -46,13 +46,13 @@ pub fn Reader(comptime S: type) type { stream_directory_rva: u32, const SourceCallable = switch (@typeInfo(Source)) { - .Pointer => |v| v.child, - .Struct => Source, + .pointer => |v| v.child, + .@"struct" => Source, else => @compileError("Source type must be a pointer or struct"), }; - const SourceReader = @typeInfo(@TypeOf(SourceCallable.reader)).Fn.return_type.?; - const SourceSeeker = @typeInfo(@TypeOf(SourceCallable.seekableStream)).Fn.return_type.?; + const SourceReader = @typeInfo(@TypeOf(SourceCallable.reader)).@"fn".return_type.?; + const SourceSeeker = @typeInfo(@TypeOf(SourceCallable.seekableStream)).@"fn".return_type.?; /// A limited reader for reading data from the source. pub const LimitedReader = std.io.LimitedReader(SourceReader); diff --git a/src/font/Collection.zig b/src/font/Collection.zig index cb16528aa..cfc633b04 100644 --- a/src/font/Collection.zig +++ b/src/font/Collection.zig @@ -639,11 +639,11 @@ pub const PresentationMode = union(enum) { /// the Backing type and everything should just work fine. pub const Index = packed struct(Index.Backing) { 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. - const idx_bits = backing_bits - @typeInfo(@typeInfo(Style).Enum.tag_type).Int.bits; - pub const IndexInt = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = idx_bits } }); + const idx_bits = backing_bits - @typeInfo(@typeInfo(Style).@"enum".tag_type).int.bits; + pub const IndexInt = @Type(.{ .int = .{ .signedness = .unsigned, .bits = idx_bits } }); /// The special-case fonts that we support. pub const Special = enum(IndexInt) { diff --git a/src/font/Metrics.zig b/src/font/Metrics.zig index c78ac0972..4c7793bed 100644 --- a/src/font/Metrics.zig +++ b/src/font/Metrics.zig @@ -324,7 +324,7 @@ pub const Modifier = union(enum) { /// Apply a modifier to a numeric value. pub fn apply(self: Modifier, v: anytype) @TypeOf(v) { const T = @TypeOf(v); - const signed = @typeInfo(T).Int.signedness == .signed; + const signed = @typeInfo(T).int.signedness == .signed; return switch (self) { .percent => |p| percent: { const p_clamped: f64 = @max(0, p); @@ -395,7 +395,7 @@ pub const Key = key: { var decls = [_]std.builtin.Type.Declaration{}; break :key @Type(.{ - .Enum = .{ + .@"enum" = .{ .tag_type = std.math.IntFittingRange(0, count - 1), .fields = enumFields[0..count], .decls = &decls, diff --git a/src/font/SharedGridSet.zig b/src/font/SharedGridSet.zig index 249a11f75..ca535eaf8 100644 --- a/src/font/SharedGridSet.zig +++ b/src/font/SharedGridSet.zig @@ -188,7 +188,7 @@ fn collection( // A buffer we use to store the font names for logging. 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); for (key.descriptorsForStyle(style)) |desc| { { @@ -297,7 +297,7 @@ fn collection( // people add other emoji fonts to their system, we always want to // prefer the official one. Users can override this by explicitly // 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; var disco_it = try disco.discover(self.alloc, .{ .family = "Apple Color Emoji", @@ -314,7 +314,7 @@ fn collection( // Emoji fallback. We don't include this on Mac since Mac is expected // 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( self.alloc, .regular, @@ -672,7 +672,7 @@ pub const Key = struct { autoHash(hasher, self.metric_modifiers.count()); autoHash(hasher, self.freetype_load_flags); 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); if (self.metric_modifiers.get(key)) |value| { autoHash(hasher, key); diff --git a/src/font/discovery.zig b/src/font/discovery.zig index 071407d92..384799da5 100644 --- a/src/font/discovery.zig +++ b/src/font/discovery.zig @@ -597,7 +597,7 @@ pub const CoreText = struct { /// We represent our sorting score as a packed struct so that we can /// compare scores numerically but build scores symbolically. 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 traits: Traits = .unmatched, diff --git a/src/font/opentype/sfnt.zig b/src/font/opentype/sfnt.zig index cbce50455..14a3b795a 100644 --- a/src/font/opentype/sfnt.zig +++ b/src/font/opentype/sfnt.zig @@ -64,7 +64,7 @@ pub const Version16Dot16 = packed struct(u32) { pub const F26Dot6 = FixedPoint(i32, 26, 6); 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); return packed struct(T) { diff --git a/src/font/opentype/svg.zig b/src/font/opentype/svg.zig index 15edff5aa..01d172d17 100644 --- a/src/font/opentype/svg.zig +++ b/src/font/opentype/svg.zig @@ -67,14 +67,13 @@ pub const SVG = struct { // Slow path: binary search our records return std.sort.binarySearch( [12]u8, - glyph_id, self.records, - {}, + glyph_id, compareGlyphId, ) != 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; if (glyph_id < start) { return .lt; diff --git a/src/font/sprite/Box.zig b/src/font/sprite/Box.zig index 2cd3d929b..f387ab240 100644 --- a/src/font/sprite/Box.zig +++ b/src/font/sprite/Box.zig @@ -2241,7 +2241,9 @@ fn draw_branch_node( var ctx = canvas.getContext() catch return; defer ctx.deinit(); - ctx.setSource(.{ .alpha8 = .{ .a = @intFromEnum(Shade.on) } }); + ctx.setSource(.{ .opaque_pattern = .{ + .pixel = .{ .alpha8 = .{ .a = @intFromEnum(Shade.on) } }, + } }); ctx.setLineWidth(float_thick); // These @intFromFloat casts shouldn't ever fail since r can never @@ -2290,7 +2292,9 @@ fn draw_circle( var ctx = canvas.getContext() catch return; defer ctx.deinit(); - ctx.setSource(.{ .alpha8 = .{ .a = @intFromEnum(Shade.on) } }); + ctx.setSource(.{ .opaque_pattern = .{ + .pixel = .{ .alpha8 = .{ .a = @intFromEnum(Shade.on) } }, + } }); ctx.setLineWidth( @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: { @setEvalBranchQuota(10_000); - var result: [octants_len]Octant = .{.{}} ** octants_len; + var result: [octants_len]Octant = .{Octant{}} ** octants_len; var i: usize = 0; const data = @embedFile("octants.txt"); @@ -2678,7 +2682,9 @@ fn draw_arc( var ctx = try canvas.getContext(); 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.setLineCapMode(.round); @@ -2970,8 +2976,9 @@ fn draw_separated_block_quadrant(self: Box, canvas: *font.sprite.Canvas, comptim var ctx = try canvas.getContext(); 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 left: f64 = gap; const right = @as(f64, @floatFromInt(self.metrics.cell_width)) - gap; diff --git a/src/global.zig b/src/global.zig index c93b35fa0..375c10538 100644 --- a/src/global.zig +++ b/src/global.zig @@ -211,9 +211,7 @@ pub const GlobalState = struct { // 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 // robust. - p.sigaction(p.SIG.PIPE, &sa, null) catch |err| { - std.log.warn("failed to ignore SIGPIPE err={}", .{err}); - }; + p.sigaction(p.SIG.PIPE, &sa, null); } }; diff --git a/src/input/Binding.zig b/src/input/Binding.zig index b684e6cd6..244cd29cd 100644 --- a/src/input/Binding.zig +++ b/src/input/Binding.zig @@ -510,7 +510,7 @@ pub const Action = union(enum) { /// crash: CrashThread, - pub const Key = @typeInfo(Action).Union.tag_type.?; + pub const Key = @typeInfo(Action).@"union".tag_type.?; pub const CrashThread = enum { main, @@ -638,17 +638,22 @@ pub const Action = union(enum) { const field_info = @typeInfo(field.type); // Fields can provide a custom "parse" function - if (field_info == .Struct or field_info == .Union or field_info == .Enum) { - if (@hasDecl(field.type, "parse") and @typeInfo(@TypeOf(field.type.parse)) == .Fn) { + if (field_info == .@"struct" or + 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 switch (field_info) { - .Enum => try parseEnum(field.type, param), - .Int => try parseInt(field.type, param), - .Float => try parseFloat(field.type, param), - .Struct => |info| blk: { + .@"enum" => try parseEnum(field.type, param), + .int => try parseInt(field.type, param), + .float => try parseFloat(field.type, param), + .@"struct" => |info| blk: { // Only tuples are supported to avoid ambiguity with field // ordering comptime assert(info.is_tuple); @@ -658,9 +663,9 @@ pub const Action = union(enum) { inline for (info.fields) |field_| { const next = it.next() orelse return Error.InvalidFormat; @field(value, field_.name) = switch (@typeInfo(field_.type)) { - .Enum => try parseEnum(field_.type, next), - .Int => try parseInt(field_.type, next), - .Float => try parseFloat(field_.type, next), + .@"enum" => try parseEnum(field_.type, next), + .int => try parseInt(field_.type, next), + .float => try parseFloat(field_.type, next), else => unreachable, }; } @@ -688,7 +693,7 @@ pub const Action = union(enum) { // An action name is always required if (action.len == 0) return Error.InvalidFormat; - const actionInfo = @typeInfo(Action).Union; + const actionInfo = @typeInfo(Action).@"union"; inline for (actionInfo.fields) |field| { if (std.mem.eql(u8, action, field.name)) { // 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 /// the given scope. 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 var i: usize = 0; @@ -829,9 +836,9 @@ pub const Action = union(enum) { } // Build our union - return @Type(.{ .Union = .{ + return @Type(.{ .@"union" = .{ .layout = .auto, - .tag_type = @Type(.{ .Enum = .{ + .tag_type = @Type(.{ .@"enum" = .{ .tag_type = std.math.IntFittingRange(0, i), .fields = enum_fields[0..i], .decls = &.{}, @@ -903,10 +910,10 @@ pub const Action = union(enum) { void => {}, []const u8 => try writer.print("{s}", .{value}), else => switch (value_info) { - .Enum => try writer.print("{s}", .{@tagName(value)}), - .Float => try writer.print("{d}", .{value}), - .Int => try writer.print("{d}", .{value}), - .Struct => |info| if (!info.is_tuple) { + .@"enum" => try writer.print("{s}", .{@tagName(value)}), + .float => try writer.print("{d}", .{value}), + .int => try writer.print("{d}", .{value}), + .@"struct" => |info| if (!info.is_tuple) { try writer.print("{} (not configurable)", .{value}); } else { inline for (info.fields, 0..) |field, i| { @@ -937,21 +944,21 @@ pub const Action = union(enum) { value: anytype, ) Allocator.Error!@TypeOf(value) { return switch (@typeInfo(@TypeOf(value))) { - .Void, - .Int, - .Float, - .Enum, + .void, + .int, + .float, + .@"enum", => value, - .Pointer => |info| slice: { - comptime assert(info.size == .Slice); + .pointer => |info| slice: { + comptime assert(info.size == .slice); break :slice try alloc.dupe( info.child, value, ); }, - .Struct => |info| if (info.is_tuple) + .@"struct" => |info| if (info.is_tuple) value else try value.clone(alloc), @@ -974,7 +981,7 @@ pub const Action = union(enum) { /// Hash the action into the given hasher. fn hashIncremental(self: Action, hasher: anytype) void { // 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)); // Hash the value of the field. @@ -1081,7 +1088,7 @@ pub const Trigger = struct { if (part.len == 0) return Error.InvalidFormat; // Check if its a modifier - const modsInfo = @typeInfo(key.Mods).Struct; + const modsInfo = @typeInfo(key.Mods).@"struct"; inline for (modsInfo.fields) |field| { if (field.type == bool) { 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; // Check if its a key - const keysInfo = @typeInfo(key.Key).Enum; + const keysInfo = @typeInfo(key.Key).@"enum"; inline for (keysInfo.fields) |field| { if (!std.mem.eql(u8, field.name, "invalid")) { if (std.mem.eql(u8, key_part, field.name)) { diff --git a/src/input/KeyEncoder.zig b/src/input/KeyEncoder.zig index c009fbe0d..8be5c672c 100644 --- a/src/input/KeyEncoder.zig +++ b/src/input/KeyEncoder.zig @@ -1531,7 +1531,7 @@ test "kitty: left shift with report all" { } 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 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" { - if (comptime !builtin.target.isDarwin()) return error.SkipZigTest; + if (comptime !builtin.target.os.tag.isDarwin()) return error.SkipZigTest; { // With Alt modifier @@ -1826,7 +1826,7 @@ test "legacy: alt+e only unshifted" { } 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 enc: KeyEncoder = .{ @@ -1845,7 +1845,7 @@ test "legacy: alt+x 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 enc: KeyEncoder = .{ diff --git a/src/input/function_keys.zig b/src/input/function_keys.zig index 1156faf56..612112e28 100644 --- a/src/input/function_keys.zig +++ b/src/input/function_keys.zig @@ -81,24 +81,24 @@ pub const keys = keys: { result.set(.left, pcStyle("\x1b[1;{}D") ++ cursorKey("\x1b[D", "\x1bOD")); result.set(.home, pcStyle("\x1b[1;{}H") ++ cursorKey("\x1b[H", "\x1bOH")); result.set(.end, pcStyle("\x1b[1;{}F") ++ cursorKey("\x1b[F", "\x1bOF")); - result.set(.insert, pcStyle("\x1b[2;{}~") ++ .{.{ .sequence = "\x1B[2~" }}); - result.set(.delete, pcStyle("\x1b[3;{}~") ++ .{.{ .sequence = "\x1B[3~" }}); - result.set(.page_up, pcStyle("\x1b[5;{}~") ++ .{.{ .sequence = "\x1B[5~" }}); - result.set(.page_down, pcStyle("\x1b[6;{}~") ++ .{.{ .sequence = "\x1B[6~" }}); + result.set(.insert, pcStyle("\x1b[2;{}~") ++ .{Entry{ .sequence = "\x1B[2~" }}); + result.set(.delete, pcStyle("\x1b[3;{}~") ++ .{Entry{ .sequence = "\x1B[3~" }}); + result.set(.page_up, pcStyle("\x1b[5;{}~") ++ .{Entry{ .sequence = "\x1B[5~" }}); + result.set(.page_down, pcStyle("\x1b[6;{}~") ++ .{Entry{ .sequence = "\x1B[6~" }}); // Function Keys. todo: f13-f35 but we need to add to input.Key - result.set(.f1, pcStyle("\x1b[1;{}P") ++ .{.{ .sequence = "\x1BOP" }}); - result.set(.f2, pcStyle("\x1b[1;{}Q") ++ .{.{ .sequence = "\x1BOQ" }}); - result.set(.f3, pcStyle("\x1b[13;{}~") ++ .{.{ .sequence = "\x1BOR" }}); - result.set(.f4, pcStyle("\x1b[1;{}S") ++ .{.{ .sequence = "\x1BOS" }}); - result.set(.f5, pcStyle("\x1b[15;{}~") ++ .{.{ .sequence = "\x1B[15~" }}); - result.set(.f6, pcStyle("\x1b[17;{}~") ++ .{.{ .sequence = "\x1B[17~" }}); - result.set(.f7, pcStyle("\x1b[18;{}~") ++ .{.{ .sequence = "\x1B[18~" }}); - result.set(.f8, pcStyle("\x1b[19;{}~") ++ .{.{ .sequence = "\x1B[19~" }}); - result.set(.f9, pcStyle("\x1b[20;{}~") ++ .{.{ .sequence = "\x1B[20~" }}); - result.set(.f10, pcStyle("\x1b[21;{}~") ++ .{.{ .sequence = "\x1B[21~" }}); - result.set(.f11, pcStyle("\x1b[23;{}~") ++ .{.{ .sequence = "\x1B[23~" }}); - result.set(.f12, pcStyle("\x1b[24;{}~") ++ .{.{ .sequence = "\x1B[24~" }}); + result.set(.f1, pcStyle("\x1b[1;{}P") ++ .{Entry{ .sequence = "\x1BOP" }}); + result.set(.f2, pcStyle("\x1b[1;{}Q") ++ .{Entry{ .sequence = "\x1BOQ" }}); + result.set(.f3, pcStyle("\x1b[13;{}~") ++ .{Entry{ .sequence = "\x1BOR" }}); + result.set(.f4, pcStyle("\x1b[1;{}S") ++ .{Entry{ .sequence = "\x1BOS" }}); + result.set(.f5, pcStyle("\x1b[15;{}~") ++ .{Entry{ .sequence = "\x1B[15~" }}); + result.set(.f6, pcStyle("\x1b[17;{}~") ++ .{Entry{ .sequence = "\x1B[17~" }}); + result.set(.f7, pcStyle("\x1b[18;{}~") ++ .{Entry{ .sequence = "\x1B[18~" }}); + result.set(.f8, pcStyle("\x1b[19;{}~") ++ .{Entry{ .sequence = "\x1B[19~" }}); + result.set(.f9, pcStyle("\x1b[20;{}~") ++ .{Entry{ .sequence = "\x1B[20~" }}); + result.set(.f10, pcStyle("\x1b[21;{}~") ++ .{Entry{ .sequence = "\x1B[21~" }}); + result.set(.f11, pcStyle("\x1b[23;{}~") ++ .{Entry{ .sequence = "\x1B[23~" }}); + result.set(.f12, pcStyle("\x1b[24;{}~") ++ .{Entry{ .sequence = "\x1B[24~" }}); // Keypad keys result.set(.kp_0, kpKeys("p")); @@ -116,7 +116,7 @@ pub const keys = keys: { result.set(.kp_multiply, kpKeys("j")); result.set(.kp_subtract, kpKeys("m")); 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_down, pcStyle("\x1b[1;{}B") ++ cursorKey("\x1b[B", "\x1bOB")); 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_home, pcStyle("\x1b[1;{}H") ++ cursorKey("\x1b[H", "\x1bOH")); 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_delete, pcStyle("\x1b[3;{}~") ++ .{.{ .sequence = "\x1B[3~" }}); - result.set(.kp_page_up, pcStyle("\x1b[5;{}~") ++ .{.{ .sequence = "\x1B[5~" }}); - result.set(.kp_page_down, pcStyle("\x1b[6;{}~") ++ .{.{ .sequence = "\x1B[6~" }}); + result.set(.kp_insert, pcStyle("\x1b[2;{}~") ++ .{Entry{ .sequence = "\x1B[2~" }}); + result.set(.kp_delete, pcStyle("\x1b[3;{}~") ++ .{Entry{ .sequence = "\x1B[3~" }}); + result.set(.kp_page_up, pcStyle("\x1b[5;{}~") ++ .{Entry{ .sequence = "\x1B[5~" }}); + result.set(.kp_page_down, pcStyle("\x1b[6;{}~") ++ .{Entry{ .sequence = "\x1B[6~" }}); result.set(.backspace, &.{ // Modify Keys Normal diff --git a/src/input/helpgen_actions.zig b/src/input/helpgen_actions.zig index 58305455b..1382bbe95 100644 --- a/src/input/helpgen_actions.zig +++ b/src/input/helpgen_actions.zig @@ -73,7 +73,7 @@ pub fn generate( var buffer = std.ArrayList(u8).init(page_allocator); defer buffer.deinit(); - const fields = @typeInfo(KeybindAction).Union.fields; + const fields = @typeInfo(KeybindAction).@"union".fields; inline for (fields) |field| { if (field.name[0] == '_') continue; diff --git a/src/input/key.zig b/src/input/key.zig index 766498d54..f9db4a04a 100644 --- a/src/input/key.zig +++ b/src/input/key.zig @@ -152,7 +152,7 @@ pub const Mods = packed struct(Mods.Backing) { pub fn translation(self: Mods, option_as_alt: config.OptionAsAlt) Mods { // We currently only process macos-option-as-alt so other // 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 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. pub fn ctrlOrSuper(self: Mods) bool { - if (comptime builtin.target.isDarwin()) { + if (comptime builtin.target.os.tag.isDarwin()) { return self.super; } return self.ctrl; @@ -187,7 +187,7 @@ pub const Mods = packed struct(Mods.Backing) { } 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; @@ -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) /// or ctrl. 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_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). pub fn ctrlOrSuper(mods: Mods) Mods { var copy = mods; - if (comptime builtin.target.isDarwin()) { + if (comptime builtin.target.os.tag.isDarwin()) { copy.super = true; } else { copy.ctrl = true; diff --git a/src/input/mouse.zig b/src/input/mouse.zig index 10eae6b48..2be2b9a26 100644 --- a/src/input/mouse.zig +++ b/src/input/mouse.zig @@ -27,7 +27,7 @@ pub const Button = enum(c_int) { /// packed array, for example. pub const max = max: { var cur = 0; - for (@typeInfo(Self).Enum.fields) |field| { + for (@typeInfo(Self).@"enum".fields) |field| { if (field.value > cur) cur = field.value; } diff --git a/src/inspector/Inspector.zig b/src/inspector/Inspector.zig index 1824f5ead..53a602abc 100644 --- a/src/inspector/Inspector.zig +++ b/src/inspector/Inspector.zig @@ -602,7 +602,7 @@ fn renderModesWindow(self: *Inspector) void { } 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)); cimgui.c.igTableNextRow(cimgui.c.ImGuiTableRowFlags_None, 0); @@ -1298,7 +1298,7 @@ fn renderTermioWindow(self: *Inspector) void { ); 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); if (tag == .apc_put or tag == .dcs_put) continue; diff --git a/src/inspector/termio.zig b/src/inspector/termio.zig index 1b499f9dd..6aa6628ab 100644 --- a/src/inspector/termio.zig +++ b/src/inspector/termio.zig @@ -199,7 +199,7 @@ pub const VTEvent = struct { void => {}, []const u8 => try md.put("data", try alloc.dupeZ(u8, v)), else => |T| switch (@typeInfo(T)) { - .Struct => |info| inline for (info.fields) |field| { + .@"struct" => |info| inline for (info.fields) |field| { try encodeMetadataSingle( alloc, 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_name = @tagName(@as(Tag, v)); inline for (info.fields) |field| { @@ -239,23 +239,23 @@ pub const VTEvent = struct { const Value = @TypeOf(value); const info = @typeInfo(Value); switch (info) { - .Optional => if (value) |unwrapped| { + .optional => if (value) |unwrapped| { try encodeMetadataSingle(alloc, md, key, unwrapped); } else { try md.put(key, try alloc.dupeZ(u8, "(unset)")); }, - .Bool => try md.put( + .bool => try md.put( key, try alloc.dupeZ(u8, if (value) "true" else "false"), ), - .Enum => try md.put( + .@"enum" => try md.put( key, try alloc.dupeZ(u8, @tagName(value)), ), - .Union => |u| { + .@"union" => |u| { const Tag = u.tag_type orelse @compileError("Unions must have a tag"); const tag_name = @tagName(@as(Tag, value)); inline for (u.fields) |field| { @@ -273,7 +273,7 @@ pub const VTEvent = struct { } }, - .Struct => try md.put( + .@"struct" => try md.put( key, try alloc.dupeZ(u8, @typeName(Value)), ), diff --git a/src/main_ghostty.zig b/src/main_ghostty.zig index 0e57fbc43..7560423db 100644 --- a/src/main_ghostty.zig +++ b/src/main_ghostty.zig @@ -130,7 +130,7 @@ fn logFn( // // 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 const mac_level: macos.os.LogType = switch (level) { .debug => .debug, diff --git a/src/os/i18n.zig b/src/os/i18n.zig index dc72d3f5d..7b0b55c8e 100644 --- a/src/os/i18n.zig +++ b/src/os/i18n.zig @@ -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; test "canonicalizeLocale darwin" { - if (!builtin.target.isDarwin()) return error.SkipZigTest; + if (!builtin.target.os.tag.isDarwin()) return error.SkipZigTest; const testing = std.testing; var buf: [256]u8 = undefined; diff --git a/src/os/locale.zig b/src/os/locale.zig index f046448ca..17e4d163c 100644 --- a/src/os/locale.zig +++ b/src/os/locale.zig @@ -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 // OS. When launching from the CLI, LANG is usually set by the parent // 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. if (lang == null or lang.?.value.len == 0) { setLangFromCocoa(); diff --git a/src/os/macos.zig b/src/os/macos.zig index a956d25e2..ca7c81a47 100644 --- a/src/os/macos.zig +++ b/src/os/macos.zig @@ -7,7 +7,7 @@ const Allocator = std.mem.Allocator; /// Verifies that the running macOS system version is at least the given version. 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 info = NSProcessInfo.msgSend(objc.Object, objc.sel("processInfo"), .{}); @@ -108,7 +108,7 @@ fn commonDir( directory: NSSearchPathDirectory, sub_paths: []const []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 manager = NSFileManager.msgSend( @@ -146,7 +146,7 @@ fn commonDir( } test "cacheDir paths" { - if (!builtin.target.isDarwin()) return; + if (!builtin.target.os.tag.isDarwin()) return; const testing = std.testing; const alloc = testing.allocator; diff --git a/src/os/open.zig b/src/os/open.zig index f6dc7ca2a..f7eadd06e 100644 --- a/src/os/open.zig +++ b/src/os/open.zig @@ -57,14 +57,14 @@ pub fn open( // 50 KiB is the default value used by std.process.Child.run const output_max_size = 50 * 1024; - var stdout = std.ArrayList(u8).init(alloc); - var stderr = std.ArrayList(u8).init(alloc); + var stdout: std.ArrayListUnmanaged(u8) = .{}; + var stderr: std.ArrayListUnmanaged(u8) = .{}; defer { - stdout.deinit(); - stderr.deinit(); + stdout.deinit(alloc); + stderr.deinit(alloc); } - try exe.collectOutput(&stdout, &stderr, output_max_size); + try exe.collectOutput(alloc, &stdout, &stderr, output_max_size); _ = try exe.wait(); // If we have any stderr output we log it. This makes it easier for diff --git a/src/os/passwd.zig b/src/os/passwd.zig index 54f84a15d..4bbd55a4d 100644 --- a/src/os/passwd.zig +++ b/src/os/passwd.zig @@ -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 comptime { - if (builtin.target.isWasm()) { + if (builtin.target.cpu.arch.isWasm()) { @compileError("passwd is not available for wasm"); } } diff --git a/src/os/resourcesdir.zig b/src/os/resourcesdir.zig index ae7c33bc3..2ae4ba39a 100644 --- a/src/os/resourcesdir.zig +++ b/src/os/resourcesdir.zig @@ -46,7 +46,7 @@ pub fn resourcesDir(alloc: std.mem.Allocator) !?[]const u8 { exe = dir; // 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| { return try std.fs.path.join(alloc, &.{ v, "ghostty" }); } diff --git a/src/os/wasm.zig b/src/os/wasm.zig index 92e12fe62..f8d7a34e2 100644 --- a/src/os/wasm.zig +++ b/src/os/wasm.zig @@ -67,7 +67,7 @@ pub export fn free(ptr: ?[*]u8) void { /// to the host. pub fn toHostOwned(ptr: anytype) ![*]u8 { // Convert our pointer to a byte array - const info = @typeInfo(@TypeOf(ptr)).Pointer; + const info = @typeInfo(@TypeOf(ptr)).pointer; const T = info.child; const size = @sizeOf(T); const casted = @as([*]u8, @ptrFromInt(@intFromPtr(ptr))); diff --git a/src/pty.zig b/src/pty.zig index 6f97e190d..06d9bcd51 100644 --- a/src/pty.zig +++ b/src/pty.zig @@ -215,19 +215,19 @@ const PosixPty = struct { .mask = posix.empty_sigset, .flags = 0, }; - try posix.sigaction(posix.SIG.ABRT, &sa, null); - try posix.sigaction(posix.SIG.ALRM, &sa, null); - try posix.sigaction(posix.SIG.BUS, &sa, null); - try posix.sigaction(posix.SIG.CHLD, &sa, null); - try posix.sigaction(posix.SIG.FPE, &sa, null); - try posix.sigaction(posix.SIG.HUP, &sa, null); - try posix.sigaction(posix.SIG.ILL, &sa, null); - try posix.sigaction(posix.SIG.INT, &sa, null); - try posix.sigaction(posix.SIG.PIPE, &sa, null); - try posix.sigaction(posix.SIG.SEGV, &sa, null); - try posix.sigaction(posix.SIG.TRAP, &sa, null); - try posix.sigaction(posix.SIG.TERM, &sa, null); - try posix.sigaction(posix.SIG.QUIT, &sa, null); + posix.sigaction(posix.SIG.ABRT, &sa, null); + posix.sigaction(posix.SIG.ALRM, &sa, null); + posix.sigaction(posix.SIG.BUS, &sa, null); + posix.sigaction(posix.SIG.CHLD, &sa, null); + posix.sigaction(posix.SIG.FPE, &sa, null); + posix.sigaction(posix.SIG.HUP, &sa, null); + posix.sigaction(posix.SIG.ILL, &sa, null); + posix.sigaction(posix.SIG.INT, &sa, null); + posix.sigaction(posix.SIG.PIPE, &sa, null); + posix.sigaction(posix.SIG.SEGV, &sa, null); + posix.sigaction(posix.SIG.TRAP, &sa, null); + posix.sigaction(posix.SIG.TERM, &sa, null); + posix.sigaction(posix.SIG.QUIT, &sa, null); // Create a new process group if (setsid() < 0) return error.ProcessGroupFailed; diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index d2477725c..3e4677bb5 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -1147,12 +1147,12 @@ pub fn updateFrame( // the entire screen. This can be optimized in the future. 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); 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); if (v > 0) break :rebuild true; } diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index 20a0a82b3..c152db14d 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -799,12 +799,12 @@ pub fn updateFrame( // the entire screen. This can be optimized in the future. 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); 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); if (v > 0) break :rebuild true; } @@ -1392,29 +1392,29 @@ pub fn rebuildCells( // Try to read the cells from the shaping cache if we can. self.font_shaper_cache.get(run) orelse cache: { - // Otherwise we have to shape them. - const cells = try self.font_shaper.shape(run); + // Otherwise we have to shape them. + const cells = try self.font_shaper.shape(run); - // Try to cache them. If caching fails for any reason we - // continue because it is just a performance optimization, - // not a correctness issue. - self.font_shaper_cache.put( - self.alloc, - run, - cells, - ) catch |err| { - log.warn( - "error caching font shaping results err={}", - .{err}, - ); - }; - - // The cells we get from direct shaping are always owned - // by the shaper and valid until the next shaping call so - // we can safely use them. - break :cache cells; + // Try to cache them. If caching fails for any reason we + // continue because it is just a performance optimization, + // not a correctness issue. + self.font_shaper_cache.put( + self.alloc, + run, + cells, + ) catch |err| { + log.warn( + "error caching font shaping results err={}", + .{err}, + ); }; + // The cells we get from direct shaping are always owned + // by the shaper and valid until the next shaping call so + // we can safely use them. + break :cache cells; + }; + // Advance our index until we reach or pass // our current x position in the shaper cells. while (shaper_cells.?[shaper_cells_i].x < x) { @@ -1637,29 +1637,29 @@ pub fn rebuildCells( // Try to read the cells from the shaping cache if we can. self.font_shaper_cache.get(run) orelse cache: { - // Otherwise we have to shape them. - const cells = try self.font_shaper.shape(run); + // Otherwise we have to shape them. + const cells = try self.font_shaper.shape(run); - // Try to cache them. If caching fails for any reason we - // continue because it is just a performance optimization, - // not a correctness issue. - self.font_shaper_cache.put( - self.alloc, - run, - cells, - ) catch |err| { - log.warn( - "error caching font shaping results err={}", - .{err}, - ); - }; - - // The cells we get from direct shaping are always owned - // by the shaper and valid until the next shaping call so - // we can safely use them. - break :cache cells; + // Try to cache them. If caching fails for any reason we + // continue because it is just a performance optimization, + // not a correctness issue. + self.font_shaper_cache.put( + self.alloc, + run, + cells, + ) catch |err| { + log.warn( + "error caching font shaping results err={}", + .{err}, + ); }; + // The cells we get from direct shaping are always owned + // by the shaper and valid until the next shaping call so + // we can safely use them. + break :cache cells; + }; + const cells = shaper_cells orelse break :glyphs; // If there are no shaper cells for this run, ignore it. @@ -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 // races with the underlying Metal layer that Apple is using to // implement OpenGL. - const is_darwin = builtin.target.isDarwin(); + const is_darwin = builtin.target.os.tag.isDarwin(); const ogl = if (comptime is_darwin) @cImport({ @cInclude("OpenGL/OpenGL.h"); }) else {}; diff --git a/src/renderer/Thread.zig b/src/renderer/Thread.zig index f4aa16dfe..46ef8609b 100644 --- a/src/renderer/Thread.zig +++ b/src/renderer/Thread.zig @@ -248,7 +248,7 @@ fn threadMain_(self: *Thread) !void { fn setQosClass(self: *const Thread) void { // 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: { // If we aren't visible (our view is fully occluded) then we diff --git a/src/renderer/metal/api.zig b/src/renderer/metal/api.zig index 535a0b42b..19db17ba4 100644 --- a/src/renderer/metal/api.zig +++ b/src/renderer/metal/api.zig @@ -34,7 +34,7 @@ pub const MTLResourceOptions = packed struct(c_ulong) { hazard_tracking_mode: HazardTrackingMode = .default, _pad: @Type(.{ - .Int = .{ .signedness = .unsigned, .bits = @bitSizeOf(c_ulong) - 10 }, + .int = .{ .signedness = .unsigned, .bits = @bitSizeOf(c_ulong) - 10 }, }) = 0, pub const CPUCacheMode = enum(u4) { diff --git a/src/renderer/metal/shaders.zig b/src/renderer/metal/shaders.zig index b297de809..8fa170bf2 100644 --- a/src/renderer/metal/shaders.zig +++ b/src/renderer/metal/shaders.zig @@ -681,11 +681,11 @@ fn initImagePipeline( } 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 FT = switch (@typeInfo(field.type)) { - .Enum => |e| e.tag_type, + .@"enum" => |e| e.tag_type, else => field.type, }; diff --git a/src/renderer/opengl/CellProgram.zig b/src/renderer/opengl/CellProgram.zig index 48386362e..c4da8e233 100644 --- a/src/renderer/opengl/CellProgram.zig +++ b/src/renderer/opengl/CellProgram.zig @@ -67,7 +67,7 @@ pub const CellMode = enum(u8) { // Since we use bit tricks below, we want to ensure the enum // doesn't change without us looking at this logic again. comptime { - const info = @typeInfo(CellMode).Enum; + const info = @typeInfo(CellMode).@"enum"; std.debug.assert(info.fields.len == 5); } diff --git a/src/renderer/size.zig b/src/renderer/size.zig index 40c5af3a9..83e921a26 100644 --- a/src/renderer/size.zig +++ b/src/renderer/size.zig @@ -75,7 +75,7 @@ pub const Coordinate = union(enum) { terminal: Terminal, 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 Terminal = struct { x: f64, y: f64 }; pub const Grid = struct { x: GridSize.Unit, y: GridSize.Unit }; diff --git a/src/surface_mouse.zig b/src/surface_mouse.zig index cc1643a88..ed1e36335 100644 --- a/src/surface_mouse.zig +++ b/src/surface_mouse.zig @@ -120,7 +120,7 @@ fn isMouseModeOverrideState(mods: input.Mods) bool { /// Returns true if our modifiers put us in a state where dragging /// should cause a rectangle select. pub fn isRectangleSelectState(mods: input.Mods) bool { - return if (comptime builtin.target.isDarwin()) + return if (comptime builtin.target.os.tag.isDarwin()) mods.alt else mods.ctrlOrSuper() and mods.alt; diff --git a/src/terminal/Parser.zig b/src/terminal/Parser.zig index bc5859ede..4e74f04ba 100644 --- a/src/terminal/Parser.zig +++ b/src/terminal/Parser.zig @@ -148,7 +148,7 @@ pub const Action = union(enum) { ) !void { _ = layout; const T = Action; - const info = @typeInfo(T).Union; + const info = @typeInfo(T).@"union"; try writer.writeAll(@typeName(T)); if (info.tag_type) |TagType| { diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index 1204a8ec8..efb9684eb 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -77,7 +77,7 @@ default_palette: color.Palette = color.default, /// The color palette to use. The mask indicates which palette indices have been /// modified with OSC 4 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, mask: Mask = Mask.initEmpty(), } = .{}, diff --git a/src/terminal/charsets.zig b/src/terminal/charsets.zig index 316238458..66d6566e3 100644 --- a/src/terminal/charsets.zig +++ b/src/terminal/charsets.zig @@ -99,7 +99,7 @@ fn initTable() [table_len]u16 { test { const testing = std.testing; - const info = @typeInfo(Charset).Enum; + const info = @typeInfo(Charset).@"enum"; inline for (info.fields) |field| { // utf8 has no table if (@field(Charset, field.name) == .utf8) continue; diff --git a/src/terminal/device_status.zig b/src/terminal/device_status.zig index 78147ddd4..1be7bf719 100644 --- a/src/terminal/device_status.zig +++ b/src/terminal/device_status.zig @@ -14,7 +14,7 @@ pub const Request = dsr_enum: { }; } - break :dsr_enum @Type(.{ .Enum = .{ + break :dsr_enum @Type(.{ .@"enum" = .{ .tag_type = Tag.Backing, .fields = &fields, .decls = &.{}, @@ -27,7 +27,7 @@ pub const Request = dsr_enum: { /// chosen somewhat arbitrarily to match the largest expected size /// we see as a multiple of 8 bits. pub const Tag = packed struct(u16) { - pub const Backing = @typeInfo(@This()).Struct.backing_integer.?; + pub const Backing = @typeInfo(@This()).@"struct".backing_integer.?; value: u15, question: bool = false, diff --git a/src/terminal/hash_map.zig b/src/terminal/hash_map.zig index 272616be1..0cc17a747 100644 --- a/src/terminal/hash_map.zig +++ b/src/terminal/hash_map.zig @@ -204,8 +204,8 @@ fn HashMapUnmanaged( } pub fn takeFingerprint(hash: Hash) FingerPrint { - const hash_bits = @typeInfo(Hash).Int.bits; - const fp_bits = @typeInfo(FingerPrint).Int.bits; + const hash_bits = @typeInfo(Hash).int.bits; + const fp_bits = @typeInfo(FingerPrint).int.bits; return @as(FingerPrint, @truncate(hash >> (hash_bits - fp_bits))); } @@ -688,8 +688,6 @@ fn HashMapUnmanaged( return result; } 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 // function is invalid for these parameters. const hash = ctx.hash(key); diff --git a/src/terminal/kitty/color.zig b/src/terminal/kitty/color.zig index a631bc6a5..b23e30ad8 100644 --- a/src/terminal/kitty/color.zig +++ b/src/terminal/kitty/color.zig @@ -30,7 +30,7 @@ pub const Special = 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, special: Special, diff --git a/src/terminal/kitty/graphics_unicode.zig b/src/terminal/kitty/graphics_unicode.zig index 339ad6202..a4a25e751 100644 --- a/src/terminal/kitty/graphics_unicode.zig +++ b/src/terminal/kitty/graphics_unicode.zig @@ -553,12 +553,11 @@ const IncompletePlacement = struct { /// Get the row/col index for a diacritic codepoint. These are 0-indexed. fn getIndex(cp: u21) ?u32 { - const idx = std.sort.binarySearch(u21, cp, diacritics, {}, (struct { - fn order(context: void, lhs: u21, rhs: u21) std.math.Order { - _ = context; - return std.math.order(lhs, rhs); + const idx = std.sort.binarySearch(u21, diacritics, cp, (struct { + fn compare(context: u21, item: u21) std.math.Order { + return std.math.order(context, item); } - }).order) orelse return null; + }).compare) orelse return null; return @intCast(idx); } diff --git a/src/terminal/modes.zig b/src/terminal/modes.zig index 89d352e4a..60ecc7698 100644 --- a/src/terminal/modes.zig +++ b/src/terminal/modes.zig @@ -93,13 +93,13 @@ pub const ModePacked = packed_struct: { fields[i] = .{ .name = entry.name, .type = bool, - .default_value = &entry.default, + .default_value_ptr = &entry.default, .is_comptime = false, .alignment = 0, }; } - break :packed_struct @Type(.{ .Struct = .{ + break :packed_struct @Type(.{ .@"struct" = .{ .layout = .@"packed", .fields = &fields, .decls = &.{}, @@ -121,7 +121,7 @@ pub const Mode = mode_enum: { }; } - break :mode_enum @Type(.{ .Enum = .{ + break :mode_enum @Type(.{ .@"enum" = .{ .tag_type = ModeTag.Backing, .fields = &fields, .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 /// in order to pack the ansi bit into the tag. pub const ModeTag = packed struct(u16) { - pub const Backing = @typeInfo(@This()).Struct.backing_integer.?; + pub const Backing = @typeInfo(@This()).@"struct".backing_integer.?; value: u15, ansi: bool = false, diff --git a/src/terminal/parse_table.zig b/src/terminal/parse_table.zig index 66c443783..2c8ccf8fc 100644 --- a/src/terminal/parse_table.zig +++ b/src/terminal/parse_table.zig @@ -37,7 +37,7 @@ pub const Transition = struct { fn genTableType(comptime optional: bool) type { const max_u8 = std.math.maxInt(u8); 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; return [max_u8 + 1][max_state]Elem; } @@ -56,7 +56,7 @@ fn genTable() Table { // anywhere transitions const stateInfo = @typeInfo(State); - inline for (stateInfo.Enum.fields) |field| { + inline for (stateInfo.@"enum".fields) |field| { const source: State = @enumFromInt(field.value); // anywhere => ground diff --git a/src/terminal/size.zig b/src/terminal/size.zig index ffa61e6be..6cedfdf6d 100644 --- a/src/terminal/size.zig +++ b/src/terminal/size.zig @@ -132,13 +132,13 @@ pub fn getOffset( fn intFromBase(base: anytype) usize { const T = @TypeOf(base); return switch (@typeInfo(T)) { - .Pointer => |v| switch (v.size) { - .One, - .Many, - .C, + .pointer => |v| switch (v.size) { + .one, + .many, + .c, => @intFromPtr(base), - .Slice => @intFromPtr(base.ptr), + .slice => @intFromPtr(base.ptr), }, else => switch (T) { diff --git a/src/terminal/stream.zig b/src/terminal/stream.zig index 3d9ed72fb..f1d66eab5 100644 --- a/src/terminal/stream.zig +++ b/src/terminal/stream.zig @@ -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 // pointer if we were given one. const T = switch (@typeInfo(Handler)) { - .Pointer => |p| p.child, + .pointer => |p| p.child, else => Handler, }; diff --git a/src/terminal/x11_color.zig b/src/terminal/x11_color.zig index f6413f96e..88bc30f09 100644 --- a/src/terminal/x11_color.zig +++ b/src/terminal/x11_color.zig @@ -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); fn colorMap() !ColorMap { - @setEvalBranchQuota(100_000); + @setEvalBranchQuota(500_000); const KV = struct { []const u8, RGB }; diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index 770420f0c..c83757e8c 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -301,7 +301,7 @@ pub fn childExitedAbnormally( // We don't print this on macOS because the exit code is always 0 // 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}); t.carriageReturn(); try t.linefeed(); @@ -369,7 +369,7 @@ fn processExit( if (runtime_ms) |runtime| runtime: { // On macOS, our exit code detection doesn't work, possibly // 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 // and we don't ever consider it abnormal. if (exit_code == 0) break :runtime; @@ -751,7 +751,7 @@ const Subprocess = struct { }); try env.put("TERMINFO", dir); } else { - if (comptime builtin.target.isDarwin()) { + if (comptime builtin.target.os.tag.isDarwin()) { log.warn("ghostty terminfo not found, using xterm-256color", .{}); log.warn("the terminfo SHOULD exist on macos, please ensure", .{}); log.warn("you're using a valid app bundle.", .{}); @@ -797,7 +797,7 @@ const Subprocess = struct { // On macOS, export additional data directories from our // 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; 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 // the proper environment variables set, a login shell, and proper // 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| { log.warn("failed to read passwd, not using a login shell err={}", .{err}); break :darwin; @@ -1289,7 +1289,7 @@ const Subprocess = struct { switch (posix.errno(c.killpg(pgid, c.SIGHUP))) { .SUCCESS => log.debug("process group killed pgid={}", .{pgid}), else => |err| killpg: { - if ((comptime builtin.target.isDarwin()) and + if ((comptime builtin.target.os.tag.isDarwin()) and err == .PERM) { log.debug("killpg failed with EPERM, expected on Darwin and ignoring", .{}); diff --git a/src/termio/message.zig b/src/termio/message.zig index 44381b228..42767e109 100644 --- a/src/termio/message.zig +++ b/src/termio/message.zig @@ -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. pub fn init(alloc: Allocator, data: anytype) !Self { switch (@typeInfo(@TypeOf(data))) { - .Pointer => |info| { - assert(info.size == .Slice); + .pointer => |info| { + assert(info.size == .slice); assert(info.child == Elem); // If it fits in our small request, do that. diff --git a/src/termio/shell_integration.zig b/src/termio/shell_integration.zig index 423e2f518..4bbf0a3b5 100644 --- a/src/termio/shell_integration.zig +++ b/src/termio/shell_integration.zig @@ -82,7 +82,7 @@ fn setupShell( // If we're running "/bin/bash" on Darwin, we can assume // we're using Apple's Bash because /bin is non-writable // 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)) { return null; } @@ -137,7 +137,7 @@ test "force shell" { var env = EnvMap.init(alloc); defer env.deinit(); - inline for (@typeInfo(Shell).Enum.fields) |field| { + inline for (@typeInfo(Shell).@"enum".fields) |field| { const shell = @field(Shell, field.name); const result = try setup(alloc, ".", "sh", &env, shell, .{}); try testing.expectEqual(shell, result.?.shell); diff --git a/src/unicode/grapheme.zig b/src/unicode/grapheme.zig index 25061b5ef..7847ef6f5 100644 --- a/src/unicode/grapheme.zig +++ b/src/unicode/grapheme.zig @@ -52,7 +52,7 @@ const Precompute = struct { var result: [std.math.maxInt(u10)]Value = undefined; @setEvalBranchQuota(3_000); - const info = @typeInfo(GraphemeBoundaryClass).Enum; + const info = @typeInfo(GraphemeBoundaryClass).@"enum"; for (0..std.math.maxInt(u2) + 1) |state_init| { for (info.fields) |field1| { for (info.fields) |field2| {