mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-12-28 17:14:39 +00:00
This adds a new stream handler implementation that updates terminal state in reaction to VT sequences, but doesn't perform any of the actions that would require responses (e.g. queries). This is exposed in two ways: first, as a standalone `ReadonlyStream` and `ReadonlyHandler` type that contains all the implementation. Second, as a convenience func on `Terminal` as `vtStream` and `vtHandler` which return their respective types preconfigured to update the calling terminal state. This dramatically simplifies libghostty-vt usage from Zig (and will eventually be exposed to C, too) since a Terminal on its own is ready to go as a full VT parser and state machine without needing to build any custom types! There's a second big bonus here which is that our `stream_readonly.zig` tests are true end-to-end tests for raw bytes to terminal state. This will let us test a wider variety of situations more broadly. To start, there are only a handful of tests implemented here. **AI disclosure:** Amp wrote basically this whole thing, but I reviewed it. https://ampcode.com/threads/T-3490efd2-1137-4112-96f6-4bf8a0141ff5
40 lines
1.1 KiB
Zig
40 lines
1.1 KiB
Zig
const std = @import("std");
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
const run_step = b.step("run", "Run the app");
|
|
const test_step = b.step("test", "Run unit tests");
|
|
|
|
const exe_mod = b.createModule(.{
|
|
.root_source_file = b.path("src/main.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
|
|
if (b.lazyDependency("ghostty", .{})) |dep| {
|
|
exe_mod.addImport(
|
|
"ghostty-vt",
|
|
dep.module("ghostty-vt"),
|
|
);
|
|
}
|
|
|
|
const exe = b.addExecutable(.{
|
|
.name = "zig_vt_stream",
|
|
.root_module = exe_mod,
|
|
});
|
|
b.installArtifact(exe);
|
|
|
|
const run_cmd = b.addRunArtifact(exe);
|
|
run_cmd.step.dependOn(b.getInstallStep());
|
|
if (b.args) |args| run_cmd.addArgs(args);
|
|
run_step.dependOn(&run_cmd.step);
|
|
|
|
const exe_unit_tests = b.addTest(.{
|
|
.root_module = exe_mod,
|
|
});
|
|
const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
|
|
test_step.dependOn(&run_exe_unit_tests.step);
|
|
}
|