Skip to content

Commit 07b63f5

Browse files
Merge pull request #113 from royalapplications/agent/ghostty-latest-api-integration
Update Ghostty integration to latest libghostty-vt API
2 parents 9a0063f + 38e6d86 commit 07b63f5

55 files changed

Lines changed: 5371 additions & 210 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ jobs:
142142

143143
native-build-macos:
144144
name: Native Build (macOS)
145-
# Zig 0.15.2 fails to link the build runner on macos-26-arm64.
145+
# Pin macOS 15 for reproducible SDK compatibility with the native artifacts.
146146
runs-on: macos-15
147147
strategy:
148148
matrix:
@@ -156,16 +156,16 @@ jobs:
156156
- name: Setup Zig
157157
uses: mlugg/setup-zig@v2
158158
with:
159-
version: 0.15.2
159+
version: 0.16.0
160160
cache-key: ${{ matrix.arch }}
161161

162162
- name: Build libghostty-vt
163163
working-directory: external/ghostty
164164
run: |
165165
if [ "${{ matrix.arch }}" = "arm64" ]; then
166-
zig build -Doptimize=ReleaseFast -Dapp-runtime=none -Demit-xcframework=false -Demit-macos-app=false
166+
zig build -Doptimize=ReleaseFast -Dapp-runtime=none -Demit-lib-vt=true -Demit-xcframework=false -Demit-macos-app=false
167167
else
168-
zig build -Doptimize=ReleaseFast -Dapp-runtime=none -Demit-xcframework=false -Demit-macos-app=false -Dtarget=x86_64-macos
168+
zig build -Doptimize=ReleaseFast -Dapp-runtime=none -Demit-lib-vt=true -Demit-xcframework=false -Demit-macos-app=false -Dtarget=x86_64-macos
169169
fi
170170
171171
- name: Build ghostty-renderer-capi
@@ -251,7 +251,7 @@ jobs:
251251
- name: Setup Zig
252252
uses: mlugg/setup-zig@v2
253253
with:
254-
version: 0.15.2
254+
version: 0.16.0
255255
cache-key: ${{ matrix.arch }}
256256

257257
- name: Build libghostty-vt
@@ -265,6 +265,7 @@ jobs:
265265
build
266266
-Doptimize=ReleaseFast
267267
-Dapp-runtime=none
268+
-Demit-lib-vt=true
268269
-Dtarget=${{ matrix.zig-target }}
269270
-Dsimd=false
270271
)
@@ -328,26 +329,30 @@ jobs:
328329
- name: Setup Zig
329330
uses: mlugg/setup-zig@v2
330331
with:
331-
version: 0.15.2
332+
version: 0.16.0
332333
cache-key: ${{ matrix.arch }}
333334

334335
- name: Build libghostty-vt
335336
working-directory: external/ghostty
336337
shell: bash
337338
run: |
338339
target=""
340+
simd=""
339341
if [ "${{ matrix.arch }}" = "arm64" ]; then
340-
target="-Dtarget=aarch64-windows"
342+
target="-Dtarget=aarch64-windows-gnu"
343+
# Zig 0.16.0's Windows ARM64 stdlib stack-trace code fails to
344+
# compile when Ghostty's vendored SIMD archive is enabled.
345+
simd="-Dsimd=false"
341346
fi
342-
zig build -Doptimize=ReleaseFast -Dapp-runtime=none ${target}
347+
zig build -Doptimize=ReleaseFast -Dapp-runtime=none -Demit-lib-vt=true ${target} ${simd}
343348
344349
- name: Build ghostty-renderer-capi
345350
working-directory: native/ghostty-renderer-capi
346351
shell: bash
347352
run: |
348353
target=""
349354
if [ "${{ matrix.arch }}" = "arm64" ]; then
350-
target="-Dtarget=aarch64-windows"
355+
target="-Dtarget=aarch64-windows-gnu"
351356
fi
352357
zig build -Doptimize=ReleaseFast ${target}
353358

.github/workflows/release.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323

2424
native-macos:
2525
name: Native (macOS ${{ matrix.arch }})
26-
# Zig 0.15.2 fails to link the build runner on macos-26-arm64.
26+
# Pin macOS 15 for reproducible SDK compatibility with the native artifacts.
2727
runs-on: macos-15
2828
strategy:
2929
matrix:
@@ -37,15 +37,15 @@ jobs:
3737
- name: Setup Zig
3838
uses: mlugg/setup-zig@v2
3939
with:
40-
version: 0.15.2
40+
version: 0.16.0
4141

