Commit Graph

154 Commits (15e41959eb762600d9549877ccee49b01c298be5)

Author SHA1 Message Date
Mitchell Hashimoto 18419d3589
Clamp initial window size configurations to screen size
Fixes #2145
2024-08-26 10:09:05 -07:00
pnodet 7ff9af1520
style(macos): cleanup trailing spaces 2024-08-21 21:53:09 +02:00
Eduardo Dominguez 262902a28d macos: jump to last_tab 2024-08-19 12:19:00 -06:00
Łukasz Niemier f9be02a20f chore: clean up typos 2024-08-05 13:56:57 +02:00
Mitchell Hashimoto 9785130c03
macos: add "Reset Terminal" context menu option 2024-08-01 14:58:03 -07:00
Mitchell Hashimoto 5268780f00
macos: comment on clearing tab 2024-07-21 10:09:18 -07:00
Justin Su f57f9f2ec9
Use 1-indexed values when dealing with tabs 2024-07-21 03:32:43 -04:00
Justin Su 823e073795
Relabel all tabs and clear labels for tabs with no key equivalent 2024-07-21 02:27:51 -04:00
Justin Su 7919cb266e
Update comment 2024-07-21 02:12:47 -04:00
Cameron Dart fc52acd47a update config in TerminalController.windowDidLoad and TerminalController.configDidReload 2024-06-10 18:22:28 -07:00
Cameron Dart 29fb70197c macos: surface focus follow mouse 2024-06-10 16:07:33 -07:00
Mitchell Hashimoto 5092cb55ad
Merge pull request #1837 from ghostty-org/titlebar-style
macos: macos-titlebar-style, remove titlebar-tabs option
2024-06-07 13:15:14 -07:00
Mitchell Hashimoto 550a9be241
config: introduce macos-window-shadow 2024-06-07 12:46:14 -07:00
Mitchell Hashimoto 5a026cf1a2
macos: set background color on transparency that matches Terminal.app 2024-06-07 12:35:57 -07:00
Mitchell Hashimoto 25484d2ccc
macos: set background opacity/blur on window controller not surface 2024-06-07 12:31:45 -07:00
Mitchell Hashimoto 4dde7edfab
config: macos-titlebar-style, remove titlebar-tabs option
Fixes #1833

This is an attempt to simplify the logic that has organically grown
convoluted over time with regards to how the titlebar and tab bar is
styled.

This field is one unified field that ONLY addresses titlebar and tab bar
styling. It can be one of "native", "transparent", or "tabs". The
"native" field is the new behavior in this commit: it makes the titlebar
and tab bar appearance be absolutely native. We do not color anything
(if we do its a bug).

The "transparent" option is the previous `macos-titlebar-tabs = false`
setting where the titlebar/tab bar is native but colored according to
the window background color.

The "tabs" option is `macos-titlebar-tabs = true`.

