224 Commits

Author SHA1 Message Date
Mitchell Hashimoto
67cbabd605 make keyboard modifiers left/right-aware throughout core 2023-08-07 14:33:56 -07:00
Thorsten Ball
39055ebf40 macOS: explicitly name the NSMainNibFile in plist
According to [this answer][0] here and [this blogpost][1], if the
`NSMainNibFile` is not specified in the `*.plist` file, then
`NSApplicationMain` will look through the bundle to get the first nib
file it finds.

I like the explicitness of naming it and it probably also saves a
miniscule amount of CPU/IO when we can skip finding the file.

[0]: https://stackoverflow.com/questions/42886400/how-does-nsapplicationmain-find-the-main-nib-file
[1]: https://jameshfisher.com/2017/03/20/how-is-mainmenu-xib-loaded/
2023-08-07 19:48:04 +02:00
Mitchell Hashimoto
5f5a23acc4 macos: help menu goes to the github repo 2023-08-05 15:03:17 -07:00
Mitchell Hashimoto
d895887361 macos: enable copy/paste menu items in "Edit" 2023-08-05 14:50:18 -07:00
Mitchell Hashimoto
2f6159b16d macos: quit menu should say "Ghostty" 2023-08-05 13:04:06 -07:00
Mitchell Hashimoto
bbe171f314 macos: remove unimplemented menu items 2023-08-05 11:59:57 -07:00
Thorsten Ball
1908895303 macos: re-add Edit submenu to main menu
This menu got list in #215 and with it we lost the ability to use the
macOS emoji picker via the `Cmd+Ctrl Space` shortcut, for example.

This adds a standard Edit menu back to the main menu.
2023-08-05 20:51:43 +02:00
Mitchell Hashimoto
2752995ec5 macos: Cmd-Q without any window focus works
Previously, this would crash. Once the crash was fixed, it would hang
because we would only show confirmation if the terminal window had
focus.

This introduces some medium complexity logic to work around this:

  1. If we are the key window, then show the confirmation dialog. Done.
  2. Otherwise, if any other window is a terminal window and is key,
     they're going to take it so we do nothing.
  3. Otherwise, if we are the first terminal window in the application
     windows list, we show it even if we're not focused.
2023-08-05 10:43:56 -07:00
Mitchell Hashimoto
7c98f991db macos: new tab menu/shortcut works even if no windows are present 2023-08-04 17:45:57 -07:00
Mitchell Hashimoto
8c01160afa macos: "+" button ensures tab is added to same window group 2023-08-04 17:39:40 -07:00
Mitchell Hashimoto
bb7c67b967 macos: implement newWindowForTab for "+" button 2023-08-04 17:35:57 -07:00
Mitchell Hashimoto
994d456223 set the title of the window 2023-08-04 17:24:28 -07:00
Mitchell Hashimoto
9105637697 macos: reorganize, rename, put files in groups 2023-08-04 17:17:18 -07:00
Mitchell Hashimoto
bf190ba442 macos: merge AppController and AppDelegate, organize groups 2023-08-04 17:05:52 -07:00
Thorsten Ball
b56ffa6285 Add config setting to turn non-native fullscreen on or off 2023-08-04 14:12:33 -07:00
Thorsten Ball
850bf3e945 macos: add support for non-native fullscreen mode
This adds support for what's commonly referred to as "non-native
fullscreen": a fullscreen-mode that doesn't use macOS' native fullscreen
mechanism and thus doesn't use animations and a separate space on which
to display the fullscreen window. Instead it's really fast and it allows
the user to `Cmd+tab` to other windows, with the fullscreen-ed window
staying in the background.

Another name for it is "traditional fullscreen" since it was the default
pre Mac OS X Lion, if I remember correctly.

Other applications that offer macOS non-native fullscreen:

- Kitty: https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.macos_traditional_fullscreen
- wezterm: https://wezfurlong.org/wezterm/config/lua/config/native_macos_fullscreen_mode.html
- MacVim
- IINA: fc66b27d50/iina/MainWindowController.swift (L1401-L1423)
- mpv: https://mpv.io/manual/stable/#options-native-fs
- iTerm2

