Commit Graph

237 Commits

Author SHA1 Message Date
Lukas
777929a8fe macOS: review windows when closing multiple tabs 2026-08-28 19:32:27 +02:00
Mitchell Hashimoto
1c3a4a8314 Update macos/Sources/Helpers/Extensions/URL+Extension.swift
Co-authored-by: Lukas <134181853+bo2themax@users.noreply.github.com>
2026-08-27 14:58:06 -07:00
Mitchell Hashimoto
07abbd1e7e Update macos/Sources/Helpers/Extensions/URL+Extension.swift
Co-authored-by: Lukas <134181853+bo2themax@users.noreply.github.com>
2026-08-27 14:57:59 -07:00
Mitchell Hashimoto
2de1596115 macos: normalize action working directory paths
Discussion #14048

Directory URLs no longer export a trailing slash through PWD, which
keeps zsh's %1~ prompt expansion from resolving to an empty string.

A shared URL helper removes trailing separators while preserving the
filesystem root and percent-decoding behavior. Tests cover normal,
repeated, encoded, and root paths.
2026-08-27 14:35:01 -07:00
Lukas
6229d4eb62 macOS: fix AppleScript send key for non-control keys
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-25 17:49:02 +02:00
Lukas
f1b9efed80 macOS: update default behaviour of KeyboardLayout.character(for:modifiers:) 2026-08-25 13:56:21 +02:00
Mitchell Hashimoto
1334cc213e macos: answer ENOSYS for Kitty clipboard writes to primary
A Kitty clipboard protocol (OSC 5522) write transaction targeting
`loc=primary` replied `type=write:status=DONE` in the macOS app even
though macOS has no primary selection and the data was silently
discarded. 

