538 Commits

Author SHA1 Message Date
Mitchell Hashimoto
220da88a9a config: make unfocused-split-fill default to bg 2023-12-13 19:06:25 -08:00
Mitchell Hashimoto
fefd4ca04d macos: style changes, make equivalent not an optional 2023-12-13 13:49:39 -08:00
Gregory Anders
163ee1d75a macos: special case handling of some control keys
Some control key combinations must be handled specially by Ghostty to
prevent undesirable behavior at the OS level. For now, this includes
only Ctrl-/, which makes a "beep" sound when processed by AppKit. It is
unclear why this beep occurs and no answer was found after extensive
searching.

This solution is inspired by iTerm2, which also handles certain control
key combinations (including C-/) manually before passing them on to
Cocoa/AppKit.
2023-12-13 14:46:34 -06:00
Matt Robenolt
ae6645586e unpack rgb correctly 2023-12-12 21:56:35 -08:00
Matt Robenolt
1b039b35ac typos 2023-12-12 17:22:37 -08:00
Matt Robenolt
91937c4ada Apply feedback 2023-12-12 17:14:47 -08:00
Matt Robenolt
8e607f372b Configurable unfocused dimming color 2023-12-12 16:34:41 -08:00
Mitchell Hashimoto
45a4573991 macos: previous_tab/next_tab wraps
Fixes #999
2023-12-10 15:12:22 -08:00
Mitchell Hashimoto
ec989d6b46 macos: newTab needs to call Controller.showWindow 2023-12-08 08:46:05 -08:00
Mitchell Hashimoto
4b25356625 macos: manually show window to handle mission control behavior
Fixes #1018
Fixes #1020

This disables the "visibleAtLaunch" configuration in the xib and
manually shows the window when it loads. This lets us carefully control
what happens particularly when a window is full screen (native) and part
of Mission Control.

Previously, the behavior depended on the Settings.app "Prefer tabs
when opening documents" setting, but we didn't handle every behavior
correctly (see #1018 and #1020). I couldn't find a way to robustly
handle all cases because there are no published macOS APIs for
interacting with Mission Control...

Plus, terminals aren't really "documents" so it did confuse at least one
user that Ghostty would follow this configuration. We just incidently
did because we use native tabbing.

This PR takes full control into our own hands. Our behavior is now:

  - If a new window is created from a native fullscreen window, the
    new window is created into native fullscreen.

  - If a new tab is created from a native fullscreen window, the
    tab is added to the existing window and does not create a new space.

  - If a window or tab is created from a non-fullscreen window, the
    existing behaviors remain.
2023-12-07 22:44:47 -08:00
Mitchell Hashimoto
3f76094d84 macos: handle the "+" button automatically adding the window to the tabs
Fixes #1010
2023-12-07 14:39:54 -08:00
Mitchell Hashimoto
fc6def01a1 macos: new tab button creates new tab after short delay
Fixes #1010

I can't explain this. See the comment in the diff.
2023-12-07 12:35:19 -08:00
Mitchell Hashimoto
7ea0dfdd5d macos: if a preedit state is cleared, don't send key event
Fixes #992
2023-12-06 09:04:59 -08:00
Mitchell Hashimoto
6fed7cde19 macos: do not open an initial window if opening from URL 2023-12-01 19:28:06 -08:00
Mitchell Hashimoto
7036676ec0 macos: relabel tabs when they're reordered with the mouse
Prior to this commit, the shortcut shown on the tab would not be updated
until a focus change occurred. There is no event for this so the way we
do it is by listening for the tab view frame to change, comparing the
window state, and then updating labels.
2023-11-22 11:43:04 -08:00
Mitchell Hashimoto
7d9eaddeb3 macos: alternate solution to ignoring "always" userTabbingPreference
Related to #642
Fixes #910

See #642 for why we want to ignore the "always" userTabbingPreference.
To do that, we'd set tabbingMode to "disallow" because we manually (in
code) handled it all.

Unfortunately, setting the tabbingMode to "disallow" introduce #910. I
still believe this is a macOS bug at heart, so I'm going to submit an
Apple Feedback item for it. However, I've found a workaround which I
also feel is the better solution, implemented here.

Instead of setting tabbingMode to "disallow" I now detect if we're in
the scenario where the user has their system tabbing preference set to
"always". In that case, we detect if the new window has been
automatically put into a tab group by macOS, and if so we remove it.

This all happens in the `windowDidLoad` controller callback. At this
phase, our Ghostty-managed windows should NEVER be in a tab group,
because "new tab" adds them to a tab _after_. So we can be certain that
if we're already in a tab group it was from the macOS system setting.

