134 Commits

Author SHA1 Message Date
Thorsten Ball
be114e792f macOS: fix cascading windows when using tabs and closing windows
This fixes two things:

1. Issue #294: cascade point for new windows is set when creating new tabs
2. Cascade point was *not* reset when closing windows, which lead to a
   big "gap" appearing when, say, opening 5 windows, closing 4, opening
   a new window.
2023-08-19 20:21:20 +02:00
Thorsten Ball
a76aea4d0a macOS: new split can inherit font size 2023-08-19 09:59:04 +02:00
Thorsten Ball
2e9b787668 macOS: new window can inherit font size
This is the second part of #281 and adds the same mechanism that was
added for tabs in #296 for windows.

It works exactly the same way.
2023-08-19 09:29:56 +02:00
Mitchell Hashimoto
4f5460475c Merge pull request #296 from mitchellh/mrn/macos-inherit-font-size
macOS: inherit font size when creating new tab
2023-08-18 09:22:06 -07:00
Mitchell Hashimoto
a18503fc01 macos: can always set base config on new tab 2023-08-18 09:21:47 -07:00
Mitchell Hashimoto
79971c62a6 macos: pass around a base surface_config_s rather than a new tab 2023-08-18 09:09:43 -07:00
Thorsten Ball
cda87a6963 embedded: use separate struct to pass options to new_tab_cb 2023-08-18 06:50:47 +02:00
Thorsten Ball
12311e9707 macOS: simplify code for new tab 2023-08-18 06:26:15 +02:00
Thorsten Ball
3e7c4475a1 macOS: move newTab code to PrimaryWindowManager 2023-08-17 20:57:00 +02:00
Thorsten Ball
d2dae7a696 macOS: inherit font size when creating new tab
This is one part of #281.
2023-08-17 20:56:56 +02:00
Thorsten Ball
0597b03fa2 macOS: remove dead code from PrimaryWindowController
I think this is a left-over from the refactor that moved this field to
the `PrimaryWindowManager`.
2023-08-17 07:04:46 +02:00
Mitchell Hashimoto
721087be76 macos: send the left/right status of modifier keys 2023-08-14 12:40:48 -07:00
Mitchell Hashimoto
d5df8aea9a apprt/embedded: handle repeat events 2023-08-11 12:02:00 -07:00
Mitchell Hashimoto
1e1ad7deb9 macos: use the new self-hosted translation 2023-08-11 12:02:00 -07:00
Mitchell Hashimoto
57a527b0c9 macos: detect keyboard layout change and reload the keymap 2023-08-11 12:01:59 -07:00
Mitchell Hashimoto
3d23f26326 input, macos: initial work on keymapper and macos usage of it 2023-08-11 12:01:58 -07:00
Mitchell Hashimoto
688ab84661 apprt/embedded: allow noting that selection clipboard is not supported 2023-08-09 14:52:22 -07:00
Mitchell Hashimoto
afc6a9976f apprt/embedded: support selection clipboard 2023-08-09 14:29:39 -07:00
Kevin Hovsäter
22b8173164 Fix typos 2023-08-08 14:27:34 +02:00
Mitchell Hashimoto
22296b377a Revert "Merge pull request #244 from mitchellh/alt-as-esc"
This reverts commit c139279d479682c17f63d9b57c2d56608d09d16a, reversing
changes made to 4ed21047a734d7c586debe0026e3b6ea90ed1622.

We do want to do this but this broke bindings.
2023-08-07 17:06:40 -07:00
Mitchell Hashimoto
67cbabd605 make keyboard modifiers left/right-aware throughout core 2023-08-07 14:33:56 -07: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
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
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
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