Files
playpen/build.zig
T
Greyson Parrelli 738cead680 vtabs: terminal with vertical tabs on libghostty-vt + GTK4
Uses libghostty-vt (the API Ghostty documents for external embedders) for
the terminal core. Ghostty's other C API, ghostty.h, exposes a full terminal
surface but only supports macOS and iOS platform tags, so it cannot be
embedded on Linux.

We supply the layers libghostty-vt deliberately leaves out: PTY and process
management, a Cairo/Pango cell renderer, and a GTK4/libadwaita UI with a
Zen-style vertical tab sidebar.

Nix pins the whole toolchain (Zig 0.16 via zig-overlay, GTK 4.22, libadwaita)
so no host setup is needed.
2026-08-11 08:36:10 -04:00

62 lines
1.9 KiB
Zig

const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// libghostty-vt provides the terminal emulator core: escape sequence
// parsing, screen/scrollback state, and input encoding. Everything above
// it (PTY, rendering, windowing) is ours.
const ghostty = b.dependency("ghostty", .{
.target = target,
.optimize = optimize,
});
// GTK4/libadwaita bindings. This is the same generated binding set
// Ghostty uses for its Linux apprt, so it matches the GObject
// introspection data of the GTK we link against.
const gobject = b.dependency("gobject", .{
.target = target,
.optimize = optimize,
});
const exe = b.addExecutable(.{
.name = "vtabs",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
}),
});
exe.root_module.addImport("ghostty-vt", ghostty.module("ghostty-vt"));
const gobject_imports = .{
.{ "adw", "adw1" },
.{ "cairo", "cairo1" },
.{ "gdk", "gdk4" },
.{ "gio", "gio2" },
.{ "glib", "glib2" },
.{ "glibunix", "glibunix2" },
.{ "gobject", "gobject2" },
.{ "gtk", "gtk4" },
.{ "pango", "pango1" },
.{ "pangocairo", "pangocairo1" },
};
inline for (gobject_imports) |import| {
const name, const module = import;
exe.root_module.addImport(name, gobject.module(module));
}
exe.root_module.linkSystemLibrary("gtk4", .{});
exe.root_module.linkSystemLibrary("libadwaita-1", .{});
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| run_cmd.addArgs(args);
b.step("run", "Run the app").dependOn(&run_cmd.step);
}