4242
- name: Build libghostty-vt
4343
working-directory: external/ghostty
4444
run: |
4545
if [ "${{ matrix.arch }}" = "arm64" ]; then
46-
zig build -Doptimize=ReleaseFast -Dapp-runtime=none -Demit-xcframework=false -Demit-macos-app=false
46+
zig build -Doptimize=ReleaseFast -Dapp-runtime=none -Demit-lib-vt=true -Demit-xcframework=false -Demit-macos-app=false
4747
else
48-
zig build -Doptimize=ReleaseFast -Dapp-runtime=none -Demit-xcframework=false -Demit-macos-app=false -Dtarget=x86_64-macos
48+
zig build -Doptimize=ReleaseFast -Dapp-runtime=none -Demit-lib-vt=true -Demit-xcframework=false -Demit-macos-app=false -Dtarget=x86_64-macos
4949
fi
5050
5151
- name: Build ghostty-renderer-capi
@@ -129,7 +129,7 @@ jobs:
129129
- name: Setup Zig
130130
uses: mlugg/setup-zig@v2
131131
with:
132-
version: 0.15.2
132+
version: 0.16.0
133133

134134
- name: Build libghostty-vt
135135
working-directory: external/ghostty
@@ -142,6 +142,7 @@ jobs:
142142
build
143143
-Doptimize=ReleaseFast
144144
-Dapp-runtime=none
145+
-Demit-lib-vt=true
145146
-Dtarget=${{ matrix.zig-target }}
146147
-Dsimd=false
147148
)
@@ -203,7 +204,7 @@ jobs:
203204
- name: Setup Zig
204205
uses: mlugg/setup-zig@v2
205206
with:
206-
version: 0.15.2
207+
version: 0.16.0
207208

208209
- name: Build libghostty-vt
209210
working-directory: external/ghostty
@@ -212,7 +213,10 @@ jobs:
212213
cpu=""
213214
simd=""
214215
if [ "${{ matrix.arch }}" = "arm64" ]; then
215-
target="-Dtarget=aarch64-windows-msvc"
216+
target="-Dtarget=aarch64-windows-gnu"
217+
# Zig 0.16.0's Windows ARM64 stdlib stack-trace code fails to
218+
# compile when Ghostty's vendored SIMD archive is enabled.
219+
simd="-Dsimd=false"
216220
else
217221
# Keep win-x64 release artifacts on a true baseline x64 CPU model.
218222
# x86_64-windows-msvc alone still allows LLVM/third-party SIMD code
@@ -223,15 +227,15 @@ jobs:
223227
cpu="-Dcpu=x86_64-vzeroupper"
224228
simd="-Dsimd=false"
225229
fi
226-
zig build -Doptimize=ReleaseFast -Dapp-runtime=none ${target} ${cpu} ${simd}
230+
zig build -Doptimize=ReleaseFast -Dapp-runtime=none -Demit-lib-vt=true ${target} ${cpu} ${simd}
227231
228232
- name: Build ghostty-renderer-capi
229233
working-directory: native/ghostty-renderer-capi
230234
shell: bash
231235
run: |
232236
cpu=""
233237
if [ "${{ matrix.arch }}" = "arm64" ]; then
234-
target="-Dtarget=aarch64-windows-msvc"
238+
target="-Dtarget=aarch64-windows-gnu"
235239
else
236240
target="-Dtarget=x86_64-windows-msvc"
237241
cpu="-Dcpu=x86_64-vzeroupper"

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
99
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
1010
<AnalysisLevel>latest</AnalysisLevel>
11-
<VersionPrefix>0.4.1</VersionPrefix>
12-
<VersionSuffix></VersionSuffix>
11+
<VersionPrefix>0.5.0</VersionPrefix>
12+
<VersionSuffix>preview.1</VersionSuffix>
1313
<RoyalTerminalEnablePretextTextPipeline Condition="'$(RoyalTerminalEnablePretextTextPipeline)' == ''">true</RoyalTerminalEnablePretextTextPipeline>
1414
<DefineConstants Condition="'$(RoyalTerminalEnablePretextTextPipeline)' == 'true'">$(DefineConstants);ROYALTERMINAL_PRETEXT_TEXT_PIPELINE</DefineConstants>
1515
</PropertyGroup>

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ Build directly:
11571157