The `window-theme = auto` affect on titlebar appearance has been
removed. Now, the titlebar will NEVER be styled with "native" and MAY be
styled with "transparent" and will ALWAYS be styled with "tabs" (since
that's a totally custom look anyways).
2024-06-07 12:12:48 -07:00
Troels Thomsen f79674097f Avoid coloring when using native tabs 2024-05-21 08:58:51 +02:00
Troels Thomsen 242858b963 Color after setting window theme and tab mode 2024-05-21 08:05:55 +02:00
Mitchell Hashimoto 92d551a3c1
macos: only set bg color and titlebar color if opaque
Fixes #1771

I'm not convinced this fix won't regress some other behavior, but in my
titlebar tab and native tab modes with and without transparency, this
has looked okay to me.
2024-05-17 17:05:21 -04:00
Mitchell Hashimoto 69a3137956
macos: use enum for window theme 2024-05-17 16:31:18 -04:00
Pete Schaffner c437416014 Make title/tab bar respect `window-theme` setting 2024-05-14 20:17:28 -04:00
cryptocode 2faa0c9bee
Rename Split Horizontally/Vertically to Split Right/Down
I make the following suggestion through a PR since I already tried this locally and have a branch ready:

- Rename Split Horizontally to Split Right
- Rename Split Vertically to Split Down

Rationale:

The terms horizontal and vertical are ambiguous in the context of splitting (does it mean the splitter is vertical, or are the panes organized vertically?)
Different apps pick different interpretations, so people get confused.

IntelliJ made the same change as above based on user feedback: https://youtrack.jetbrains.com/issue/IJPL-130991/Split-Vertically-and-Split-Horizontally-are-ambiguous-and-should-be-renamed

Ghostty is using the left/right nomenclature in other menu items. In the codebase, SplitDirection is already left/right.
2024-05-10 11:17:11 +02:00
Mitchell Hashimoto 45eecf801e
macos: show alert when creating new tab in non-native fs
Fixes #1683

The root issue is #392 and we can likely find a way to fix it, but for
now let's prevent the full program hang by showing an alert.
2024-04-16 09:34:10 -07:00
Pete Schaffner b947ed0070 Update titlebar tabs when config changes 2024-04-05 16:40:04 +02:00
Pete Schaffner 4ede25dd00 Update standard title/tab bar when config changes 2024-04-05 15:19:55 +02:00
Pete Schaffner ab26863088 Merge remote-tracking branch 'upstream/main' into titlebar-unzoom-button 2024-04-03 15:25:51 +02:00
Pete Schaffner bbe35ee02e Revert luminance check from commit f7129880f5
This fixes the issues reporting wrong toolbar colors:
https://github.com/mitchellh/ghostty/pull/1550#issuecomment-2021538747
2024-03-28 10:51:00 +01:00
Pete Schaffner cf6017e777 Revert "Revert "Merge pull request #1550 from peteschaffner/titlebar-unzoom-button""
This reverts commit 7f59d844c0.
2024-03-28 10:48:05 +01:00
Jon Parise baf75dfaaf macos: configurable titlebar fonts
Add support for configurable fonts for window and tab titles. This is
only implemented for macOS (and could be macOS-only if other platforms
aren't able to support this using their windowing toolkits). It plays
nicely with regular and titlebar tabs.
2024-03-26 16:56:39 -07:00
Mitchell Hashimoto 7f59d844c0
Revert "Merge pull request #1550 from peteschaffner/titlebar-unzoom-button"
This reverts commit 6b7a1ce1eb, reversing
changes made to b68e1c6a5d.
2024-03-26 14:53:26 -07:00
Mitchell Hashimoto ef4b3fed54
macos: remove some slight duplication 2024-03-26 11:14:43 -07:00
Mitchell Hashimoto f7129880f5
macos: only set titlebar color with enough luminance to avoid #1549 2024-03-26 11:13:39 -07:00
Pete Schaffner 447310425d Fix wrong tint color and improve tab labeling 2024-02-24 18:54:01 +01:00
Pete Schaffner 34f5bf4fe6 Move unzoom button logic into TerminalWindow
This fixed some bugs with keeping the correct button state when
reordering tabs
2024-02-23 22:30:03 +01:00
Pete Schaffner dc60afc261 Get unzoom button working with standard title/tab bar
To do this I forced a toolbar, so that we would have a place to put the
button when no tabs were opened. I also took the opportunity to make the
standard title/tab bar meld better with the terminal's background color,
just as we do with titlebar tabs.
2024-02-23 15:08:35 +01:00
Pete Schaffner 021daeedb2 Hide zoom button in toolbar when not zoomed
Hiding it via its alphaValue would allow the button to still respond
to clicks…
2024-02-22 18:01:13 +01:00
Pete Schaffner 472a5c93ad Move un-zoom button into the tab/toolbar 2024-02-22 17:54:51 +01:00
Mitchell Hashimoto 9e4cd0b51c
macos: minor reordering 2024-02-16 13:55:09 -08:00
Troels Thomsen 3bf18560bb Set background color in title bar tab mode only 2024-02-16 21:53:26 +01:00
Troels Thomsen 05fe0e830b Correct grammatical mistake 2024-02-16 21:52:46 +01:00
Troels Thomsen 41e94cf0be Remove trailing whitespace 2024-02-15 23:39:14 +01:00
Mitchell Hashimoto 9bc972568c
macos: call occlusion callback for state change 2024-02-12 13:48:29 -08:00
Mitchell Hashimoto 118b51157a
macos: more robust surface focus state detection
Fixes #1500

This overhauls how we do focus management for surfaces to make it more
robust. This DID somehow all work before but was always brittle and was
a sketchy play with SwiftUI/AppKit behavior across macOS versions.

The new approach uses our window controller and terminal delegate
system to disseminate focus information whenever any surface changes
focus. This ensures that only ONE surface ever has focus in libghostty
because the controller ensures it is widely distributed.
2024-02-11 09:19:13 -08:00
Mitchell Hashimoto 3c0317bf9d
macos: small stylistic edits 2024-02-05 19:04:50 -08:00
Qwerasd 1d6b952c8f fix(macOS): Improve updating of transparent titlebar tabs backgrounds
FAR from a perfect fix, as the background seen through the tabs during window drags will be behind by a frame or so still, but definitely a vast improvement over not updating at all.
2024-02-05 17:05:13 -05:00
Mitchell Hashimoto e5400bad06
config: add window-theme = auto for automatic choosing based on bg color 2024-02-01 20:49:28 -08:00
Qwerasd 2944128e05 fix(macOS): restoring tabbed windows with titlebar tabs enabled 2024-01-31 20:07:35 -05:00
Mitchell Hashimoto 4a93181b79
macos: minor edits 2024-01-31 15:43:35 -08:00
Qwerasd 308f8cce36 macOS: center window title when titlebar tabs enabled
Uses a custom toolbar that populates itself with a centered text field and provides a method to set the text.
2024-01-31 16:16:41 -05:00
Mitchell Hashimoto 1a3d2d151e
macos: fix tabs vs spaces 2024-01-31 12:06:58 -08:00
Mitchell Hashimoto fbac2d9810
macos: titlebar tab logic shuffling 2024-01-31 10:08:05 -08:00
Qwerasd dacbdf3f38 fix(macOS): set titlebar background color to support transparent windows with titlebar tabs 2024-01-31 07:58:31 -05:00
Qwerasd ba16d65d02 macOS: Added titlebar tabs 2024-01-30 18:48:36 -05:00
Mitchell Hashimoto fa0ba0a354
macos: terminals with custom commands are not restorable
Fixes #1317
2024-01-17 08:26:48 -08:00
Mitchell Hashimoto 875a774d4b
macos: remove AppState and unify onto Ghostty.App cross-platform 2024-01-14 19:35:57 -08:00
Mitchell Hashimoto eba3d5414d
macos: Ghostty.Config to store all config-related operations 2024-01-14 15:53:33 -08:00
Mitchell Hashimoto 837b551a92
macos: invalid restorable state whenever surface tree changes
Related to #1177

This detects whenever the surface tree (splits) change in any way and
requests that the restorable state be invalided by macOS.
2024-01-10 21:24:47 -08:00
Mitchell Hashimoto 44544f29b2
macos: support Display P3 colorspace through configuration
Fixes #1214

This introduces the `window-colorspace` configuration which allows
configuring the colorspace to use for windows on macOS. The default is
sRGB (same as before) but this can also be set to `display-p3`.
2024-01-09 20:47:07 -08:00
Mitchell Hashimoto 9bf13c6236
macos: set initial window size in controller window init
Fixes #1227
Fixes #1206

This moves the logic that respects `window-width` and `window-height` to
the controller window initialization. This is where it should've been
all the time but we previously didn't use a controller architecture so
we did our best to use heuristics in the view to do this.

This location now ensures that this only happens on window
initialization and only if we have one surface.
2024-01-05 09:42:50 -08:00
Mitchell Hashimoto 0008fb0a27
macos: set surface tree on init in restore
This prevents an unnecessary SurfaceView from being created. Creating a
SurfaceView is very expensive because this starts multiple threads,
creates the pty, starts the pty process, etc.

Additionally, this was exposing what I believe to be #497 when restoring
state: a surface view was created and destroyed very quickly causing
hangs on some machines. This still needs to be resolved but the behavior
in this commit was still a bug anyways.
2023-12-27 20:12:46 -08:00
Mitchell Hashimoto a321ef515d
macos: assign unique UUID per surface, store in app state 2023-12-26 14:24:05 -08:00
Mitchell Hashimoto 2390668834
macos: encode surface tree in state restore 2023-12-23 13:15:46 -08:00
Mitchell Hashimoto 59f54a1d88
macos: initial window save/restore is working for frames only 2023-12-22 21:24:27 -08:00
Mitchell Hashimoto 20ba6f3d78
macos: close_window binding works properly again
This binding closes the physical window and all surfaces in that window.
2023-12-17 20:29:23 -08:00
Mitchell Hashimoto 45a4573991
macos: previous_tab/next_tab wraps
Fixes #999
2023-12-10 15:12:22 -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 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 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
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
Gregory Anders cd01340cce macos: add key binding for equalizing split sizes 2023-11-07 16:23:28 -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
Mitchell Hashimoto ef44551522
apprt/embedded: hook up paste confirmation 2023-11-05 09:20:16 -08: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 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
Gregory Anders 6c340810a5 macos: fix tab labeling
Fixes a regression introduced in
https://github.com/mitchellh/ghostty/pull/772.
2023-11-03 07:40:56 -07:00
Mitchell Hashimoto 833e1a5329
macos: only modify style mask, don't overwrite
Fixes #784

The issue before was we were removing the fullscreen style which was
triggering a Cocoa assertion.
2023-11-02 22:12:52 -07:00
Mitchell Hashimoto 60e1ca81f0
macos: if alert is already showing, don't check if need confirm 2023-10-31 09:41:40 -07:00
Mitchell Hashimoto 6a024897a6
macos: new window on existing terminal inherits properly 2023-10-30 22:57:46 -07:00
Mitchell Hashimoto ecd7a17384
macos: new tab while a window is focused inherits 2023-10-30 22:55:57 -07:00
Mitchell Hashimoto 07c4692799
macos: forgot the toggle fullscreen binding 2023-10-30 22:18:20 -07:00
Mitchell Hashimoto 09ad0f6b7b
macos: attach various menu items to first responder, terminal
Fixes #758
2023-10-30 22:06:55 -07:00
Mitchell Hashimoto 9d3a4d2a58
Update macos/Sources/Features/Terminal/TerminalController.swift
Co-authored-by: Gregory Anders <8965202+gpanders@users.noreply.github.com>
2023-10-30 18:26:44 -07:00
Mitchell Hashimoto db309a0b61
macos: fix cascade points 2023-10-30 15:28:14 -07:00
Mitchell Hashimoto b4c973cd23
macos: improved comments 2023-10-30 15:15:56 -07:00
Mitchell Hashimoto b010875176
macos: do not need base config 2023-10-30 14:59:19 -07:00
Mitchell Hashimoto 7fe6f15d2d
macos: only show alert once 2023-10-30 14:56:59 -07:00
Mitchell Hashimoto 350a9da68b
macos: confirm quit with splits, tab 2023-10-30 14:50:54 -07:00
Mitchell Hashimoto 1fcc5812be
macos: detect when surface tree becomes empty 2023-10-30 14:46:28 -07:00
Mitchell Hashimoto b40245f01d
macos: remove old primary window stuff 2023-10-30 14:36:20 -07:00
Mitchell Hashimoto c86faa37c2
macos: terminal controller owns split data 2023-10-30 14:31:04 -07:00
Mitchell Hashimoto 05fd3f25b3
macos: clear content view on window close 2023-10-30 11:58:23 -07:00
Mitchell Hashimoto ed1741730e
macos: base config plumbed through 2023-10-30 11:53:05 -07:00
Mitchell Hashimoto 61451942e8
macos: implement last surface close to close window 2023-10-30 09:53:59 -07:00
Mitchell Hashimoto 8a03dcbb5b
macos: goto tab works 2023-10-30 09:24:06 -07:00