mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-04 14:48:39 +00:00
Update to Zig 0.16.0
This commit represents the majority of the work necessary to upgrade Ghostty to use Zig 0.16.0. Key parts: * In addition to its previous responsibilities, the global state now houses state for global I/O implementations and the process environment. It is now also utilized in the main application along with the C library. Where necessary, global state is isolated from key parts of the implementation (e.g., in libghostty subsystems), and it's expected that this list will grow. * We currently manage our own C translation layer where necessary. In these cases, cImport has been removed in favor of the new external translate-c package. Due to fixes that have needed be made to properly translate the dependencies that were swapped out, as mentioned, we have had to backport fixes from the current translate-c package (and the upstream Arocc dependency). We will host this ourselves until Zig 0.17.0 is released with these fixes. * Where necessary (only a small number of cases), some stdlib code from 0.15.2 (and even from 0.17.0) has been taken, adopted, and vendored in lib/compat. Co-authored-by: Leah Amelia Chen <hi@pluie.me>
This commit is contained in:
@@ -10,6 +10,7 @@ const vaxis = @import("vaxis");
|
||||
const input = @import("../input.zig");
|
||||
const tui = @import("tui.zig");
|
||||
const Binding = input.Binding;
|
||||
const global = @import("../global.zig");
|
||||
|
||||
pub const Options = struct {
|
||||
/// If `true`, print out the default keybinds instead of the ones configured
|
||||
@@ -56,7 +57,7 @@ pub fn run(alloc: Allocator) !u8 {
|
||||
defer opts.deinit();
|
||||
|
||||
{
|
||||
var iter = try args.argsIterator(alloc);
|
||||
var iter = try args.argsIterator(alloc, global.args());
|
||||
defer iter.deinit();
|
||||
try args.parse(Options, alloc, &opts, &iter);
|
||||
}
|
||||
@@ -65,11 +66,11 @@ pub fn run(alloc: Allocator) !u8 {
|
||||
defer config.deinit();
|
||||
|
||||
var buffer: [1024]u8 = undefined;
|
||||
const stdout: std.fs.File = .stdout();
|
||||
var stdout_writer = stdout.writer(&buffer);
|
||||
const stdout: std.Io.File = .stdout();
|
||||
var stdout_writer = stdout.writer(global.io(), &buffer);
|
||||
const writer = &stdout_writer.interface;
|
||||
|
||||
if (tui.can_pretty_print and !opts.plain and stdout.isTty()) {
|
||||
if (tui.can_pretty_print and !opts.plain and try stdout.isTty(global.io())) {
|
||||
var arena = std.heap.ArenaAllocator.init(alloc);
|
||||
defer arena.deinit();
|
||||
return prettyPrint(arena.allocator(), config.keybind);
|
||||
@@ -218,11 +219,14 @@ const ChordBinding = struct {
|
||||
};
|
||||
|
||||
fn prettyPrint(alloc: Allocator, keybinds: Config.Keybinds) !u8 {
|
||||
var env_map = try global.environMap();
|
||||
defer env_map.deinit();
|
||||
|
||||
// Set up vaxis
|
||||
var buf: [1024]u8 = undefined;
|
||||
var tty = try vaxis.Tty.init(&buf);
|
||||
var tty = try vaxis.Tty.init(global.io(), &buf);
|
||||
defer tty.deinit();
|
||||
var vx = try vaxis.init(alloc, .{});
|
||||
var vx = try vaxis.init(global.io(), alloc, &env_map, .{});
|
||||
const writer = tty.writer();
|
||||
defer vx.deinit(alloc, writer);
|
||||
|
||||
@@ -242,7 +246,7 @@ fn prettyPrint(alloc: Allocator, keybinds: Config.Keybinds) !u8 {
|
||||
.y_pixel = 768,
|
||||
},
|
||||
|
||||
else => try vaxis.Tty.getWinsize(tty.fd),
|
||||
else => try tty.getWinsize(),
|
||||
};
|
||||
try vx.resize(alloc, writer, winsize);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user