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
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;
}

View File

@@ -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;
}
}

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.
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;

View File

@@ -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);

View File

@@ -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,