11581158
```bash
11591159
cd external/ghostty
1160-
zig build -Doptimize=ReleaseFast -Dapp-runtime=none
1160+
zig build -Doptimize=ReleaseFast -Dapp-runtime=none -Demit-lib-vt=true
11611161
```
11621162

11631163
For distributable Windows x64 artifacts, build a scalar compatibility DLL with
@@ -1167,7 +1167,7 @@ older CPUs, constrained VMs, and Windows ARM64 x64 emulation:
11671167
```powershell
11681168
.\scripts\build-native.ps1 -Arch x64 -Release
11691169
# or, from external/ghostty:
1170-
zig build -Doptimize=ReleaseFast -Dapp-runtime=none -Dtarget=x86_64-windows-msvc -Dcpu=x86_64-vzeroupper -Dsimd=false
1170+
zig build -Doptimize=ReleaseFast -Dapp-runtime=none -Demit-lib-vt=true -Dtarget=x86_64-windows-msvc -Dcpu=x86_64-vzeroupper -Dsimd=false
11711171
```
11721172

11731173
CI verifies the Windows x64 native artifacts with `scripts/verify-windows-x64-no-avx.ps1`.
@@ -1281,7 +1281,7 @@ RoyalTerminal/
12811281
### Prerequisites
12821282

12831283
- .NET 10 SDK
1284-
- Zig 0.15.2+
1284+
- Zig 0.16.0
12851285
- Ghostty submodule:
12861286

