Commit Graph

16089 Commits

Author SHA1 Message Date
Mikel Larreategi
afb8fc7eb3 Update po/eu.po
Co-authored-by: kat <65649991+00-kat@users.noreply.github.com>
2026-05-01 13:51:01 +02:00
Mikel Larreategi
cbd43fd483 feature: add basque translation 2026-05-01 13:34:23 +02:00
Mitchell Hashimoto
4dcb09ada0 macos: suppress control-char input while composing (#12518)
macos: suppress control-char input while composing

When AppKit delivers a single C0 control character during marked-text
composition, Ghostty should treat it as input consumed by the composing
state instead of forwarding it to the terminal.

This prevents control-key IME actions, such as Japanese input shortcuts
like ctrl+h/j/m/n, from leaking into the terminal while composition is
still active. Printable text and non-composing control input continue
through the normal key path.

Refs #10460
Related: #2628, #4539
Vouched in #12169

Testing:
- xcodebuild test -scheme Ghostty -destination platform=macOS
-only-testing:GhosttyTests/SurfaceViewAppKitTests
- Manually tested Japanese IME control-key shortcuts on macOS

AI usage:
- OpenAI Codex helped investigate, implement, test, and refine this
change. I reviewed and tested the resulting code.
2026-04-30 06:48:58 -07:00
Mitchell Hashimoto
95b56eb525 macOS: fix focus state when toggling command palette from inline title editor (#12524)
A bug found while recording that menu fix.
> ~~Will link to an open issue if there is one.~~

When toggling the command palette from the inline title editor, the
first responder state of the surface is changed quickly from true to
false.

`makeFirstResponder:` is called by the title editor when finishing, but
it happens **after** the command palette is shown, so the `focused` is
set to `true` while the command palette is shown. (Could be an AppKit
issue as well, since the resign is not called after but the command
palette is receiving `keyDown`.)

Since `performKeyEquivalent(with:)` is called on all of the subviews
until one of the return `true` so the paste action is consumed by the
surface instead of the first responder (command palette).
2026-04-30 06:42:12 -07:00
Mitchell Hashimoto
1623daf21c macOS: enable copy only when there’s actual selected text (#12521)
This matches the `peformable` definition and the default behaviors of
text editing on macOS.
2026-04-30 06:41:04 -07:00
Mitchell Hashimoto
25cd206e25 chore(macOS): remove Ghostty.xctestplan in project tree. (#12520)
`lastKnownFileType = file` will change to `text` if you checking out
branches with Xcode opened. But this was generated by Xcode in the first
place.

Anyway we don't need it to be in the project tree to run the tests, and
you can still open the test plan in scheme editor.
2026-04-30 06:39:09 -07:00
Mitchell Hashimoto
83ae47191a Fall back to Zig-bundled Darwin headers when an SDK can't be found (#12534)
Currently, cross to Darwin uses the Darwin headers bundled with Zig.
However, if you're running a build _on_ Darwin, an error is thrown if
the SDK can't be found, even though the bundled headers are still
available.

Now, we continue to search for and prefer the installed SDK, but if it
can't be found, we fall back to the bundled headers rather than failing
the build.
2026-04-30 06:38:41 -07:00
ghostty-vouch[bot]
f5664cd7b0 Update VOUCHED list (#12533)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/12530#discussioncomment-16765566)
from @jcollie.

Vouch: @Samasaur1

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-30 06:29:58 +00:00
Sam
f8f3b6f694 Fall back to Zig-bundled Darwin headers when an SDK can't be found
Currently, cross to Darwin uses the Darwin headers bundled with Zig.
However, if you're running a build _on_ Darwin, an error is thrown if
the SDK can't be found, even though the bundled headers are still
available.

Now, we continue to search for and prefer the installed SDK, but if it
can't be found, we fall back to the bundled headers rather than failing
the build.
2026-04-29 22:15:20 -07:00
Lukas
61595b5ec9 macOS: fix focus state when toggling command palette from inline title editor 2026-04-29 22:41:18 +02:00
Lukas
6fdca6bb53 macOS: enable copy only when there’s actual selected text 2026-04-29 19:33:09 +02:00
Lukas
dbffe994db chore: remove Ghostty.xctestplan in project tree.
`lastKnownFileType = file` will change to `text` if you checking out branches with Xcode opened. But this was generated by Xcode in the first place.

Anyway we don't need it to be in the project tree to run the tests, and you can still open the test plan in scheme editor.
2026-04-29 19:24:03 +02:00
Akinori Musha
a43cc02ebd macos: suppress control-char input while composing
When AppKit delivers a single C0 control character during
marked-text composition, Ghostty should treat it as input consumed by
the composing state instead of forwarding it to the terminal.

This prevents control-key IME actions, such as Japanese input
shortcuts like ctrl+h/j/m/n, from leaking into the terminal while
composition is still active. Printable text and non-composing control
input continue through the normal key path.

AI usage: OpenAI Codex helped investigate, implement, test, and refine
this change. I reviewed and tested the resulting code.
2026-04-29 22:50:35 +09:00
Mitchell Hashimoto
6590196661 Fix speedy high-resolution scrolling on Linux (#12483)
Enforcing an absolute minimum of 1 for scroll events causes differing
scroll speeds between high-resolution and standard scroll wheels on
Linux. Since this was added to handle MacOS's precision scrolling
emulation, this patch alters the behaviour so that the absolute minimum
is only enforced on MacOS.

NB: This can't just be fixed by adjusting `mouse-scroll-multiplier`
since that affects *all* scroll events whether they're high-resolution
or not. Reducing `mouse-scroll-multiplier` to handle high-res scroll
events better makes scrolling unusably slow for regular scroll wheels
connected to the same machine.

Fixes #11648.
2026-04-27 13:33:46 -07:00
Aditya Bhargava
5871a2d4f0 zig-fmt cleanup 2026-04-27 16:28:23 -04:00
Aditya Bhargava
154169b054 Fix speedy high-resolution scrolling on Linux
Enforcing an absolute minimum of 1 for scroll events causes differing
scroll speeds between high-resolution and standard scroll wheels on
Linux. Since this was added to handle MacOS's precision scrolling
emulation, this patch alters the behaviour so that the absolute minimum
is only enforced on MacOS.

Fixes #11648.
2026-04-27 16:28:23 -04:00
Mitchell Hashimoto
2cbe706276 macOS: fix keybindings for end_search not working correctly (#12492)
This now fixes #11410 completely, `navigate_search:next` and
`navigate_search:previous` are already fixed in
18f2702225.

Also fixes: surface is not focused after ending search via menu bar
2026-04-27 13:14:08 -07:00
Mitchell Hashimoto
8925a91c5c update zon2nix to 0.5.0 (#12488)
fix hash outputs for flatpak
2026-04-27 13:13:46 -07:00
Jeffrey C. Ollie
acbaa47de5 switch back to older nixpkgs 2026-04-27 13:53:02 -05:00
Jeffrey C. Ollie
8f3d9b4690 update zon2nix to 0.5.0
fix hash outputs for flatpak
build with Zig 0.16 from nixpkgs
(which required fixing prettier reference in devShell.nix)
2026-04-27 12:42:04 -05:00
Lukas
97c5a21aba macOS: fix ending search in menu bar does focus on surface 2026-04-27 19:03:06 +02:00
Lukas
1df7a5d3f3 macOS: update keybind for end_search 2026-04-27 18:55:31 +02:00
Mitchell Hashimoto
34cbb5fa81 feat: add middle-click action configuration (#12478)
This PR addresses
https://github.com/ghostty-org/ghostty/discussions/12108 implemented
similarly to https://github.com/ghostty-org/ghostty/pull/8254 to allow
middle click + TrackPoint scrolling on MacOS. `primary-paste` naming
comes from `gtk_enable_primary_paste`.

The following configuration values for `middle-click-action` are
provided:
- `primary-paste` - Paste from the selection (or system) clipboard per
`copy-on-select`.
- `ignore` - Do nothing, ignore the middle click.

Tested locally on macOS with Zig 0.15.2 using `zig build
-Doptimize=ReleaseFast`.

Thank you!
2026-04-27 09:29:29 -07:00
Mitchell Hashimoto
0b56ae2cc7 gtk: fix quick terminal breaking when manually toggled off while auto-hide is enabled (#12471)
Fixes quick terminal breaking when auto-hide is enabled and quick
terminal is manually toggled off (#11679).

`quick-terminal-autohide` is implemented by the `Window.propIsActive`
function in `apprt/gtk/class/window.zig` which calls
`Window.toggleVisibility` when the quick terminal window becomes
inactive (loses focus). However `Window.propIsActive` is also triggered
when you manually hide the quick terminal because hiding it causes the
window to become inactive. Normally that should just toggle the quick
terminal off and immediately back on, but there is also a re-entrancy
issue. Manually toggling off the terminal causes the
`Application.toggleQuickTerminal` (in `apprt/gtk/class/application.zig`)
to run which sets off the call chain `Window.toggleVisibility ->
gtk_widget_set_visible -> ... GTK signal/event handling ... ->
Window.propIsActive -> Window.toggleVisibility ->
gtk_widget_set_visible`.
The nested calls to `gtk_widget_set_visible` cause the GTK window state
to become corrupted. The window is marked visible, but is not actually
visible or just shows a placeholder. What exactly happens depends on the
compositor and how it handles moving window focus.

Reproduced the bug on KDE and hyprland and verified the fix on both.

### Changes

`apprt/gtk/class/window.zig`: added check to `Window.propIsActive` to
only toggle quick-terminal if it is inactive **and** visible.

### AI Disclosure

Found the bug without AI using "printf debugging" then traced it through
GTK with valgrind. Used GPT5.4 in setting up valgrind and researching
how signals/events move through GTK internally.
2026-04-27 09:26:24 -07:00
Mitchell Hashimoto
576d07ffc1 macOS: update tests and add test plan (#12473)
This updates UI tests and adds a test plan on disk, so we can change the
configuration to different ones with the host app.

If you changed the icon in regular ghostty config file, the tests can
only be run once, since the signature is changed after changing the
icon. Adding an on-disk test plan helps us to better control the
environment for the tests.
2026-04-27 09:25:51 -07:00
Mitchell Hashimoto
1ed22a5210 renderer: fix preedit range width (#12479)
Related to #12466

`Preedit.range()` returns an inclusive range, but the end position was
calculated as `start + w`. For wide preedit text, this covers one extra
cell.

In Debug builds, Korean IME composition between existing Hangul
characters can panic with:
`index out of bounds: index 2, len 2`

I reproduced this reliably when there are two Hangul characters to the
right of the cursor. For example, type `가나다`, move the cursor between
`가` and `나`, then start a new Korean IME composition. With the old range
calculation, the renderer skips the first wide character plus the head
cell of the next wide character, then resumes on that character's spacer
tail.

This changes the inclusive end to `start + (w - 1)` and adds focused
tests for narrow, wide, and right-edge preedit ranges.

This does not fully fix the visual behavior reported in #12466. The
adjacent character can still disappear during composition, so this PR
only fixes the crash side of the problem.
2026-04-27 09:24:55 -07:00
Mitchell Hashimoto
c19ce03b3e fix: update Se terminfo entry to reset cursor to configured default (#12487)
## Problem

Current `Se` sequence (reset cursor style) is `\E[2 q`, which always
sets steady block, regardless of user config.

## Solution

Update sequence to `\E[0 q`, which sets the cursor style to the user
configured default cursor.

fix https://github.com/ghostty-org/ghostty/issues/12482
Helps with neovim issue: https://github.com/neovim/neovim/issues/38987

## AI Disclosure

I didn't use AI for this, haha. Unless you count random questions to
learn about terminfo beforehand, but I relied on [legit
resources](https://invisible-island.net/xterm/terminfo.html) for real
info. It says:

>  Se resets the cursor style to the terminal power-on default.

I think the useful interpretation is to set the user configured default.
2026-04-27 09:23:51 -07:00
Mitchell Hashimoto
5031973623 input: remove translated in capi (#12490)
Follow up for a3462dd2bd

<img width="884" height="255" alt="image"
src="https://github.com/user-attachments/assets/da4e4dd5-e645-40ed-8e9c-0ed8c9aee1c4"
/>
2026-04-27 09:23:25 -07:00
Lukas
971753074b input: remove translated in capi
Follow up for a3462dd2bd
2026-04-27 13:39:51 +02:00
Kyle Sower
6c68650920 fix: update Se terminfo entry to reset cursor to configured default 2026-04-26 22:31:01 -05:00
ghostty-vouch[bot]
8769d32202 Update VOUCHED list (#12485)
Triggered by [discussion
comment](https://github.com/ghostty-org/ghostty/discussions/12484#discussioncomment-16723661)
from @jcollie.

Vouch: @kylesower

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-04-27 03:16:59 +00:00
dobbylee
ac67a6160c renderer: fix preedit range width 2026-04-27 01:17:43 +09:00
Andrei Lebedev
12ac19939c feat: add middle-click action configuration 2026-04-27 01:27:22 +10:00
Lukas
df365baf18 test: add test plan and override default config when running tests 2026-04-26 14:49:20 +02:00
Lukas
a7eaecf929 test: always use temporary config when running ui tests 2026-04-26 13:53:36 +02:00
Lukas
b66258806e test: only change themes in theme tests 2026-04-26 13:53:36 +02:00
Mitchell Hashimoto
c74f6d56d1 os: use GetTempPathW for allocTmpDir on Windows (#12469)
`allocTmpDir` previously read `%TMP%` via `getenvW` and returned `null`
if the variable wasn't set, requiring each caller to to deal with the
nullable. Unfortunately, there isn't a platform-neutral default value
that makes sense for those cases (i.e. `/tmp` is POSIX-y).

We now use `GetTempPathW` on Windows, which is the official way to get
this directory: `TMP` → `TEMP` → `USERPROFILE` → `GetWindowsDirectoryW`.

With a real system call behind it, the function no longer needs to be
nullable: the only remaining failure modes are OOM (propagated) and the
syscall itself failing or returning data we can't decode. In those later
cases, we use `C:\Windows\Temp` as a fallback, similar to how we use
`/tmp` in the POSIX case.

The Windows path always allocates so it still must be paired with
`freeTmpDir`, which matches the existing contract.

---

*AI Disclosure:* I verified the Windows path using Claude and Zig's
cross-compilation capabilities because I don't have a Windows
environment in which to test this. I do fully understand the code based
on my prior life as a Windows game developer though.
2026-04-25 20:49:54 -07:00
Mitchell Hashimoto
278041c4bc flatpak: terminate session if Ghostty disconnects from bus (#12427)
This makes sure that if Ghostty crashes, commands spawned are also
terminated automatically by the Flatpak Session Helper.

The few crashes I got left a lot of background processes, some of them
pretty heavy and took awhile to be figured out.
2026-04-25 20:49:33 -07:00
Jon Parise
8b90efd913 os: use GetTempPathW for allocTmpDir on Windows
`allocTmpDir` previously read `%TMP%` via `getenvW` and returned `null`
if the variable wasn't set, requiring each caller to to deal with the
nullable. Unfortunately, there isn't a platform-neutral default value
that makes sense for those cases (i.e. `/tmp` is POSIX-y).

We now use `GetTempPathW` on Windows, which is the official way to get
this directory: `TMP` → `TEMP` → `USERPROFILE` → `GetWindowsDirectoryW`.

With a real system call behind it, the function no longer needs to be
nullable: the only remaining failure modes are OOM (propagated) and the
syscall itself failing or returning data we can't decode. In those later
cases, we use `C:\Windows\Temp` as a fallback, similar to how we use
`/tmp` in the POSIX case.

The Windows path always allocates so it still must be paired with
`freeTmpDir`, which matches the existing contract.
2026-04-25 21:44:37 -04:00
Leorize
8b8f7136d0 flatpak: don't assume c_uint to be u32
Thanks pluie for the pointer.
2026-04-25 17:04:26 -07:00
Mitchell Hashimoto
67b5783bdd os: RANDOM_BASENAME_LEN -> random_basename_len (#12467) 2026-04-25 13:34:28 -07:00
Jon Parise
13ada38ac4 os: RANDOM_BASENAME_LEN -> random_basename_len 2026-04-25 16:29:25 -04:00
Mitchell Hashimoto
e9ca0f8c9a core: Acquire renderer state mutex before calling processLinks (#12463)
Holding the renderer state mutex is a documented precondition of
`processLinks`, but `mouseButtonCallback` previously called the function
without the mutex.

This creates a race with the I/O thread's `processOutput`, which can
prune scrollback pages while `processLinks` is reading them, resulting
in a use-after-free segfault. See
https://github.com/ghostty-org/ghostty/discussions/12409 (Linux: crash
while selecting text).


57b5e1e250/src/Surface.zig (L4354-L4355)


57b5e1e250/src/Surface.zig (L3822-L3824)

995e4e375 (os: open) changed the body of `processLinks` to be
non-trivial and documented the precondition, but the lock was not held
at the call site.
2026-04-25 13:21:38 -07:00
Mitchell Hashimoto
0e0bcafed5 macOS: remove manual invalidateRestorableState() (#12464)
This should be safe to delete now after #12461.

I tested saving 27 tabs, 4 with 2 splits,
`TerminalRestorable.encode(with:` finished successfully.

And I check the breakpoints when the Sparkle sends
`-[NSRunningApplication treminate]`. The call stack at `-[NSResponder
invalidateRestorableState]` is pretty much the same as quitting via
`cmd+q`.
2026-04-25 13:16:08 -07:00
Mitchell Hashimoto
aedf39f3bd macOS: support migrations when restoring window state (#12461)
First two commits fix the issue when upgrading from 1.2.x to 1.3.x.
(#11304)

> To double check if this pr really fixes the issue, you can either
archive a release build, sign with the same profile, and override
manually.
> 
> Or you can find the `savedState` files (located in `~/Library/Daemon\
Containers/<uuid>`), can copy them the local build dir (which is what I
did), and run the debug build.

Following commits add tests for migrations and some logs.

**Currently the minimum version is set to 1.2.x**, since there's a lot
changes comparing to 1.1.x. It will be difficult to restore
`Ghostty.SplitNode` -> `SplitTree<Ghostty.SurfaceView>` without
introducing a lot of checks.
2026-04-25 13:15:50 -07:00
Mitchell Hashimoto
8e1dfbcf3e os: add randomTmpPath for allocating temp paths (#12465)
Factor TempDir's name generation into a reusable `randomBasename` (16
random bytes, url-safe base64) and add `randomTmpPath` on top, which
composes `allocTmpDir` + `randomBasename` into a single allocated path
in the form `{TMPDIR}/{prefix}{random}` (`mktemp(1)`-ish).

This is convenient for callers who want a unique path under TMPDIR (for
a temporary file, socket, etc.) without having to think about basename
buffer sizing or path joining.

Also, use `std.base64.url_safe_no_pad.Encoder` instead of the custom
base64 alphabet, which is exactly equivalent.
2026-04-25 13:14:30 -07:00
Jon Parise
c9d2285f63 os: add randomTmpPath for allocating temp paths
Factor TempDir's name generation into a reusable `randomBasename` (16
random bytes, url-safe base64) and add `randomTmpPath` on top, which
composes `allocTmpDir` + `randomBasename` into a single allocated path
in the form `{TMPDIR}/{prefix}{random}` (mktemp(1)-ish).

This is convenient for callers who want a unique path under TMPDIR (for
a temporary file, socket, etc.) without having to think about basename
buffer sizing or path joining.

Also, use `std.base64.url_safe_no_pad.Encoder` instead of the custom
base64 alphabet, which is exactly equivalent.
2026-04-25 15:52:40 -04:00
Lukas
385376185c macOS: remove manual invalidateRestorableState() 2026-04-25 21:25:38 +02:00
Lukas
231f6f4c75 macOS: move the restoration logs 2026-04-25 21:06:20 +02:00
Lukas
72c03e7fb8 macOS: add window restoration tests 2026-04-25 21:06:20 +02:00