diff --git a/build.zig b/build.zig index feeb808ad..459278e41 100644 --- a/build.zig +++ b/build.zig @@ -25,7 +25,7 @@ const Command = @import("src/Command.zig"); // but we liberally update it. In the future, we'll be more careful about // using released versions so that package managers can integrate better. comptime { - const required_zig = "0.12.0-dev.3405+31791ae15"; + const required_zig = "0.12.0-dev.3676+21a6a1b0f"; const current_zig = builtin.zig_version; const min_zig = std.SemanticVersion.parse(required_zig) catch unreachable; if (current_zig.order(min_zig) == .lt) { @@ -221,7 +221,7 @@ pub fn build(b: *std.Build) !void { // We only build an exe if we have a runtime set. const exe_: ?*std.Build.Step.Compile = if (config.app_runtime != .none) b.addExecutable(.{ .name = "ghostty", - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }) else null; @@ -265,7 +265,7 @@ pub fn build(b: *std.Build) !void { if (target.result.os.tag == .windows) { exe.subsystem = .Windows; exe.addWin32ResourceFile(.{ - .file = .{ .path = "dist/windows/ghostty.rc" }, + .file = b.path("dist/windows/ghostty.rc"), }); // Building with LTO on Windows is broken. @@ -309,7 +309,7 @@ pub fn build(b: *std.Build) !void { // Shell-integration { const install = b.addInstallDirectory(.{ - .source_dir = .{ .path = "src/shell-integration" }, + .source_dir = b.path("src/shell-integration"), .install_dir = .{ .custom = "share" }, .install_subdir = b.pathJoin(&.{ "ghostty", "shell-integration" }), .exclude_extensions = &.{".md"}, @@ -483,7 +483,7 @@ pub fn build(b: *std.Build) !void { { const lib = b.addSharedLibrary(.{ .name = "ghostty", - .root_source_file = .{ .path = "src/main_c.zig" }, + .root_source_file = b.path("src/main_c.zig"), .optimize = optimize, .target = target, }); @@ -500,7 +500,7 @@ pub fn build(b: *std.Build) !void { { const lib = b.addStaticLibrary(.{ .name = "ghostty", - .root_source_file = .{ .path = "src/main_c.zig" }, + .root_source_file = b.path("src/main_c.zig"), .optimize = optimize, .target = target, }); @@ -515,7 +515,7 @@ pub fn build(b: *std.Build) !void { // Copy our ghostty.h to include. const header_install = b.addInstallHeaderFile( - "include/ghostty.h", + b.path("include/ghostty.h"), "ghostty.h", ); b.getInstallStep().dependOn(&header_install.step); @@ -570,7 +570,7 @@ pub fn build(b: *std.Build) !void { // Copy our ghostty.h to include. The header file is shared by // all embedded targets. const header_install = b.addInstallHeaderFile( - "include/ghostty.h", + b.path("include/ghostty.h"), "ghostty.h", ); b.getInstallStep().dependOn(&header_install.step); @@ -583,15 +583,15 @@ pub fn build(b: *std.Build) !void { .libraries = &.{ .{ .library = macos_lib_path, - .headers = .{ .path = "include" }, + .headers = b.path("include"), }, .{ .library = ios_lib_path, - .headers = .{ .path = "include" }, + .headers = b.path("include"), }, .{ .library = ios_sim_lib_path, - .headers = .{ .path = "include" }, + .headers = b.path("include"), }, }, }); @@ -645,7 +645,7 @@ pub fn build(b: *std.Build) !void { const wasm = b.addSharedLibrary(.{ .name = "ghostty-wasm", - .root_source_file = .{ .path = "src/main_wasm.zig" }, + .root_source_file = b.path("src/main_wasm.zig"), .target = b.resolveTargetQuery(wasm_crosstarget), .optimize = optimize, }); @@ -675,7 +675,7 @@ pub fn build(b: *std.Build) !void { const test_step = b.step("test-wasm", "Run all tests for wasm"); const main_test = b.addTest(.{ .name = "wasm-test", - .root_source_file = .{ .path = "src/main_wasm.zig" }, + .root_source_file = b.path("src/main_wasm.zig"), .target = b.resolveTargetQuery(wasm_crosstarget), }); @@ -714,7 +714,7 @@ pub fn build(b: *std.Build) !void { const main_test = b.addTest(.{ .name = "ghostty-test", - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = test_target, .filter = test_filter, }); @@ -796,7 +796,7 @@ fn createMacOSLib( const static_lib_aarch64 = lib: { const lib = b.addStaticLibrary(.{ .name = "ghostty", - .root_source_file = .{ .path = "src/main_c.zig" }, + .root_source_file = b.path("src/main_c.zig"), .target = genericMacOSTarget(b), .optimize = optimize, }); @@ -820,7 +820,7 @@ fn createMacOSLib( const static_lib_x86_64 = lib: { const lib = b.addStaticLibrary(.{ .name = "ghostty", - .root_source_file = .{ .path = "src/main_c.zig" }, + .root_source_file = b.path("src/main_c.zig"), .target = b.resolveTargetQuery(.{ .cpu_arch = .x86_64, .os_tag = .macos, @@ -875,7 +875,7 @@ fn createIOSLib( const lib = b.addStaticLibrary(.{ .name = "ghostty", - .root_source_file = .{ .path = "src/main_c.zig" }, + .root_source_file = b.path("src/main_c.zig"), .optimize = optimize, .target = b.resolveTargetQuery(.{ .cpu_arch = .aarch64, @@ -1027,12 +1027,12 @@ fn addDeps( // C files step.linkLibC(); - step.addIncludePath(.{ .path = "src/stb" }); + step.addIncludePath(b.path("src/stb")); step.addCSourceFiles(.{ .files = &.{"src/stb/stb.c"} }); // C++ files step.linkLibCpp(); - step.addIncludePath(.{ .path = "src" }); + step.addIncludePath(b.path("src")); step.addCSourceFiles(.{ .files = &.{ "src/simd/codepoint_width.cpp", "src/simd/index_of.cpp", @@ -1160,9 +1160,9 @@ fn addDeps( if (!lib) { // We always statically compile glad - step.addIncludePath(.{ .path = "vendor/glad/include/" }); + step.addIncludePath(b.path("vendor/glad/include/")); step.addCSourceFile(.{ - .file = .{ .path = "vendor/glad/src/gl.c" }, + .file = b.path("vendor/glad/src/gl.c"), .flags = &.{}, }); @@ -1246,7 +1246,7 @@ fn addHelp( const help_output = HelpState.generated orelse strings: { const help_exe = b.addExecutable(.{ .name = "helpgen", - .root_source_file = .{ .path = "src/helpgen.zig" }, + .root_source_file = b.path("src/helpgen.zig"), .target = b.host, }); if (step_ == null) b.installArtifact(help_exe); @@ -1286,7 +1286,7 @@ fn addUnicodeTables( const output = State.generated orelse strings: { const exe = b.addExecutable(.{ .name = "unigen", - .root_source_file = .{ .path = "src/unicode/props.zig" }, + .root_source_file = b.path("src/unicode/props.zig"), .target = b.host, }); exe.linkLibC(); @@ -1326,7 +1326,7 @@ fn buildDocumentation( inline for (manpages) |manpage| { const generate_markdown = b.addExecutable(.{ .name = "mdgen_" ++ manpage.name ++ "_" ++ manpage.section, - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = b.host, }); try addHelp(b, generate_markdown, config); @@ -1412,7 +1412,7 @@ fn benchSteps( const bin_name = try std.fmt.allocPrint(b.allocator, "bench-{s}", .{name}); const c_exe = b.addExecutable(.{ .name = bin_name, - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, // We always want our benchmarks to be in release mode. @@ -1468,7 +1468,7 @@ fn conformanceSteps( // Executable builder. const c_exe = b.addExecutable(.{ .name = name, - .root_source_file = .{ .path = path }, + .root_source_file = b.path(path), .target = target, .optimize = optimize, }); diff --git a/build.zig.zon b/build.zig.zon index 00e737cf4..56f43dde9 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -5,17 +5,17 @@ .dependencies = .{ // Zig libs .libxev = .{ - .url = "https://github.com/mitchellh/libxev/archive/0f73adfda1cff9c740160717b5431ebada6b8755.tar.gz", - .hash = "12203dcbe098ee49ea242432cd198b1ca557626988f056bea86630dcfe8660244407", + .url = "https://github.com/mitchellh/libxev/archive/a284cf851fe2f88f8947c01160c39ff216dacea1.tar.gz", + .hash = "12205b8ea5495b812b9a8943535a7af8da556644d2c1599dc01e1a5ea7aaf59bb2c7", }, .mach_glfw = .{ - .url = "https://github.com/der-teufel-programming/mach-glfw/archive/250affff8c52d1eaa0fab2ef1118f691bf1225ec.tar.gz", - .hash = "122029f65edf3965d86f7d0741fe141bcc1d68b1f013fa7280bbfda4e87c6affc15f", + .url = "https://github.com/mitchellh/mach-glfw/archive/20c773d86df269722d8926f98bc8af26ebd90999.tar.gz", + .hash = "1220d6df7eb57501616e86ed812854164ff02d2f4a0eaa06b8301f32950d8d3e89df", .lazy = true, }, .zig_objc = .{ - .url = "https://github.com/mitchellh/zig-objc/archive/0a89cc09da6804ae448241a673ce85a282216074.tar.gz", - .hash = "1220acfc53954f699415c6942422571670544a5236866fa7b6e069e2b1b2ba86ae9c", + .url = "https://github.com/mitchellh/zig-objc/archive/9e2174ed9b5a2c11bf1779cf6c819260c8091888.tar.gz", + .hash = "1220014cd3774aa0b18320e6527ed7b3270412c70958ab16a3c55070ffb7f2042f87", }, .zig_js = .{ .url = "https://github.com/mitchellh/zig-js/archive/d4edb682733aef8dc3933683272bdf7c8b9fe658.tar.gz", diff --git a/flake.lock b/flake.lock index 4e3484063..5b167dee4 100644 --- a/flake.lock +++ b/flake.lock @@ -147,11 +147,11 @@ }, "nixpkgs-zig-0-12": { "locked": { - "lastModified": 1712247214, - "narHash": "sha256-7PTw86NnE2nCQPf+PPI/kOKwmlbbTqUthYSz/nDnAoc=", + "lastModified": 1713479535, + "narHash": "sha256-PnquFNhs0vtXwHkKk44dmnrNTMMCQelgi8pS/DGh6Ks=", "owner": "vancluever", "repo": "nixpkgs", - "rev": "6726262c930716f601345b2c9d0c42ba069991b8", + "rev": "153458bf17bfeedd3ab8b9a3250ba1168135e8ae", "type": "github" }, "original": { @@ -194,11 +194,11 @@ ] }, "locked": { - "lastModified": 1711109355, - "narHash": "sha256-VZPO5mq2di5yjHkkY9ZGEIZaX7EtdusSkxICBAtHAec=", + "lastModified": 1713476117, + "narHash": "sha256-97U178Ob/D+EYiGMg/ne7je292ZLCghclhXiPfIfpdQ=", "owner": "mitchellh", "repo": "zig-overlay", - "rev": "5fe52bdf2c213e47712d93c9ce12dfed4c4cef86", + "rev": "8f336c6f54b57492ac1d8a7385a79fefac84b7dc", "type": "github" }, "original": { diff --git a/nix/zigCacheHash.nix b/nix/zigCacheHash.nix index 167a14fbf..6ef34a2a7 100644 --- a/nix/zigCacheHash.nix +++ b/nix/zigCacheHash.nix @@ -1,3 +1,3 @@ # This file is auto-generated! check build-support/check-zig-cache-hash.sh for # more details. -"sha256-nr8utAh2oMwnN6nyWzJo8VubFO5cCrHK+QNYuT2WBi0=" +"sha256-HkGZWT8drDMqZOb5tUEmNZ7TpBldM15bAkeNbCh2yT0=" diff --git a/pkg/cimgui/build.zig b/pkg/cimgui/build.zig index 3e397f955..6a3607cf5 100644 --- a/pkg/cimgui/build.zig +++ b/pkg/cimgui/build.zig @@ -79,12 +79,11 @@ pub fn build(b: *std.Build) !void { } } - lib.installHeadersDirectoryOptions(.{ - .source_dir = .{ .path = "vendor" }, - .install_dir = .header, - .install_subdir = "", - .include_extensions = &.{".h"}, - }); + lib.installHeadersDirectory( + .{ .path = "vendor" }, + "", + .{ .include_extensions = &.{".h"} }, + ); b.installArtifact(lib); diff --git a/pkg/fontconfig/build.zig b/pkg/fontconfig/build.zig index a43a2cb6e..2882eae96 100644 --- a/pkg/fontconfig/build.zig +++ b/pkg/fontconfig/build.zig @@ -162,12 +162,11 @@ pub fn build(b: *std.Build) !void { .flags = flags.items, }); - lib.installHeadersDirectoryOptions(.{ - .source_dir = upstream.path("fontconfig"), - .install_dir = .header, - .install_subdir = "fontconfig", - .include_extensions = &.{".h"}, - }); + lib.installHeadersDirectory( + upstream.path("fontconfig"), + "fontconfig", + .{ .include_extensions = &.{".h"} }, + ); b.installArtifact(lib); diff --git a/pkg/fontconfig/common.zig b/pkg/fontconfig/common.zig index 5562815db..fea613423 100644 --- a/pkg/fontconfig/common.zig +++ b/pkg/fontconfig/common.zig @@ -91,7 +91,8 @@ pub const Property = enum { var name: [replaced.len:0]u8 = undefined; @memcpy(&name, replaced); name[replaced.len] = 0; - break :name &name; + const final = name; + break :name &final; }; } } diff --git a/pkg/freetype/build.zig b/pkg/freetype/build.zig index d330140b6..9819c5328 100644 --- a/pkg/freetype/build.zig +++ b/pkg/freetype/build.zig @@ -81,13 +81,12 @@ pub fn build(b: *std.Build) !void { }), } - lib.installHeader("freetype-zig.h", "freetype-zig.h"); - lib.installHeadersDirectoryOptions(.{ - .source_dir = upstream.path("include"), - .install_dir = .header, - .install_subdir = "", - .include_extensions = &.{".h"}, - }); + lib.installHeader(.{ .path = "freetype-zig.h" }, "freetype-zig.h"); + lib.installHeadersDirectory( + upstream.path("include"), + "", + .{ .include_extensions = &.{".h"} }, + ); b.installArtifact(lib); diff --git a/pkg/glslang/build.zig b/pkg/glslang/build.zig index 9dcae7b1e..e25fd67ee 100644 --- a/pkg/glslang/build.zig +++ b/pkg/glslang/build.zig @@ -141,12 +141,11 @@ fn buildGlslang( }); } - lib.installHeadersDirectoryOptions(.{ - .source_dir = upstream.path(""), - .install_dir = .header, - .install_subdir = "", - .include_extensions = &.{".h"}, - }); + lib.installHeadersDirectory( + upstream.path(""), + "", + .{ .include_extensions = &.{".h"} }, + ); return lib; } diff --git a/pkg/harfbuzz/build.zig b/pkg/harfbuzz/build.zig index 597270730..1329250ba 100644 --- a/pkg/harfbuzz/build.zig +++ b/pkg/harfbuzz/build.zig @@ -76,12 +76,11 @@ pub fn build(b: *std.Build) !void { .file = upstream.path("src/harfbuzz.cc"), .flags = flags.items, }); - lib.installHeadersDirectoryOptions(.{ - .source_dir = upstream.path("src"), - .install_dir = .header, - .install_subdir = "", - .include_extensions = &.{".h"}, - }); + lib.installHeadersDirectory( + upstream.path("src"), + "", + .{ .include_extensions = &.{".h"} }, + ); b.installArtifact(lib); diff --git a/pkg/highway/build.zig b/pkg/highway/build.zig index f086f0491..1ef08de79 100644 --- a/pkg/highway/build.zig +++ b/pkg/highway/build.zig @@ -84,12 +84,11 @@ pub fn build(b: *std.Build) !void { "hwy/timer.cc", }, }); - lib.installHeadersDirectoryOptions(.{ - .source_dir = upstream.path("hwy"), - .install_dir = .header, - .install_subdir = "hwy", - .include_extensions = &.{".h"}, - }); + lib.installHeadersDirectory( + upstream.path("hwy"), + "hwy", + .{ .include_extensions = &.{".h"} }, + ); b.installArtifact(lib); diff --git a/pkg/libpng/build.zig b/pkg/libpng/build.zig index ee1846add..e5bcf5963 100644 --- a/pkg/libpng/build.zig +++ b/pkg/libpng/build.zig @@ -40,13 +40,12 @@ pub fn build(b: *std.Build) !void { .flags = flags.items, }); - lib.installHeader("pnglibconf.h", "pnglibconf.h"); - lib.installHeadersDirectoryOptions(.{ - .source_dir = upstream.path(""), - .install_dir = .header, - .install_subdir = "", - .include_extensions = &.{".h"}, - }); + lib.installHeader(.{ .path = "pnglibconf.h" }, "pnglibconf.h"); + lib.installHeadersDirectory( + upstream.path(""), + "", + .{ .include_extensions = &.{".h"} }, + ); b.installArtifact(lib); } diff --git a/pkg/libxml2/build.zig b/pkg/libxml2/build.zig index 26c44fb92..430bfdb54 100644 --- a/pkg/libxml2/build.zig +++ b/pkg/libxml2/build.zig @@ -100,13 +100,15 @@ pub fn build(b: *std.Build) !void { .flags = flags.items, }); - lib.installHeader("override/include/libxml/xmlversion.h", "libxml/xmlversion.h"); - lib.installHeadersDirectoryOptions(.{ - .source_dir = upstream.path("include"), - .install_dir = .header, - .install_subdir = "", - .include_extensions = &.{".h"}, - }); + lib.installHeader( + .{ .path = "override/include/libxml/xmlversion.h" }, + "libxml/xmlversion.h", + ); + lib.installHeadersDirectory( + upstream.path("include"), + "", + .{ .include_extensions = &.{".h"} }, + ); b.installArtifact(lib); } diff --git a/pkg/oniguruma/build.zig b/pkg/oniguruma/build.zig index e9f7bc546..d973c89df 100644 --- a/pkg/oniguruma/build.zig +++ b/pkg/oniguruma/build.zig @@ -125,12 +125,11 @@ fn buildOniguruma( }, }); - lib.installHeadersDirectoryOptions(.{ - .source_dir = upstream.path("src"), - .install_dir = .header, - .install_subdir = "", - .include_extensions = &.{".h"}, - }); + lib.installHeadersDirectory( + upstream.path("src"), + "", + .{ .include_extensions = &.{".h"} }, + ); return lib; } diff --git a/pkg/pixman/build.zig b/pkg/pixman/build.zig index 70f78e35e..f993ba46f 100644 --- a/pkg/pixman/build.zig +++ b/pkg/pixman/build.zig @@ -62,13 +62,12 @@ pub fn build(b: *std.Build) !void { .flags = flags.items, }); - lib.installHeader("pixman-version.h", "pixman-version.h"); - lib.installHeadersDirectoryOptions(.{ - .source_dir = upstream.path("pixman"), - .install_dir = .header, - .install_subdir = "", - .include_extensions = &.{".h"}, - }); + lib.installHeader(.{ .path = "pixman-version.h" }, "pixman-version.h"); + lib.installHeadersDirectory( + upstream.path("pixman"), + "", + .{ .include_extensions = &.{".h"} }, + ); b.installArtifact(lib); diff --git a/pkg/simdutf/build.zig b/pkg/simdutf/build.zig index 479713ca2..bc53b30be 100644 --- a/pkg/simdutf/build.zig +++ b/pkg/simdutf/build.zig @@ -27,12 +27,11 @@ pub fn build(b: *std.Build) !void { "vendor/simdutf.cpp", }, }); - lib.installHeadersDirectoryOptions(.{ - .source_dir = .{ .path = "vendor" }, - .install_dir = .header, - .install_subdir = "", - .include_extensions = &.{".h"}, - }); + lib.installHeadersDirectory( + .{ .path = "vendor" }, + "", + .{ .include_extensions = &.{".h"} }, + ); b.installArtifact(lib); diff --git a/pkg/spirv-cross/build.zig b/pkg/spirv-cross/build.zig index a75c72346..be18f3043 100644 --- a/pkg/spirv-cross/build.zig +++ b/pkg/spirv-cross/build.zig @@ -78,12 +78,11 @@ fn buildSpirvCross( }, }); - lib.installHeadersDirectoryOptions(.{ - .source_dir = upstream.path(""), - .install_dir = .header, - .install_subdir = "", - .include_extensions = &.{".h"}, - }); + lib.installHeadersDirectory( + upstream.path(""), + "", + .{ .include_extensions = &.{".h"} }, + ); return lib; } diff --git a/pkg/utfcpp/build.zig b/pkg/utfcpp/build.zig index a68631851..f148acbba 100644 --- a/pkg/utfcpp/build.zig +++ b/pkg/utfcpp/build.zig @@ -27,12 +27,11 @@ pub fn build(b: *std.Build) !void { .flags = flags.items, .files = &.{"empty.cc"}, }); - lib.installHeadersDirectoryOptions(.{ - .source_dir = upstream.path("source"), - .install_dir = .header, - .install_subdir = "", - .include_extensions = &.{".h"}, - }); + lib.installHeadersDirectory( + upstream.path("source"), + "", + .{ .include_extensions = &.{".h"} }, + ); b.installArtifact(lib); diff --git a/pkg/zlib/build.zig b/pkg/zlib/build.zig index 334c3c59e..10a937a36 100644 --- a/pkg/zlib/build.zig +++ b/pkg/zlib/build.zig @@ -18,12 +18,11 @@ pub fn build(b: *std.Build) !void { try apple_sdk.addPaths(b, &lib.root_module); } - lib.installHeadersDirectoryOptions(.{ - .source_dir = upstream.path(""), - .install_dir = .header, - .install_subdir = "", - .include_extensions = &.{".h"}, - }); + lib.installHeadersDirectory( + upstream.path(""), + "", + .{ .include_extensions = &.{".h"} }, + ); var flags = std.ArrayList([]const u8).init(b.allocator); defer flags.deinit(); diff --git a/src/apprt/gtk/Surface.zig b/src/apprt/gtk/Surface.zig index c7aaf9343..6e2d4d035 100644 --- a/src/apprt/gtk/Surface.zig +++ b/src/apprt/gtk/Surface.zig @@ -145,8 +145,8 @@ pub const Container = union(enum) { pub fn split(self: Container) ?*Split { return switch (self) { .none, .tab_ => null, - .split_tl => |ptr| @fieldParentPtr(Split, "top_left", ptr), - .split_br => |ptr| @fieldParentPtr(Split, "bottom_right", ptr), + .split_tl => |ptr| @fieldParentPtr("top_left", ptr), + .split_br => |ptr| @fieldParentPtr("bottom_right", ptr), }; } diff --git a/src/apprt/gtk/gresource.zig b/src/apprt/gtk/gresource.zig index e0dc6f549..5705e96da 100644 --- a/src/apprt/gtk/gresource.zig +++ b/src/apprt/gtk/gresource.zig @@ -61,7 +61,8 @@ fn comptimeGenerateGResourceXML(comptime libadwaita: bool) []const u8 { var buf: [counter.bytes_written]u8 = undefined; var stream = std.io.fixedBufferStream(&buf); try writeGResourceXML(libadwaita, stream.writer()); - return stream.getWritten(); + const final = buf; + return final[0..stream.getWritten().len]; } } diff --git a/src/build/fish_completions.zig b/src/build/fish_completions.zig index f789c0d10..b72360e7d 100644 --- a/src/build/fish_completions.zig +++ b/src/build/fish_completions.zig @@ -19,7 +19,8 @@ fn comptimeGenerateFishCompletions() []const u8 { var buf: [counter.bytes_written]u8 = undefined; var stream = std.io.fixedBufferStream(&buf); try writeFishCompletions(stream.writer()); - return stream.getWritten(); + const final = buf; + return final[0..stream.getWritten().len]; } } diff --git a/src/config/vim.zig b/src/config/vim.zig index a57a59b72..c5fe4cd6d 100644 --- a/src/config/vim.zig +++ b/src/config/vim.zig @@ -35,7 +35,8 @@ fn comptimeGenSyntax() []const u8 { var buf: [counting_writer.bytes_written]u8 = undefined; var stream = std.io.fixedBufferStream(&buf); try writeSyntax(stream.writer()); - return stream.getWritten(); + const final = buf; + return final[0..stream.getWritten().len]; } } diff --git a/src/input/key.zig b/src/input/key.zig index 3f75e7e6e..7886d0b55 100644 --- a/src/input/key.zig +++ b/src/input/key.zig @@ -83,7 +83,7 @@ pub const Mods = packed struct(Mods.Backing) { super: Side = .left, }; - pub const Side = enum { left, right }; + pub const Side = enum(u1) { left, right }; /// Integer value of this struct. pub fn int(self: Mods) Backing { diff --git a/src/input/keycodes.zig b/src/input/keycodes.zig index 82f526818..47190a841 100644 --- a/src/input/keycodes.zig +++ b/src/input/keycodes.zig @@ -25,7 +25,9 @@ pub const entries: []const Entry = entries: { .native = raw[native_idx], }; } - break :entries &result; + + const final = result; + break :entries &final; }; /// Entry contains the USB code, native keycode, and W3C dom code for diff --git a/src/input/kitty.zig b/src/input/kitty.zig index bfaa60022..6e9cdddf8 100644 --- a/src/input/kitty.zig +++ b/src/input/kitty.zig @@ -22,7 +22,9 @@ pub const entries: []const Entry = entries: { .modifier = raw[3], }; } - break :entries &result; + + const final = result; + break :entries &final; }; /// Raw entry is the tuple form of an entry for easy human management. diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index cc58093bf..94d32e1a8 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -112,7 +112,7 @@ flags: packed struct { /// Set via the XTSHIFTESCAPE sequence. If true (XTSHIFTESCAPE = 1) /// then we want to capture the shift key for the mouse protocol /// if the configuration allows it. - mouse_shift_capture: enum { null, false, true } = .null, + mouse_shift_capture: enum(u2) { null, false, true } = .null, } = .{}, /// The event types that can be reported for mouse-related activities. diff --git a/src/terminal/page.zig b/src/terminal/page.zig index 4dfdc29e4..02bd45776 100644 --- a/src/terminal/page.zig +++ b/src/terminal/page.zig @@ -1236,7 +1236,7 @@ pub const Cell = packed struct(u64) { // } test "Cell is zero by default" { - const cell: Cell = .{}; + const cell = Cell.init(0); const cell_int: u64 = @bitCast(cell); try std.testing.expectEqual(@as(u64, 0), cell_int); } diff --git a/src/terminfo/Source.zig b/src/terminfo/Source.zig index 82bb7f1fc..97f31d5b6 100644 --- a/src/terminfo/Source.zig +++ b/src/terminfo/Source.zig @@ -88,7 +88,8 @@ pub fn xtgettcapMap(comptime self: Source) type { .numeric => |v| numeric: { var buf: [10]u8 = undefined; const num_len = std.fmt.formatIntBuf(&buf, v, 10, .upper, .{}); - break :numeric buf[0..num_len]; + const final = buf; + break :numeric final[0..num_len]; }, } }; } @@ -100,7 +101,7 @@ pub fn xtgettcapMap(comptime self: Source) type { // The value is more complex var buf: [5 + entry[0].len + 1 + (entry[1].len * 2) + 2]u8 = undefined; - entry[1] = if (std.mem.eql(u8, entry[1], "")) std.fmt.bufPrint( + const out = if (std.mem.eql(u8, entry[1], "")) std.fmt.bufPrint( &buf, "\x1bP1+r{s}\x1b\\", .{entry[0]}, // important: hex-encoded name @@ -109,9 +110,13 @@ pub fn xtgettcapMap(comptime self: Source) type { "\x1bP1+r{s}={s}\x1b\\", .{ entry[0], hexencode(entry[1]) }, // important: hex-encoded name ) catch unreachable; + + const final = buf; + entry[1] = final[0..out.len]; } - return std.ComptimeStringMap([]const u8, kvs); + const kvs_final = kvs; + return std.ComptimeStringMap([]const u8, &kvs_final); } fn hexencode(comptime input: []const u8) []const u8 { diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index 27ac5a078..fd74bd1a7 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -2646,9 +2646,15 @@ const StreamHandler = struct { // any host (such an SSH session). The best practice terminals follow // is to valid the hostname to be local. const host_valid = host_valid: { - const host = uri.host orelse break :host_valid false; + const host_component = uri.host orelse break :host_valid false; - // Empty or localhost is always good + // Get the raw string of the URI. Its unclear to me if the various + // tags of this enum guarantee no percent-encoding so we just + // check all of it. This isn't a performance critical path. + const host = switch (host_component) { + .raw => |v| v, + .percent_encoded => |v| v, + }; if (host.len == 0 or std.mem.eql(u8, "localhost", host)) { break :host_valid true; } @@ -2671,24 +2677,32 @@ const StreamHandler = struct { // the stack and fall back to heap allocation if we have to. var pathBuf: [1024]u8 = undefined; const path, const heap = path: { + // Get the raw string of the URI. Its unclear to me if the various + // tags of this enum guarantee no percent-encoding so we just + // check all of it. This isn't a performance critical path. + const path = switch (uri.path) { + .raw => |v| v, + .percent_encoded => |v| v, + }; + // If the path doesn't have any escapes, we can use it directly. - if (std.mem.indexOfScalar(u8, uri.path, '%') == null) - break :path .{ uri.path, false }; + if (std.mem.indexOfScalar(u8, path, '%') == null) + break :path .{ path, false }; // First try to stack-allocate var fba = std.heap.FixedBufferAllocator.init(&pathBuf); - if (std.Uri.unescapeString(fba.allocator(), uri.path)) |path| - break :path .{ path, false } + if (std.fmt.allocPrint(fba.allocator(), "{raw}", .{uri.path})) |v| + break :path .{ v, false } else |_| {} // Fall back to heap - if (std.Uri.unescapeString(self.alloc, uri.path)) |path| - break :path .{ path, true } + if (std.fmt.allocPrint(self.alloc, "{raw}", .{uri.path})) |v| + break :path .{ v, true } else |_| {} // Fall back to using it directly... - log.warn("failed to unescape OSC 7 path, using it directly path={s}", .{uri.path}); - break :path .{ uri.path, false }; + log.warn("failed to unescape OSC 7 path, using it directly path={s}", .{path}); + break :path .{ path, false }; }; defer if (heap) self.alloc.free(path);