Commit Graph

15849 Commits

Author SHA1 Message Date
Jeffrey C. Ollie
aea70a5f7c core: implement backarrow key mode (DECBKM) - mode 67
This mode allows programs to modify the code that the `backspace`
key (backarrow key in DEC parlance) sends. If this mode is
`off`/`false`/`reset` (the default, the same as before this PR), we
send the byte `0x7f`. If this mode is `on`/`true`/`set` we send the
byte `0x08`.
2026-04-12 15:40:54 -05:00
Mitchell Hashimoto
94cd3da8bc build: add ghostty-internal pkg-config modules (shared + static) (#12214)
## Summary
Mirror the `libghostty-vt-static` pkg-config pattern from #12210 for the
internal library.

- Add `ghostty-internal.pc` (shared, `-lghostty`) and
`ghostty-internal-static.pc` (static, direct archive reference) so
consumers can discover either variant via pkg-config
- Named `ghostty-internal` to distinguish from the public
`libghostty-vt` API
- Static module points at the platform-correct archive name
(`ghostty-static.lib` on Windows, `libghostty.a` elsewhere)
- pkg-config files are generated during shared builds and installed via
`GhosttyLib.install()`

## Test plan

- [x] `zig build` succeeds (default target)
- [x] `ghostty-internal.pc` and `ghostty-internal-static.pc` appear in
`zig-out/share/pkgconfig/`
- [x] Static `.pc` points at `ghostty-static.lib` (Windows) /
`libghostty.a` (Unix)
- [x] Shared `.pc` uses standard `-L -l` flags
- [x] Existing `libghostty-vt` pkg-config files are unaffected
2026-04-12 13:18:03 -07:00
Mitchell Hashimoto
d2b79bea77 macOS: fix the arrow alignment of the secure input popover (#12249) 2026-04-12 13:16:15 -07:00
Mitchell Hashimoto
7f6d2a44b8 macOS: fix cannot rebind super+up and super+down (#12245)
Fix: #11989
Cause identified to: ab352b5af9
Original PR: #10003
Problem: I don't think it is OK to hard code the keybind like this at
all. Ghostty's config is flexible enough to achieve this.
Proposal: Revert the above commit via this PR.

@yasuf @bo2themax
2026-04-12 13:16:06 -07:00
Mitchell Hashimoto
032596442f macOS: clean up duplicated declarations in SurfaceView_AppKit/UIKit (#12250)
Added a shared `OSSurfaceView` as the base class to share common
variables and functions across platforms.

Each commit contains a small change to move one or two variables or
functions to `OSSurfaceView`.
2026-04-12 13:15:52 -07:00
Lukas
53019991f7 macOS: fix the arrow alignment of the secure input popover 2026-04-12 16:04:41 +02:00
Lukas
bf6fd4abe5 macOS: add focusDidChange & sizeDidChange placeholders to OSSurfaceView 2026-04-12 14:23:46 +02:00
Lukas
90ea604a7c macOS: move searchState to OSSurfaceView 2026-04-12 14:23:46 +02:00
Lukas
a541e23120 macOS: move surface to OSSurfaceView 2026-04-12 14:23:46 +02:00
Lukas
1665755a93 macOS: move highlighted to OSSurfaceView 2026-04-12 14:23:46 +02:00
Lukas
2efe851cda macOS: move readonly to OSSurfaceView 2026-04-12 14:23:45 +02:00
Lukas
3834751aef macOS: move surfaceSize to OSSurfaceView 2026-04-12 12:08:56 +02:00
Lukas
7c83561f9e macOS: move focusInstant to OSSurfaceView 2026-04-12 12:07:22 +02:00
Lukas
56b505cbb0 macOS: move keyTables to OSSurfaceView 2026-04-12 12:06:28 +02:00
Lukas
19af8e9ce2 macOS: move progressReport to OSSurfaceView 2026-04-12 12:04:09 +02:00
Lukas
8b99c77bf7 macOS: update title comments 2026-04-12 12:02:59 +02:00
Lukas
619e12dc75 macOS: move hoverUrl to OSSurfaceView 2026-04-12 11:59:51 +02:00
Lukas
3936069297 macOS: move healthy and error to OSSurfaceView 2026-04-12 11:59:04 +02:00
Lukas
d38301bb9f macOS: move cellSize to OSSurfaceView 2026-04-12 11:58:04 +02:00
Lukas
46fef7718c macOS: move pwd to OSSurfaceView 2026-04-12 11:57:15 +02:00
Lukas
8bd1aba40a macOS: add shared OSSurfaceView 2026-04-12 11:54:16 +02:00
Mitchell Hashimoto
557de7c925 build: stop linking libc++ for utfcpp (#12239)
utfcpp is a header-only dependency, so its package wrapper does not need
to link the C++ standard library. Keep the empty static archive for
build integration, but stop adding an unnecessary libc++ dependency.
2026-04-11 14:55:11 -07:00
Mitchell Hashimoto
5e102c9dc7 build: stop linking libc++ for utfcpp
utfcpp is a header-only dependency, so its package wrapper does not
need to link the C++ standard library. Keep the empty static archive
for build integration, but stop adding an unnecessary libc++
dependency.
2026-04-11 14:44:05 -07:00
Mitchell Hashimoto
fa2c3a1e60 pkg/highway: drop libc++ dependency from vendored hwy (#12238)
The vendored Highway package was being built with libc++ even though
Ghostty only uses its runtime target selection and dispatch support.
That pulled in extra C++ runtime baggage from upstream support files
such as abort, timer, print, and benchmark helpers.

Build Highway in HWY_NO_LIBCXX mode, only compile the target dispatch
sources we actually need, and compile Ghostty's SIMD translation units
with the same define so the header ABI stays consistent. Replace the
upstream abort implementation with a small local bridge that provides
Highway's Warn/Abort hooks and the target-query shim without depending
on libc++.

This keeps the Highway archive down to the dispatch pieces Ghostty uses
while preserving the existing dynamic dispatch behavior. The bridge is
documented so it is clear why Ghostty carries this small local
replacement.

We still depend on libc++ for other reasons, but I figure we should just
trim it down as needed. 😄
2026-04-11 14:41:55 -07:00
Mitchell Hashimoto
3e6a65f73f pkg/highway: drop libc++ from vendored hwy
The vendored Highway package was being built with libc++ even though
Ghostty only uses its runtime target selection and dispatch support.
That pulled in extra C++ runtime baggage from upstream support files
such as abort, timer, print, and benchmark helpers.

Build Highway in HWY_NO_LIBCXX mode, only compile the target dispatch
sources we actually need, and compile Ghostty's SIMD translation units
with the same define so the header ABI stays consistent. Replace the
upstream abort implementation with a small local bridge that provides
Highway's Warn/Abort hooks and the target-query shim without depending
on libc++.

This keeps the Highway archive down to the dispatch pieces Ghostty
uses while preserving the existing dynamic dispatch behavior. The
bridge is documented so it is clear why Ghostty carries this small
local replacement.
2026-04-11 14:28:56 -07:00
Mitchell Hashimoto
c36b458ad5 libghostty: add _get_multi to all _get APIs (#12236)
Replace the ImageInfo and PlacementInfo sized structs and their
associated .info enum variants with a new _get_multi pattern that
batches multiple enum+pointer pairs into a single call. This avoids
struct ABI concerns (field order, padding, alignment,
GHOSTTY_INIT_SIZED) while preserving the single-call-crossing
performance benefit for FFI and Cgo callers.

Each _get_multi function takes an array of enum keys, an array of output
pointers, and an optional out_written parameter that reports how many
values were successfully written before any error. This applies
uniformly to all _get APIs: terminal_get, cell_get, row_get,
render_state_get, render_state_row_get, render_state_row_cells_get,
kitty_graphics_image_get, and kitty_graphics_placement_get.

The C example is updated to use compound-literal _get_multi calls, and
tests cover both success and error paths for every new function.
2026-04-11 12:56:49 -07:00
Mitchell Hashimoto
abf1332737 macOS: fix memory leak of TerminalController (#12237)
Regression of #12119, this memory leak affects new tabs, since the
terminal controller is not deallocated correctly, hitting `cmd+t` will
create a new window with two tabs, but only one actually contains usable
surface.

You can reproduce by:
1. Quit and Reopen Ghostty
2. Open a new window if no window is created (initial-window = false)
3. Close the window
4. Hit `cmd+t`
2026-04-11 12:51:53 -07:00
Mitchell Hashimoto
2c1dad790b libghostty: add _get_multi to all _get APIs
Replace the ImageInfo and PlacementInfo sized structs and their
associated .info enum variants with a new _get_multi pattern that
batches multiple enum+pointer pairs into a single call. This avoids
struct ABI concerns (field order, padding, alignment, GHOSTTY_INIT_SIZED)
while preserving the single-call-crossing performance benefit for FFI
and Cgo callers.

Each _get_multi function takes an array of enum keys, an array of
output pointers, and an optional out_written parameter that reports
how many values were successfully written before any error. This
applies uniformly to all _get APIs: terminal_get, cell_get, row_get,
render_state_get, render_state_row_get, render_state_row_cells_get,
kitty_graphics_image_get, and kitty_graphics_placement_get.

The C example is updated to use compound-literal _get_multi calls,
and tests cover both success and error paths for every new function.
2026-04-11 12:51:36 -07:00
Lukas
650cd96646 macOS: fix memory leak of TerminalController
Regression of #12119, this memory leak affects new tabs, since the terminal controller is not deallocated correctly. Hitting `cmd+t` will create a new window with two tabs, but only one actually contains usable surface.

You can reproduce by:
1. Quit and Reopen Ghostty
2. Open a new window if no window is created (initial-window = false)
3. Close the window
4. Hit `cmd+t`
2026-04-11 21:20:16 +02:00
Alessandro De Blasis
19bf63ab71 test/windows: update README for ghostty-internal.dll rename
Match the dll filename rename so the copy/run instructions stay
accurate.
2026-04-11 03:02:08 +02:00
Alessandro De Blasis
935b08acea test/windows: load ghostty-internal.dll in CRT init reproducer
The internal glue DLL was renamed from ghostty.dll to
ghostty-internal.dll. Update the LoadLibraryA call and the comment
block so this regression test still exercises the right artifact.
2026-04-11 03:01:12 +02:00
Alessandro De Blasis
1988ac94d4 build: point ghostty-internal pkg-config files at direct paths
Switch the shared ghostty-internal.pc Libs: line from -lghostty to a
direct ${libdir}/<file> path, matching what the -static module already
does. The name-per-OS helpers now emit:

  shared:  ghostty-internal.dll (Windows) / ghostty-internal.so (other)
  static:  ghostty-internal-static.lib (Windows) / ghostty-internal.a

Direct paths sidestep the GNU-ld -l<name> search template, which
expects libghostty-internal.so/.a on Unix - we drop the lib prefix to
match the ghostty-internal pkg-config module name.

Also update the LipoStep out_name for the macOS universal static
archive to ghostty-internal.a for consistency.
2026-04-11 03:00:39 +02:00
Alessandro De Blasis
4fd16ef9bc build: install ghostty-internal dll/static with new names
Rename the internal library's install names to match the new
ghostty-internal pkg-config module convention:

  ghostty.dll          -> ghostty-internal.dll
  ghostty-static.lib   -> ghostty-internal-static.lib
  libghostty.so        -> ghostty-internal.so
  libghostty.a         -> ghostty-internal.a

This is the glue library between Ghostty's app shells and the GUI
core, historically (mis)named "libghostty". It is not the public
libghostty-vt API.
2026-04-11 02:59:50 +02:00
Mitchell Hashimoto
7421b4b13f libghostty: add convenience accessors for kitty graphics (#12229)
Add three sized structs that let callers fetch all image, placement, or
rendering metadata in a single call instead of many individual queries.
This is an optimization for environments with high per-call overhead
such as FFI or Cgo.

GhosttyKittyGraphicsImageInfo is returned via image_get() with the new
GHOSTTY_KITTY_IMAGE_DATA_INFO data kind. It bundles id, number, width,
height, format, compression, data pointer, and data length.

GhosttyKittyGraphicsPlacementInfo is returned via placement_get() with
the new GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_INFO data kind. It bundles
image id, placement id, virtual flag, offsets, source rect, columns,
rows, and z-index.

GhosttyKittyGraphicsPlacementRenderInfo is returned by the new
ghostty_kitty_graphics_placement_render_info() function, which combines
pixel size, grid size, viewport position, and resolved source rectangle.
This one requires image and terminal handles so it does not fit the
existing _get() pattern and is a dedicated function.

All three use the sized-struct ABI pattern with GHOSTTY_INIT_SIZED for
forward compatibility.
2026-04-10 14:26:28 -07:00
Mitchell Hashimoto
3295bf40a7 libghostty: add convenience accessors for kitty graphics
Add three sized structs that let callers fetch all image, placement,
or rendering metadata in a single call instead of many individual
queries. This is an optimization for environments with high per-call
overhead such as FFI or Cgo.

GhosttyKittyGraphicsImageInfo is returned via image_get() with the
new GHOSTTY_KITTY_IMAGE_DATA_INFO data kind. It bundles id, number,
width, height, format, compression, data pointer, and data length.

GhosttyKittyGraphicsPlacementInfo is returned via placement_get()
with the new GHOSTTY_KITTY_GRAPHICS_PLACEMENT_DATA_INFO data kind.
It bundles image id, placement id, virtual flag, offsets, source
rect, columns, rows, and z-index.

GhosttyKittyGraphicsPlacementRenderInfo is returned by the new
ghostty_kitty_graphics_placement_render_info() function, which
combines pixel size, grid size, viewport position, and resolved
source rectangle. This one requires image and terminal handles so
it does not fit the existing _get() pattern and is a dedicated
function.

All three use the sized-struct ABI pattern with GHOSTTY_INIT_SIZED
for forward compatibility.
2026-04-10 14:16:24 -07:00
Jeffrey C. Ollie
d3ce8926b9 build: skip ghostty-test graph when building libghostty-vt (#12224)
Fixes #12151

When `emit_lib_vt` is true, the `// Tests` block was still
evaluated, pulling in the full ghostty-test dependency graph
(freetype, zlib, dcimgui, etc.). This causes the Nix
`libghostty-vt` package to fail when `doCheck` is enabled,
since those system libraries aren't available in the sandbox.

Guard the block with `if (!config.emit_lib_vt)`, following
the existing pattern at line 179.
2026-04-10 13:41:11 -05:00
Mitchell Hashimoto
c34901dddb libghostty: add log callback configuration (#12227)
In C ABI builds, the Zig std.log default writes to stderr which is not
appropriate for a library. Override std_options.logFn with a custom sink
that dispatches to an embedder-provided callback, or silently discards
when none is registered.

Add GHOSTTY_SYS_OPT_LOG to ghostty_sys_set() following the existing
decode_png pattern. The callback receives the log level as a
GhosttySysLogLevel enum, scope and message as separate byte slices,
giving embedders full control over formatting and routing.

Export ghostty_sys_log_stderr as a built-in convenience callback that
writes to stderr using std.debug.lockStderrWriter for thread-safe
output. Embedders who want the old behavior can install it at startup
with a single ghostty_sys_set call.
2026-04-10 11:03:18 -07:00
Mitchell Hashimoto
aa6943da37 libghostty: add log callback configuration
In C ABI builds, the Zig std.log default writes to stderr which is
not appropriate for a library. Override std_options.logFn with a
custom sink that dispatches to an embedder-provided callback, or
silently discards when none is registered.

Add GHOSTTY_SYS_OPT_LOG to ghostty_sys_set() following the existing
decode_png pattern. The callback receives the log level as a
GhosttySysLogLevel enum, scope and message as separate byte slices,
giving embedders full control over formatting and routing.

Export ghostty_sys_log_stderr as a built-in convenience callback that
writes to stderr using std.debug.lockStderrWriter for thread-safe
output. Embedders who want the old behavior can install it at startup
with a single ghostty_sys_set call.
2026-04-10 10:52:45 -07:00
Mitchell Hashimoto
7127abfe28 cmake: add ghostty_vt_add_target() for cross-compilation (#12212)
Add a ghostty_vt_add_target() CMake function that lets downstream
projects build libghostty-vt for a specific Zig target triple. The
function encapsulates zig discovery, build-type-to-optimize mapping, the
zig build invocation, and output path conventions so consumers do not
need to duplicate any of that logic. It creates named IMPORTED targets
(e.g. ghostty-vt-static-linux-amd64) that work alongside the existing
native ghostty-vt and ghostty-vt-static targets.

The build-type mapping is factored into a shared _GHOSTTY_ZIG_OPT_FLAG
variable used by both the native build and the new function.

A new example/c-vt-cmake-cross/ demonstrates end-to-end cross-
compilation using zig cc as the C compiler, auto-detecting a cross
target based on the host OS.
2026-04-10 08:00:03 -07:00
ghostty-vouch[bot]
b5d54d8f51 Update VOUCHED list (#12225)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/12223#discussioncomment-16518906)
from @jcollie.

Vouch: @kataokatsuki

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-10 14:31:37 +00:00
Alessandro De Blasis
dd04856482 build: add ghostty-internal pkg-config modules (shared + static) 2026-04-10 16:12:23 +02:00
Mitchell Hashimoto
f2e299fb46 cmake: add ghostty_vt_add_target() for cross-compilation
Add a ghostty_vt_add_target() CMake function that lets downstream
projects build libghostty-vt for a specific Zig target triple. The
function encapsulates zig discovery, build-type-to-optimize mapping,
the zig build invocation, and output path conventions so consumers
do not need to duplicate any of that logic. It creates named IMPORTED
targets (e.g. ghostty-vt-static-linux-amd64) that work alongside the
existing native ghostty-vt and ghostty-vt-static targets.

The build-type mapping is factored into a shared _GHOSTTY_ZIG_OPT_FLAG
variable used by both the native build and the new function.

The static library targets now propagate c++ as a link dependency on
non-Windows platforms, fixing link failures when consumers use static
linking with the default SIMD-enabled build.

A new example/c-vt-cmake-cross/ demonstrates end-to-end cross-
compilation using zig cc as the C compiler, auto-detecting a cross
target based on the host OS.
2026-04-10 06:52:09 -07:00
kataokatsuki
85be3ca2c1 build: skip ghostty-test graph when building libghostty-vt
Fixes #12151
2026-04-10 22:41:16 +09:00
Mitchell Hashimoto
19b0ed2bdf macOS: double click title to enlarge window (#12219)
Previously with `macos-titlebar-style = tabs`, double clicking title
would do nothing
2026-04-10 06:18:11 -07:00
Mitchell Hashimoto
d51e94f7eb macOS: fix tab title editor frame update during winding resizing (#12220)
https://github.com/user-attachments/assets/69bee4f9-e3e1-4dc7-8e9c-c395572d2dbf
2026-04-10 06:17:35 -07:00
Lukas
41c872c1f4 macOS: fix tab title editor frame update during winding resizing 2026-04-10 13:57:09 +02:00
Lukas
e7f58ad72e macOS: double click title to enlarge window
Previously with `macos-titlebar-style	= tabs`, double clicking title will do nothing
2026-04-10 13:41:53 +02:00
ghostty-vouch[bot]
1348e04626 Update VOUCHED list (#12216)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/12213#discussioncomment-16512677)
from @pluiedev.

Vouch: @otomn

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-10 06:52:01 +00:00
Mitchell Hashimoto
48a01b8bd5 build: add libghostty-vt-static pkg-config module (#12210)
Keep libghostty-vt.pc as the shared/default pkg-config module so
`pkg-config --static libghostty-vt` continues to emit the historical
`-lghostty-vt` flags. This preserves the old behavior for consumers that
still want it, even though that form remains ambiguous on macOS when
both the dylib and archive are installed in the same directory.

Add a separate libghostty-vt-static.pc module for consumers that need an
unambiguous static link. Its `Libs:` entry points directly at the
installed archive so macOS does not resolve the request to the dylib.

Update the Nix packaging to rewrite the new static module into the `dev`
output, use it in the static-link smoke test, and add a compatibility
check that covers both pkg-config entry points.
2026-04-09 20:38:03 -07:00
Mitchell Hashimoto
a82e156925 build: add libghostty-vt-static pkg-config module
Keep libghostty-vt.pc as the shared/default pkg-config module so
`pkg-config --static libghostty-vt` continues to emit the historical
`-lghostty-vt` flags. This preserves the old behavior for consumers
that still want it, even though that form remains ambiguous on macOS
when both the dylib and archive are installed in the same directory.

Add a separate libghostty-vt-static.pc module for consumers that need
an unambiguous static link. Its `Libs:` entry points directly at the
installed archive so macOS does not resolve the request to the dylib.

Update the Nix packaging to rewrite the new static module into the `dev`
output, use it in the static-link smoke test, and add a compatibility
check that covers both pkg-config entry points.
2026-04-09 20:27:30 -07:00