Adding this wasn't straightforward, as it turned out. Mainly because
SwiftUI's app lifecycle management doesn't allow one to use a custom
class for the windows it creates. And without custom classes we'd always
get a warning when entering/leaving fullscreen mode.

So what I did here is the following:

- remove SwiftUI app lifecycle management
- introduce `MainMenu.xib` to define the main menu via interface builder
- add `GhosttyAppController` to handle requests from the app
- add a `main.swift` file to boot up the app without a storyboard and
  without SwiftUI lifecycle management
- introduce the `FullScreenHandler` to manage non-native fullscreen -
  this is where the "magic" is

But since removing the SwiftUI lifecycle management also means removing
the top-level `App` that means I had to introduce the menu (which I
mentioned), but also tab and window management.

So I also added the `WindowService` which manages open tabs and windows.
It's based on the ideas presented in

    https://christiantietze.de/posts/2019/07/nswindow-tabbing-multiple-nswindowcontroller/

and essentially keeps tracks of windows.

Then there's some auxilliary changes: `CustomWindow` and `WindowController` and so on.

Now everything still works, in addition to non-native fullscreen:

* opening/closing of tabs
* opening/closing of windows
* splits
* `gotoTab`

Worthy of note: when toggling back from non-native fullscreen to
non-fullscreen I had to manually implement the logic to re-add the
window back to a tabgroup. The only other app that supports tabs with
non-native FS is iTerm2 and they have implemented their own tab
management to keep the tab bar even in non-native FS -- that's a bit too
much for me. Every other app has non-native apps and doesn't have to
wory about it.
2023-08-04 14:12:30 -07:00
Mitchell Hashimoto
b11734bd67 default the title to the ghostty emoji
This only happens if the shell hasn't reported a pwd AND title.
2023-08-04 11:11:15 -07:00
Mitchell Hashimoto
ad62e3ac1b fish shell integration 2023-07-06 16:10:30 -07:00
Mitchell Hashimoto
9a079bb5b9 background-blur-radius for macOS 2023-07-03 20:43:53 -07:00
Mitchell Hashimoto
338f89679d apprt: add C API for detecting background transparency per surface 2023-07-03 19:44:06 -07:00
Mitchell Hashimoto
84550f276a macos: make close the terminal button non-destructive
So that "return" works.
2023-07-02 12:38:16 -07:00
Thorsten Ball
8e464db049 Toggle fullscreen on super/ctrl+return, only macOS for now
This fixes or at least is the first step towards #171:

- it adds `cmd/super + return` as the default keybinding to toggle
  fullscreen for currently focused window.
- it adds a keybinding handler to the embedded apprt and then changes
  the macOS app to handle the keybinding by toggling currently focused
  window.
2023-07-02 20:23:49 +02:00
Mitchell Hashimoto
eebcbb6955 macos: attach gotoTab listener to contentView and filter on focused win 2023-07-01 09:19:38 -07:00
Thorsten Ball
6ff3f62e3a macOS: implement cmd+[0-9] to goto tab
This is my attempt at fixing #63. It works! But:

1. The `NotificationCenter` subscription is triggered once for every
   open tab. That's obviously wrong. But I'm not sure and could use some
   pointers where else to put the subscription. That leads me to...
2. I'm _not_ knowledgable in Swift/AppKit/SwiftUI, so I might have put
   the wrong/right things in the wrong/right places. For example: wasn't
   sure what's to be handled in Swift and what's to be handled by the
   core in Zig.

Would love some pointers :)
2023-07-01 09:08:02 -07:00
Thorsten Ball
eea37033bf macOS: change quit dialog to handle return by removing role
This is, as it turns out, the simple version of #166.

It changes the quit dialog to handle return by removing the
`.destructive` role from the `Quit` button.

When that role is set, the `keyboardShortcut(.defaultAction)` doesn't have an effect.

With the role removed, the dialog handles the return key to quit the
application

