119 Commits

Author SHA1 Message Date
Mitchell Hashimoto
984d123fe4 macos: support configuration via CLI arguments
This makes it so `zig build run` can take arguments such as
`--config-default-files=false` or any other configuration. Previously,
it only accepted commands such as `+version`.

Incidentally, this also makes it so that the app in general can now take
configuration arguments via the CLI if it is launched as a new instance
via `open`. For example:

    open -n Ghostty.app --args --config-default-files=false

This previously didn't work. This is kind of cool.

To make this work, the libghostty C API was modified so that
initialization requires the CLI args, and there is a new C API to try to
execute an action if it was set.
2025-07-05 21:31:23 -07:00
Mitchell Hashimoto
8c3caee15c macOS: zig build run disables window saved state 2025-07-05 19:58:17 -07:00
Mitchell Hashimoto
7bd90e6ec4 Build system can build macOS app bundle and open it
`zig build run` on macOS now builds the app bundle via the `xcodebuild`
CLI and runs it. The experience for running the app is now very similar
to Linux or the prior GLFW build, where the app runs, blocks the zig
command, and logs to the terminal.

`xcodebuild` has its own build cache system that we can't really hook
into so it runs on every `zig build run` command, but it does cache and
I find its actually relatively fast so I think this is a good
replacement for the glfw-based system.
2025-07-04 13:32:15 -07:00
Mitchell Hashimoto
2fa4fc8902 reload configuration on SIGUSR2
This is done at the apprt-level for a couple reasons.

  (1) For libghostty, we don't have a way to know what the embedding
      application is doing, so its risky to create signal handlers that
      might overwrite the application's signal handlers.

  (2) It's extremely messy to deal with signals and multi-threading.
      Apprts have framework access that handles this for us.

For GTK, we use g_unix_signal_add.

For macOS, we use `DispatchSource.makeSignalSource`. This is an awkward
API but made for this purpose.
2025-07-01 15:51:58 -07:00
Mitchell Hashimoto
471098df30 macOS: Run scripts using stdin rather than executing directly
Fixes #7647

See #7647 for context. This commit works by extending the `input` work
introduced in #7652 to libghostty so that the macOS can take advantage
of it. At that point, its just the macOS utilizing `input` in order to
set the command and `exit` up similar to Terminal and iTerm2.
2025-06-22 21:06:32 -04:00
Mitchell Hashimoto
2c1e83ba2f macos: intent to open quick terminal 2025-06-21 06:39:20 -07:00
Mitchell Hashimoto
7ae5018fe8 macos: new terminal intent 2025-06-21 06:39:18 -07:00
Mitchell Hashimoto
57c79fa357 macos: Tahoe menu item icons, missed the "Ghostty" menu entirely
This is a follow up to #7594, I missed an entire menu.
2025-06-15 07:48:20 -07:00
Mitchell Hashimoto
202020cd7d macos: menu item symbols for Tahoe
This is recommended for macOS Tahoe and all standard menu items now have
associated images. This makes our app look more polished and native for
macOS Tahoe.

For icon choice, I tried to copy other native macOS apps as much as
possible, mostly from Xcode. It looks like a lot of apps aren't updated
yet. I'm absolutely open to suggestions for better icons but I think
these are a good starting point.