The spec requires ENOSYS when the requested location is not
available on the system, which the read path already answers correctly:
https://sw.kovidgoyal.net/kitty/clipboard/
2026-08-24 13:11:23 -07:00
Mitchell Hashimoto
c2c0db68aa macOS: enable mode 5522 paste events
Advertise Kitty clipboard protocol mode 5522 on macOS and route
clipboard paste requests through the protocol when it is enabled.
2026-08-24 09:37:57 -07:00
Mitchell Hashimoto
c1f0ef73a9 macos: serve copied files as text/uri-list in Kitty clipboard reads 2026-08-24 08:18:36 -07:00
Mitchell Hashimoto
8c7a34d4c9 macos: Kitty clipboard reads serve all clipboard content types 2026-08-24 08:18:36 -07:00
Lukas
6a508fd5e3 macos: translate physical menu shortcuts (#13888)
Translate printable physical keybindings through the current macOS
keyboard layout before assigning menu key equivalents. Previously these
bindings could not be represented because SwiftUI shortcuts are
character-based, so actions such as `super+backquote` had no native menu
shortcut.

Keep native keycodes as dispatch identity so translated display
characters do not change physical semantics or precedence over Unicode
bindings. Refresh shortcuts when the input source changes, and prevent
AppKit from transforming equivalents that are already localized.

**AI Usage:** The approach was suggested by GPT 5.6 Sol, but I wrote
most of the code and understand it all.
2026-08-24 09:55:02 +02:00
Lukas
fd17869d15 macOS: rework for #10943
Keep the background color as it is and apply glass effect on top of it
2026-08-20 13:30:33 +02:00
Jon Parise
f5ad3a0a4a macos: use AppKit for shortcut translation
Translate synthetic physical-key events with characters(byApplyingModifiers:).
This preserves current-layout and Command-table behavior while avoiding a
duplicate direct UCKeyTranslate implementation in Swift.
2026-08-19 14:14:12 -04:00
Lukas
f6990690f0 Revert "macOS: hide settings menu icon on macOS 27 (#13664)"
This reverts commit 99c483f477, reversing
changes made to 33bdeed1cb.
2026-08-19 15:02:01 +02:00
Jon Parise
9886f4817c macos: enforce keyboard layout actor isolation
Text Input Sources APIs are not thread-safe, but shortcut translation could
be called outside a declared main-actor context.

Mark keyboard layout and shortcut conversion as main-actor isolated, update
their tests, and dispatch key-sequence UI notifications to the main queue
before translating their shortcuts.
2026-08-18 12:40:28 -04:00
Jon Parise
569ff3307c macos: translate physical menu shortcuts
Translate printable physical keybindings through the current macOS
keyboard layout before assigning menu key equivalents. Previously these
bindings could not be represented because SwiftUI shortcuts are
character-based, so actions such as super+backquote had no native menu
shortcut.

Keep native keycodes as dispatch identity so translated display characters
do not change physical semantics or precedence over Unicode bindings.
Refresh shortcuts when the input source changes, and prevent AppKit from
transforming equivalents that are already localized.
2026-08-18 11:27:06 -04:00
Jon Parise
5c952ac977 macos: simplify command palette sort keys
Store the Comparable ObjectIdentifier directly instead of wrapping the
only sort key type in AnySortKey.

The expected deterministic ordering of equal terminal command titles is
also now verified by a unit test.
2026-08-17 12:50:27 -04:00
Mitchell Hashimoto
faaf07e7c0 macos: remove unused hosting window helper (#13873)
Remove the unused SwiftUI environment key intended to expose a hosting
window. Nothing sets or reads the value.
2026-08-17 09:36:11 -07:00
Jon Parise
d19f8f7f9d macos: remove unused hosting window helper
Remove the unused SwiftUI environment key intended to expose a hosting
window. Nothing sets or reads the value.
2026-08-17 10:58:41 -04:00
Mitchell Hashimoto
f4309055fb macos: don't put 0x7F as text in key event
Fixes #13869

We already checked `< 0x20` but missed `0x7F` which causes similar
problems.
2026-08-17 06:44:16 -07:00
Lukas
daab08ec01 macOS: drop the cross-platform check and abstraction
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-12 14:00:03 +02:00
Lukas
4b9d589bcb macOS: disable text selection on macOS 15 2026-08-10 11:44:43 +02:00
Lukas
301bd6f8b0 macOS: hide settings menu icon on macOS 27
Settings appears to be somehow special and it's not hidden previously.
2026-08-06 12:21:36 +02:00
Mitchell Hashimoto
8696bef644 macos: guard fullscreen tab presentation
#13611

Route new-tab window presentation through an Objective-C exception catcher.

AppKit can raise an NSInternalInconsistencyException while selecting a
new tab in native fullscreen.

Catch the presentation exception, report it through the existing error
logging path, and leave Ghostty running when AppKit’s fullscreen window
stack is inconsistent.

This was pretty hard to reproduce but I was able to reproduce it about
1/3rd of the time via AppleScript automation...
2026-08-05 11:25:18 -07:00
Mitchell Hashimoto
77537c8065 macos: handled untrusted OSC8 hyperlinks more carefully
OSC8 hyperlinks previously executed directly via the NSWorkspace opener
so a malicious application can just do whatever it wanted and trick the
user into opening something through Launch Services.

This PR notifies apprt of OSC8 hyperlinks so they can be handled
specially. In this PR, I added macOS-specific handling of OSC8 through a
variety of improvements:

  - Preview text is sanitized, so invisible Unicode characters now show.
  - Questionable-looking URLs require confirmation to open, but a user
    can confirm to open.
  - Very questionable or definitely unsafe URLs are blocked with an 
    alert that only allows the user to copy the link. The alert also
    notifies the user why.
2026-08-05 10:22:28 -07:00
Lukas
fa3802a70e macOS: change split drag's point style to match HIG 2026-07-23 21:33:47 +02:00
Lukas
49806fc4cc macOS: read string contents per pasteboard item in order
Pasteboards mixing file URLs with other items will now be pasted as joined string.
2026-07-03 12:53:34 +02:00
Claude Opus 4.7
eb5c1c7220 fix(macos): mark Swift os.Logger interpolations as public 2026-05-31 16:35:11 +02:00
Nolin McFarland
bf716a0c39 feat: add extension to normalize OSPasteboard string interface 2026-05-18 10:12:26 -04:00
Nolin McFarland
ed52160612 feat: support BackportSelectionTextField on iOS 18 2026-05-17 12:33:56 -04:00
Nolin McFarland
69cab3d808 feat: select needle when reading from pasteboard 2026-05-17 11:26:32 -04:00
Nolin McFarland
59eece9a8e feat: use find pasteboard to store search needle 2026-05-16 19:59:20 -04:00
Lukas
c2a93db591 macOS: move url hover to a separate file 2026-04-13 08:18:11 +02:00
Lukas
41c872c1f4 macOS: fix tab title editor frame update during winding resizing 2026-04-10 13:57:09 +02:00
Lukas
591dbd5112 macOS: fix incorrect delete symbol mapping 2026-03-31 10:27:12 +02: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
Lukas
51cd63871d macos: passthrough right mouse down event to TabTitleEditor if needed (#11150) 2026-03-30 12:22:54 +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
Lukas
4f849a1512 macOS: fix window position for the very first window 2026-03-12 15:42:29 +01:00
Lukas
d6dfaf28fe macOS: support injecting temporary defaults when testing 2026-03-12 13:16:55 +01:00
Lukas
596d502a75 macOS: restore window frame under certain conditions 2026-03-11 17:45:10 +01:00
Lukas
e8c82ca1af macOS: save frame only if the window is visible 2026-03-11 17:45:09 +01:00
ydah
c2206542d3 macos: fix tab title rename hit testing and focus handling in fullscreen mode 2026-03-11 07:24:49 -07:00
chronologos
7629130fb4 macOS: restore keyboard focus after inline tab title edit
After finishing an inline tab title edit (via keybind or double-click),
`TabTitleEditor.finishEditing()` calls `makeFirstResponder(nil)` to
clear focus from the text field, leaving the window itself as first
responder. No code path restores focus to the terminal surface, so all
keyboard input is lost until the user clicks into a pane.

Add a `tabTitleEditorDidFinishEditing` delegate callback that fires
after every edit (commit or cancel). TerminalWindow implements it by
calling `makeFirstResponder(focusedSurface)` to hand focus back to the
terminal.

Fixes https://github.com/ghostty-org/ghostty/discussions/11315

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-10 08:52:00 -07:00
Mitchell Hashimoto
341d8bdf75 macos: AppleScript windows/tabs
Add ScriptWindow and ScriptTab classes to expose window/tab hierarchy
to AppleScript, along with the corresponding sdef definitions.
2026-03-06 07:59:58 -08:00
Mitchell Hashimoto
ef669eeae7 macos: add AppleScript split command
Add a new `split` command to the AppleScript scripting dictionary that
splits a terminal in a given direction (right, left, down, up) and
returns the newly created terminal.

The command is exposed as:
  split terminal <terminal> direction <direction>

Also adds a `fourCharCode` String extension for converting four-character
ASCII strings to their FourCharCode (UInt32) representation.
2026-03-05 20:54:34 -08:00
Lukas
4437707132 macos: use a separated struct to hide and restore tab states 2026-03-03 17:42:17 +01:00
Lukas
78fdff34a9 macos: hide close button when editing tab title 2026-03-03 17:24:56 +01:00
Lukas
661470897e macos: passthrough right mouse down event to TabTitleEditor if needed 2026-03-03 17:24:56 +01:00
Lukas
205c05d59d macos: passthrough mouse down event to TabTitleEditor if needed 2026-03-03 17:15:12 +01:00