Commit Graph

13665 Commits

Author SHA1 Message Date
Mitchell Hashimoto
e3dd5b93e6 gtk: pass through keypress when clipboard has no text (#10089)
## Summary

When `paste_from_clipboard` is triggered but the clipboard contains no
text (e.g., an image), the action now returns `false` to indicate it
couldn't be performed. This enables the `performable:` keybind prefix to
work correctly for paste actions.

## Problem

On GTK/Linux, when a user has `keybind = ctrl+v=paste_from_clipboard`
and the clipboard contains an image (not text), pressing Ctrl+V does
nothing. Applications like `opencode` that handle their own clipboard
reading via `wl-paste` never receive the keypress.

## Solution

Make `clipboardRequest` return `bool` to indicate whether the action
could be performed. For paste requests on GTK, synchronously check if
the clipboard contains text formats before starting the async read. When
no text format is available, return `false`.

Users can now use:
```
keybind = performable:ctrl+v=paste_from_clipboard
```

When the clipboard has no text, the keybind is not consumed and Ctrl+V
passes through to the terminal application.

## Changes

- `Surface.startClipboardRequest` now returns `bool`
- `paste_from_clipboard` / `paste_from_selection` actions return the
result
- GTK apprt checks clipboard formats synchronously before async read
- Embedded apprt always returns `true` (can't check synchronously)

## Testing

1. Add `keybind = performable:ctrl+v=paste_from_clipboard` to config
2. Copy an image to clipboard
3. Open an application that handles image paste (e.g., `opencode`)
4. Press Ctrl+V
5. Image pastes successfully (app receives keypress and handles
clipboard itself)

## Disclaimer

Most of the changes is done with Opus 4.5
2025-12-29 09:39:17 -08:00
cyppe
972b65eb1b review 2025-12-29 18:32:25 +01:00
Mitchell Hashimoto
560a58e0ea terminal: PageList needs to fix up viewport pin after row change (#10095)
From #10074

The test comments explain in detail. I also added a new integrity check
to validate this at runtime. All existing tests pass the integrity
check.
2025-12-29 09:15:23 -08:00
Mitchell Hashimoto
86d5048dad terminal: PageList needs to fix up viewport pin after row change
From #10074

The test comments explain in detail.
2025-12-29 09:12:25 -08:00
Mitchell Hashimoto
14a56e31a8 macOS: Split drag move (#10090)
Related to #1525

This implements a _Mouse-only_ approach to moving splits. When you hover
near the top of a split, a grab handle now appears that can be used to
drag the split into any other split position.

> [!NOTE]
>
> **This PR only lets you move splits to _other split positions_.** I
will create follow-up issues to track moving a split out into a new tab
or window.

## Demo


https://github.com/user-attachments/assets/fbeeff13-a03c-4e79-b4ba-95537d43c083

## Other Notes

This PR also lays a ton of the groundwork on macOS for surfaces to be
draggable and copyable (pasteboard) _in general_. That isn't used yet
but there might be some interesting ideas here like pasting screenshots
by simply dragging the surface. I don't know!
2025-12-29 08:29:34 -08:00
cyppe
8331447398 Improve type detection 2025-12-29 16:15:02 +01:00
Mitchell Hashimoto
c164e3bc02 macos: fix messy rebase 2025-12-29 07:13:25 -08:00
Mitchell Hashimoto
cfa3de5d9b macos: change style 2025-12-29 06:55:01 -08:00
Mitchell Hashimoto
1b1ff3d76c macos: add some unit tests 2025-12-29 06:55:01 -08:00
Mitchell Hashimoto
dbeeb952cc macos: fix dragging point 2025-12-29 06:55:01 -08:00
Mitchell Hashimoto
e56dce3d84 macos: don't create drop zone at all if self dragging 2025-12-29 06:55:01 -08:00
Mitchell Hashimoto
e1f22472f6 macos: convert the transferable to a nsdraggingitem 2025-12-29 06:55:01 -08:00
Mitchell Hashimoto
7b743164ef macos: fix iOS builds 2025-12-29 06:55:01 -08:00
Mitchell Hashimoto
be97b5bede macOS: convert Surface dragging to use NSDraggingSource 2025-12-29 06:55:01 -08:00
Mitchell Hashimoto
9b7124cf62 macos: use preference key to detect self dragging 2025-12-29 06:55:01 -08:00
Mitchell Hashimoto
5245757875 macos: all sorts of cleanups 2025-12-29 06:55:01 -08:00
Mitchell Hashimoto
1dd8e3ef4a macos: add GhosttyDelegate for global operations 2025-12-29 06:55:00 -08:00
Mitchell Hashimoto
9724541a33 macos: unify split callbacks into a single tagged enum 2025-12-29 06:55:00 -08:00
Mitchell Hashimoto
60bc5a9ae7 macos: clean up some SwiftUI nesting 2025-12-29 06:55:00 -08:00
Mitchell Hashimoto
5916755388 macos: drop splits across windows 2025-12-29 06:55:00 -08:00
Mitchell Hashimoto
8f8b5846c6 macos: hook up onDrop to move splits 2025-12-29 06:55:00 -08:00
Mitchell Hashimoto
d92fe44d0d macos: fix various iOS build errors 2025-12-29 06:55:00 -08:00
Mitchell Hashimoto
485b861342 macos: drag preview is an image of the surface 2025-12-29 06:55:00 -08:00
Mitchell Hashimoto
5d8c9357c0 macos: move around some functions 2025-12-29 06:55:00 -08:00
Mitchell Hashimoto
0a80f77766 macos: wire up onDrop 2025-12-29 06:55:00 -08:00
Mitchell Hashimoto
43d87cf9f8 macos: setup drop UI on our split views 2025-12-29 06:55:00 -08:00
Mitchell Hashimoto
ddfd4fe7c2 macos: export our ghostty surface ID type 2025-12-29 06:55:00 -08:00
Mitchell Hashimoto
304e2612ab macOS: work on drop destination 2025-12-29 06:55:00 -08:00
Mitchell Hashimoto
5045688623 macos: move grab handle to separate file 2025-12-29 06:55:00 -08:00
Mitchell Hashimoto
57bb636655 surfaceview as transferable 2025-12-29 06:55:00 -08:00
Mitchell Hashimoto
88adffd734 macOS: add handle to the top of surfaces that can be used to drag
UI only
2025-12-29 06:54:59 -08:00
Mitchell Hashimoto
ab232b3060 macos: move Ghostty surface view into dedicated folder 2025-12-29 06:54:59 -08:00
Mitchell Hashimoto
551031e41f macOS: move NSGlassEffectView into TerminalViewContainer (#10062)
- Fixes #9991
> Modifying the subview of NSThemeFrame seems "dangerous" and
unpredictable.
- Provides correct `intrinsicContentSize` as previous
`NSHostingView<TerminalView>` did
  > Fixes regression caused by #10046

> [!NOTE]
> AI Proofread some of my comments
2025-12-29 06:52:18 -08:00
Mitchell Hashimoto
76ad1f4563 Only use macOS 26.0 workarounds on macOS 26.0 (#10083)
Following up on my comment here about ripping out the NSScrollPocket
frame change observer in SurfaceScrollView once it's no longer needed:
https://github.com/ghostty-org/ghostty/pull/9446#issuecomment-3505314976

I tested the full macOS {26.0, 26.1, 26.2} times Xcode {26.0, 26.1,
26.2} matrix, and the fix was actually on the macOS side, i.e., the
workaround is always needed on macOS 26.0 and never on macOS 26.1+,
regardless of Xcode version. So if we want to avoid this kludge when
it's not needed, we have to use `#available` predicates rather than
removing the code outright.

I'll let maintainers judge whether the juice is worth the squeeze.

I also looked into the other 26.0-only workaround, pertaining to the
window title in the tabs titlebar, but I found that even though the
behavior with an empty view is OK on 26.1+, a warning about ambiguous
content size is still logged, so I figured this should be left as-is. I
updated the comment accordingly.
2025-12-29 06:51:30 -08:00
Mitchell Hashimoto
e5ef246e9a deps: update z2d to v0.10.0 (#10085)
Release notes at:
 https://github.com/vancluever/z2d/blob/v0.10.0/CHANGELOG.md

Mainly a maintenance update with regards to Ghostty use, with a couple
of minor changes required to some type references to match new API
semantics.

However, the new release does bring hairline stroking, if that's of any
interest 🙂
2025-12-29 06:50:30 -08:00
cyppe
0da650e7dd gtk: support performable keybinds for clipboard paste
Make clipboardRequest return bool to indicate whether the action could
be performed. For paste requests, synchronously check if the clipboard
contains text formats before starting the async read.

This allows 'performable:paste_from_clipboard' keybinds to pass through
when the clipboard contains non-text content (e.g., images), enabling
terminal applications to handle their own clipboard reading.

Changes:
- Surface.startClipboardRequest now returns bool
- paste_from_clipboard/paste_from_selection actions return the result
- GTK apprt checks clipboard formats synchronously before async read
- Embedded apprt always returns true (can't check synchronously)
- All other call sites discard the return value with _
2025-12-29 15:50:06 +01:00
cyppe
8a419e5526 gtk: pass through keypress when clipboard has no text
When paste_from_clipboard is triggered but the clipboard contains no
text (e.g., an image), send the raw Ctrl+V keypress to the terminal
instead of silently returning. This allows applications to handle
their own clipboard reading (e.g., via wl-paste for images on Wayland).
2025-12-29 09:58:09 +01:00
Chris Marchesi
6d36193378 deps: update z2d to v0.10.0
Release notes at:
 https://github.com/vancluever/z2d/blob/v0.10.0/CHANGELOG.md

Mainly a maintenance update with regards to Ghostty use, with a couple
of minor changes required to some type references to match new API
semantics.
2025-12-28 12:30:36 -08:00
Daniel Wennberg
b7a12effce Only use macOS 26.0 workarounds on macOS 26.0 2025-12-28 09:47:22 -08:00
Mitchell Hashimoto
52d8e1f44c build: fix pkgs for FBSD port runs (#10081)
Looks like this is the final piece (local builds are working). The FBSD
port is now building with no issues.
2025-12-28 06:07:00 -08:00
-k
e63a4ab774 build: fix pkgs for FBSD port runs 2025-12-28 07:21:58 -05:00
Mitchell Hashimoto
38664afde0 Update iTerm2 colorschemes (#10079)
Upstream release:
https://github.com/mbadolato/iTerm2-Color-Schemes/releases/tag/release-20251222-150520-0add1e1
2025-12-27 17:06:15 -08:00
mitchellh
03ecc9fdbf deps: Update iTerm2 color schemes 2025-12-28 00:16:19 +00:00
Mitchell Hashimoto
c00d7fc5c4 shell-integration: ensure clean env on failure (#10035)
Our shell integration routines can now fail when resources are missing.
This change introduces tests to ensure that they leave behind a clean
environment upon failure.

The bash integration needed a little reordering to support this.
2025-12-26 13:29:27 -08:00
Mitchell Hashimoto
9eceea18ec macOS: Don't duplicate command palette entries for terminal commands (#10069)
This is a regression introduced when we added macOS support for custom
entries. I mistakingly thought that only custom entries were in the
config, but we do initialize it with all!
2025-12-26 11:13:21 -08:00
Mitchell Hashimoto
14f592b8d4 macOS: Don't duplicate command palette entries for terminal commands
This is a regression introduced when we added macOS support for custom
entries. I mistakingly thought that only custom entries were in the
config, but we do initialize it with all!
2025-12-26 11:03:50 -08:00
Mitchell Hashimoto
78e895dfae terminal: Fix possible crash on RenderState with invalid mouse point (#10067)
Fixes #10032
2025-12-26 10:48:24 -08:00
Mitchell Hashimoto
26b104c9e0 terminal: Fix possible crash on RenderState with invalid mouse point
Fixes #10032
2025-12-26 10:45:15 -08:00
Mitchell Hashimoto
ebcc350018 datastruct/circ_buf: fix n=0 edge cases (#10066)
From #10063

This fixes and tests various edge cases around noop operations.
2025-12-26 10:36:36 -08:00
Mitchell Hashimoto
23addb3c67 terminal: fix crash when sliding window sees empty node (#10065)
Related to #10063

This fixes a crash that can happen if the SlidingWindow search portion
sees a zero-byte page.

We have more fixes to implement in the circular buffer handling but
putting the fix at this layer also prevents some unnecessary allocations
for zero-byte data.
2025-12-26 10:36:15 -08:00