One menu change is I moved "reset font size" above "increase font size"
which better matches other apps (e.g. Terminal.app).
2025-06-14 19:44:24 -07:00
Mitchell Hashimoto
6e77a5a6ca macos: address quick terminal basic functionality with new API 2025-06-07 13:07:31 -07:00
Mitchell Hashimoto
b234cb2014 macos: only process reopen if already activated 2025-06-07 12:46:15 -07:00
Mitchell Hashimoto
636b1fff8a macos: initial window shouldn't support undo 2025-06-07 12:46:15 -07:00
Mitchell Hashimoto
33d128bcff macos: remove TerminalManager
All logic related to TerminalController is now in TerminalController.
2025-06-07 12:46:15 -07:00
Mitchell Hashimoto
b044f4864a add undo/redo keybindings, default them on macOS 2025-06-07 12:46:14 -07:00
Mitchell Hashimoto
f571519157 macos: setup undo responders at the AppDelegate level 2025-06-07 12:46:14 -07:00
Mitchell Hashimoto
6d32b01c64 macos: implement a custom ExpiringUndoManager, setup undo for new/close 2025-06-07 12:46:14 -07:00
Mitchell Hashimoto
493b1f5350 wip: undo 2025-06-07 12:46:13 -07:00
Mitchell Hashimoto
269d29624b Add bell feature flags for audio, attention, and title actions on macOS (#7533)
Resolve #7526
2025-06-06 12:59:23 -07:00
Aaron Ruan
5f6a15abef Add bell feature flags for audio, attention, and title actions on macOS
Signed-off-by: Aaron Ruan <i@ar212.com>
2025-06-06 23:54:34 +08:00
Mitchell Hashimoto
70f030e3c2 macos: dismiss notifications on focus, application exit
I've only recently been using programs that use user notifications heavily
and this commit addresses a number of annoyances I've encountered.

  1. Notifications dispatched while the source terminal surface is
     focused are now only shown for a short time (3 seconds hardcoded)
     and then automatically dismiss.

  2. Notifications are dismissed when the target surface becomes focused
     from an unfocused state. This dismissal happens immediately (no
     delay).

  3. Notifications are dismissed when the application exits.

  4. This fixes a bug where notification callbacks were modifying view
     state, but the notification center doesn't guarantee that the
     callback is called on the main thread. We now ensure that
     the callback is always called on the main thread.
2025-06-06 07:28:32 -07:00
Mitchell Hashimoto
77458ef308 macos: rename surfaceTree2 to surfaceTree 2025-06-05 07:05:13 -07:00
Mitchell Hashimoto
f1ed07caf4 macos: Remove the legacy SurfaceTree 2025-06-05 07:05:13 -07:00
Aaron Ruan
7ccc181332 macos: add "Check for Updates" action, menu item & key-binding support 2025-05-15 13:34:44 +08:00
Mitchell Hashimoto
a26310e83f macOS: app key is binding check should include utf-8 chars 2025-05-09 10:45:43 -07:00
Mitchell Hashimoto
6e11d947e7 Binding for toggling window float on top (macOS only)
This adds a keybinding and apprt action for #7237.
2025-05-01 09:47:17 -07:00
Martin Hettiger
f83729ba48 macos: add float on top feature for terminal windows 2025-05-01 09:13:33 -07:00
Mitchell Hashimoto
74e1c47623 macOS: Command Palette (#7153)
This introduces a command palette (inspired by @pluiedev's work in
#5681, but not using it as a base) for macOS.

The command palette is available in the `View` menu and also bindable
via `toggle_command_palette`, default binding is `cmd+shift+p` to match
VSCode.

The commands in the command palette must map to a _bindable_ action,
though they may not have an associated keybinding. This means that any
new binding actions we add in the future can be represented here and
also makes it easy in the future to add configuration to add new custom
entries to the command palette. For this initial PR, the available
commands are hardcoded (`src/input/commands.zig`).

I've noticed in other programs (VSCode, Zed), the command palette
contains pretty much _all available actions_ even if they're basically
useless in the context of a command palette. For example, Zed has the
"toggle command palette" action in the command palette and it... does
nothing (it probably should hide the palette). I followed @pluiedev's
lead and made this subjective in this PR but I wonder if we should
actually force all binding actions to be available.

There are various other improvements I'd like to make but omitted from
this PR for the sake of limiting scope:

* Instead of an entry with no matches doing nothing, we can allow users
to manually input _any_ configurable binding.
* Localization, since macOS doesn't have any yet. But for Linux when we
port this we probably have to change our strings extraction.

## Demo


https://github.com/user-attachments/assets/a2155cfb-d86b-4c1a-82b5-74ba927e4d69
2025-04-22 08:52:27 -07:00
Mitchell Hashimoto
ce987ba56d macOS: Add dock badge notification for bell events (#7118)
Resolves #7108

This PR adds visual notification badges to the Ghostty dock icon when
bell events are triggered while the application is in the background.
This complements the existing dock bounce notification, making it easier
for users to notice when a terminal needs attention.


https://github.com/user-attachments/assets/b54c881f-fea8-4085-8614-432d9e5847b9
2025-04-22 08:39:49 -07:00
Mitchell Hashimoto
6d2685b5a2 add toggle command palette binding 2025-04-21 10:05:30 -07:00
Mitchell Hashimoto
643c882597 macOS: use KeyboardShortcut rather than homegrown KeyEquivalent (#7139)
This replaces the use of our custom `Ghostty.KeyEquivalent` with the
SwiftUI `KeyboardShortcut` type. This is a more standard way to
represent keyboard shortcuts and lets us more tightly integrate with
SwiftUI/AppKit when necessary over our custom type.

This PR should have no user impact. This is just some cleanup for future
work.

Note that not all Ghostty triggers can be represented as
KeyboardShortcut values because macOS itself does not support binding
keys such as function keys (e.g. F1-F12) to KeyboardShortcuts.

This isn't an issue since all input also passes through a lower level
libghostty API which can handle all key events, we just can't show these
keyboard shortcuts on things like the menu bar. This was already true
before this commit.
2025-04-21 07:26:34 -07:00
Kat
d4525f2c57 Correct remaining instances of change_title_prompt to prompt_surface_title. 2025-04-21 03:41:52 +00:00
Mitchell Hashimoto
b05826ac9d macOS: use KeyboardShortcut rather than homegrown KeyEquivalent
This replaces the use of our custom `Ghostty.KeyEquivalent` with
the SwiftUI `KeyboardShortcut` type. This is a more standard way to
represent keyboard shortcuts and lets us more tightly integrate with
SwiftUI/AppKit when necessary over our custom type.

Note that not all Ghostty triggers can be represented as
KeyboardShortcut values because macOS itself does not support
binding keys such as function keys (e.g. F1-F12) to KeyboardShortcuts.

This isn't an issue since all input also passes through a lower level
libghostty API which can handle all key events, we just can't show these
keyboard shortcuts on things like the menu bar. This was already true
before this commit.
2025-04-19 14:39:48 -07:00
Bryan Lee
90499f0749 macOS: Add dock badge notification for bell events 2025-04-18 09:43:48 +08:00
Mitchell Hashimoto
cc690eddb5 macOS: Implement basic bell features (no sound)
Fixes #7099

This adds basic bell features to macOS to conceptually match the GTK
implementation. When a bell is triggered, macOS will do the following:

  1. Bounce the dock icon once, if the app isn't already in focus.
  2. Add a bell emoji (🔔) to the title of the surface that triggered
     the bell. This emoji will be removed after the surface is focused
     or a keyboard event if the surface is already focused. This
     behavior matches iTerm2.

This doesn't add an icon badge because macOS's dockTitle.badgeLabel API
wasn't doing anything for me and I wasn't able to fully figure out
why...
2025-04-15 10:41:15 -07:00
Mitchell Hashimoto
17cae57f51 Introduce reset_window_size keybinding and apprt action
Related to #6035

This implements the keybind/action portion of #5974 so that this can
have a binding and so that other apprts can respond to this and
implement it this way.
2025-02-28 15:31:17 -08:00
Mikhail Borisov
8838ebf02a Refactor to use height/width from ghostty configuration 2025-02-28 14:17:46 -08:00
Mikhail Borisov
f73c1a2c59 "Return to Default Size" implementation
Added support for "Return To Default Size"
2025-02-28 14:17:46 -08:00
Mitchell Hashimoto
1013ba63ee [macOS] feat: Add "Split Left" and "Split Up" actions to menubar (#5807)
Fixes #5779
2025-02-16 12:37:11 -08:00
mbrown379
b1df97b33f Add Split Left and Split Up to menu 2025-02-16 15:14:02 -05:00
Albert Dong
d7a82f212a Add setting to hide icon from dock/cmd-tab 2025-02-15 10:45:27 -08:00
Damien Mehala
a0f243691a feat: add bring_all_to_front keybinding
Resolves #4704.
2025-02-14 14:41:49 -08:00
Aswin M Prabhu
a581955b9b Add tab title rename feature to macos 2025-02-14 13:29:36 -08:00
Mitchell Hashimoto
58ab66f094 macos: add a variety of artist-drawn alternate icons
This is just a fun change to add a bunch of alternate icons. We don't
want to add too many since this increases the final bundle size but we
also want to have some fun. :)
2025-02-11 14:51:43 -08:00
Bryan Lee
c627231b0f Fix confirm-close-surface not working for hidden quick terminal 2025-02-11 12:42:34 -08:00
Mitchell Hashimoto
c6da845f33 macos: ensure previously key window regains key on toggle_visibility
Fixes #5690

When we hide the app and then show it again, the previously key window
is lost. This is because we are not using unhide and are manually
doing it (and we're not using unhide for good reasons commented in the
source already).

Modify our hidden state to include what the key window was (as a weak
ref) and restore it when we show the app again.
2025-02-11 11:13:19 -08:00
Mitchell Hashimoto
f986a32185 macos: toggle_visibility fullscreen check requires active app
This fixes a regression from #5472. The fullscreen check must check if
the app is active otherwise the guard statement fails and we can't bring
the macOS app back from the background.
2025-02-11 11:01:20 -08:00
Shaps Benkau
8d31f6ce2e Toggling visibility is now ignored when in fullscreen mode. 2025-02-03 13:44:23 -08:00
Mitchell Hashimoto
200aee9acf macos: rework toggle_visibility to better match iTerm2
Two major changes:

1. Hiding uses `NSApp.hide` which hides all windows, preserves tabs, and
   yields focus to the next app.

2. Unhiding manually tracks and brings forward only the windows we hid.
   Proper focus should be retained.
2025-01-10 14:40:02 -08:00
Alexandre Antonio Juca
3a5aecc216 fix: hide windows without calling orderOut API 2025-01-10 14:16:47 -08:00
Alexandre Antonio Juca
4dd9fe5cfd fix: ensure terminal tabs are reconstructed in main window after toggling visibility 2025-01-10 14:16:47 -08:00