diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 84280cd..5e9b7da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,6 @@ jobs: check: uses: fizzyedit/plugin-build-action/.github/workflows/check.yml@v7 with: - zig-version: "0.16.0" + zig-version: "0.17.0" # secrets: # build_env: ${{ secrets.MY_BUILD_ENV }} # as in release.yml, if the build needs one diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dab756a..0c266e1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,4 +12,4 @@ jobs: permissions: contents: write with: - zig-version: "0.16.0" + zig-version: "0.17.0" diff --git a/.github/workflows/sdk-repin.yml b/.github/workflows/sdk-repin.yml index e1a776c..28a0fd0 100644 --- a/.github/workflows/sdk-repin.yml +++ b/.github/workflows/sdk-repin.yml @@ -31,4 +31,4 @@ jobs: with: sdk-version: ${{ github.event.client_payload.version || inputs.sdk-version || '' }} force: ${{ inputs.force == true }} - zig-version: "0.16.0" + zig-version: "0.17.0" diff --git a/build.zig b/build.zig index a00901b..09870a4 100644 --- a/build.zig +++ b/build.zig @@ -27,6 +27,17 @@ pub fn build(b: *std.Build) void { else => @panic("unsupported target for ghostty_vt"), }; plugin.module.addIncludePath(ghostty_vt.path("include")); + // libghostty-vt's header, translated once into a module of its own (`c`): Zig 0.17 removed + // `@cImport`. `GHOSTTY_STATIC` makes `GHOSTTY_API` a no-op, right for the static lib. + const vt_h = b.addTranslateC(.{ + .root_source_file = ghostty_vt.path("include/ghostty/vt.h"), + .target = target, + .optimize = optimize, + .link_libc = true, + }); + vt_h.addIncludePath(ghostty_vt.path("include")); + vt_h.defineCMacro("GHOSTTY_STATIC", "1"); + plugin.module.addImport("c", vt_h.createModule()); plugin.module.addObjectFile(ghostty_vt.path(ghostty_vt_lib)); plugin.module.link_libc = true; diff --git a/build.zig.zon b/build.zig.zon index c5c6634..cd582c4 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -2,7 +2,7 @@ .name = .ghostty, .version = "0.0.1", .fingerprint = 0x64407a2a356ac9fe, - .minimum_zig_version = "0.16.0", + .minimum_zig_version = "0.17.0", .dependencies = .{ .ghostty_vt = .{ .url = "https://github.com/fizzyedit/ghostty_vt/releases/download/v0.1.2/ghostty-vt-v0.1.2.tar.gz", @@ -12,8 +12,8 @@ // The published SDK, not a path into a checkout: a release has to build from a // clean clone, and the release asset (never the tag's git archive) is the SDK // package alone — the monorepo root zon carries the app's own dependencies. - .url = "https://github.com/fizzyedit/fizzy/releases/download/sdk-v0.2.29/fizzy-sdk-v0.2.29.tar.gz", - .hash = "fizzy-0.2.29-SGBwY2sxJgCLLSPt4HLdlMSg7WtcP4K0fdtXI5WwJl2d", + .url = "https://github.com/fizzyedit/fizzy/releases/download/sdk-v0.2.30/fizzy-sdk-v0.2.30.tar.gz", + .hash = "fizzy-0.2.30-SGBwY1QnJwDznUMVnSLATxXgH2e8_Vz7eMwLj9UQ0sVU", }, }, .paths = .{ diff --git a/plugin.zig.zon b/plugin.zig.zon index 4fd5e65..f38b21d 100644 --- a/plugin.zig.zon +++ b/plugin.zig.zon @@ -1,8 +1,8 @@ .{ .id = "ghostty", .name = "Ghostty", - .version = "0.1.31", - .min_sdk_version = "0.2.29", + .version = "0.1.32", + .min_sdk_version = "0.2.30", .description = "Ghostty terminal emulator plugin for fizzy", .tags = .{ "terminal", "ghostty" }, .author = "foxnne", diff --git a/src/Pty.zig b/src/Pty.zig index 1c39608..7c28a03 100644 --- a/src/Pty.zig +++ b/src/Pty.zig @@ -4,7 +4,7 @@ //! Windows: ConPTY + PowerShell (`Pty_windows.zig`). const builtin = @import("builtin"); -const backend = if (builtin.os.tag == .windows) +const backend = if (builtin.target.os.tag == .windows) @import("Pty_windows.zig") else @import("Pty_unix.zig"); diff --git a/src/Pty_unix.zig b/src/Pty_unix.zig index f89529e..9cbb280 100644 --- a/src/Pty_unix.zig +++ b/src/Pty_unix.zig @@ -28,7 +28,7 @@ pub const Pty = struct { extern "c" fn ioctl(fd: c_int, request: c_ulong, ...) c_int; extern "c" fn _exit(code: c_int) noreturn; - const TIOCSWINSZ: c_ulong = switch (builtin.os.tag) { + const TIOCSWINSZ: c_ulong = switch (builtin.target.os.tag) { .linux => 0x5414, else => 0x80087467, // macOS / BSD }; @@ -103,7 +103,7 @@ pub const Pty = struct { while (off < bytes.len) { const n = std.c.write(self.master, bytes.ptr + off, bytes.len - off); if (n < 0) { - if (std.c._errno().* == @intFromEnum(std.c.E.INTR)) continue; + if (std.c._errno().* == @backingInt(std.c.E.INTR)) continue; break; // real error (e.g. EPIPE on child exit) — drop the rest } off += @intCast(n); diff --git a/src/c.zig b/src/c.zig index 54da2d2..b149aea 100644 --- a/src/c.zig +++ b/src/c.zig @@ -1,7 +1,3 @@ -//! C bindings for libghostty-vt (from the ghostty_vt package dependency). The include path -//! and static archive are wired in `build.zig`. `GHOSTTY_STATIC` makes the `GHOSTTY_API` -//! visibility/import-export attributes a no-op, which is correct when linking the static lib. -pub const c = @cImport({ - @cDefine("GHOSTTY_STATIC", "1"); - @cInclude("ghostty/vt.h"); -}); +//! C bindings for libghostty-vt (from the ghostty_vt package dependency): its header, translated +//! in `build.zig`, which also wires the static archive. +pub const c = @import("c"); diff --git a/src/input.zig b/src/input.zig index 1c8594f..d726a25 100644 --- a/src/input.zig +++ b/src/input.zig @@ -109,18 +109,18 @@ const Mapped = struct { fn mapKey(code: dvui.enums.Key) ?Mapped { const Key = dvui.enums.Key; - const ci = @intFromEnum(code); + const ci = @backingInt(code); - if (ci >= @intFromEnum(Key.a) and ci <= @intFromEnum(Key.z)) { - const off: c_int = @intCast(ci - @intFromEnum(Key.a)); + if (ci >= @backingInt(Key.a) and ci <= @backingInt(Key.z)) { + const off: c_int = @intCast(ci - @backingInt(Key.a)); return .{ .key = c.GHOSTTY_KEY_A + off, .cp = @intCast('a' + off) }; } - if (ci >= @intFromEnum(Key.zero) and ci <= @intFromEnum(Key.nine)) { - const off: c_int = @intCast(ci - @intFromEnum(Key.zero)); + if (ci >= @backingInt(Key.zero) and ci <= @backingInt(Key.nine)) { + const off: c_int = @intCast(ci - @backingInt(Key.zero)); return .{ .key = c.GHOSTTY_KEY_DIGIT_0 + off, .cp = @intCast('0' + off) }; } - if (ci >= @intFromEnum(Key.f1) and ci <= @intFromEnum(Key.f12)) { - const off: c_int = @intCast(ci - @intFromEnum(Key.f1)); + if (ci >= @backingInt(Key.f1) and ci <= @backingInt(Key.f12)) { + const off: c_int = @intCast(ci - @backingInt(Key.f1)); return .{ .key = c.GHOSTTY_KEY_F1 + off, .cp = 0 }; } diff --git a/src/render.zig b/src/render.zig index 1eda0a8..36a1a0e 100644 --- a/src/render.zig +++ b/src/render.zig @@ -18,7 +18,7 @@ const input = @import("input.zig"); /// the app process itself inherited, which for a packaged `.app` launched from Finder/Dock is /// `/` rather than `~`. Null if the relevant env var isn't set. fn defaultCwd() ?[]const u8 { - const name = if (builtin.os.tag == .windows) "USERPROFILE" else "HOME"; + const name = if (builtin.target.os.tag == .windows) "USERPROFILE" else "HOME"; const value = std.c.getenv(name) orelse return null; return std.mem.span(value); }