This happens to fix #910.
2023-11-18 21:09:08 -08:00
Gregory Anders
be7be538af macos: ensure all surfaces are closed when a window is closed 2023-11-18 08:40:40 -06:00
Gregory Anders
86b7442f3c macos: implement desktop notifications 2023-11-15 11:21:30 -06:00
Gregory Anders
54a489eefa macos: remove optional from Ghostty.AppState.surfaceUserdata
The return value of takeUnretainedValue() is non-optional, so this
function was never _actually_ returning an optional value, so the guard
clauses sprinkled throughout were unnecessary.
2023-11-15 10:36:45 -06:00
Mitchell Hashimoto
ab948f6f8f macos: reuse original event if translation mods changes nothing
Fixes #766 (again)

This is a repeat fix of 766 after fixing a number of other regressions
from the original fix. See the comment for reasons.
2023-11-14 08:14:24 -08:00
Mitchell Hashimoto
35e78939e5 macos: ignore alt key with other modifiers set
This enables shifted alt-prefixed keys, such as `shift+alt+.` on
US standard becoming `M->`. To do this, we needed to fix a few bugs:

  (1) translation mods should strip alt even if other mods are set
  (2) AppKit translation event needs to construct new characters with
      the translation mods.
  (3) Alt-prefix handling in KeyEncoder needs to allow ASCII utf8
      translations even for macOS.
2023-11-13 19:21:51 -08:00
Mitchell Hashimoto
5001e2c60c macos: filter option in AppKit when option-as-alt set
Fixes #872

In #867 we fixed macos-option-as-alt, but unfortunately AppKit ALSO does
some translation so some behaviors were not working correctly.
Specifically, when you had macos-option-as-alt set, option+e would
properly send `esc+e` to the pty but it would ALSO set the dead key
state for "`" since AppKit was still translating the option key.

This commit introduces a function to strip alt when necessary from the
translation modifiers used at the AppKit layer, preventing this
behavior.
2023-11-13 13:26:37 -08:00
Mitchell Hashimoto
d0a5faf57d Merge pull request #857 from gpanders/osc52-prompt
Implement user prompts for accessing clipboard via OSC 52
2023-11-11 15:16:12 -08:00
Mitchell Hashimoto
2489ef4c13 stylistic tweaks 2023-11-11 15:15:52 -08:00
Thorsten Ball
ae9d7fc76a macOS: only unhide manu in non-native FS if focus lost to Ghostty
This fixes #786 by adding a check to the callback that unhides the menu
bar to only unhide the menu bar if focus was lost to another Ghostty
window.

That's the desired behaviour: when focus is lost to another app's
window, we want the non-native-fullscreen window to stay unchanged in
background, but when changing focus to another Ghostty window, we want
to unhide the menu bar.

Why did this problem even show up?

It started to show up with the introduction of the Xib-file based
approach, in 3018377.

Before that, in 27ddc90, for example, the app would receive the same
notifications, but the `.autoHideMenuBar` didn't have an effect on the
window. Only after adding the Xib-file did it start to have an effect.

So I figured there's two ways we could fix it:

1. Figure out why the `.autoHideMenuBar` now works with Xib-files and
   suppress it, or
2. Encode in the code the behaviour that we actually want: we only want
   to show the menu bar when focus shifts to another one of Ghostty's
   windows, but we want to leave it untouched when focus is lost to
   another app's window.

I went with (2) but I think (1) is also valid and happy to close PR if
that's what we want to do.
2023-11-11 07:41:12 +01:00
Gregory Anders
98b43007a0 core: use ClipboardRequestType instead of ClipboardPromptReason
Instead of making a separate enum that must be translated from the
ClipboardRequest type, simply re-use ClipboardRequest to determine the
clipboard confirmation reason.
2023-11-10 23:12:39 -05:00
Gregory Anders
86245ff0cf macos: add option to prompt user for confirmation on OSC 52 commands 2023-11-10 23:12:39 -05:00
Mitchell Hashimoto
dd1faf5e50 macos: handle preedit in AppKit, enables Korean input 2023-11-10 09:53:56 -08:00
Gregory Anders
dffb5e9f15 macos: ensure tab labels are always visible
This tells AppKit to give the tab labels higher priority than the tab
titles. When the tabs become small, this causes the tab title text to be
truncated instead of dropping the tab label.