12871287
```bash

docs/articles/build-test-release.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ RoyalTerminal combines managed .NET packages with native artifacts. A successful
1111
Minimum toolchain:
1212

1313
- .NET 10 SDK
14-
- Zig 0.15.2 or newer
14+
- Zig 0.16.0
1515
- initialized git submodules for native builds
1616

1717
Common optional requirements:

docs/articles/ghostty-integration.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ If you want Ghostty behavior inside RoyalTerminal, you usually begin with the ma
4646
| `GhosttyMouseEvent` | Mutable mouse event payload. |
4747
| `GhosttyPaste` | Static helper for paste encoding. |
4848
| `GhosttySelection` | Managed selection value used by formatters and helpers. |
49+
| `GhosttySelectionGesture` | Owned state machine for native text-selection gestures. |
50+
| `GhosttySelectionGestureEvent` | Reusable selection pointer/click event. |
51+
| `GhosttyTrackedGridReference` | Owned reference that follows a cell through scroll, pruning, and reflow. |
52+
| `GhosttyColorUtilities` | Native-backed color parsing, palettes, color math, X11 names, and color-scheme reports. |
53+
| `GhosttyUnicode` | Ghostty-exact codepoint and grapheme width helpers. |
4954
| `GhosttyKittyGraphics` | Managed helper for Kitty graphics extraction. |
5055
| `GhosttyKittyGraphicsImage` | Managed Kitty image snapshot. |
5156
| `GhosttyKittyGraphicsPlacementIterator` | Managed iterator over Kitty placements. |
@@ -59,10 +64,30 @@ If you want Ghostty behavior inside RoyalTerminal, you usually begin with the ma
5964

6065
These are the types used by RoyalTerminal itself when it wants native VT behavior without forcing consumers to work directly against raw pointers and C structs.
6166

67+
## Engine-neutral effects and Unicode
68+
69+
Hosts that can use either VT engine should query the terminal contracts instead
70+
of depending directly on Ghostty types:
71+
72+
| Contract | Capability |
73+
| --- | --- |
74+
| `ITerminalEffectSource` | Clipboard writes, desktop notifications, progress reports, and working-directory changes. |
75+
| `ITerminalUnicodeWidthProvider` | Codepoint width and first-grapheme width using the active engine's rules. |
76+
77+
`GhosttyVtProcessor` implements these contracts with the normalized
78+
libghostty callbacks and Ghostty Unicode tables. `BasicVtProcessor` implements
79+
the same contracts with managed OSC parsing and RoyalTerminal Unicode tables.
80+
The effect callbacks are policy boundaries: applications still decide whether
81+
clipboard writes and desktop notifications are allowed.
82+
6283
## The raw VT mirror is also public
6384

6485
Under those wrappers, `GhosttyVtNative` exposes the Ghostty VT ABI directly. This is not the right layer for most applications, but it is the right layer for advanced interop, diagnostics, or custom wrappers.
6586

87+
At the current Ghostty revision, `TerminalNew` takes `columns` and `rows`
88+
directly. Configure the returned terminal through `TerminalSet`; the former
89+
`GhosttyTerminalOptions` constructor struct no longer exists.
90+
6691
### Root VT exports
6792

6893
`GhosttyVtNative`, `GhosttyResult`, `GhosttyVtKeyAction`, `GhosttyVtKey`, `GhosttyVtMods`, `GhosttyOscCommandType`, `GhosttyOscCommandData`, `GhosttySgrAttributeTag`, `GhosttySgrUnderline`, `GhosttySgrUnknown`, `GhosttySgrAttributeValue`, `GhosttySgrAttribute`, `GhosttyColorRgb`
@@ -85,15 +110,15 @@ Under those wrappers, `GhosttyVtNative` exposes the Ghostty VT ABI directly. Thi
85110

86111
### Render-state exports
87112

88-
`GhosttyRenderStateDirty`, `GhosttyRenderStateCursorVisualStyle`, `GhosttyRenderStateData`, `GhosttyRenderStateOption`, `GhosttyRenderStateRowData`, `GhosttyRenderStateRowOption`, `GhosttyRenderStateRowCellsData`, `GhosttyRenderStateColors`
113+
`GhosttyRenderStateDirty`, `GhosttyRenderStateCursorVisualStyle`, `GhosttyRenderStateData`, `GhosttyRenderStateOption`, `GhosttyRenderStateRowData`, `GhosttyRenderStateRowOption`, `GhosttyRenderStateRowCellsData`, `GhosttyRenderStateColors`, `GhosttyRenderStateRowSelection`, `GhosttyBuffer`
89114

90115
### Screen exports
91116

92117
`GhosttyStyleColorTag`, `GhosttyStyleColorValue`, `GhosttyStyleColor`, `GhosttyStyle`, `GhosttyGridRef`, `GhosttyCellContentTag`, `GhosttyCellWide`, `GhosttyCellSemanticContent`, `GhosttyCellData`, `GhosttyRowSemanticPrompt`, `GhosttyRowData`
93118

94119
### Selection, system, and terminal exports
95120

96-
`GhosttySelectionRange`, `GhosttyAllocatorVtable`, `GhosttyAllocator`, `GhosttySysImage`, `GhosttySysDecodePngCallback`, `GhosttySysOption`, `GhosttyTerminalOptions`, `GhosttyTerminalScrollViewportTag`, `GhosttyTerminalScrollViewportValue`, `GhosttyTerminalScrollViewport`, `GhosttyTerminalScreen`, `GhosttyTerminalScrollbar`, `GhosttyTerminalBellCallback`, `GhosttyTerminalWritePtyCallback`, `GhosttyTerminalTitleChangedCallback`, `GhosttyTerminalEnquiryCallback`, `GhosttyTerminalXtversionCallback`, `GhosttyTerminalSizeCallback`, `GhosttyTerminalColorSchemeCallback`, `GhosttyTerminalDeviceAttributesCallback`, `GhosttyTerminalOption`, `GhosttyTerminalData`
121+
`GhosttySelectionRange`, `GhosttySelectionOrder`, `GhosttySelectionAdjust`, `GhosttySelectionGestureBehavior`, `GhosttySelectionGestureBehaviors`, `GhosttySelectionGestureGeometry`, `GhosttySelectionGestureAutoscroll`, `GhosttySelectionGestureData`, `GhosttySelectionGestureEventType`, `GhosttySelectionGestureEventOption`, `GhosttyAllocatorVtable`, `GhosttyAllocator`, `GhosttySysImage`, `GhosttySysDecodePngCallback`, `GhosttySysOption`, `GhosttyTerminalScrollViewportTag`, `GhosttyTerminalScrollViewportValue`, `GhosttyTerminalScrollViewport`, `GhosttyTerminalCompressionMode`, `GhosttyTerminalCompressionResult`, `GhosttyTerminalScreen`, `GhosttyTerminalScrollbar`, `GhosttyTerminalBellCallback`, `GhosttyTerminalWritePtyCallback`, `GhosttyTerminalTitleChangedCallback`, `GhosttyTerminalEnquiryCallback`, `GhosttyTerminalXtversionCallback`, `GhosttyTerminalSizeCallback`, `GhosttyTerminalColorSchemeCallback`, `GhosttyTerminalDeviceAttributesCallback`, `GhosttyTerminalPwdChangedCallback`, `GhosttyTerminalClipboardWriteCallback`, `GhosttyTerminalDesktopNotificationCallback`, `GhosttyTerminalProgressReportCallback`, `GhosttyTerminalOption`, `GhosttyTerminalData`
97122

98123
## Runtime enums, structs, and callbacks
99124

docs/articles/windows-x64-native-compatibility.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Build the Windows x64 native artifacts:
7070
Direct Ghostty build from `external/ghostty`:
7171

7272
```powershell
73-
zig build -Doptimize=ReleaseFast -Dapp-runtime=none -Dtarget=x86_64-windows-msvc -Dcpu=x86_64-vzeroupper -Dsimd=false
73+
zig build -Doptimize=ReleaseFast -Dapp-runtime=none -Demit-lib-vt=true -Dtarget=x86_64-windows-msvc -Dcpu=x86_64-vzeroupper -Dsimd=false
7474
```
7575

7676
Verify a DLL with disassembly:

external/ghostty

Submodule ghostty updated 582 files

native/ghostty-renderer-capi/build.zig

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ const std = @import("std");
88

99
fn linkAppleObjc(step: *std.Build.Step.Compile) void {
1010
// Add common SDK library locations so cross-target macOS builds can resolve libobjc.
11-
step.addLibraryPath(.{ .cwd_relative = "/usr/lib" });
12-
step.addLibraryPath(.{ .cwd_relative = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib" });
13-
step.addLibraryPath(.{ .cwd_relative = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib" });
14-
step.linkSystemLibrary("objc");
11+
step.root_module.addLibraryPath(.{ .cwd_relative = "/usr/lib" });
12+
step.root_module.addLibraryPath(.{ .cwd_relative = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib" });
13+
step.root_module.addLibraryPath(.{ .cwd_relative = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib" });
14+
step.root_module.linkSystemLibrary("objc", .{});
1515
}
1616

1717
pub fn build(b: *std.Build) void {
@@ -30,10 +30,10 @@ pub fn build(b: *std.Build) void {
3030
.root_source_file = b.path("src/main.zig"),
3131
.target = target,
3232
.optimize = optimize,
33+
.link_libc = true,
3334
}),
3435
.version = .{ .major = 0, .minor = 1, .patch = 0 },
3536
});
36-
lib.linkLibC();
3737

3838
if (target.result.os.tag == .macos) {
3939
linkAppleObjc(lib);
@@ -49,9 +49,9 @@ pub fn build(b: *std.Build) void {
4949
.root_source_file = b.path("src/main.zig"),
5050
.target = target,
5151
.optimize = optimize,
52+
.link_libc = true,
5253
}),
5354
});
54-
static_lib.linkLibC();
5555

5656
if (target.result.os.tag == .macos) {
5757
linkAppleObjc(static_lib);
@@ -65,9 +65,9 @@ pub fn build(b: *std.Build) void {
6565
.root_source_file = b.path("src/main.zig"),
6666
.target = target,
6767
.optimize = optimize,
68+
.link_libc = true,
6869
}),
6970
});
70-
tests.linkLibC();
7171

7272
if (target.result.os.tag == .macos) {
7373
linkAppleObjc(tests);
@@ -82,16 +82,16 @@ pub fn build(b: *std.Build) void {
8282
.root_source_file = b.path("samples/metal_texture_smoke.zig"),
8383
.target = target,
8484
.optimize = optimize,
85+
.link_libc = true,
8586
.imports = &.{
8687
.{ .name = "renderer_capi", .module = renderer_module },
8788
},
8889
}),
8990
});
90-
sample.linkLibC();
9191

9292
if (target.result.os.tag == .macos) {
9393
linkAppleObjc(sample);
94-
sample.linkFramework("Metal");
94+
sample.root_module.linkFramework("Metal", .{});
9595
}
9696

9797
const sample_install = b.addInstallArtifact(sample, .{});

native/ghostty-renderer-capi/build.zig.zon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
.version = "0.1.5",
44
.paths = .{""},
55
.fingerprint = 0x227859aca4c0de44,
6-
.minimum_zig_version = "0.15.2",
6+
.minimum_zig_version = "0.16.0",
77
}

0 commit comments

Comments
 (0)