Commit Graph

15741 Commits

Author SHA1 Message Date
Mitchell Hashimoto
e89b2c88f3 libghostty: introduce the kitty graphics opaque type 2026-04-06 08:56:23 -07:00
Mitchell Hashimoto
f65fb3d442 libghostty: expose Kitty image configs, decode png callback from C API (#12144)
This exposes the APIs necessary to enable Kitty image protocol parsing
and state from the C API.

* You can now set the PNG decoder via the `ghostty_sys_set` API.
* You can set Kitty image configs via `ghostty_terminal_set` API.
* An example showing this working has been added.
* **You cannot yet query Kitty images for metadata or rendering.** I'm
going to follow that up in a separate PR.
2026-04-06 08:46:21 -07:00
Mitchell Hashimoto
64340c62bf example: add c-vt-kitty-graphics
Demonstrates the sys interface for Kitty Graphics Protocol PNG
support. The example installs a PNG decode callback via
ghostty_sys_set, creates a terminal with image storage enabled,
and sends an inline 1x1 PNG image through vt_write. Snippet
markers are wired up to the sys.h doxygen docs.
2026-04-06 08:05:29 -07:00
Mitchell Hashimoto
d7fa92088c libghostty: expose sys interface to C API
The terminal sys module provides runtime-swappable function pointers
for operations that depend on external implementations (e.g. PNG
decoding). This exposes that functionality through the C API via a
ghostty_sys_set() function, modeled after the ghostty_terminal_set()
enum-based option pattern.

Embedders can install a PNG decode callback to enable Kitty Graphics
Protocol PNG support. The callback receives a userdata pointer
(set via GHOSTTY_SYS_OPT_USERDATA) and a GhosttyAllocator that must
be used to allocate the returned pixel data, since the library takes
ownership of the buffer. Passing NULL clears the callback and
disables the feature.
2026-04-06 07:45:16 -07:00
Mitchell Hashimoto
8ae80892ba macos: fix dock icon badge permission (#12133)
The previous version requested general notification permissions but
omitted the `.badge` option. Because the initial request was granted,
`settings.authorizationStatus` returns `.authorized`, leading the app to
believe it has full notification privileges when it actually lacks the
authority to update the dock icon badge.

Debug hint:
You can reset the notification settings by right-clicking on the app
name.
<img width="307" height="85" alt=""
src="https://github.com/user-attachments/assets/660cd332-eda6-45d6-8bfd-a6f9e28e21e8"
/>
2026-04-06 07:31:36 -07:00
Mitchell Hashimoto
fd884bc532 macOS: force surface layout sync in updateOSView (#12143)
`updateOSView` assumed SwiftUI always propagates frame changes to the
scroll view. Under system load, this can be deferred, leaving the
surface rendering at stale dimensions. Check for size mismatch and mark
layout as needed.


<img width="1408" height="464" alt="ghostty_bug"
src="https://github.com/user-attachments/assets/3a6f81ff-9d02-4ffa-aded-e2eddc9f40a5"
/>

---
AI Disclosure: Used Claude Code for PR preparation.
2026-04-06 07:31:28 -07:00
Mitchell Hashimoto
3a52e0e3bd libghostty: expose kitty image options via terminal set/get
Add four new terminal options for configuring Kitty graphics at runtime
through the C API: storage limit, and the three loading medium flags
(file, temporary file, shared memory).

The storage limit setter propagates to all initialized screens and
uses setLimit which handles eviction when lowering the limit. The
medium setters similarly propagate to all screens. Getters read from
the active screen. All options compile to no-ops or return no_value
when kitty graphics are disabled at build time.
2026-04-06 07:21:05 -07:00
Mitchell Hashimoto
c9c3c701e2 terminal: make wuffs runtime-swappable, enable Kitty graphics for libvt (#12117)
This enables Kitty Graphics for `libghostty-vt` for the Zig API (C to
come next).

First, a note on security: by default, Kitty graphics will only allow
images transferred via the _direct_ medium (directly via the pty) and
will not allow file or shared memory based images. libghostty-vt
consumers need to manually opt-in via terminal init options or
`terminal.setKittyGraphicsLoadingLimits` to enable file-based things.
**This is so we're as secure as possible by default.**

Second, for PNG decoding, embedders must now set a global
runtime-callback at `ghostty.sys.decode_png`. If this is not set, PNG
formatted images are rejected. If this is set, then we'll use this to
decode and embedders can use any decoder they want.

There is no C API exposed yet to set this, so this is only for Zig to
start.

## Examples (Zig)

### Configuring Allowed Formats

```zig
var term = try Terminal.init(alloc, .{
    .cols = 80,
    .rows = 24,
    // Only allow direct (inline) image data, no file/shm access.
    // This is the default so you don't need to specify it.
    .kitty_image_loading_limits = .direct,
});
```

```zig
var term = try Terminal.init(alloc, .{
    .cols = 80,
    .rows = 24,
    // Allow all transmission mediums: direct, file, temporary file, shared memory.
    .kitty_image_loading_limits = .all,
});
```

```zig
var term = try Terminal.init(alloc, .{
    .cols = 80,
    .rows = 24,
    .kitty_image_loading_limits = .{
        .file = true,
        .temporary_file = true,
        .shared_memory = false,
    },
});
```

### Iterate all images

```zig
var it = term.screens.active.kitty_images.images.iterator();
while (it.next()) |kv| {
    const img = kv.value_ptr;
    std.debug.print("id={} {}x{} format={} bytes={}\n", .{
        img.id, img.width, img.height, img.format, img.data.len,
    });
}
```

### Delete all images

```zig
term.screens.active.kitty_images.delete(alloc, &term, .{ .all = true });
```
2026-04-06 06:57:14 -07:00
Mitchell Hashimoto
810ebae8e8 terminal: lower default kitty image storage limit for libghostty
The default kitty image storage limit was 320 MB for all build
artifacts. For libghostty, this is overly generous since it is an
embedded library where conservative memory usage is preferred.
Lower the default to 10 MB when building as the lib artifact while
keeping the 320 MB default for the full Ghostty application.
2026-04-06 06:56:20 -07:00
fru1tworld
13f7d23145 macOS: force layout sync when frame size mismatches GeometryReader 2026-04-06 19:22:47 +09:00
ghostty-vouch[bot]
841a49ae1a Update VOUCHED list (#12138)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/12137#discussioncomment-16460337)
from @rhodes-b.

Vouch: @neurosnap

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-06 04:31:17 +00:00
ghostty-vouch[bot]
4f543ff3d8 Update VOUCHED list (#12135)
Triggered by
[comment](https://github.com/ghostty-org/ghostty/issues/12133#issuecomment-4189589541)
from @jcollie.

Vouch: @KayLeung

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-05 21:54:29 +00:00
Kay Leung
e390937867 macos: fix badge permission
The previous version requested general notification permissions but omitted the `.badge` option. Because the initial request was granted, `settings.authorizationStatus` returns `.authorized`, leading the app to believe it has full notification privileges when it actually lacks the authority to update the dock icon badge.
2026-04-06 05:19:25 +08:00
Mitchell Hashimoto
306acc4941 terminal/kitty: use direct medium for tests if we're not using files 2026-04-05 07:22:44 -07:00
Mitchell Hashimoto
935d37fbf1 terminal: add kitty image limits to Terminal.Options
Move kitty_image_storage_limit and kitty_image_loading_limits into
Terminal.Options so callers can set them at construction time
rather than calling setter functions after init. The values flow
through to Screen.Options during ScreenSet initialization. Termio
now passes both at construction, keeping the setter functions for
the updateConfig path.
2026-04-05 07:21:15 -07:00
Mitchell Hashimoto
64dcb91c1f terminal/kitty: add loading limits to kitty graphics protocol
Add a Limits type to LoadingImage that controls which transmission
mediums (file, temporary_file, shared_memory) are allowed when
loading images. This defaults to "direct" (most restrictive) on
ImageStorage and is set to "all" by Termio, allowing apprt
embedders like libghostty to restrict medium types for resource or
security reasons.

The limits are stored on ImageStorage, plumbed through
Screen.Options for screen initialization and inheritance, and
enforced in graphics_exec during both query and transmit. Two new
Terminal methods (setKittyGraphicsSizeLimit, setKittyGraphicsLoadingLimits)
centralize updating all screens, replacing the manual iteration
previously done in Termio.
2026-04-05 07:18:45 -07:00
Mitchell Hashimoto
6a99c248d0 terminal/kitty: add Limits to restrict capabilities of image transfer 2026-04-05 07:08:30 -07:00
ghostty-vouch[bot]
ba398dfff3 Update VOUCHED list (#12123)
Triggered by
[comment](https://github.com/ghostty-org/ghostty/issues/12119#issuecomment-4188681042)
from @bo2themax.

Vouch: @jamylak

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-05 10:38:47 +00:00
Mitchell Hashimoto
29e3de737e terminal: make wuffs runtime-swappable, enable Kitty graphics for libvt
Introduce terminal/sys.zig which provides runtime-swappable function
pointers for operations that depend on external implementations. This
allows embedders of the terminal package to swap out implementations
at startup without hard dependencies on specific libraries.

The first function exposed is decode_png, which defaults to a wuffs
implementation. The kitty graphics image loader now calls through
sys.decode_png instead of importing wuffs directly.

This allows us to enable Kitty graphics support in libghostty-vt
for all targets except wasm32-freestanding.
2026-04-04 22:01:38 -07:00
Mitchell Hashimoto
c541ceb120 terminal: add APC handler to stream_terminal (#12116)
Wire up the APC handler to `terminal.TerminalStream` to process APC
sequences, enabling support for kitty graphics commands in libghostty,
in theory.

The "in theory" is because we still don't export a way to actually
enable Kitty graphics in libghostty because we have some other things in
the way: PNG decoding and OS filesystem access that need to be more
conditionally compiled before we can enable the feature. However, this
is a step in the right direction, and we can at least verify that the
APC handler works via a test in Ghostty GUI.
2026-04-04 21:21:10 -07:00
Mitchell Hashimoto
a8e92c9c53 terminal: add APC handler to stream_terminal
Wire up the APC handler to `terminal.TerminalStream` to process
APC sequences, enabling support for kitty graphics commands in 
libghostty, in theory.

The "in theory" is because we still don't export a way to actually
enable Kitty graphics in libghostty because we have some other things in
the way: PNG decoding and OS filesystem access that need to be more 
conditionally compiled before we can enable the feature. However, this
is a step in the right direction, and we can at least verify that the
APC handler works via a test in Ghostty GUI.
2026-04-04 21:11:31 -07:00
Mitchell Hashimoto
10696b5ed1 libghostty: add GhosttySelection type and selection support to formatter (#12115)
Add a new GhosttySelection C API type (selection.h / c/selection.zig)
that pairs two GhosttyGridRef endpoints with a rectangle flag. This maps
directly to the internal Selection type using untracked pins.

The formatter terminal options gain an optional selection pointer. When
non-null the formatter restricts output to the specified range instead
of emitting the entire screen. When null the existing behavior of
formatting the full screen is preserved.
2026-04-04 20:48:39 -07:00
Mitchell Hashimoto
86554de090 libghostty: add hyperlink URI accessor to grid_ref API (#12114)
Add ghostty_grid_ref_hyperlink_uri to extract the OSC 8 hyperlink URI
from a cell at a grid reference position. Follows the same buffer
pattern as ghostty_grid_ref_graphemes: callers pass a buffer and get
back the byte length, or GHOSTTY_OUT_OF_SPACE with the required size if
the buffer is too small. Cells without a hyperlink return success with
length 0.
2026-04-04 20:39:07 -07:00
Mitchell Hashimoto
757eff5881 libghostty: add GhosttySelection type and selection support to formatter
Add a new GhosttySelection C API type (selection.h / c/selection.zig)
that pairs two GhosttyGridRef endpoints with a rectangle flag. This
maps directly to the internal Selection type using untracked pins.

The formatter terminal options gain an optional selection pointer.
When non-null the formatter restricts output to the specified range
instead of emitting the entire screen. When null the existing
behavior of formatting the full screen is preserved.
2026-04-04 20:38:05 -07:00
Mitchell Hashimoto
b9a241d1e2 libghostty: add hyperlink URI accessor to grid_ref API
Add ghostty_grid_ref_hyperlink_uri to extract the OSC 8 hyperlink
URI from a cell at a grid reference position. Follows the same
buffer pattern as ghostty_grid_ref_graphemes: callers pass a buffer
and get back the byte length, or GHOSTTY_OUT_OF_SPACE with the
required size if the buffer is too small. Cells without a hyperlink
return success with length 0.
2026-04-04 20:28:13 -07:00
ghostty-vouch[bot]
cf8a2407a0 Update VOUCHED list (#12113)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/12098#discussioncomment-16452103)
from @mitchellh.

Vouch: @fru1tworld

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-05 03:17:59 +00:00
Jeffrey C. Ollie
0a4cf5877e nix: add option to disable simd in libghostty-vt package (#12103) 2026-04-04 16:06:26 -05:00
Jeffrey C. Ollie
1bd7c19dac nix: add option to disable simd in libghostty-vt package 2026-04-04 15:06:19 -05:00
Mitchell Hashimoto
0a492fdb33 build: add pkg-config static linking support and fat archives to libghostty (#12096)
The libghostty-vt pkg-config file was missing Libs.private, so
pkg-config --libs --static returned the same flags as the shared case,
omitting the C++ standard library needed by the SIMD code.

Additionally, the static archive did not bundle the vendored SIMD
dependencies (simdutf, highway, utfcpp), leaving consumers with
unresolved symbols when linking. If we're choosing to vendor (no -fsys)
then we should produce a fat static archive that includes them. If
`-fsys` is used, then we should not bundle them and instead reference
them via Requires.private, letting pkg-config chain to their own .pc
files.

Add Libs.private with the C++ runtime (-lc++ on Darwin, -lstdc++ on
Linux) and Requires.private for any SIMD deps provided via system
integration. When SIMD deps are vendored (the default), produce a fat
static archive that bundles them using libtool on Darwin and ar on
Linux. When they come from the system (-fsys=), reference them via
Requires.private instead, letting pkg-config chain to their own .pc
files.
2026-04-04 06:56:19 -07:00
Mitchell Hashimoto
e157dd69c5 build: add pkg-config static linking support and fat archives to libghostty
The libghostty-vt pkg-config file was missing Libs.private, so
pkg-config --libs --static returned the same flags as the shared
case, omitting the C++ standard library needed by the SIMD code.

Additionally, the static archive did not bundle the vendored SIMD
dependencies (simdutf, highway, utfcpp), leaving consumers with
unresolved symbols when linking. If we're choosing to vendor (no -fsys)
then we should produce a fat static archive that includes them. If `-fsys`
is used, then we should not bundle them and instead reference them via
Requires.private, letting pkg-config chain to their own .pc files.

Add Libs.private with the C++ runtime (-lc++ on Darwin, -lstdc++
on Linux) and Requires.private for any SIMD deps provided via
system integration. When SIMD deps are vendored (the default),
produce a fat static archive that bundles them using libtool on
Darwin and ar on Linux. When they come from the system (-fsys=),
reference them via Requires.private instead, letting pkg-config
chain to their own .pc files.
2026-04-04 06:54:42 -07:00
Mitchell Hashimoto
707cd57acb add a nix package (with CI tests) for libghostty-vt (#12090) 2026-04-03 20:12:52 -07:00
ghostty-vouch[bot]
e3bbd54dd3 Update VOUCHED list (#12094)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/12093#discussioncomment-16444399)
from @jcollie.

Vouch: @jordandm

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-04 01:46:07 +00:00
Jeffrey C. Ollie
326178adb8 nix: address review comments
* split out dev subpackage
* change version number to 0.1.0
* supported on same platforms as Zig
2026-04-03 20:19:50 -05:00
Jeffrey C. Ollie
4f825e87f5 add a nix package (with CI tests) for libghostty-vt 2026-04-03 16:28:21 -05:00
Mitchell Hashimoto
0790937d03 macOS: fix Find Next/Previous button in the menu bar is not working as expected (#12070)
I don’t know why the search-related commands were added as performable
keybinds in 240d5e0fc5, but **I asked
Claude to add some tests for that**

> This won't fix cmd+g/G not working when the search bar is focused.
2026-04-02 12:56:39 -07:00
Lukas
18f2702225 macOS: fix Find Next/Previous button in the menu bar is not working as expected 2026-04-02 20:31:31 +02:00
ghostty-vouch[bot]
7747c96033 Update VOUCHED list (#12069)
Triggered by
[comment](https://github.com/ghostty-org/ghostty/issues/12068#issuecomment-4179350272)
from @jcollie.

Vouch: @Douglas-MacGregor

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-02 17:28:57 +00:00
ghostty-vouch[bot]
63372f8ddb Update VOUCHED list (#12066)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/12038#discussioncomment-16423690)
from @mitchellh.

Vouch: @h3nock

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-02 13:53:39 +00:00
ghostty-vouch[bot]
48d3e972d8 Update VOUCHED list (#12052)
Triggered by
[comment](https://github.com/ghostty-org/ghostty/issues/12050#issuecomment-4173393542)
from @mitchellh.

Vouch: @justonia

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-01 22:42:46 +00:00
Mitchell Hashimoto
b8251de7e8 fix: Ensure snap paths come first in gio module loading (#12045)
This fixes the issue reported in
https://github.com/ghostty-org/ghostty/discussions/11311
2026-04-01 14:32:27 -07:00
Mitchell Hashimoto
92a4601f39 Revert "macOS: close search bar if needed when it loses focus (#11980)" (#12046)
This reverts commit 20cfaae2e5, reversing
changes made to 3509ccf78e.

This breaks some behaviours when there are multiple splits, which
requires another click to focus to another split in the same window🫪
2026-04-01 14:32:09 -07:00
Ken VanDine
c16cf0ef07 fix: Ensure snap paths come first in gio module loading 2026-04-01 13:30:40 -04:00
Lukas
9ec5672505 Revert "macOS: close search bar if needed when it loses focus (#11980)"
This reverts commit 20cfaae2e5, reversing
changes made to 3509ccf78e.
2026-04-01 19:21:42 +02:00
Mitchell Hashimoto
f6e6bb0238 macOS: fix upper cased letter is not correctly mapped to menu shortcut (#12039)
This is known issues before key-related PRs, tested on
fa9265636b.

The following config is mapped incorrectly to the menu shortcut:
```
keybind=A=goto_split:left
```
<img width="223" height="106" alt="image"
src="https://github.com/user-attachments/assets/b80da251-9cff-4b29-b143-64854a5c4271"
/>

Surfaces only accept `a` as a trigger to select left split, not
`shift+a`
2026-04-01 08:10:47 -07:00
Leah Amelia Chen
6d15b53fc7 gtk(chore): fix typos (#12036) 2026-04-01 22:12:23 +08:00
Lukas
702a2b43c3 macOS: fix upper cased letter is not correctly mapped to menu shortcut 2026-04-01 14:50:53 +02:00
Lukas
c8702ece8f gtk(chore): fix typos
### AI Disclosure

Claude wrote the regex to ignore base64-encoded sequences
2026-04-01 13:08:55 +02:00
ghostty-vouch[bot]
b7e56044db Update VOUCHED list (#12031)
Triggered by
[comment](https://github.com/ghostty-org/ghostty/issues/12030#issuecomment-4167464133)
from @mitchellh.

Vouch: @Jarred-Sumner

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-01 04:59:00 +00:00
Jeffrey C. Ollie
c2dd7579e2 core/gtk: ensure that first surface gets marked as focused surface by app (#12029) 2026-03-31 15:29:18 -05:00
Jeffrey C. Ollie
0f6836c69f gtk: use surface id for notifications instead of pointer (#12028) 2026-03-31 15:07:47 -05:00