Commit Graph

15672 Commits

Author SHA1 Message Date
Louis Qian
90d71dd2f6 chore: clean up comments 2026-03-30 18:49:17 -07:00
Louis Qian
b29f261dc8 chore: clean up versionConfig to be init-able 2026-03-30 18:44:49 -07:00
Louis Qian
ed6f0588a3 feat: make version clickable depending on type 2026-03-30 18:41:26 -07:00
ghostty-vouch[bot]
3509ccf78e Update VOUCHED list (#12005)
Triggered by
[comment](https://github.com/ghostty-org/ghostty/issues/11981#issuecomment-4158783258)
from @tristan957.

Vouch: @yabbal

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-03-30 23:27:44 +00:00
Mitchell Hashimoto
50f3b1d60d libghostty: export function table and make it growable for wasm (#12003)
Replaces #11958

This exports the function table and makes it growable so that the
effects API can be used. It's still very not ergonomic to use the
effects API so I'm going to work on that next, but this at least makes
it _possible_. Zig 0.15.x is missing the ability to pass
`--growable-table` to the linker so we use binary patching to add it
(yay!) lol.
2026-03-30 15:29:29 -07:00
Mitchell Hashimoto
f89195ace9 revert example/wasm-vt 2026-03-30 15:21:27 -07:00
ghostty-vouch[bot]
8fc0c85e0c Update VOUCHED list (#12002)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/12001#discussioncomment-16386924)
from @jcollie.

Vouch: @louisunlimited

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-03-30 22:14:54 +00:00
Jeffrey C. Ollie
c75081b89c build: normalize input archives before Darwin libtool merge (#11999)
## Root cause

Zig 0.15.2 can produce macOS `.a` archives where some 64-bit Mach-O
members are only 4-byte aligned inside the archive. Recent Apple
`libtool -static` does not handle that layout correctly: it emits `not
8-byte aligned` warnings and, in the failing case, silently drops those
members when creating the combined static library.

In Ghostty, this happened in the Darwin `libtool` merge step that builds
`libghostty-fat.a`. The x86_64 input `libghostty.a` still contained the
expected `libghostty_zcu.o` and about 97 exported `_ghostty_` symbols,
but after `libtool -static` the output archive contained only 4 SIMD
symbols because `libghostty_zcu.o` had been discarded. The same warning
pattern also appeared in third-party input archives such as
`libfreetype.a` and `libz.a`, so this was not only a `libghostty.a`
problem.

## What needed to be done

The inputs to Apple `libtool` needed to be normalized before they were
merged.

The safest fix is to copy each input archive and run `ranlib -D` on the
copy before passing it to `libtool`. `ranlib` rewrites the archive into
a form that Apple’s linker tools accept, fixing the alignment/layout
issue without changing the archive’s semantic contents.

## Why this approach

An `ar x` -> `ar rcs` workaround can also make the warnings go away, but
it is a broader and riskier transformation. Extracting archive members
into a flat directory is not semantics-preserving:

- duplicate member basenames can collide
- non-`.o` members can be lost
- member order can change

That means an `ar`-based rearchive can silently change valid archives
while fixing alignment. `ranlib -D` avoids those hazards because it
rewrites the archive in place instead of flattening it through the
filesystem.

`-D` is also important because plain `ranlib` is not deterministic. In
local testing, `ranlib -D` still fixed the alignment issue, preserved
all 97 `_ghostty_` symbols, produced no `libtool` warnings, and was
byte-stable across repeated runs.

## Validation

This was reproduced directly:

- before normalization, running `libtool -static` on the affected x86_64
`libghostty.a` produced a `libghostty_zcu.o not 8-byte aligned` warning
and the output archive dropped from 97 `_ghostty_` symbols to 4
- after `ranlib -D`, the same `libtool -static` command preserved all 97
`_ghostty_` symbols and emitted no alignment warnings

After applying the normalization step, a clean `zig build` succeeded,
and the final macOS xcframework archive contained 97 `_ghostty_` symbols
in both the `x86_64` and `arm64` slices.

## Summary

This was not a Metal issue, not an Xcode project issue, and not a
stale-cache issue. The actual root cause was an Apple `libtool`
interoperability problem with Zig-produced macOS archives. The required
fix was to normalize each archive before the Darwin `libtool` merge
step, and `ranlib -D` is the least invasive way to do that while
preserving archive semantics.
2026-03-30 16:22:20 -05:00
Barut
a83a82b3f8 build: normalize input archives before Darwin libtool merge
Apple's recent libtool can warn about misaligned 64-bit archive members
and silently drop them when merging static libraries. In Ghostty this
showed up in the Darwin libtool step that builds libghostty-fat.a.

Normalize each input archive by copying it and running ranlib on the
copy
before handing it to libtool. That rewrites the archive into a layout
Apple's linker tools accept without flattening members through the
filesystem or changing Ghostty's archive format.
2026-03-30 16:59:07 -04:00
ghostty-vouch[bot]
500ab13c86 Update VOUCHED list (#12000)
Triggered by
[comment](https://github.com/ghostty-org/ghostty/issues/11999#issuecomment-4158097469)
from @jcollie.

Vouch: @BarutSRB

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-03-30 20:50:51 +00:00
Mitchell Hashimoto
01a8ea7212 build: binary patching with Zig 2026-03-30 12:06:41 -07:00
Mitchell Hashimoto
6c085e5442 build: binary patch to add growable tables 2026-03-30 11:41:24 -07:00
Mitchell Hashimoto
624b4884c3 Add build_table 2026-03-30 11:34:09 -07:00
Mitchell Hashimoto
ee19c8ff7f wasm: binary patching wow 2026-03-30 11:28:13 -07:00
Mitchell Hashimoto
7269fa7d14 lib: rename GHOSTTY_EXPORT to GHOSTTY_API (#11994)
Rename the shared library visibility macro from GHOSTTY_EXPORT to
GHOSTTY_API across all public C headers. This applies to both the
libghostty-vt headers under include/ghostty/vt/ and the main
include/ghostty.h header.

This is a bit more idiomatic compared to other C libs and addresses the
fact that we're not always exporting...
2026-03-30 10:51:52 -07:00
Mitchell Hashimoto
40d108599f lib: rename GHOSTTY_EXPORT to GHOSTTY_API
Rename the shared library visibility macro from GHOSTTY_EXPORT to
GHOSTTY_API across all public C headers. This applies to both the
libghostty-vt headers under include/ghostty/vt/ and the main
include/ghostty.h header.

This is a bit more idiomatic compared to other C libs and addresses the
fact that we're not always exporting...
2026-03-30 10:26:32 -07:00
Mitchell Hashimoto
53871e4d52 libghostty: WASM VT example, add ghostty_type_json (#11992)
This adds a new `example/wasm-vt` example that initializes a terminal,
lets you write text to write to it, and shows you the screen state.

In doing so, I realized that writing structs in WASM is extremely
painful. You had to do manually hardcoded sizes and byte offsets and
it's scary as hell! So I added a new `ghostty_type_json` API that
returns a C string with JSON-encoded type information about all exported
C structures.

## Example

<img width="1912" height="1574" alt="CleanShot 2026-03-30 at 10 20
16@2x"
src="https://github.com/user-attachments/assets/7cae92bc-3403-4e4c-958c-b7ea58026afe"
/>
2026-03-30 10:24:00 -07:00
Mitchell Hashimoto
bd7415f4b7 terminal: clean up some types tests 2026-03-30 10:21:08 -07:00
Mitchell Hashimoto
3c6e98c5a7 vt: export the new API 2026-03-30 10:16:39 -07:00
Mitchell Hashimoto
0c38e8be60 vt: simplify ghostty_type_json to return null-terminated string
The function previously took a size_t* out-parameter for the string
length. Since the JSON blob is now null-terminated, the len parameter
is unnecessary. Remove it from the Zig implementation, C header, and
the WASM example consumer which no longer needs to allocate and free
a usize just to read the length.
2026-03-30 10:16:19 -07:00
Mitchell Hashimoto
6479d90ca5 example/wasm-vt: use ghostty_type_json for struct layouts
Replace hardcoded byte offsets and struct sizes with dynamic lookups
from the ghostty_type_json API. On WASM load, the type layout JSON
is fetched once and parsed into a lookup table. Two helpers,
fieldInfo and setField, use this metadata to write struct fields at
the correct offsets with the correct types.

This removes the need to manually maintain wasm32 struct layout
comments and magic numbers for GhosttyTerminalOptions and
GhosttyFormatterTerminalOptions, so the example stays correct if
the struct layouts change.
2026-03-30 10:16:19 -07:00
Mitchell Hashimoto
2e827cc39d vt: add ghostty_type_json for struct layout metadata
Add a new C API function that returns a comptime-generated JSON string
describing the size, alignment, and field layout of every C API extern
struct. This lets FFI consumers (particularly WASM) construct structs
by byte offset without hardcoding platform-specific layout.

The JSON is built at comptime using std.json.Stringify via a
StructInfo type that holds per-struct metadata and implements
jsonStringify. A StaticStringMap keyed by C struct name provides
lookup by name as well as iteration for the JSON serialization.

The function is declared in types.h alongside the other common types
and exported as ghostty_type_json.
2026-03-30 10:16:19 -07:00
Mitchell Hashimoto
8fab3ac3f3 example/wasm-vt 2026-03-30 10:16:19 -07:00
Mitchell Hashimoto
6d4528e471 libghostty: add GHOSTTY_EXPORT for shared lib symbol visibility (#11977)
## Summary

Add a `GHOSTTY_EXPORT` annotation macro to all public function
declarations across both `ghostty.h` (the main libghostty header) and
the `include/ghostty/vt/` headers (the libghostty-vt API). This is the
standard pattern used by C libraries that support both static and shared
library builds.

On Windows, functions need `__declspec(dllexport)` when building the DLL
and `__declspec(dllimport)` when consuming it, or they won't be visible
across the DLL boundary. On Linux/macOS with GCC/Clang,
`__attribute__((visibility("default")))` keeps the public API visible
when building with `-fvisibility=hidden`, which reduces symbol table
size and avoids collisions.

The macro resolves to nothing for static builds (when `GHOSTTY_STATIC`
is defined) and on compilers that don't support visibility attributes,
so this is a no-op for the current macOS static library path.

## Why

I looked at how popular C libraries handle this and every serious one
follows the same pattern:

- SDL (`SDL_DECLSPEC`)
- cURL (`CURL_EXTERN`)
- SQLite (`SQLITE_API`)
- zlib (`ZEXTERN`)
- FreeType (`FT_EXPORT`) -- already vendored by Ghostty
- GLFW (`GLFWAPI`)
- Lua (`LUA_API`)

The header comment says "the API is built to be more general purpose"
and the long-term goal is libghostty as a reusable library. Export
annotations are table stakes for that -- they explicitly mark the public
API surface, enable proper shared library builds on all platforms, and
give consumers the right linker hints.

## Test plan

- [x] Windows build and full test suite
- [x] Linux build and full test suite
- [x] macOS build, full test suite, and app launch verified working
- [x] macOS xcodebuild app build and launch verified working
- [x] Shared library symbol inspection on all three platforms
- [x] Linux: validated version script + LLD restricts exports to only
ghostty_* (107/107, 0 leaked, 12 MB .so)
- [x] Linux: C link test against restricted .so -- compiled, linked, ran
successfully
- [x] Windows: DLL exports verified (102 ghostty_ + 3 unavoidable
CRT/simdutf)
2026-03-30 10:15:49 -07:00
Alessandro De Blasis
80e35af763 cmake: define GHOSTTY_STATIC for static library consumers
The ghostty-vt-static target needs to propagate GHOSTTY_STATIC to
consumers so that GHOSTTY_EXPORT resolves to nothing instead of
__declspec(dllimport) on Windows. Without this, static linking
fails with unresolved __imp_ghostty_* symbols.
2026-03-30 18:56:09 +02:00
Mitchell Hashimoto
d643792f36 macOS: add keyboard shortcut test (#11986)
This is the first step (also another step forward for completing #7879)
to fix various responder issues regarding keyboard shortcuts. I tried my
best to separate changes chunk by chunk; there will follow up pr based
on this to fix them.

This pr doesn't change any existing behaviours/flaws, but following
changes will be easier to review after this.

## AI Disclosure

Claude wrote most of the test cases
2026-03-30 09:20:35 -07:00
Mitchell Hashimoto
1672e891b9 macOS: remove redundant tab event overrides (#11984)
- Revert 5540f5f249, middle click comes
out of box with native tabbing, but we override it wrong previous.
- Reverts 894e8d91ba, I check it the
commit right before it and all the way back to
ffe4afe538, right mouse down on tab bar
works well without any issue
- Add back reverted handling in #11150


https://github.com/user-attachments/assets/8660368e-05ae-45b0-aa81-6196f3434daf
2026-03-30 09:19:33 -07:00
Mitchell Hashimoto
bf3f9b3150 macOS: fix focus update when using search or command palette (#11978)
This fixes two things:

1. Surface focus state is not consistent with first responder state when
the search bar is open.
> Reproduce: Open search, switch to another app and back, observe the
cursor state of the surface.
> And after switching back, `cmd+shift+f` will close the search bar,
surface will become focused but not first responder, so it will not
accept any input
2. Command palette is not focused when built with Xcode 26.4 (26.3 works
fine).
> This is weird to me, because the tip (and built with 26.3) works fine.
I guess it's related to the SDK update? I couldn’t be sure what went
wrong, but dispatching it to the next loop works as previously.
  > Also cleaned some previous checks when quickly open and reopen.
  > This fix works great both with 26.4 and 26.3



https://github.com/user-attachments/assets/c9cf4c1b-60d9-4c71-802c-55f82e40eec7
2026-03-30 09:18:28 -07:00
Mitchell Hashimoto
f66cf179cd gtk: only trigger resize callbacks and overlay when size actually changes (#11972)
Fixes #11970

Also fixes problem that resize overlay would intercept mouse activity
while active.
2026-03-30 08:45:50 -07:00
Mitchell Hashimoto
fdb914c680 build(deps): bump cachix/install-nix-action from 31.10.2 to 31.10.3 (#11967)
Bumps
[cachix/install-nix-action](https://github.com/cachix/install-nix-action)
from 31.10.2 to 31.10.3.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/cachix/install-nix-action/releases">cachix/install-nix-action's
releases</a>.</em></p>
<blockquote>
<h2>v31.10.3</h2>
<h2>What's Changed</h2>
<ul>
<li>nix: 2.34.2 -&gt; 2.34.4 by <a
href="https://github.com/github-actions"><code>@​github-actions</code></a>[bot]
in <a
href="https://redirect.github.com/cachix/install-nix-action/pull/271">cachix/install-nix-action#271</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/cachix/install-nix-action/compare/v31...v31.10.3">https://github.com/cachix/install-nix-action/compare/v31...v31.10.3</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="96951a368b"><code>96951a3</code></a>
Merge pull request <a
href="https://redirect.github.com/cachix/install-nix-action/issues/271">#271</a>
from cachix/create-pull-request/patch</li>
<li><a
href="6281169445"><code>6281169</code></a>
nix: 2.34.2 -&gt; 2.34.4</li>
<li>See full diff in <a
href="51f3067b56...96951a368b">compare
view</a></li>
</ul>
</details>
<br />
2026-03-30 08:31:03 -07:00
dependabot[bot]
3864fa585f build(deps): bump cachix/install-nix-action from 31.10.2 to 31.10.3
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 31.10.2 to 31.10.3.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Changelog](https://github.com/cachix/install-nix-action/blob/master/RELEASE.md)
- [Commits](51f3067b56...96951a368b)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-version: 31.10.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-30 15:22:36 +00:00
Jeffrey C. Ollie
7ad3888819 cli: add pager support to +explain-config (#11940)
Add a new Pager type that wraps output to an external pager program when
stdout is a TTY, following the same conventions as git. The pager
command is resolved from $PAGER, falling back to `less`. An empty $PAGER
disables paging. If the pager fails to spawn, we fall back to stdout.

Previously, +explain-config wrote directly to stdout with no paging,
which meant long help text would scroll by. Now output is automatically
piped through the user's preferred pager when running interactively. A
--no-pager flag is available to disable this.
2026-03-30 10:12:33 -05:00
Jon Parise
840ab46009 cli: also recognize $GHOSTTY_PAGER
When defined, GHOSTTY_PAGER takes precedence over PAGER. If either of
those variables is set to an empty value, paging is disabled.
2026-03-30 10:53:53 -04:00
Jon Parise
11d45cd43c cli: add pager support for +show-config 2026-03-30 10:48:07 -04:00
Jon Parise
62f8a1cbcf cli: use a caller-provided write buffer
This follows Zig's conventions more closely, where the caller owns the
write buffer.
2026-03-30 10:48:07 -04:00
Jon Parise
4a0cca1c5b cli: add pager support to +explain-config
Add a new Pager type that wraps output to an external pager program when
stdout is a TTY, following the same conventions as git. The pager
command is resolved from $PAGER, falling back to `less`. An empty $PAGER
disables paging. If the pager fails to spawn, we fall back to stdout.

Previously, +explain-config wrote directly to stdout with no paging,
which meant long help text would scroll by. Now output is automatically
piped through the user's preferred pager when running interactively. A
--no-pager flag is available to disable this.
2026-03-30 10:48:07 -04:00
Lukas
de8139bbc3 macOS: move MenuShortcutManager to a separate file 2026-03-30 16:10:06 +02:00
Lukas
1845dd26b6 macOS: extract menu shortcut syncing into MenuShortcutManager 2026-03-30 16:09:21 +02:00
Lukas
65cd31dc79 macOS: add NormalizedMenuShortcutKeyTests 2026-03-30 15:47:07 +02:00
Lukas
5c5f645b61 macOS: support reloading temporary config for testing 2026-03-30 15:47:07 +02:00
Lukas
51cd63871d macos: passthrough right mouse down event to TabTitleEditor if needed (#11150) 2026-03-30 12:22:54 +02:00
Lukas
5de30c0dce Revert "macOS: fix tab context menu opens on macOS 26 with titlebar tabs (#9831)"
This reverts commit 894e8d91ba, reversing
changes made to 4a173052fb.
2026-03-30 12:09:51 +02:00
Lukas
5c5029b0c4 Revert "macos: add support for middle-click tab close for macos-titlebar-style = tabs (#11963)"
This reverts commit 5540f5f249, reversing
changes made to cca4c788ad.
2026-03-30 12:08:49 +02:00
Lukas
013579cfcf macOS: fix initial focus of command palette when building with Xcode 26.4
Tip works fine, but I've tried release and debug build with Xcode 26.4, it failed to focus as expected
2026-03-30 10:03:09 +02:00
Lukas
32920b6b2a macOS: handle surface focus more gracefully
This will fix surface focus state is not consistent with first responder state when the search bar is open
2026-03-30 10:03:09 +02:00
Alessandro De Blasis
0c765c7c58 libghostty: add GHOSTTY_EXPORT to VT headers
Extend GHOSTTY_EXPORT annotations to all public function declarations
in include/ghostty/vt/ headers. Add GHOSTTY_EXPORT macro to types.h
with ifndef guard so both ghostty.h and VT headers share the same
definition without conflict.
2026-03-30 09:28:11 +02:00
Alessandro De Blasis
bd413cc7bd libghostty: add GHOSTTY_EXPORT for shared library symbol visibility 2026-03-30 08:20:24 +02:00
Jeffrey C. Ollie
af36959942 gtk: only trigger resize callbacks and overlay when size actually changes
Fixes #11970

Also fixes problem that resize overlay would intercept mouse activity
while active.
2026-03-29 23:38:34 -05:00
Mitchell Hashimoto
5540f5f249 macos: add support for middle-click tab close for macos-titlebar-style = tabs (#11963)
Fixes #11962

### Summary
This PR implements a fix for:
https://github.com/ghostty-org/ghostty/discussions/10264

This allows the `macos-titlebar-style` setting `tabs` to behave the same
way other titlebar style options do with middle click handling.

### AI Disclosure
I used claude code (Sonnet 4.6) to identify the best place to start when
implementing this change, as well as for general Swift questions. The
code within this PR is written by me.
2026-03-29 15:24:16 -07:00
Nicholas Ochoa
3f6683df02 macos: add support for middle-click tab close 2026-03-29 15:19:35 -07:00