Fixes: https://github.com/mitchellh/ghostty/issues/843
2023-11-08 08:48:20 -06:00
Mitchell Hashimoto
e542215c21 macos: update xib version from xcode 2023-11-07 19:26:52 -08:00
Mitchell Hashimoto
d482fed7f2 simplify some swift 2023-11-07 15:26:41 -08:00
Gregory Anders
cd01340cce macos: add key binding for equalizing split sizes 2023-11-07 16:23:28 -06:00
Gregory Anders
dc7c313166 macos: pass split as a binding to SplitView
Fixes: https://github.com/mitchellh/ghostty/issues/833
2023-11-07 11:55:29 -06:00
Mitchell Hashimoto
4e3ab4879d Merge pull request #822 from gpanders/split-resizing
macos: implement split resizing
2023-11-06 09:35:43 -08:00
Mitchell Hashimoto
bc0d1a9255 macos: remove focused cell size resize increment setter 2023-11-06 09:11:50 -08:00
Mitchell Hashimoto
1ff0573518 macos: use normal swiftui parameters for resizable publisher/inc 2023-11-06 09:06:20 -08:00
Mitchell Hashimoto
f8b0654a19 Merge pull request #816 from Raiden1411/feat/options
feat: add support for `--fullscreen`, `--title` and `--class` values
2023-11-06 08:55:33 -08:00
Mitchell Hashimoto
efe9721c98 macos: honor fullscreen setting 2023-11-06 08:52:36 -08:00
Gregory Anders
582df33083 macos: use Ghostty.AppState as @EnvironmentObject
This is a small cleanup change. This provides the Ghostty.AppState
object to any view that needs it within the TerminalSplit view hierarchy
without needing to explicitly define EnvironmentKeys.
2023-11-05 20:42:59 -06:00
Gregory Anders
9b14398153 macos: support resizing splits 2023-11-05 20:42:59 -06:00
Gregory Anders
3b2799ce97 macos: refactor SplitNode
This commit does two things: adds a weak reference to the parent
container of each SplitNode.Container and SplitNode.Leaf and moves the
"direction" of a split out of the SplitNode enum and into the
SplitNode.Container struct as a field.

Both changes are required for supporting split resizing. A reference to
the parent in each leaf and split container is needed in order to
traverse upwards through the split tree. If the focused split is not
part of a container that is split along the direction that was requested
to be resized, then we instead try and resize the parent. If the parent
is split along the requested direction, then it is resized
appropriately; otherwise, repeat until the root of the tree is reached.

The direction is needed inside the SplitNode.Container object itself so
that the container knows whether or not it is able to resize itself in
the direction requested by the user. Once the split direction was moved
inside of SplitNode.Container, it became redundant to also have it as
part of the SplitNode enum, so this simplifies things.
2023-11-05 20:20:39 -06:00
Gregory Anders
f614d45e28 macos: set id on nested terminal splits
This fixes https://github.com/mitchellh/ghostty/issues/761 for terminal
splits that are not at the root.
2023-11-05 19:37:20 -06:00
Mitchell Hashimoto
5de8efcccc macos: comment the new views 2023-11-05 09:31:12 -08:00
Mitchell Hashimoto
ef44551522 apprt/embedded: hook up paste confirmation 2023-11-05 09:20:16 -08:00
Mitchell Hashimoto
5dac8fba96 macos: paste protection text should be selectable 2023-11-04 20:48:18 -07:00
Mitchell Hashimoto
04acaf8b20 macos: hook up paste protection delegate, cancel button 2023-11-04 20:47:16 -07:00
Mitchell Hashimoto
5f5f5a44ec macos: paste protection boilerplate 2023-11-04 20:15:39 -07:00
Mitchell Hashimoto
3bef50f0cf macos: deminiaturize on new tab 2023-11-03 09:35:14 -07:00
Mitchell Hashimoto
cad461fff7 macos: modify tabbing mode when entering/exiting fullscreen
Related to #799

With tabbing mode disabled, fullscreen (native) windows when creating a
new tab creates a window in the tab bar, but ALSO puts the window into a
new "screen" on macOS. When you click the tab bar, macOS animates
between screens. Its jarring!

This commit makes it so that in fullscreen we go back to automatic
tabbing even for new windows, which produces new windows within a tab.
This is normal default behavior for macOS tabbed programs. When you are
not in fullscreen or exit fullscreen, then the tabbing mode returns to
disabled so Ghostty can manage it.
2023-11-03 09:16:55 -07:00
Mitchell Hashimoto
c6ce9aea4a macos: do not set window initial size if fullscreen
Fixes #798
2023-11-03 09:06:17 -07:00