As I wrote in #166, I can understand if you don't want this change, but
I personally think it's nice to be able to only use the keyboard. iTerm2
also handles return like this in the "Are you sure?" dialog.
2023-07-01 14:52:27 +02:00
Mitchell Hashimoto
de5468e214 scale x, speed up scrolling 2023-06-29 11:47:28 -07:00
Mitchell Hashimoto
32031701b8 core: do high precision scrolling Y calculations 2023-06-29 11:42:43 -07:00
Mitchell Hashimoto
9a40dc4630 macos: build scroll mods value 2023-06-29 11:06:34 -07:00
Mitchell Hashimoto
20f46d5c08 define precision scrolling and momentum structs, C API 2023-06-29 10:38:15 -07:00
Mitchell Hashimoto
f9978e8524 build: Copy terminfo resources from xcodeproj
This should fix #158. Instead of manually copying the resources, we
create a relative dependency from the xcodeproj directly so that
xcodebuild should handle this for us.
2023-06-25 09:09:23 -07:00
Mitchell Hashimoto
e998e053b1 mac: fix split initial focus
When making a split, the window focus doesn't change so the new splits
were defaulting to "false" (not focused). Let's just assume when a
surface is created that it is in fact focused. This generally fixes the
issue.

If we ever programmatically create splits in background windows this
will probably fail so we should find a way on View init to detect if the
window has focus.
2023-05-27 14:37:00 -07:00
Mitchell Hashimoto
1d14b121c0 renderer: do not draw cursor cell inversion if we don't draw the cursor
We previously used the "screen.viewportIsBottom" check but this is
always true since awhile back since we copy only the viewport now. A
cleaner check really is that we only track the cursor cell if we're even
drawing the cursor.
2023-05-25 21:41:43 -07:00
Mitchell Hashimoto
472958fd12 macos: don't block shutdown/restart on confirmation 2023-05-19 08:27:19 -07:00
Mitchell Hashimoto
f36a35ecc9 core: quit flag is reset after tick 2023-03-27 10:10:06 -07:00
Mitchell Hashimoto
41943b9a00 macos: quit if we have no visible windows 2023-03-27 10:05:29 -07:00
Mitchell Hashimoto
ef30ad394d macos: only show confirm quit on focused window 2023-03-27 09:52:38 -07:00
Mitchell Hashimoto
92870e4e60 macos: confirm on quit 2023-03-27 09:41:00 -07:00
Mitchell Hashimoto
4d41b3ff54 Merge pull request #134 from mitchellh/gtk-confirm
gtk, macos: show confirmation dialog on surface close with active child process
2023-03-26 10:59:09 -07:00
Mitchell Hashimoto
8fa5a9d299 macos: Cmd+W closes settings window if focused 2023-03-26 10:43:57 -07:00
Mitchell Hashimoto
a1831ecacb macos: show close confirmation if running process exists 2023-03-26 10:40:38 -07:00
Mitchell Hashimoto
86c4a8ed7d apprt/embedded: support new process alive callback on close 2023-03-25 16:41:18 -07:00
Mitchell Hashimoto
decaee61b2 apprt/embedded: support unmapped keys 2023-03-25 15:44:17 -07:00
Mitchell Hashimoto
f092cce69e macos: translate ASCII keys 2023-03-25 15:26:04 -07:00
Mitchell Hashimoto
b26e51d222 macos: implement config reloading callback 2023-03-19 09:50:54 -07:00
Mitchell Hashimoto
8d3f40fa41 apprt/embedded: reload config support 2023-03-19 09:50:54 -07:00
Mitchell Hashimoto
c01e8337bd macos: reliable window focus tracking for surface 2023-03-15 21:29:20 -07:00
Mitchell Hashimoto
363a03a30d macos: explicitly free surface resource on split/tab close
We don't wait for Swift to garbage collect. We just free the expensive
stuff (our surface) immediately.
2023-03-15 21:11:52 -07:00
Mitchell Hashimoto
04b1625a68 ghostty.h: fix type usage before declaration 2023-03-15 15:55:52 -07:00
Mitchell Hashimoto
a6b43fa694 macos: set default window size on macOS 13+ 2023-03-15 15:03:45 -07:00
Mitchell Hashimoto
3976da8149 macos: navigate splits directionally 2023-03-11 17:55:31 -08:00