mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-05-05 15:33:00 +00:00
Zig 0.14
This commit is contained in:
parent
95daca616d
commit
7e2286eb8c
@ -3,7 +3,7 @@ const builtin = @import("builtin");
|
||||
const buildpkg = @import("src/build/main.zig");
|
||||
|
||||
comptime {
|
||||
buildpkg.requireZig("0.13.0");
|
||||
buildpkg.requireZig("0.14.0");
|
||||
}
|
||||
|
||||
pub fn build(b: *std.Build) !void {
|
||||
@ -50,7 +50,7 @@ pub fn build(b: *std.Build) !void {
|
||||
// As such, these build steps are lacking. For example, the Darwin
|
||||
// build only produces an xcframework.
|
||||
if (config.app_runtime == .none) {
|
||||
if (config.target.result.isDarwin()) darwin: {
|
||||
if (config.target.result.os.tag.isDarwin()) darwin: {
|
||||
if (!config.emit_xcframework) break :darwin;
|
||||
|
||||
// Build the xcframework
|
||||
|
@ -1,35 +1,36 @@
|
||||
.{
|
||||
.name = "ghostty",
|
||||
.name = .ghostty,
|
||||
.version = "1.1.3",
|
||||
.paths = .{""},
|
||||
.fingerprint = 0x64407a2a0b4147e5,
|
||||
.dependencies = .{
|
||||
// Zig libs
|
||||
|
||||
.libxev = .{
|
||||
// mitchellh/libxev
|
||||
.url = "https://github.com/mitchellh/libxev/archive/8943932a668f338cb2c500f6e1a7396bacd8b55d.tar.gz",
|
||||
.hash = "1220a67b584c9499154de8c96851ed8e92315452cb2027c06e2d7d07a39c6f900d1a",
|
||||
.url = "https://github.com/mitchellh/libxev/archive/3df9337a9e84450a58a2c4af434ec1a036f7b494.tar.gz",
|
||||
.hash = "1220db2cfd2f8a1527d4c86cc4d298e0624481ae8112bee8c87a73baee0746797d66",
|
||||
},
|
||||
.mach_glfw = .{
|
||||
// mitchellh/mach-glfw
|
||||
.url = "https://deps.files.ghostty.org/mach_glfw-12206ed982e709e565d536ce930701a8c07edfd2cfdce428683f3f2a601d37696a62.tar.gz",
|
||||
.hash = "12206ed982e709e565d536ce930701a8c07edfd2cfdce428683f3f2a601d37696a62",
|
||||
.url = "https://github.com/mitchellh/mach-glfw/archive/112fc46340f5c8527e072e442e0375004303e82b.zip",
|
||||
.hash = "12206ed982e709e565d536ce930701a8c07edfd2cfdce428683f3f2a601d37696a63",
|
||||
.lazy = true,
|
||||
},
|
||||
.vaxis = .{
|
||||
// rockorager/libvaxis
|
||||
.url = "git+https://github.com/rockorager/libvaxis#2237a7059eae99e9f132dd5acd1555e49d6c7d93",
|
||||
.hash = "1220f5aec880d4f430cc1597ede88f1530da69e39a4986080e976b0c7b919c2ebfeb",
|
||||
.url = "git+https://github.com/rockorager/libvaxis#1e24e0dfb509e974e1c8713bcd119d0ae032a8c7",
|
||||
.hash = "vaxis-0.1.0-BWNV_MHyCAARemSCSwwc3sA1etNgv7ge0BCIXspX6CZv",
|
||||
},
|
||||
.z2d = .{
|
||||
// vancluever/z2d
|
||||
.url = "https://deps.files.ghostty.org/z2d-12201f0d542e7541cf492a001d4d0d0155c92f58212fbcb0d224e95edeba06b5416a.tar.gz",
|
||||
.hash = "12201f0d542e7541cf492a001d4d0d0155c92f58212fbcb0d224e95edeba06b5416a",
|
||||
.url = "https://github.com/vancluever/z2d/archive/03f6ef642e696dce8c6019d4365234d9538eea5d.tar.gz",
|
||||
.hash = "z2d-0.1.0-AAAAAMz7BwCFCN76WmSoRhlTe8ZOgPMmG44AyXxBEpHs",
|
||||
},
|
||||
.zig_objc = .{
|
||||
// mitchellh/zig-objc
|
||||
.url = "https://deps.files.ghostty.org/zig_objc-1220e17e64ef0ef561b3e4b9f3a96a2494285f2ec31c097721bf8c8677ec4415c634.tar.gz",
|
||||
.hash = "1220e17e64ef0ef561b3e4b9f3a96a2494285f2ec31c097721bf8c8677ec4415c634",
|
||||
.url = "https://github.com/mitchellh/zig-objc/archive/2329503f692fd5c8ff4c0528b066a22c40dc58e8.tar.gz",
|
||||
.hash = "1220458700f3a8319286715099ec64a787c77124da7c0f52fcbae13c40beeab8fe58",
|
||||
},
|
||||
.zig_js = .{
|
||||
// mitchellh/zig-js
|
||||
@ -42,13 +43,13 @@
|
||||
},
|
||||
.zig_wayland = .{
|
||||
// codeberg ifreund/zig-wayland
|
||||
.url = "https://deps.files.ghostty.org/zig-wayland-fbfe3b4ac0b472a27b1f1a67405436c58cbee12d.tar.gz",
|
||||
.hash = "12209ca054cb1919fa276e328967f10b253f7537c4136eb48f3332b0f7cf661cad38",
|
||||
.url = "https://codeberg.org/ifreund/zig-wayland/archive/f3c5d503e540ada8cbcb056420de240af0c094f7.tar.gz",
|
||||
.hash = "1220a686142edf1174287fbde3e4f378c5cea9f9cfd3e0e0e96cb2bcde0e9d5dcaa8",
|
||||
},
|
||||
.zf = .{
|
||||
// natecraddock/zf
|
||||
.url = "https://deps.files.ghostty.org/zf-1220edc3b8d8bedbb50555947987e5e8e2f93871ca3c8e8d4cc8f1377c15b5dd35e8.tar.gz",
|
||||
.hash = "1220edc3b8d8bedbb50555947987e5e8e2f93871ca3c8e8d4cc8f1377c15b5dd35e8",
|
||||
.url = "https://github.com/natecraddock/zf/archive/03176fcf23fda543cc02a8675e92c1fe3b1ee2eb.tar.gz",
|
||||
.hash = "zf-0.10.3-OIRy8bKIAACV6JaNNncXA68Nw2BUAD9JVfQdzjyoZQ-J",
|
||||
},
|
||||
.gobject = .{
|
||||
// ianprime0509/zig-gobject
|
||||
|
6
flake.lock
generated
6
flake.lock
generated
@ -102,11 +102,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1738239110,
|
||||
"narHash": "sha256-Y5i9mQ++dyIQr+zEPNy+KIbc5wjPmfllBrag3cHZgcE=",
|
||||
"lastModified": 1741702955,
|
||||
"narHash": "sha256-Emk3VnNByigCBlBN34IH2cMrsUqIhdex02uw9TSDsN0=",
|
||||
"owner": "mitchellh",
|
||||
"repo": "zig-overlay",
|
||||
"rev": "1a8fb6f3a04724519436355564b95fce5e272504",
|
||||
"rev": "1152ce759114a94134081270affd970ae1b957ed",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -49,7 +49,7 @@
|
||||
pkgs-unstable = nixpkgs-unstable.legacyPackages.${system};
|
||||
in {
|
||||
devShell.${system} = pkgs-stable.callPackage ./nix/devShell.nix {
|
||||
zig = zig.packages.${system}."0.13.0";
|
||||
zig = zig.packages.${system}."0.14.0";
|
||||
wraptest = pkgs-stable.callPackage ./nix/wraptest.nix {};
|
||||
zig2nix = zig2nix;
|
||||
};
|
||||
|
@ -1,5 +1,7 @@
|
||||
.{
|
||||
.name = "apple-sdk",
|
||||
.name = .apple_sdk,
|
||||
.version = "0.1.0",
|
||||
.dependencies = .{},
|
||||
.fingerprint = 0xdde52860f7c464d2,
|
||||
.paths = .{""},
|
||||
}
|
||||
|
@ -14,9 +14,9 @@ pub fn build(b: *std.Build) !void {
|
||||
lib.linkLibCpp();
|
||||
lib.addIncludePath(upstream.path("src"));
|
||||
lib.addIncludePath(b.path("vendor"));
|
||||
if (target.result.isDarwin()) {
|
||||
if (target.result.os.tag.isDarwin()) {
|
||||
const apple_sdk = @import("apple_sdk");
|
||||
try apple_sdk.addPaths(b, &lib.root_module);
|
||||
try apple_sdk.addPaths(b, lib.root_module);
|
||||
}
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
@ -29,7 +29,7 @@ pub fn build(b: *std.Build) !void {
|
||||
.flags = flags.items,
|
||||
});
|
||||
|
||||
if (target.result.isDarwin()) {
|
||||
if (target.result.os.tag.isDarwin()) {
|
||||
lib.addCSourceFiles(.{
|
||||
.root = upstream.path(""),
|
||||
.files = common_apple,
|
||||
|
@ -76,9 +76,9 @@ pub fn build(b: *std.Build) !void {
|
||||
.flags = flags.items,
|
||||
});
|
||||
|
||||
if (target.result.isDarwin()) {
|
||||
if (target.result.os.tag.isDarwin()) {
|
||||
if (!target.query.isNative()) {
|
||||
try @import("apple_sdk").addPaths(b, &lib.root_module);
|
||||
try @import("apple_sdk").addPaths(b, lib.root_module);
|
||||
try @import("apple_sdk").addPaths(b, module);
|
||||
}
|
||||
lib.addCSourceFile(.{
|
||||
|
@ -69,9 +69,9 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
|
||||
});
|
||||
lib.linkLibC();
|
||||
lib.addIncludePath(upstream.path("include"));
|
||||
if (target.result.isDarwin()) {
|
||||
if (target.result.os.tag.isDarwin()) {
|
||||
const apple_sdk = @import("apple_sdk");
|
||||
try apple_sdk.addPaths(b, &lib.root_module);
|
||||
try apple_sdk.addPaths(b, lib.root_module);
|
||||
}
|
||||
|
||||
module.addIncludePath(upstream.path("include"));
|
||||
|
@ -16,7 +16,7 @@ pub fn build(b: *std.Build) !void {
|
||||
|
||||
module.addIncludePath(upstream.path(""));
|
||||
module.addIncludePath(b.path("override"));
|
||||
if (target.result.isDarwin()) {
|
||||
if (target.result.os.tag.isDarwin()) {
|
||||
const apple_sdk = @import("apple_sdk");
|
||||
try apple_sdk.addPaths(b, module);
|
||||
}
|
||||
@ -53,9 +53,9 @@ fn buildGlslang(
|
||||
lib.linkLibCpp();
|
||||
lib.addIncludePath(upstream.path(""));
|
||||
lib.addIncludePath(b.path("override"));
|
||||
if (target.result.isDarwin()) {
|
||||
if (target.result.os.tag.isDarwin()) {
|
||||
const apple_sdk = @import("apple_sdk");
|
||||
try apple_sdk.addPaths(b, &lib.root_module);
|
||||
try apple_sdk.addPaths(b, lib.root_module);
|
||||
}
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
|
@ -1,6 +1,7 @@
|
||||
.{
|
||||
.name = "gtk4-layer-shell",
|
||||
.name = .gtk4_layer_shell,
|
||||
.version = "1.1.0",
|
||||
.fingerprint = 0x4b96f9483c6feeb1,
|
||||
.paths = .{""},
|
||||
.dependencies = .{
|
||||
.gtk4_layer_shell = .{
|
||||
|
@ -95,8 +95,8 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
|
||||
lib.addIncludePath(upstream.path("src"));
|
||||
module.addIncludePath(upstream.path("src"));
|
||||
|
||||
if (target.result.isDarwin()) {
|
||||
try apple_sdk.addPaths(b, &lib.root_module);
|
||||
if (target.result.os.tag.isDarwin()) {
|
||||
try apple_sdk.addPaths(b, lib.root_module);
|
||||
try apple_sdk.addPaths(b, module);
|
||||
}
|
||||
|
||||
|
@ -21,9 +21,9 @@ pub fn build(b: *std.Build) !void {
|
||||
lib.addIncludePath(upstream.path(""));
|
||||
module.addIncludePath(upstream.path(""));
|
||||
|
||||
if (target.result.isDarwin()) {
|
||||
if (target.result.os.tag.isDarwin()) {
|
||||
const apple_sdk = @import("apple_sdk");
|
||||
try apple_sdk.addPaths(b, &lib.root_module);
|
||||
try apple_sdk.addPaths(b, lib.root_module);
|
||||
try apple_sdk.addPaths(b, module);
|
||||
}
|
||||
|
||||
|
@ -42,9 +42,9 @@ pub fn build(b: *std.Build) !void {
|
||||
lib.addIncludePath(upstream.path("gettext-runtime/intl"));
|
||||
lib.addIncludePath(upstream.path("gettext-runtime/intl/gnulib-lib"));
|
||||
|
||||
if (target.result.isDarwin()) {
|
||||
if (target.result.os.tag.isDarwin()) {
|
||||
const apple_sdk = @import("apple_sdk");
|
||||
try apple_sdk.addPaths(b, &lib.root_module);
|
||||
try apple_sdk.addPaths(b, lib.root_module);
|
||||
}
|
||||
|
||||
lib.addCSourceFiles(.{
|
||||
|
@ -15,9 +15,9 @@ pub fn build(b: *std.Build) !void {
|
||||
if (target.result.os.tag == .linux) {
|
||||
lib.linkSystemLibrary("m");
|
||||
}
|
||||
if (target.result.isDarwin()) {
|
||||
if (target.result.os.tag.isDarwin()) {
|
||||
const apple_sdk = @import("apple_sdk");
|
||||
try apple_sdk.addPaths(b, &lib.root_module);
|
||||
try apple_sdk.addPaths(b, lib.root_module);
|
||||
}
|
||||
|
||||
// For dynamic linking, we prefer dynamic linking and to search by
|
||||
|
@ -66,7 +66,7 @@ pub fn build(b: *std.Build) !void {
|
||||
// it to the `LIBXML_{field}_ENABLED` C define where field is uppercased.
|
||||
inline for (std.meta.fields(Options)) |field| {
|
||||
const opt = b.option(bool, field.name, "Configure flag") orelse
|
||||
@as(*const bool, @ptrCast(field.default_value.?)).*;
|
||||
@as(*const bool, @ptrCast(field.default_value_ptr.?)).*;
|
||||
if (opt) {
|
||||
var nameBuf: [32]u8 = undefined;
|
||||
const name = std.ascii.upperString(&nameBuf, field.name);
|
||||
|
@ -38,7 +38,7 @@ pub fn build(b: *std.Build) !void {
|
||||
module.linkFramework("Carbon", .{});
|
||||
}
|
||||
|
||||
if (target.result.isDarwin()) {
|
||||
if (target.result.os.tag.isDarwin()) {
|
||||
module.linkFramework("CoreFoundation", .{});
|
||||
module.linkFramework("CoreGraphics", .{});
|
||||
module.linkFramework("CoreText", .{});
|
||||
@ -46,7 +46,7 @@ pub fn build(b: *std.Build) !void {
|
||||
module.linkFramework("QuartzCore", .{});
|
||||
|
||||
if (!target.query.isNative()) {
|
||||
try apple_sdk.addPaths(b, &lib.root_module);
|
||||
try apple_sdk.addPaths(b, lib.root_module);
|
||||
try apple_sdk.addPaths(b, module);
|
||||
}
|
||||
}
|
||||
|
@ -68,9 +68,9 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
|
||||
lib.addIncludePath(upstream.path("src"));
|
||||
module.addIncludePath(upstream.path("src"));
|
||||
|
||||
if (target.result.isDarwin()) {
|
||||
if (target.result.os.tag.isDarwin()) {
|
||||
const apple_sdk = @import("apple_sdk");
|
||||
try apple_sdk.addPaths(b, &lib.root_module);
|
||||
try apple_sdk.addPaths(b, lib.root_module);
|
||||
}
|
||||
|
||||
lib.addConfigHeader(b.addConfigHeader(.{
|
||||
@ -88,10 +88,10 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
|
||||
.HAVE_SYS_TYPES_H = true,
|
||||
.HAVE_UNISTD_H = true,
|
||||
.HAVE_INTTYPES_H = true,
|
||||
.SIZEOF_INT = t.c_type_byte_size(.int),
|
||||
.SIZEOF_LONG = t.c_type_byte_size(.long),
|
||||
.SIZEOF_LONG_LONG = t.c_type_byte_size(.longlong),
|
||||
.SIZEOF_VOIDP = t.ptrBitWidth() / t.c_type_bit_size(.char),
|
||||
.SIZEOF_INT = t.cTypeByteSize(.int),
|
||||
.SIZEOF_LONG = t.cTypeByteSize(.long),
|
||||
.SIZEOF_LONG_LONG = t.cTypeByteSize(.longlong),
|
||||
.SIZEOF_VOIDP = t.ptrBitWidth() / t.cTypeByteSize(.char),
|
||||
}));
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
|
@ -23,9 +23,9 @@ pub fn build(b: *std.Build) !void {
|
||||
lib.linkLibC();
|
||||
lib.addIncludePath(upstream.path("include"));
|
||||
lib.addIncludePath(upstream.path("src"));
|
||||
if (target.result.isDarwin()) {
|
||||
if (target.result.os.tag.isDarwin()) {
|
||||
const apple_sdk = @import("apple_sdk");
|
||||
try apple_sdk.addPaths(b, &lib.root_module);
|
||||
try apple_sdk.addPaths(b, lib.root_module);
|
||||
try apple_sdk.addPaths(b, module);
|
||||
}
|
||||
|
||||
|
@ -12,9 +12,9 @@ pub fn build(b: *std.Build) !void {
|
||||
lib.linkLibCpp();
|
||||
lib.addIncludePath(b.path("vendor"));
|
||||
|
||||
if (target.result.isDarwin()) {
|
||||
if (target.result.os.tag.isDarwin()) {
|
||||
const apple_sdk = @import("apple_sdk");
|
||||
try apple_sdk.addPaths(b, &lib.root_module);
|
||||
try apple_sdk.addPaths(b, lib.root_module);
|
||||
}
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
|
@ -42,9 +42,9 @@ fn buildSpirvCross(
|
||||
});
|
||||
lib.linkLibC();
|
||||
lib.linkLibCpp();
|
||||
if (target.result.isDarwin()) {
|
||||
if (target.result.os.tag.isDarwin()) {
|
||||
const apple_sdk = @import("apple_sdk");
|
||||
try apple_sdk.addPaths(b, &lib.root_module);
|
||||
try apple_sdk.addPaths(b, lib.root_module);
|
||||
}
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
|
@ -1,6 +1,7 @@
|
||||
.{
|
||||
.name = "spirv-cross",
|
||||
.name = .spirv_cross,
|
||||
.version = "13.1.1",
|
||||
.fingerprint = 0x7ea1d8312b06cca,
|
||||
.paths = .{""},
|
||||
.dependencies = .{
|
||||
// KhronosGroup/SPIRV-Cross
|
||||
|
@ -14,9 +14,9 @@ pub fn build(b: *std.Build) !void {
|
||||
lib.linkLibCpp();
|
||||
lib.addIncludePath(upstream.path(""));
|
||||
|
||||
if (target.result.isDarwin()) {
|
||||
if (target.result.os.tag.isDarwin()) {
|
||||
const apple_sdk = @import("apple_sdk");
|
||||
try apple_sdk.addPaths(b, &lib.root_module);
|
||||
try apple_sdk.addPaths(b, lib.root_module);
|
||||
}
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
|
@ -13,7 +13,7 @@ pub fn build(b: *std.Build) !void {
|
||||
.link_libc = true,
|
||||
});
|
||||
|
||||
if (target.result.isDarwin()) {
|
||||
if (target.result.os.tag.isDarwin()) {
|
||||
const apple_sdk = @import("apple_sdk");
|
||||
try apple_sdk.addPaths(b, module);
|
||||
}
|
||||
|
@ -13,9 +13,9 @@ pub fn build(b: *std.Build) !void {
|
||||
});
|
||||
lib.linkLibC();
|
||||
lib.addIncludePath(upstream.path(""));
|
||||
if (target.result.isDarwin()) {
|
||||
if (target.result.os.tag.isDarwin()) {
|
||||
const apple_sdk = @import("apple_sdk");
|
||||
try apple_sdk.addPaths(b, &lib.root_module);
|
||||
try apple_sdk.addPaths(b, lib.root_module);
|
||||
}
|
||||
|
||||
lib.installHeadersDirectory(
|
||||
|
@ -24,7 +24,7 @@ const global_state = &@import("global.zig").state;
|
||||
const oni = @import("oniguruma");
|
||||
const crash = @import("crash/main.zig");
|
||||
const unicode = @import("unicode/main.zig");
|
||||
const renderer = @import("renderer.zig");
|
||||
const rendererpkg = @import("renderer.zig");
|
||||
const termio = @import("termio.zig");
|
||||
const objc = @import("objc");
|
||||
const imgui = @import("imgui");
|
||||
@ -36,13 +36,13 @@ const configpkg = @import("config.zig");
|
||||
const input = @import("input.zig");
|
||||
const App = @import("App.zig");
|
||||
const internal_os = @import("os/main.zig");
|
||||
const inspector = @import("inspector/main.zig");
|
||||
const inspectorpkg = @import("inspector/main.zig");
|
||||
const SurfaceMouse = @import("surface_mouse.zig");
|
||||
|
||||
const log = std.log.scoped(.surface);
|
||||
|
||||
// The renderer implementation to use.
|
||||
const Renderer = renderer.Renderer;
|
||||
const Renderer = rendererpkg.Renderer;
|
||||
|
||||
/// Minimum window size in cells. This is used to prevent the window from
|
||||
/// being resized to a size that is too small to be useful. These defaults
|
||||
@ -70,10 +70,10 @@ font_metrics: font.Metrics,
|
||||
renderer: Renderer,
|
||||
|
||||
/// The render state
|
||||
renderer_state: renderer.State,
|
||||
renderer_state: rendererpkg.State,
|
||||
|
||||
/// The renderer thread manager
|
||||
renderer_thread: renderer.Thread,
|
||||
renderer_thread: rendererpkg.Thread,
|
||||
|
||||
/// The actual thread
|
||||
renderer_thr: std.Thread,
|
||||
@ -113,10 +113,10 @@ io_thread: termio.Thread,
|
||||
io_thr: std.Thread,
|
||||
|
||||
/// Terminal inspector
|
||||
inspector: ?*inspector.Inspector = null,
|
||||
inspector: ?*inspectorpkg.Inspector = null,
|
||||
|
||||
/// All our sizing information.
|
||||
size: renderer.Size,
|
||||
size: rendererpkg.Size,
|
||||
|
||||
/// The configuration derived from the main config. We "derive" it so that
|
||||
/// we don't have a shared pointer hanging around that we need to worry about
|
||||
@ -339,7 +339,7 @@ const DerivedConfig = struct {
|
||||
self.arena.deinit();
|
||||
}
|
||||
|
||||
fn scaledPadding(self: *const DerivedConfig, x_dpi: f32, y_dpi: f32) renderer.Padding {
|
||||
fn scaledPadding(self: *const DerivedConfig, x_dpi: f32, y_dpi: f32) rendererpkg.Padding {
|
||||
const padding_top: u32 = padding_top: {
|
||||
const padding_top: f32 = @floatFromInt(self.window_padding_top);
|
||||
break :padding_top @intFromFloat(@floor(padding_top * y_dpi / 72));
|
||||
@ -431,8 +431,8 @@ pub fn init(
|
||||
);
|
||||
|
||||
// Build our size struct which has all the sizes we need.
|
||||
const size: renderer.Size = size: {
|
||||
var size: renderer.Size = .{
|
||||
const size: rendererpkg.Size = size: {
|
||||
var size: rendererpkg.Size = .{
|
||||
.screen = screen: {
|
||||
const surface_size = try rt_surface.getSize();
|
||||
break :screen .{
|
||||
@ -445,7 +445,7 @@ pub fn init(
|
||||
.padding = .{},
|
||||
};
|
||||
|
||||
const explicit: renderer.Padding = derived_config.scaledPadding(
|
||||
const explicit: rendererpkg.Padding = derived_config.scaledPadding(
|
||||
x_dpi,
|
||||
y_dpi,
|
||||
);
|
||||
@ -475,7 +475,7 @@ pub fn init(
|
||||
errdefer alloc.destroy(mutex);
|
||||
|
||||
// Create the renderer thread
|
||||
var render_thread = try renderer.Thread.init(
|
||||
var render_thread = try rendererpkg.Thread.init(
|
||||
alloc,
|
||||
config,
|
||||
rt_surface,
|
||||
@ -611,7 +611,7 @@ pub fn init(
|
||||
// Start our renderer thread
|
||||
self.renderer_thr = try std.Thread.spawn(
|
||||
.{},
|
||||
renderer.Thread.threadMain,
|
||||
rendererpkg.Thread.threadMain,
|
||||
.{&self.renderer_thread},
|
||||
);
|
||||
self.renderer_thr.setName("renderer") catch {};
|
||||
@ -736,9 +736,9 @@ pub fn activateInspector(self: *Surface) !void {
|
||||
if (self.inspector != null) return;
|
||||
|
||||
// Setup the inspector
|
||||
const ptr = try self.alloc.create(inspector.Inspector);
|
||||
const ptr = try self.alloc.create(inspectorpkg.Inspector);
|
||||
errdefer self.alloc.destroy(ptr);
|
||||
ptr.* = try inspector.Inspector.init(self);
|
||||
ptr.* = try inspectorpkg.Inspector.init(self);
|
||||
self.inspector = ptr;
|
||||
|
||||
// Put the inspector onto the render state
|
||||
@ -1091,7 +1091,7 @@ fn mouseRefreshLinks(
|
||||
}
|
||||
|
||||
/// Called when our renderer health state changes.
|
||||
fn updateRendererHealth(self: *Surface, health: renderer.Health) void {
|
||||
fn updateRendererHealth(self: *Surface, health: rendererpkg.Health) void {
|
||||
log.warn("renderer health status change status={}", .{health});
|
||||
_ = self.rt_app.performAction(
|
||||
.{ .surface = self },
|
||||
@ -1163,7 +1163,7 @@ pub fn updateConfig(
|
||||
|
||||
// We need to store our configs in a heap-allocated pointer so that
|
||||
// our messages aren't huge.
|
||||
var renderer_message = try renderer.Message.initChangeConfig(self.alloc, config);
|
||||
var renderer_message = try rendererpkg.Message.initChangeConfig(self.alloc, config);
|
||||
errdefer renderer_message.deinit();
|
||||
var termio_config_ptr = try self.alloc.create(termio.Termio.DerivedConfig);
|
||||
errdefer self.alloc.destroy(termio_config_ptr);
|
||||
@ -1497,7 +1497,7 @@ fn setSelection(self: *Surface, sel_: ?terminal.Selection) !void {
|
||||
|
||||
/// Change the cell size for the terminal grid. This can happen as
|
||||
/// a result of changing the font size at runtime.
|
||||
fn setCellSize(self: *Surface, size: renderer.CellSize) !void {
|
||||
fn setCellSize(self: *Surface, size: rendererpkg.CellSize) !void {
|
||||
// Update our cell size within our size struct
|
||||
self.size.cell = size;
|
||||
self.balancePaddingIfNeeded();
|
||||
@ -1573,7 +1573,7 @@ pub fn sizeCallback(self: *Surface, size: apprt.SurfaceSize) !void {
|
||||
crash.sentry.thread_state = self.crashThreadState();
|
||||
defer crash.sentry.thread_state = null;
|
||||
|
||||
const new_screen_size: renderer.ScreenSize = .{
|
||||
const new_screen_size: rendererpkg.ScreenSize = .{
|
||||
.width = size.width,
|
||||
.height = size.height,
|
||||
};
|
||||
@ -1586,7 +1586,7 @@ pub fn sizeCallback(self: *Surface, size: apprt.SurfaceSize) !void {
|
||||
try self.resize(new_screen_size);
|
||||
}
|
||||
|
||||
fn resize(self: *Surface, size: renderer.ScreenSize) !void {
|
||||
fn resize(self: *Surface, size: rendererpkg.ScreenSize) !void {
|
||||
// Save our screen size
|
||||
self.size.screen = size;
|
||||
self.balancePaddingIfNeeded();
|
||||
@ -1667,7 +1667,7 @@ pub fn preeditCallback(self: *Surface, preedit_: ?[]const u8) !void {
|
||||
var it = view.iterator();
|
||||
|
||||
// Allocate the codepoints slice
|
||||
const Codepoint = renderer.State.Preedit.Codepoint;
|
||||
const Codepoint = rendererpkg.State.Preedit.Codepoint;
|
||||
var codepoints: std.ArrayListUnmanaged(Codepoint) = .{};
|
||||
defer codepoints.deinit(self.alloc);
|
||||
while (it.nextCodepoint()) |cp| {
|
||||
@ -1734,7 +1734,7 @@ pub fn keyCallback(
|
||||
defer crash.sentry.thread_state = null;
|
||||
|
||||
// Setup our inspector event if we have an inspector.
|
||||
var insp_ev: ?inspector.key.Event = if (self.inspector != null) ev: {
|
||||
var insp_ev: ?inspectorpkg.key.Event = if (self.inspector != null) ev: {
|
||||
var copy = event;
|
||||
copy.utf8 = "";
|
||||
if (event.utf8.len > 0) copy.utf8 = try self.alloc.dupe(u8, event.utf8);
|
||||
@ -1898,7 +1898,7 @@ pub fn keyCallback(
|
||||
fn maybeHandleBinding(
|
||||
self: *Surface,
|
||||
event: input.KeyEvent,
|
||||
insp_ev: ?*inspector.key.Event,
|
||||
insp_ev: ?*inspectorpkg.key.Event,
|
||||
) !?InputEffect {
|
||||
switch (event.action) {
|
||||
// Release events never trigger a binding but we need to check if
|
||||
@ -2106,7 +2106,7 @@ fn endKeySequence(
|
||||
fn encodeKey(
|
||||
self: *Surface,
|
||||
event: input.KeyEvent,
|
||||
insp_ev: ?*inspector.key.Event,
|
||||
insp_ev: ?*inspectorpkg.key.Event,
|
||||
) !?termio.Message.WriteReq {
|
||||
// Build up our encoder. Under different modes and
|
||||
// inputs there are many keybindings that result in no encoding
|
||||
@ -2749,7 +2749,7 @@ fn mouseReport(
|
||||
const final: u8 = if (action == .release) 'm' else 'M';
|
||||
|
||||
// The position has to be adjusted to the terminal space.
|
||||
const coord: renderer.Coordinate.Terminal = (renderer.Coordinate{
|
||||
const coord: rendererpkg.Coordinate.Terminal = (rendererpkg.Coordinate{
|
||||
.surface = .{
|
||||
.x = pos.x,
|
||||
.y = pos.y,
|
||||
@ -3819,7 +3819,7 @@ pub fn colorSchemeCallback(self: *Surface, scheme: apprt.ColorScheme) !void {
|
||||
|
||||
pub fn posToViewport(self: Surface, xpos: f64, ypos: f64) terminal.point.Coordinate {
|
||||
// Get our grid cell
|
||||
const coord: renderer.Coordinate = .{ .surface = .{ .x = xpos, .y = ypos } };
|
||||
const coord: rendererpkg.Coordinate = .{ .surface = .{ .x = xpos, .y = ypos } };
|
||||
const grid = coord.convert(.grid, self.size).grid;
|
||||
return .{ .x = grid.x, .y = grid.y };
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ const c = @import("c.zig").c;
|
||||
const version = @import("version.zig");
|
||||
const inspector = @import("inspector.zig");
|
||||
const key = @import("key.zig");
|
||||
const winproto = @import("winproto.zig");
|
||||
const winprotopkg = @import("winproto.zig");
|
||||
const testing = std.testing;
|
||||
const adwaita = @import("adwaita.zig");
|
||||
|
||||
@ -58,7 +58,7 @@ app: *c.GtkApplication,
|
||||
ctx: *c.GMainContext,
|
||||
|
||||
/// State and logic for the underlying windowing protocol.
|
||||
winproto: winproto.App,
|
||||
winproto: winprotopkg.App,
|
||||
|
||||
/// True if the app was launched with single instance mode.
|
||||
single_instance: bool,
|
||||
@ -401,7 +401,7 @@ pub fn init(core_app: *CoreApp, opts: Options) !App {
|
||||
}
|
||||
|
||||
// Setup our windowing protocol logic
|
||||
var winproto_app = try winproto.App.init(
|
||||
var winproto_app = try winprotopkg.App.init(
|
||||
core_app.alloc,
|
||||
display,
|
||||
app_id,
|
||||
|
@ -32,7 +32,7 @@ const ClipboardConfirmationWindow = @import("ClipboardConfirmationWindow.zig");
|
||||
const ResizeOverlay = @import("ResizeOverlay.zig");
|
||||
const URLWidget = @import("URLWidget.zig");
|
||||
const CloseDialog = @import("CloseDialog.zig");
|
||||
const inspector = @import("inspector.zig");
|
||||
const inspectorpkg = @import("inspector.zig");
|
||||
const gtk_key = @import("key.zig");
|
||||
const c = @import("c.zig").c;
|
||||
const Builder = @import("Builder.zig");
|
||||
@ -290,7 +290,7 @@ size: apprt.SurfaceSize,
|
||||
cursor_pos: apprt.CursorPos,
|
||||
|
||||
/// Inspector state.
|
||||
inspector: ?*inspector.Inspector = null,
|
||||
inspector: ?*inspectorpkg.Inspector = null,
|
||||
|
||||
/// Key input states. See gtkKeyPressed for detailed descriptions.
|
||||
in_keyevent: IMKeyEvent = .false,
|
||||
@ -703,7 +703,7 @@ pub fn controlInspector(
|
||||
|
||||
// If we already have an inspector, we don't need to show anything.
|
||||
if (self.inspector != null) return;
|
||||
self.inspector = inspector.Inspector.create(
|
||||
self.inspector = inspectorpkg.Inspector.create(
|
||||
self,
|
||||
.{ .window = {} },
|
||||
) catch |err| {
|
||||
|
@ -34,7 +34,7 @@ const TabView = @import("TabView.zig");
|
||||
const HeaderBar = @import("headerbar.zig");
|
||||
const CloseDialog = @import("CloseDialog.zig");
|
||||
const version = @import("version.zig");
|
||||
const winproto = @import("winproto.zig");
|
||||
const winprotopkg = @import("winproto.zig");
|
||||
|
||||
const log = std.log.scoped(.gtk);
|
||||
|
||||
@ -69,7 +69,7 @@ toast_overlay: *c.GtkWidget,
|
||||
adw_tab_overview_focus_timer: ?c.guint = null,
|
||||
|
||||
/// State and logic for windowing protocol for a window.
|
||||
winproto: winproto.Window,
|
||||
winproto: winprotopkg.Window,
|
||||
|
||||
pub const DerivedConfig = struct {
|
||||
background_opacity: f64,
|
||||
@ -693,7 +693,7 @@ fn gtkRealize(_: *c.GtkWindow, ud: ?*anyopaque) callconv(.C) bool {
|
||||
const self = userdataSelf(ud.?);
|
||||
|
||||
// Initialize our window protocol logic
|
||||
if (winproto.Window.init(
|
||||
if (winprotopkg.Window.init(
|
||||
self.app.core_app.alloc,
|
||||
&self.app.winproto,
|
||||
self,
|
||||
|
@ -7,7 +7,7 @@ const builtin = @import("builtin");
|
||||
|
||||
const apprt = @import("../apprt.zig");
|
||||
const font = @import("../font/main.zig");
|
||||
const renderer = @import("../renderer.zig");
|
||||
const rendererpkg = @import("../renderer.zig");
|
||||
const Command = @import("../Command.zig");
|
||||
const WasmTarget = @import("../os/wasm/target.zig").Target;
|
||||
|
||||
@ -28,7 +28,7 @@ wasm_target: WasmTarget,
|
||||
|
||||
/// Comptime interfaces
|
||||
app_runtime: apprt.Runtime = .none,
|
||||
renderer: renderer.Impl = .opengl,
|
||||
renderer: rendererpkg.Impl = .opengl,
|
||||
font_backend: font.Backend = .freetype,
|
||||
|
||||
/// Feature flags
|
||||
@ -69,7 +69,9 @@ pub fn init(b: *std.Build) !Config {
|
||||
|
||||
// If we're building for macOS and we're on macOS, we need to
|
||||
// use a generic target to workaround compilation issues.
|
||||
if (result.result.os.tag == .macos and builtin.target.isDarwin()) {
|
||||
if (result.result.os.tag == .macos and
|
||||
builtin.target.os.tag.isDarwin())
|
||||
{
|
||||
result = genericMacOSTarget(b, null);
|
||||
}
|
||||
|
||||
@ -122,10 +124,10 @@ pub fn init(b: *std.Build) !Config {
|
||||
) orelse apprt.Runtime.default(target.result);
|
||||
|
||||
config.renderer = b.option(
|
||||
renderer.Impl,
|
||||
rendererpkg.Impl,
|
||||
"renderer",
|
||||
"The app runtime to use. Not all values supported on all platforms.",
|
||||
) orelse renderer.Impl.default(target.result, wasm_target);
|
||||
) orelse rendererpkg.Impl.default(target.result, wasm_target);
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Feature Flags
|
||||
@ -331,7 +333,7 @@ pub fn init(b: *std.Build) !Config {
|
||||
bool,
|
||||
"emit-xcframework",
|
||||
"Build and install the xcframework for the macOS library.",
|
||||
) orelse builtin.target.isDarwin() and
|
||||
) orelse builtin.target.os.tag.isDarwin() and
|
||||
target.result.os.tag == .macos and
|
||||
config.app_runtime == .none and
|
||||
(!config.emit_bench and
|
||||
@ -366,7 +368,7 @@ pub fn init(b: *std.Build) !Config {
|
||||
.{
|
||||
// If we're not on darwin we want to use whatever the
|
||||
// default is via the system package mode
|
||||
.default = if (target.result.isDarwin()) false else null,
|
||||
.default = if (target.result.os.tag.isDarwin()) false else null,
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -395,7 +397,7 @@ pub fn addOptions(self: *const Config, step: *std.Build.Step.Options) !void {
|
||||
step.addOption(bool, "sentry", self.sentry);
|
||||
step.addOption(apprt.Runtime, "app_runtime", self.app_runtime);
|
||||
step.addOption(font.Backend, "font_backend", self.font_backend);
|
||||
step.addOption(renderer.Impl, "renderer", self.renderer);
|
||||
step.addOption(rendererpkg.Impl, "renderer", self.renderer);
|
||||
step.addOption(ExeEntrypoint, "exe_entrypoint", self.exe_entrypoint);
|
||||
step.addOption(WasmTarget, "wasm_target", self.wasm_target);
|
||||
step.addOption(bool, "wasm_shared", self.wasm_shared);
|
||||
@ -436,7 +438,7 @@ pub fn fromOptions() Config {
|
||||
.flatpak = options.flatpak,
|
||||
.app_runtime = std.meta.stringToEnum(apprt.Runtime, @tagName(options.app_runtime)).?,
|
||||
.font_backend = std.meta.stringToEnum(font.Backend, @tagName(options.font_backend)).?,
|
||||
.renderer = std.meta.stringToEnum(renderer.Impl, @tagName(options.renderer)).?,
|
||||
.renderer = std.meta.stringToEnum(rendererpkg.Impl, @tagName(options.renderer)).?,
|
||||
.exe_entrypoint = std.meta.stringToEnum(ExeEntrypoint, @tagName(options.exe_entrypoint)).?,
|
||||
.wasm_target = std.meta.stringToEnum(WasmTarget, @tagName(options.wasm_target)).?,
|
||||
.wasm_shared = options.wasm_shared,
|
||||
|
@ -27,7 +27,7 @@ pub fn init(
|
||||
const generate_markdown = b.addExecutable(.{
|
||||
.name = "mdgen_" ++ manpage.name ++ "_" ++ manpage.section,
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = b.host,
|
||||
.target = b.graph.host,
|
||||
});
|
||||
deps.help_strings.addImport(generate_markdown);
|
||||
|
||||
|
@ -16,7 +16,7 @@ pub fn init(b: *std.Build) !GhosttyFrameData {
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "framegen",
|
||||
.root_source_file = b.path("src/build/framegen/main.zig"),
|
||||
.target = b.host,
|
||||
.target = b.graph.host,
|
||||
});
|
||||
|
||||
const run = b.addRunArtifact(exe);
|
||||
|
@ -97,8 +97,8 @@ fn createUpdateStep(b: *std.Build) !*std.Build.Step {
|
||||
}
|
||||
}
|
||||
|
||||
const wf = b.addWriteFiles();
|
||||
wf.addCopyFileToSource(
|
||||
const usf = b.addUpdateSourceFiles();
|
||||
usf.addCopyFileToSource(
|
||||
xgettext.captureStdOut(),
|
||||
"po/" ++ domain ++ ".pot",
|
||||
);
|
||||
@ -107,8 +107,8 @@ fn createUpdateStep(b: *std.Build) !*std.Build.Step {
|
||||
const msgmerge = b.addSystemCommand(&.{ "msgmerge", "-q" });
|
||||
msgmerge.addFileArg(b.path("po/" ++ locale ++ ".po"));
|
||||
msgmerge.addFileArg(xgettext.captureStdOut());
|
||||
wf.addCopyFileToSource(msgmerge.captureStdOut(), "po/" ++ locale ++ ".po");
|
||||
usf.addCopyFileToSource(msgmerge.captureStdOut(), "po/" ++ locale ++ ".po");
|
||||
}
|
||||
|
||||
return &wf.step;
|
||||
return &usf.step;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ pub fn initStatic(
|
||||
var lib_list = try deps.add(lib);
|
||||
try lib_list.append(lib.getEmittedBin());
|
||||
|
||||
if (!deps.config.target.result.isDarwin()) return .{
|
||||
if (!deps.config.target.result.os.tag.isDarwin()) return .{
|
||||
.step = &lib.step,
|
||||
.output = lib.getEmittedBin(),
|
||||
};
|
||||
|
@ -19,7 +19,7 @@ pub fn init(
|
||||
const webgen_config = b.addExecutable(.{
|
||||
.name = "webgen_config",
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = b.host,
|
||||
.target = b.graph.host,
|
||||
});
|
||||
deps.help_strings.addImport(webgen_config);
|
||||
|
||||
@ -48,7 +48,7 @@ pub fn init(
|
||||
const webgen_actions = b.addExecutable(.{
|
||||
.name = "webgen_actions",
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = b.host,
|
||||
.target = b.graph.host,
|
||||
});
|
||||
deps.help_strings.addImport(webgen_actions);
|
||||
|
||||
@ -77,7 +77,7 @@ pub fn init(
|
||||
const webgen_commands = b.addExecutable(.{
|
||||
.name = "webgen_commands",
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = b.host,
|
||||
.target = b.graph.host,
|
||||
});
|
||||
deps.help_strings.addImport(webgen_commands);
|
||||
|
||||
|
@ -13,7 +13,7 @@ pub fn init(b: *std.Build, cfg: *const Config) !HelpStrings {
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "helpgen",
|
||||
.root_source_file = b.path("src/helpgen.zig"),
|
||||
.target = b.host,
|
||||
.target = b.graph.host,
|
||||
});
|
||||
|
||||
const help_config = config: {
|
||||
|
@ -320,8 +320,8 @@ pub fn add(
|
||||
|
||||
// We always require the system SDK so that our system headers are available.
|
||||
// This makes things like `os/log.h` available for cross-compiling.
|
||||
if (step.rootModuleTarget().isDarwin()) {
|
||||
try @import("apple_sdk").addPaths(b, &step.root_module);
|
||||
if (step.rootModuleTarget().os.tag.isDarwin()) {
|
||||
try @import("apple_sdk").addPaths(b, step.root_module);
|
||||
|
||||
const metallib = self.metallib.?;
|
||||
metallib.output.addStepDependencies(&step.step);
|
||||
@ -363,7 +363,7 @@ pub fn add(
|
||||
}).module("zf"));
|
||||
|
||||
// Mac Stuff
|
||||
if (step.rootModuleTarget().isDarwin()) {
|
||||
if (step.rootModuleTarget().os.tag.isDarwin()) {
|
||||
const objc_dep = b.dependency("zig_objc", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
@ -470,7 +470,7 @@ pub fn add(
|
||||
}
|
||||
|
||||
if (self.config.wayland) {
|
||||
const scanner = Scanner.create(b.dependency("zig_wayland", .{}), .{
|
||||
const scanner = Scanner.create(b.dependency("zig_wayland", .{}).builder, .{
|
||||
.wayland_xml = b.dependency("wayland", .{}).path("protocol/wayland.xml"),
|
||||
.wayland_protocols = b.dependency("wayland_protocols", .{}).path(""),
|
||||
});
|
||||
@ -523,7 +523,7 @@ pub fn add(
|
||||
const generate_gresource_xml = b.addExecutable(.{
|
||||
.name = "generate_gresource_xml",
|
||||
.root_source_file = b.path("src/apprt/gtk/gresource.zig"),
|
||||
.target = b.host,
|
||||
.target = b.graph.host,
|
||||
});
|
||||
|
||||
const generate = b.addRunArtifact(generate_gresource_xml);
|
||||
@ -531,7 +531,7 @@ pub fn add(
|
||||
const gtk_blueprint_compiler = b.addExecutable(.{
|
||||
.name = "gtk_blueprint_compiler",
|
||||
.root_source_file = b.path("src/apprt/gtk/blueprint_compiler.zig"),
|
||||
.target = b.host,
|
||||
.target = b.graph.host,
|
||||
});
|
||||
gtk_blueprint_compiler.linkSystemLibrary2("gtk4", dynamic_link_opts);
|
||||
gtk_blueprint_compiler.linkSystemLibrary2("libadwaita-1", dynamic_link_opts);
|
||||
@ -569,7 +569,7 @@ pub fn add(
|
||||
const gtk_builder_check = b.addExecutable(.{
|
||||
.name = "gtk_builder_check",
|
||||
.root_source_file = b.path("src/apprt/gtk/builder_check.zig"),
|
||||
.target = b.host,
|
||||
.target = b.graph.host,
|
||||
});
|
||||
gtk_builder_check.root_module.addOptions("build_options", self.options);
|
||||
gtk_builder_check.root_module.addImport("gtk", gobject.module("gtk4"));
|
||||
@ -593,7 +593,6 @@ pub fn add(
|
||||
});
|
||||
const ghostty_resources_c = generate_resources_c.addOutputFileArg("ghostty_resources.c");
|
||||
generate_resources_c.addFileArg(gresource_xml);
|
||||
generate_resources_c.extra_file_dependencies = &gresource.dependencies;
|
||||
step.addCSourceFile(.{ .file = ghostty_resources_c, .flags = &.{} });
|
||||
|
||||
const generate_resources_h = b.addSystemCommand(&.{
|
||||
@ -605,7 +604,6 @@ pub fn add(
|
||||
});
|
||||
const ghostty_resources_h = generate_resources_h.addOutputFileArg("ghostty_resources.h");
|
||||
generate_resources_h.addFileArg(gresource_xml);
|
||||
generate_resources_h.extra_file_dependencies = &gresource.dependencies;
|
||||
step.addIncludePath(ghostty_resources_h.dirname());
|
||||
}
|
||||
},
|
||||
|
@ -13,11 +13,11 @@ pub fn init(b: *std.Build) !UnicodeTables {
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "unigen",
|
||||
.root_source_file = b.path("src/unicode/props.zig"),
|
||||
.target = b.host,
|
||||
.target = b.graph.host,
|
||||
});
|
||||
|
||||
const ziglyph_dep = b.dependency("ziglyph", .{
|
||||
.target = b.host,
|
||||
.target = b.graph.host,
|
||||
});
|
||||
exe.root_module.addImport("ziglyph", ziglyph_dep.module("ziglyph"));
|
||||
|
||||
|
@ -88,7 +88,7 @@ fn writeBashCompletions(writer: anytype) !void {
|
||||
\\
|
||||
);
|
||||
|
||||
for (@typeInfo(Config).Struct.fields) |field| {
|
||||
for (@typeInfo(Config).@"struct".fields) |field| {
|
||||
if (field.name[0] == '_') continue;
|
||||
switch (field.type) {
|
||||
bool, ?bool => try writer.writeAll(pad2 ++ "config+=\" '--" ++ field.name ++ " '\"\n"),
|
||||
@ -102,7 +102,7 @@ fn writeBashCompletions(writer: anytype) !void {
|
||||
\\
|
||||
);
|
||||
|
||||
for (@typeInfo(Config).Struct.fields) |field| {
|
||||
for (@typeInfo(Config).@"struct".fields) |field| {
|
||||
if (field.name[0] == '_') continue;
|
||||
try writer.writeAll(pad3 ++ "--" ++ field.name ++ ") ");
|
||||
|
||||
@ -118,8 +118,8 @@ fn writeBashCompletions(writer: anytype) !void {
|
||||
const compgenPrefix = "mapfile -t COMPREPLY < <( compgen -W \"";
|
||||
const compgenSuffix = "\" -- \"$cur\" ); _add_spaces ;;";
|
||||
switch (@typeInfo(field.type)) {
|
||||
.Bool => try writer.writeAll("return ;;"),
|
||||
.Enum => |info| {
|
||||
.bool => try writer.writeAll("return ;;"),
|
||||
.@"enum" => |info| {
|
||||
try writer.writeAll(compgenPrefix);
|
||||
for (info.fields, 0..) |f, i| {
|
||||
if (i > 0) try writer.writeAll(" ");
|
||||
@ -127,7 +127,7 @@ fn writeBashCompletions(writer: anytype) !void {
|
||||
}
|
||||
try writer.writeAll(compgenSuffix);
|
||||
},
|
||||
.Struct => |info| {
|
||||
.@"struct" => |info| {
|
||||
if (!@hasDecl(field.type, "parseCLI") and info.layout == .@"packed") {
|
||||
try writer.writeAll(compgenPrefix);
|
||||
for (info.fields, 0..) |f, i| {
|
||||
@ -157,13 +157,13 @@ fn writeBashCompletions(writer: anytype) !void {
|
||||
\\
|
||||
);
|
||||
|
||||
for (@typeInfo(Action).Enum.fields) |field| {
|
||||
for (@typeInfo(Action).@"enum".fields) |field| {
|
||||
if (std.mem.eql(u8, "help", field.name)) continue;
|
||||
if (std.mem.eql(u8, "version", field.name)) continue;
|
||||
|
||||
const options = @field(Action, field.name).options();
|
||||
// assumes options will never be created with only <_name> members
|
||||
if (@typeInfo(options).Struct.fields.len == 0) continue;
|
||||
if (@typeInfo(options).@"struct".fields.len == 0) continue;
|
||||
|
||||
var buffer: [field.name.len]u8 = undefined;
|
||||
const bashName: []u8 = buffer[0..field.name.len];
|
||||
@ -174,7 +174,7 @@ fn writeBashCompletions(writer: anytype) !void {
|
||||
|
||||
{
|
||||
var count = 0;
|
||||
for (@typeInfo(options).Struct.fields) |opt| {
|
||||
for (@typeInfo(options).@"struct".fields) |opt| {
|
||||
if (opt.name[0] == '_') continue;
|
||||
if (count > 0) try writer.writeAll(" ");
|
||||
switch (opt.type) {
|
||||
@ -193,12 +193,12 @@ fn writeBashCompletions(writer: anytype) !void {
|
||||
\\
|
||||
);
|
||||
|
||||
for (@typeInfo(Action).Enum.fields) |field| {
|
||||
for (@typeInfo(Action).@"enum".fields) |field| {
|
||||
if (std.mem.eql(u8, "help", field.name)) continue;
|
||||
if (std.mem.eql(u8, "version", field.name)) continue;
|
||||
|
||||
const options = @field(Action, field.name).options();
|
||||
if (@typeInfo(options).Struct.fields.len == 0) continue;
|
||||
if (@typeInfo(options).@"struct".fields.len == 0) continue;
|
||||
|
||||
// bash doesn't allow variable names containing '-' so replace them
|
||||
var buffer: [field.name.len]u8 = undefined;
|
||||
@ -207,7 +207,7 @@ fn writeBashCompletions(writer: anytype) !void {
|
||||
|
||||
try writer.writeAll(pad3 ++ "+" ++ field.name ++ ")\n");
|
||||
try writer.writeAll(pad4 ++ "case $prev in\n");
|
||||
for (@typeInfo(options).Struct.fields) |opt| {
|
||||
for (@typeInfo(options).@"struct".fields) |opt| {
|
||||
if (opt.name[0] == '_') continue;
|
||||
|
||||
try writer.writeAll(pad5 ++ "--" ++ opt.name ++ ") ");
|
||||
@ -215,8 +215,8 @@ fn writeBashCompletions(writer: anytype) !void {
|
||||
const compgenPrefix = "mapfile -t COMPREPLY < <( compgen -W \"";
|
||||
const compgenSuffix = "\" -- \"$cur\" ); _add_spaces ;;";
|
||||
switch (@typeInfo(opt.type)) {
|
||||
.Bool => try writer.writeAll("return ;;"),
|
||||
.Enum => |info| {
|
||||
.bool => try writer.writeAll("return ;;"),
|
||||
.@"enum" => |info| {
|
||||
try writer.writeAll(compgenPrefix);
|
||||
for (info.fields, 0..) |f, i| {
|
||||
if (i > 0) try writer.writeAll(" ");
|
||||
@ -224,9 +224,9 @@ fn writeBashCompletions(writer: anytype) !void {
|
||||
}
|
||||
try writer.writeAll(compgenSuffix);
|
||||
},
|
||||
.Optional => |optional| {
|
||||
.optional => |optional| {
|
||||
switch (@typeInfo(optional.child)) {
|
||||
.Enum => |info| {
|
||||
.@"enum" => |info| {
|
||||
try writer.writeAll(compgenPrefix);
|
||||
for (info.fields, 0..) |f, i| {
|
||||
if (i > 0) try writer.writeAll(" ");
|
||||
@ -271,7 +271,7 @@ fn writeBashCompletions(writer: anytype) !void {
|
||||
\\
|
||||
);
|
||||
|
||||
for (@typeInfo(Action).Enum.fields) |field| {
|
||||
for (@typeInfo(Action).@"enum".fields) |field| {
|
||||
if (std.mem.eql(u8, "help", field.name)) continue;
|
||||
if (std.mem.eql(u8, "version", field.name)) continue;
|
||||
|
||||
|
@ -25,7 +25,7 @@ fn writeFishCompletions(writer: anytype) !void {
|
||||
{
|
||||
try writer.writeAll("set -l commands \"");
|
||||
var count: usize = 0;
|
||||
for (@typeInfo(Action).Enum.fields) |field| {
|
||||
for (@typeInfo(Action).@"enum".fields) |field| {
|
||||
if (std.mem.eql(u8, "help", field.name)) continue;
|
||||
if (std.mem.eql(u8, "version", field.name)) continue;
|
||||
if (count > 0) try writer.writeAll(" ");
|
||||
@ -41,7 +41,7 @@ fn writeFishCompletions(writer: anytype) !void {
|
||||
try writer.writeAll("complete -c ghostty -s e -l help -f\n");
|
||||
try writer.writeAll("complete -c ghostty -n \"not __fish_seen_subcommand_from $commands\" -l version -f\n");
|
||||
|
||||
for (@typeInfo(Config).Struct.fields) |field| {
|
||||
for (@typeInfo(Config).@"struct".fields) |field| {
|
||||
if (field.name[0] == '_') continue;
|
||||
|
||||
try writer.writeAll("complete -c ghostty -n \"not __fish_seen_subcommand_from $commands\" -l ");
|
||||
@ -56,8 +56,8 @@ fn writeFishCompletions(writer: anytype) !void {
|
||||
else {
|
||||
try writer.writeAll(if (field.type != Config.RepeatablePath) " -f" else " -F");
|
||||
switch (@typeInfo(field.type)) {
|
||||
.Bool => {},
|
||||
.Enum => |info| {
|
||||
.bool => {},
|
||||
.@"enum" => |info| {
|
||||
try writer.writeAll(" -a \"");
|
||||
for (info.fields, 0..) |f, i| {
|
||||
if (i > 0) try writer.writeAll(" ");
|
||||
@ -65,7 +65,7 @@ fn writeFishCompletions(writer: anytype) !void {
|
||||
}
|
||||
try writer.writeAll("\"");
|
||||
},
|
||||
.Struct => |info| {
|
||||
.@"struct" => |info| {
|
||||
if (!@hasDecl(field.type, "parseCLI") and info.layout == .@"packed") {
|
||||
try writer.writeAll(" -a \"");
|
||||
for (info.fields, 0..) |f, i| {
|
||||
@ -86,7 +86,7 @@ fn writeFishCompletions(writer: anytype) !void {
|
||||
{
|
||||
try writer.writeAll("complete -c ghostty -n \"string match -q -- '+*' (commandline -pt)\" -f -a \"");
|
||||
var count: usize = 0;
|
||||
for (@typeInfo(Action).Enum.fields) |field| {
|
||||
for (@typeInfo(Action).@"enum".fields) |field| {
|
||||
if (std.mem.eql(u8, "help", field.name)) continue;
|
||||
if (std.mem.eql(u8, "version", field.name)) continue;
|
||||
if (count > 0) try writer.writeAll(" ");
|
||||
@ -97,12 +97,12 @@ fn writeFishCompletions(writer: anytype) !void {
|
||||
try writer.writeAll("\"\n");
|
||||
}
|
||||
|
||||
for (@typeInfo(Action).Enum.fields) |field| {
|
||||
for (@typeInfo(Action).@"enum".fields) |field| {
|
||||
if (std.mem.eql(u8, "help", field.name)) continue;
|
||||
if (std.mem.eql(u8, "version", field.name)) continue;
|
||||
|
||||
const options = @field(Action, field.name).options();
|
||||
for (@typeInfo(options).Struct.fields) |opt| {
|
||||
for (@typeInfo(options).@"struct".fields) |opt| {
|
||||
if (opt.name[0] == '_') continue;
|
||||
try writer.writeAll("complete -c ghostty -n \"__fish_seen_subcommand_from +" ++ field.name ++ "\" -l ");
|
||||
try writer.writeAll(opt.name);
|
||||
@ -114,8 +114,8 @@ fn writeFishCompletions(writer: anytype) !void {
|
||||
} else try writer.writeAll(" -f");
|
||||
|
||||
switch (@typeInfo(opt.type)) {
|
||||
.Bool => {},
|
||||
.Enum => |info| {
|
||||
.bool => {},
|
||||
.@"enum" => |info| {
|
||||
try writer.writeAll(" -a \"");
|
||||
for (info.fields, 0..) |f, i| {
|
||||
if (i > 0) try writer.writeAll(" ");
|
||||
@ -123,9 +123,9 @@ fn writeFishCompletions(writer: anytype) !void {
|
||||
}
|
||||
try writer.writeAll("\"");
|
||||
},
|
||||
.Optional => |optional| {
|
||||
.optional => |optional| {
|
||||
switch (@typeInfo(optional.child)) {
|
||||
.Enum => |info| {
|
||||
.@"enum" => |info| {
|
||||
try writer.writeAll(" -a \"");
|
||||
for (info.fields, 0..) |f, i| {
|
||||
if (i > 0) try writer.writeAll(" ");
|
||||
|
@ -45,7 +45,7 @@ fn writeZshCompletions(writer: anytype) !void {
|
||||
try writer.writeAll(" _arguments \\\n");
|
||||
try writer.writeAll(" \"--help\" \\\n");
|
||||
try writer.writeAll(" \"--version\" \\\n");
|
||||
for (@typeInfo(Config).Struct.fields) |field| {
|
||||
for (@typeInfo(Config).@"struct".fields) |field| {
|
||||
if (field.name[0] == '_') continue;
|
||||
try writer.writeAll(" \"--");
|
||||
try writer.writeAll(field.name);
|
||||
@ -64,8 +64,8 @@ fn writeZshCompletions(writer: anytype) !void {
|
||||
try writer.writeAll("_files"); // todo check if this is needed
|
||||
} else {
|
||||
switch (@typeInfo(field.type)) {
|
||||
.Bool => {},
|
||||
.Enum => |info| {
|
||||
.bool => {},
|
||||
.@"enum" => |info| {
|
||||
try writer.writeAll(equals_required);
|
||||
try writer.writeAll("(");
|
||||
for (info.fields, 0..) |f, i| {
|
||||
@ -74,7 +74,7 @@ fn writeZshCompletions(writer: anytype) !void {
|
||||
}
|
||||
try writer.writeAll(")");
|
||||
},
|
||||
.Struct => |info| {
|
||||
.@"struct" => |info| {
|
||||
try writer.writeAll(equals_required);
|
||||
if (!@hasDecl(field.type, "parseCLI") and info.layout == .@"packed") {
|
||||
try writer.writeAll("(");
|
||||
@ -138,7 +138,7 @@ fn writeZshCompletions(writer: anytype) !void {
|
||||
// how to get 'commands'
|
||||
var count: usize = 0;
|
||||
const padding = " ";
|
||||
for (@typeInfo(Action).Enum.fields) |field| {
|
||||
for (@typeInfo(Action).@"enum".fields) |field| {
|
||||
if (std.mem.eql(u8, "help", field.name)) continue;
|
||||
if (std.mem.eql(u8, "version", field.name)) continue;
|
||||
|
||||
@ -167,25 +167,25 @@ fn writeZshCompletions(writer: anytype) !void {
|
||||
);
|
||||
{
|
||||
const padding = " ";
|
||||
for (@typeInfo(Action).Enum.fields) |field| {
|
||||
for (@typeInfo(Action).@"enum".fields) |field| {
|
||||
if (std.mem.eql(u8, "help", field.name)) continue;
|
||||
if (std.mem.eql(u8, "version", field.name)) continue;
|
||||
|
||||
const options = @field(Action, field.name).options();
|
||||
// assumes options will never be created with only <_name> members
|
||||
if (@typeInfo(options).Struct.fields.len == 0) continue;
|
||||
if (@typeInfo(options).@"struct".fields.len == 0) continue;
|
||||
|
||||
try writer.writeAll(padding ++ "(+" ++ field.name ++ ")\n");
|
||||
try writer.writeAll(padding ++ " _arguments \\\n");
|
||||
for (@typeInfo(options).Struct.fields) |opt| {
|
||||
for (@typeInfo(options).@"struct".fields) |opt| {
|
||||
if (opt.name[0] == '_') continue;
|
||||
|
||||
try writer.writeAll(padding ++ " '--");
|
||||
try writer.writeAll(opt.name);
|
||||
|
||||
switch (@typeInfo(opt.type)) {
|
||||
.Bool => {},
|
||||
.Enum => |info| {
|
||||
.bool => {},
|
||||
.@"enum" => |info| {
|
||||
try writer.writeAll(equals_required);
|
||||
try writer.writeAll("(");
|
||||
for (info.fields, 0..) |f, i| {
|
||||
@ -194,10 +194,10 @@ fn writeZshCompletions(writer: anytype) !void {
|
||||
}
|
||||
try writer.writeAll(")");
|
||||
},
|
||||
.Optional => |optional| {
|
||||
.optional => |optional| {
|
||||
try writer.writeAll(equals_required);
|
||||
switch (@typeInfo(optional.child)) {
|
||||
.Enum => |info| {
|
||||
.@"enum" => |info| {
|
||||
try writer.writeAll("(");
|
||||
for (info.fields, 0..) |f, i| {
|
||||
if (i > 0) try writer.writeAll(" ");
|
||||
|
@ -80,7 +80,7 @@ pub const Artifact = enum {
|
||||
wasm_module,
|
||||
|
||||
pub fn detect() Artifact {
|
||||
if (builtin.target.isWasm()) {
|
||||
if (builtin.target.cpu.arch.isWasm()) {
|
||||
assert(builtin.output_mode == .Obj);
|
||||
assert(builtin.link_mode == .Static);
|
||||
return .wasm_module;
|
||||
|
@ -39,14 +39,14 @@ pub const State = struct {
|
||||
|
||||
/// An enum of the available conditional configuration keys.
|
||||
pub const Key = key: {
|
||||
const stateInfo = @typeInfo(State).Struct;
|
||||
const stateInfo = @typeInfo(State).@"struct";
|
||||
var fields: [stateInfo.fields.len]std.builtin.Type.EnumField = undefined;
|
||||
for (stateInfo.fields, 0..) |field, i| fields[i] = .{
|
||||
.name = field.name,
|
||||
.value = i,
|
||||
};
|
||||
|
||||
break :key @Type(.{ .Enum = .{
|
||||
break :key @Type(.{ .@"enum" = .{
|
||||
.tag_type = std.math.IntFittingRange(0, fields.len - 1),
|
||||
.fields = &fields,
|
||||
.decls = &.{},
|
||||
|
@ -36,7 +36,7 @@ fn isInternal(name: []const u8) bool {
|
||||
fn generateKeywords() []const u8 {
|
||||
@setEvalBranchQuota(5000);
|
||||
var keywords: []const u8 = "";
|
||||
const config_fields = @typeInfo(Config).Struct.fields;
|
||||
const config_fields = @typeInfo(Config).@"struct".fields;
|
||||
|
||||
for (config_fields) |field| {
|
||||
if (isInternal(field.name)) continue;
|
||||
|
@ -91,7 +91,7 @@ fn writeSyntax(writer: anytype) !void {
|
||||
\\syn keyword ghosttyConfigKeyword
|
||||
);
|
||||
|
||||
const config_fields = @typeInfo(Config).Struct.fields;
|
||||
const config_fields = @typeInfo(Config).@"struct".fields;
|
||||
inline for (config_fields) |field| {
|
||||
if (field.name[0] == '_') continue;
|
||||
try writer.print("\n\t\\ {s}", .{field.name});
|
||||
|
@ -30,7 +30,7 @@ pub const Library = library.Library;
|
||||
|
||||
// If we're targeting wasm then we export some wasm APIs.
|
||||
comptime {
|
||||
if (builtin.target.isWasm()) {
|
||||
if (builtin.target.cpu.arch.isWasm()) {
|
||||
_ = Atlas.Wasm;
|
||||
_ = DeferredFace.Wasm;
|
||||
_ = face.web_canvas.Wasm;
|
||||
@ -45,7 +45,7 @@ pub const options: struct {
|
||||
// TODO: we need to modify the build config for wasm builds. the issue
|
||||
// is we're sharing the build config options between all exes in build.zig.
|
||||
// We need to construct it per target.
|
||||
.backend = if (builtin.target.isWasm()) .web_canvas else build_config.font_backend,
|
||||
.backend = if (builtin.target.cpu.arch.isWasm()) .web_canvas else build_config.font_backend,
|
||||
};
|
||||
|
||||
pub const Backend = enum {
|
||||
@ -91,7 +91,7 @@ pub const Backend = enum {
|
||||
// macOS also supports "coretext_freetype" but there is no scenario
|
||||
// that is the default. It is only used by people who want to
|
||||
// self-compile Ghostty and prefer the freetype aesthetic.
|
||||
return if (target.isDarwin()) .coretext else .fontconfig_freetype;
|
||||
return if (target.os.tag.isDarwin()) .coretext else .fontconfig_freetype;
|
||||
}
|
||||
|
||||
// All the functions below can be called at comptime or runtime to
|
||||
@ -176,7 +176,7 @@ pub const sprite_index = Collection.Index.initSpecial(.sprite);
|
||||
|
||||
test {
|
||||
// For non-wasm we want to test everything we can
|
||||
if (!comptime builtin.target.isWasm()) {
|
||||
if (!comptime builtin.target.cpu.arch.isWasm()) {
|
||||
@import("std").testing.refAllDecls(@This());
|
||||
return;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ pub const Impl = enum {
|
||||
};
|
||||
}
|
||||
|
||||
if (target.isDarwin()) return .metal;
|
||||
if (target.os.tag.isDarwin()) return .metal;
|
||||
return .opengl;
|
||||
}
|
||||
};
|
||||
|
@ -3,7 +3,7 @@
|
||||
const std = @import("std");
|
||||
const Allocator = std.mem.Allocator;
|
||||
const Inspector = @import("../inspector/main.zig").Inspector;
|
||||
const terminal = @import("../terminal/main.zig");
|
||||
const terminalpkg = @import("../terminal/main.zig");
|
||||
const inputpkg = @import("../input.zig");
|
||||
const renderer = @import("../renderer.zig");
|
||||
|
||||
@ -14,7 +14,7 @@ const renderer = @import("../renderer.zig");
|
||||
mutex: *std.Thread.Mutex,
|
||||
|
||||
/// The terminal data.
|
||||
terminal: *terminal.Terminal,
|
||||
terminal: *terminalpkg.Terminal,
|
||||
|
||||
/// The terminal inspector, if any. This will be null while the inspector
|
||||
/// is not active and will be set when it is active.
|
||||
@ -34,7 +34,7 @@ pub const Mouse = struct {
|
||||
/// The point on the viewport where the mouse currently is. We use
|
||||
/// viewport points to avoid the complexity of mapping the mouse to
|
||||
/// the renderer state.
|
||||
point: ?terminal.point.Coordinate = null,
|
||||
point: ?terminalpkg.point.Coordinate = null,
|
||||
|
||||
/// The mods that are currently active for the last mouse event.
|
||||
/// This could really just be mods in general and we probably will
|
||||
@ -80,11 +80,11 @@ pub const Preedit = struct {
|
||||
/// into the available space.
|
||||
pub fn range(
|
||||
self: *const Preedit,
|
||||
start: terminal.size.CellCountInt,
|
||||
max: terminal.size.CellCountInt,
|
||||
start: terminalpkg.size.CellCountInt,
|
||||
max: terminalpkg.size.CellCountInt,
|
||||
) struct {
|
||||
start: terminal.size.CellCountInt,
|
||||
end: terminal.size.CellCountInt,
|
||||
start: terminalpkg.size.CellCountInt,
|
||||
end: terminalpkg.size.CellCountInt,
|
||||
cp_offset: usize,
|
||||
} {
|
||||
// If our width is greater than the number of cells we have
|
||||
@ -96,7 +96,7 @@ pub const Preedit = struct {
|
||||
|
||||
// Rebuild our width in reverse order. This is because we want
|
||||
// to offset by the end cells, not the start cells (if we have to).
|
||||
var w: terminal.size.CellCountInt = 0;
|
||||
var w: terminalpkg.size.CellCountInt = 0;
|
||||
for (0..self.codepoints.len) |i| {
|
||||
const reverse_i = self.codepoints.len - i - 1;
|
||||
const cp = self.codepoints[reverse_i];
|
||||
|
@ -8,7 +8,7 @@ const assert = std.debug.assert;
|
||||
const xev = @import("../global.zig").xev;
|
||||
const crash = @import("../crash/main.zig");
|
||||
const internal_os = @import("../os/main.zig");
|
||||
const renderer = @import("../renderer.zig");
|
||||
const rendererpkg = @import("../renderer.zig");
|
||||
const apprt = @import("../apprt.zig");
|
||||
const configpkg = @import("../config.zig");
|
||||
const BlockingQueue = @import("../datastruct/main.zig").BlockingQueue;
|
||||
@ -23,7 +23,7 @@ const CURSOR_BLINK_INTERVAL = 600;
|
||||
/// The type used for sending messages to the IO thread. For now this is
|
||||
/// hardcoded with a capacity. We can make this a comptime parameter in
|
||||
/// the future if we want it configurable.
|
||||
pub const Mailbox = BlockingQueue(renderer.Message, 64);
|
||||
pub const Mailbox = BlockingQueue(rendererpkg.Message, 64);
|
||||
|
||||
/// Allocator used for some state
|
||||
alloc: std.mem.Allocator,
|
||||
@ -67,10 +67,10 @@ cursor_c_cancel: xev.Completion = .{},
|
||||
surface: *apprt.Surface,
|
||||
|
||||
/// The underlying renderer implementation.
|
||||
renderer: *renderer.Renderer,
|
||||
renderer: *rendererpkg.Renderer,
|
||||
|
||||
/// Pointer to the shared state that is used to generate the final render.
|
||||
state: *renderer.State,
|
||||
state: *rendererpkg.State,
|
||||
|
||||
/// The mailbox that can be used to send this thread messages. Note
|
||||
/// this is a blocking queue so if it is full you will get errors (or block).
|
||||
@ -117,8 +117,8 @@ pub fn init(
|
||||
alloc: Allocator,
|
||||
config: *const configpkg.Config,
|
||||
surface: *apprt.Surface,
|
||||
renderer_impl: *renderer.Renderer,
|
||||
state: *renderer.State,
|
||||
renderer_impl: *rendererpkg.Renderer,
|
||||
state: *rendererpkg.State,
|
||||
app_mailbox: App.Mailbox,
|
||||
) !Thread {
|
||||
// Create our event loop.
|
||||
@ -209,7 +209,7 @@ fn threadMain_(self: *Thread) !void {
|
||||
self.setQosClass();
|
||||
|
||||
// Run our loop start/end callbacks if the renderer cares.
|
||||
const has_loop = @hasDecl(renderer.Renderer, "loopEnter");
|
||||
const has_loop = @hasDecl(rendererpkg.Renderer, "loopEnter");
|
||||
if (has_loop) try self.renderer.loopEnter(self);
|
||||
defer if (has_loop) self.renderer.loopExit();
|
||||
|
||||
@ -278,7 +278,7 @@ fn setQosClass(self: *const Thread) void {
|
||||
|
||||
fn startDrawTimer(self: *Thread) void {
|
||||
// If our renderer doesn't support animations then we never run this.
|
||||
if (!@hasDecl(renderer.Renderer, "hasAnimations")) return;
|
||||
if (!@hasDecl(rendererpkg.Renderer, "hasAnimations")) return;
|
||||
if (!self.renderer.hasAnimations()) return;
|
||||
if (self.config.custom_shader_animation == .false) return;
|
||||
|
||||
@ -442,7 +442,7 @@ fn drainMailbox(self: *Thread) !void {
|
||||
.inspector => |v| self.flags.has_inspector = v,
|
||||
|
||||
.macos_display_id => |v| {
|
||||
if (@hasDecl(renderer.Renderer, "setMacOSDisplayID")) {
|
||||
if (@hasDecl(rendererpkg.Renderer, "setMacOSDisplayID")) {
|
||||
try self.renderer.setMacOSDisplayID(v);
|
||||
}
|
||||
},
|
||||
@ -466,8 +466,8 @@ fn drawFrame(self: *Thread, now: bool) void {
|
||||
|
||||
// If we're doing single-threaded GPU calls then we just wake up the
|
||||
// app thread to redraw at this point.
|
||||
if (renderer.Renderer == renderer.OpenGL and
|
||||
renderer.OpenGL.single_threaded_draw)
|
||||
if (rendererpkg.Renderer == rendererpkg.OpenGL and
|
||||
rendererpkg.OpenGL.single_threaded_draw)
|
||||
{
|
||||
_ = self.app_mailbox.push(
|
||||
.{ .redraw_surface = self.surface },
|
||||
|
@ -56,7 +56,7 @@ const std_size = Page.layout(std_capacity).total_size;
|
||||
/// allocator because we need memory that is zero-initialized and page-aligned.
|
||||
const PagePool = std.heap.MemoryPoolAligned(
|
||||
[std_size]u8,
|
||||
std.mem.page_size,
|
||||
std.heap.page_size_min,
|
||||
);
|
||||
|
||||
/// List of pins, known as "tracked" pins. These are pins that are kept
|
||||
@ -1977,7 +1977,7 @@ fn createPageExt(
|
||||
else
|
||||
try page_alloc.alignedAlloc(
|
||||
u8,
|
||||
std.mem.page_size,
|
||||
std.heap.page_size_min,
|
||||
layout.total_size,
|
||||
);
|
||||
errdefer if (pooled)
|
||||
|
@ -11,7 +11,7 @@ const Allocator = std.mem.Allocator;
|
||||
const unicode = @import("../unicode/main.zig");
|
||||
|
||||
const ansi = @import("ansi.zig");
|
||||
const modes = @import("modes.zig");
|
||||
const modespkg = @import("modes.zig");
|
||||
const charsets = @import("charsets.zig");
|
||||
const csi = @import("csi.zig");
|
||||
const hyperlink = @import("hyperlink.zig");
|
||||
@ -20,7 +20,7 @@ const point = @import("point.zig");
|
||||
const sgr = @import("sgr.zig");
|
||||
const Tabstops = @import("Tabstops.zig");
|
||||
const color = @import("color.zig");
|
||||
const mouse_shape = @import("mouse_shape.zig");
|
||||
const mouse_shape_pkg = @import("mouse_shape.zig");
|
||||
|
||||
const size = @import("size.zig");
|
||||
const pagepkg = @import("page.zig");
|
||||
@ -87,10 +87,10 @@ color_palette: struct {
|
||||
previous_char: ?u21 = null,
|
||||
|
||||
/// The modes that this terminal currently has active.
|
||||
modes: modes.ModeState = .{},
|
||||
modes: modespkg.ModeState = .{},
|
||||
|
||||
/// The most recently set mouse shape for the terminal.
|
||||
mouse_shape: mouse_shape.MouseShape = .text,
|
||||
mouse_shape: mouse_shape_pkg.MouseShape = .text,
|
||||
|
||||
/// These are just a packed set of flags we may set on the terminal.
|
||||
flags: packed struct {
|
||||
@ -196,7 +196,7 @@ pub const Options = struct {
|
||||
|
||||
/// The default mode state. When the terminal gets a reset, it
|
||||
/// will revert back to this state.
|
||||
default_modes: modes.ModePacked = .{},
|
||||
default_modes: modespkg.ModePacked = .{},
|
||||
};
|
||||
|
||||
/// Initialize a new terminal.
|
||||
|
@ -118,7 +118,6 @@ fn HashMapUnmanaged(
|
||||
const Self = @This();
|
||||
|
||||
comptime {
|
||||
std.hash_map.verifyContext(Context, K, K, u64, false);
|
||||
assert(@alignOf(Metadata) == 1);
|
||||
}
|
||||
|
||||
@ -510,8 +509,6 @@ fn HashMapUnmanaged(
|
||||
/// from this function. To encourage that, this function is
|
||||
/// marked as inline.
|
||||
inline fn getIndex(self: Self, key: anytype, ctx: anytype) ?usize {
|
||||
comptime std.hash_map.verifyContext(@TypeOf(ctx), @TypeOf(key), K, Hash, false);
|
||||
|
||||
if (self.header().size == 0) {
|
||||
return null;
|
||||
}
|
||||
@ -519,8 +516,6 @@ fn HashMapUnmanaged(
|
||||
// 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);
|
||||
// verifyContext can't verify the return type of generic hash functions,
|
||||
// so we need to double-check it here.
|
||||
if (@TypeOf(hash) != Hash) {
|
||||
@compileError("Context " ++ @typeName(@TypeOf(ctx)) ++ " has a generic hash function that returns the wrong type! " ++ @typeName(Hash) ++ " was expected, but found " ++ @typeName(@TypeOf(hash)));
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ const std = @import("std");
|
||||
pub const FlagStack = struct {
|
||||
const len = 8;
|
||||
|
||||
flags: [len]Flags = .{.{}} ** len,
|
||||
flags: [len]Flags = .{Flags{}} ** len,
|
||||
idx: u3 = 0,
|
||||
|
||||
/// Return the current stack value
|
||||
|
@ -83,7 +83,7 @@ pub const Page = struct {
|
||||
comptime {
|
||||
// The alignment of our members. We want to ensure that the page
|
||||
// alignment is always divisible by this.
|
||||
assert(std.mem.page_size % @max(
|
||||
assert(std.heap.page_size_min % @max(
|
||||
@alignOf(Row),
|
||||
@alignOf(Cell),
|
||||
style.Set.base_align,
|
||||
@ -93,7 +93,7 @@ pub const Page = struct {
|
||||
/// The backing memory for the page. A page is always made up of a
|
||||
/// a single contiguous block of memory that is aligned on a page
|
||||
/// boundary and is a multiple of the system page size.
|
||||
memory: []align(std.mem.page_size) u8,
|
||||
memory: []align(std.heap.page_size_min) u8,
|
||||
|
||||
/// The array of rows in the page. The rows are always in row order
|
||||
/// (i.e. index 0 is the top row, index 1 is the row below that, etc.)
|
||||
@ -198,7 +198,7 @@ pub const Page = struct {
|
||||
// (small but meaningful for this path) and because a private
|
||||
// anonymous mmap is guaranteed on Linux and macOS to be zeroed,
|
||||
// which is a critical property for us.
|
||||
assert(l.total_size % std.mem.page_size == 0);
|
||||
assert(l.total_size % std.heap.page_size_min == 0);
|
||||
const backing = try posix.mmap(
|
||||
null,
|
||||
l.total_size,
|
||||
@ -611,7 +611,7 @@ pub const Page = struct {
|
||||
/// Clone the entire contents of this page.
|
||||
///
|
||||
/// The buffer must be at least the size of self.memory.
|
||||
pub fn cloneBuf(self: *const Page, buf: []align(std.mem.page_size) u8) Page {
|
||||
pub fn cloneBuf(self: *const Page, buf: []align(std.heap.page_size_min) u8) Page {
|
||||
assert(buf.len >= self.memory.len);
|
||||
|
||||
// The entire concept behind a page is that everything is stored
|
||||
@ -1721,7 +1721,7 @@ pub const Page = struct {
|
||||
const dirty_start = alignForward(usize, cells_end, @alignOf(usize));
|
||||
const dirty_end: usize = dirty_start + (dirty_usize_length * @sizeOf(usize));
|
||||
|
||||
const styles_layout = style.Set.layout(cap.styles);
|
||||
const styles_layout: style.Set.Layout = .init(cap.styles);
|
||||
const styles_start = alignForward(usize, dirty_end, style.Set.base_align);
|
||||
const styles_end = styles_start + styles_layout.total_size;
|
||||
|
||||
@ -1739,7 +1739,7 @@ pub const Page = struct {
|
||||
const string_end = string_start + string_layout.total_size;
|
||||
|
||||
const hyperlink_count = @divFloor(cap.hyperlink_bytes, @sizeOf(hyperlink.Set.Item));
|
||||
const hyperlink_set_layout = hyperlink.Set.layout(@intCast(hyperlink_count));
|
||||
const hyperlink_set_layout: hyperlink.Set.Layout = .init(@intCast(hyperlink_count));
|
||||
const hyperlink_set_start = alignForward(usize, string_end, hyperlink.Set.base_align);
|
||||
const hyperlink_set_end = hyperlink_set_start + hyperlink_set_layout.total_size;
|
||||
|
||||
@ -1755,7 +1755,7 @@ pub const Page = struct {
|
||||
const hyperlink_map_start = alignForward(usize, hyperlink_set_end, hyperlink.Map.base_align);
|
||||
const hyperlink_map_end = hyperlink_map_start + hyperlink_map_layout.total_size;
|
||||
|
||||
const total_size = alignForward(usize, hyperlink_map_end, std.mem.page_size);
|
||||
const total_size = alignForward(usize, hyperlink_map_end, std.heap.page_size_min);
|
||||
|
||||
return .{
|
||||
.total_size = total_size,
|
||||
@ -2124,12 +2124,12 @@ pub const Cell = packed struct(u64) {
|
||||
// .styles = 128,
|
||||
// .grapheme_bytes = 1024,
|
||||
// }).total_size,
|
||||
// std.mem.page_size,
|
||||
// std.heap.page_size_min,
|
||||
// );
|
||||
//
|
||||
// std.log.warn("total_size={} pages={}", .{
|
||||
// total_size,
|
||||
// total_size / std.mem.page_size,
|
||||
// total_size / std.heap.page_size_min,
|
||||
// });
|
||||
// }
|
||||
//
|
||||
@ -2139,7 +2139,7 @@ pub const Cell = packed struct(u64) {
|
||||
// // so we fail a test if it changes.
|
||||
// const total_size = Page.layout(std_capacity).total_size;
|
||||
// try testing.expectEqual(@as(usize, 524_288), total_size); // 512 KiB
|
||||
// //const pages = total_size / std.mem.page_size;
|
||||
// //const pages = total_size / std.heap.page_size_min;
|
||||
// }
|
||||
|
||||
test "Cell is zero by default" {
|
||||
|
@ -132,60 +132,6 @@ pub fn RefCountedSet(
|
||||
/// An instance of the context structure.
|
||||
context: Context,
|
||||
|
||||
/// Returns the memory layout for the given base offset and
|
||||
/// desired capacity. The layout can be used by the caller to
|
||||
/// determine how much memory to allocate, and the layout must
|
||||
/// be used to initialize the set so that the set knows all
|
||||
/// the offsets for the various buffers.
|
||||
///
|
||||
/// The capacity passed for cap will be used for the hash table,
|
||||
/// which has a load factor of `0.8125` (13/16), so the number of
|
||||
/// items which can actually be stored in the set will be smaller.
|
||||
///
|
||||
/// The laid out capacity will be at least `cap`, but may be higher,
|
||||
/// since it is rounded up to the next power of 2 for efficiency.
|
||||
///
|
||||
/// The returned layout `cap` property will be 1 more than the number
|
||||
/// of items that the set can actually store, since ID 0 is reserved.
|
||||
pub fn layout(cap: usize) Layout {
|
||||
// Experimentally, this load factor works quite well.
|
||||
const load_factor = 0.8125;
|
||||
|
||||
assert(cap <= @as(usize, @intCast(std.math.maxInt(Id))) + 1);
|
||||
|
||||
// Zero-cap set is valid, return special case
|
||||
if (cap == 0) return .{
|
||||
.cap = 0,
|
||||
.table_cap = 0,
|
||||
.table_mask = 0,
|
||||
.table_start = 0,
|
||||
.items_start = 0,
|
||||
.total_size = 0,
|
||||
};
|
||||
|
||||
const table_cap: usize = std.math.ceilPowerOfTwoAssert(usize, cap);
|
||||
const items_cap: usize = @intFromFloat(load_factor * @as(f64, @floatFromInt(table_cap)));
|
||||
|
||||
const table_mask: Id = @intCast((@as(usize, 1) << std.math.log2_int(usize, table_cap)) - 1);
|
||||
|
||||
const table_start = 0;
|
||||
const table_end = table_start + table_cap * @sizeOf(Id);
|
||||
|
||||
const items_start = std.mem.alignForward(usize, table_end, @alignOf(Item));
|
||||
const items_end = items_start + items_cap * @sizeOf(Item);
|
||||
|
||||
const total_size = items_end;
|
||||
|
||||
return .{
|
||||
.cap = items_cap,
|
||||
.table_cap = table_cap,
|
||||
.table_mask = table_mask,
|
||||
.table_start = table_start,
|
||||
.items_start = items_start,
|
||||
.total_size = total_size,
|
||||
};
|
||||
}
|
||||
|
||||
pub const Layout = struct {
|
||||
cap: usize,
|
||||
table_cap: usize,
|
||||
@ -193,6 +139,60 @@ pub fn RefCountedSet(
|
||||
table_start: usize,
|
||||
items_start: usize,
|
||||
total_size: usize,
|
||||
|
||||
/// Returns the memory layout for the given base offset and
|
||||
/// desired capacity. The layout can be used by the caller to
|
||||
/// determine how much memory to allocate, and the layout must
|
||||
/// be used to initialize the set so that the set knows all
|
||||
/// the offsets for the various buffers.
|
||||
///
|
||||
/// The capacity passed for cap will be used for the hash table,
|
||||
/// which has a load factor of `0.8125` (13/16), so the number of
|
||||
/// items which can actually be stored in the set will be smaller.
|
||||
///
|
||||
/// The laid out capacity will be at least `cap`, but may be higher,
|
||||
/// since it is rounded up to the next power of 2 for efficiency.
|
||||
///
|
||||
/// The returned layout `cap` property will be 1 more than the number
|
||||
/// of items that the set can actually store, since ID 0 is reserved.
|
||||
pub fn init(cap: usize) Layout {
|
||||
// Experimentally, this load factor works quite well.
|
||||
const load_factor = 0.8125;
|
||||
|
||||
assert(cap <= @as(usize, @intCast(std.math.maxInt(Id))) + 1);
|
||||
|
||||
// Zero-cap set is valid, return special case
|
||||
if (cap == 0) return .{
|
||||
.cap = 0,
|
||||
.table_cap = 0,
|
||||
.table_mask = 0,
|
||||
.table_start = 0,
|
||||
.items_start = 0,
|
||||
.total_size = 0,
|
||||
};
|
||||
|
||||
const table_cap: usize = std.math.ceilPowerOfTwoAssert(usize, cap);
|
||||
const items_cap: usize = @intFromFloat(load_factor * @as(f64, @floatFromInt(table_cap)));
|
||||
|
||||
const table_mask: Id = @intCast((@as(usize, 1) << std.math.log2_int(usize, table_cap)) - 1);
|
||||
|
||||
const table_start = 0;
|
||||
const table_end = table_start + table_cap * @sizeOf(Id);
|
||||
|
||||
const items_start = std.mem.alignForward(usize, table_end, @alignOf(Item));
|
||||
const items_end = items_start + items_cap * @sizeOf(Item);
|
||||
|
||||
const total_size = items_end;
|
||||
|
||||
return .{
|
||||
.cap = items_cap,
|
||||
.table_cap = table_cap,
|
||||
.table_mask = table_mask,
|
||||
.table_start = table_start,
|
||||
.items_start = items_start,
|
||||
.total_size = total_size,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
pub fn init(base: OffsetBuf, l: Layout, context: Context) Self {
|
||||
|
@ -233,12 +233,10 @@ test "encode" {
|
||||
try src.encode(buf_stream.writer());
|
||||
|
||||
const expected =
|
||||
\\ghostty|xterm-ghostty|Ghostty,
|
||||
\\ am,
|
||||
\\ ccc@,
|
||||
\\ colors#256,
|
||||
\\ bel=^G,
|
||||
\\
|
||||
;
|
||||
"ghostty|xterm-ghostty|Ghostty\n" ++
|
||||
"\tam,\n" ++
|
||||
"\tccc@,\n" ++
|
||||
"\tcolors#256,\n" ++
|
||||
"\tbel=^G,\n\n";
|
||||
try std.testing.expectEqualStrings(@as([]const u8, expected), buf_stream.getWritten());
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ const termio = @import("../termio.zig");
|
||||
const Command = @import("../Command.zig");
|
||||
const Pty = @import("../pty.zig").Pty;
|
||||
const StreamHandler = @import("stream_handler.zig").StreamHandler;
|
||||
const terminal = @import("../terminal/main.zig");
|
||||
const terminalpkg = @import("../terminal/main.zig");
|
||||
const terminfo = @import("../terminfo/main.zig");
|
||||
const xev = @import("../global.zig").xev;
|
||||
const renderer = @import("../renderer.zig");
|
||||
@ -41,7 +41,7 @@ config: DerivedConfig,
|
||||
/// The terminal emulator internal state. This is the abstract "terminal"
|
||||
/// that manages input, grid updating, etc. and is renderer-agnostic. It
|
||||
/// just stores internal state about a grid.
|
||||
terminal: terminal.Terminal,
|
||||
terminal: terminalpkg.Terminal,
|
||||
|
||||
/// The shared render state
|
||||
renderer_state: *renderer.State,
|
||||
@ -64,7 +64,7 @@ mailbox: termio.Mailbox,
|
||||
|
||||
/// The stream parser. This parses the stream of escape codes and so on
|
||||
/// from the child process and calls callbacks in the stream handler.
|
||||
terminal_stream: terminal.Stream(StreamHandler),
|
||||
terminal_stream: terminalpkg.Stream(StreamHandler),
|
||||
|
||||
/// Last time the cursor was reset. This is used to prevent message
|
||||
/// flooding with cursor resets.
|
||||
@ -76,9 +76,9 @@ last_cursor_reset: ?std.time.Instant = null,
|
||||
pub const DerivedConfig = struct {
|
||||
arena: ArenaAllocator,
|
||||
|
||||
palette: terminal.color.Palette,
|
||||
palette: terminalpkg.color.Palette,
|
||||
image_storage_limit: usize,
|
||||
cursor_style: terminal.CursorStyle,
|
||||
cursor_style: terminalpkg.CursorStyle,
|
||||
cursor_blink: ?bool,
|
||||
cursor_color: ?configpkg.Config.Color,
|
||||
cursor_invert: bool,
|
||||
@ -128,8 +128,8 @@ pub const DerivedConfig = struct {
|
||||
/// to run a child process.
|
||||
pub fn init(self: *Termio, alloc: Allocator, opts: termio.Options) !void {
|
||||
// The default terminal modes based on our config.
|
||||
const default_modes: terminal.ModePacked = modes: {
|
||||
var modes: terminal.ModePacked = .{};
|
||||
const default_modes: terminalpkg.ModePacked = modes: {
|
||||
var modes: terminalpkg.ModePacked = .{};
|
||||
|
||||
// Setup our initial grapheme cluster support if enabled. We use a
|
||||
// switch to ensure we get a compiler error if more cases are added.
|
||||
@ -145,7 +145,7 @@ pub fn init(self: *Termio, alloc: Allocator, opts: termio.Options) !void {
|
||||
};
|
||||
|
||||
// Create our terminal
|
||||
var term = try terminal.Terminal.init(alloc, opts: {
|
||||
var term = try terminalpkg.Terminal.init(alloc, opts: {
|
||||
const grid_size = opts.size.grid();
|
||||
break :opts .{
|
||||
.cols = grid_size.columns,
|
||||
@ -510,7 +510,7 @@ pub fn clearScreen(self: *Termio, td: *ThreadData, history: bool) !void {
|
||||
}
|
||||
|
||||
/// Scroll the viewport
|
||||
pub fn scrollViewport(self: *Termio, scroll: terminal.Terminal.ScrollViewport) !void {
|
||||
pub fn scrollViewport(self: *Termio, scroll: terminalpkg.Terminal.ScrollViewport) !void {
|
||||
self.renderer_state.mutex.lock();
|
||||
defer self.renderer_state.mutex.unlock();
|
||||
try self.terminal.scrollViewport(scroll);
|
||||
|
Loading…
x
Reference in New Issue
Block a user