Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macOS] feat: Support Tabs in Quick Terminal #5370

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

sohsatoh
Copy link
Contributor

@sohsatoh sohsatoh commented Jan 25, 2025

related to #2329

This pull request implements a tab management feature for the Quick Terminal in the Ghostty for macOS.

macOS does not support tab management without a title bar. Therefore, this PR implements non-native tabs instead of using macOS native tabs.

Changes

  • Add tab management feature for Quick Terminal

Appearance

window-theme = dark

スクリーンショット 2025-01-26 19 21 54

window-theme = light

スクリーンショット 2025-01-26 19 22 18

Notes

The implementation is designed to work similarly to native tabs and to behave consistently with the (standard) terminal windows in Ghostty. However, there may be some aspects I might have overlooked. Please feel free to make any necessary fixes to the implementation as needed.

animateOut()
}

@IBAction func newTab(_ sender: Any?) {
Copy link
Contributor Author

@sohsatoh sohsatoh Jan 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝
This is never called because the window is an NSPanel without a title bar. So, I removed it and added the observer for Ghostty.Notification.ghosttyNewTab.

@@ -329,6 +329,9 @@ class TerminalManager {
guard let surfaceView = notification.object as? Ghostty.SurfaceView else { return }
guard let window = surfaceView.window else { return }

// return if window is not in our managed windows
guard windows.contains(where: { $0.controller.window == window }) else { return }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝
If the window is not managed by the TerminalManager (which is usually the case when it is managed by the QuickTerminalManager), the process will be aborted. Without this, a new TerminalWindow would be created.

@sohsatoh sohsatoh force-pushed the feat/quickterm-with-tab branch from be37844 to 98a0e07 Compare January 26, 2025 10:03
@mitchellh
Copy link
Contributor

Just noting I'm going to wait to review this until after 1.1.

@SindreMA
Copy link

SindreMA commented Feb 5, 2025

I've swapped to this forked version this were a required features for me to use Ghostty.

I've noticed two things that differs from the built in tabs.

  • Its missing hotkey support (cmd+1, cmd+2...)
  • When you only have 1x tab open, the "tab selector" should hide.

@DoctorRyner
Copy link

DoctorRyner commented Feb 9, 2025

@sohsatoh I noticed a really huge bug, if you have splits and you open a new tab, all the splits disappear. So, you can't switch tabs without all splits disappearing

@DoctorRyner
Copy link

DoctorRyner commented Feb 10, 2025

@mitchellh this issue is a deal breaker for many macOS users since we are trying to migrate from iTerm, I tested this and it looks like a really good implementation IMO, if the bug I mentioned earlier is fixed of course.

I also wanted to ask you something because I'm not sure about your policies. May I? Okay, so, I use quick term in center position and it's very annoying that every time you spawn the terminal, its position gets reset which isn't really convenient after I toggle it. I rewrote the code so it "remembers" Terminal position even after you toggle it.

So, my question is, can I create an issue for it or maybe a merge request or maybe you don't want this feature?

@sohsatoh
Copy link
Contributor Author

sohsatoh commented Feb 10, 2025

@DoctorRyner

I noticed I really huge bug, if you have splits and you open a new tab, all the splits disappear. So, you can't switch tabs without all splits disappearing

Oh, thanks. I haven't noticed that as I don't use split term. I will try to fix it in this weekend (hopefully).

I use quick term in center position and it's very annoying that every time you spawn the terminal, its position gets reset which isn't really convenient after I toggle it. I rewrote the code so it "remembers" Terminal position even after you toggle it.

Just to clarify, is this question related to my PR? If not, I believe it would be best to follow the guidelines in CONTRIBUTING.md. Of course, we are happy to answer questions or provide/take advice about the implementation, but please keep in mind that a PR is not an open forum for general discussions.

@DoctorRyner
Copy link

@sohsatoh I also noticed that that cmd+t sometimes opens a new window instead of new tab when I was in fullscreen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants