diff --git a/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift b/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift index a4ef7ad1e..9e33d2dd6 100644 --- a/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift +++ b/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift @@ -58,8 +58,11 @@ class QuickTerminalController: BaseTerminalController { selector: #selector(ghosttyConfigDidChange(_:)), name: .ghosttyConfigDidChange, object: nil) - - // Setup our notifications for tab behaviors + center.addObserver( + self, + selector: #selector(onNewTab(_:)), + name: Ghostty.Notification.ghosttyNewTab, + object: nil) center.addObserver( tabManager, selector: #selector(tabManager.onMoveTab(_:)), @@ -452,11 +455,6 @@ class QuickTerminalController: BaseTerminalController { } // MARK: First Responder - - @IBAction func newTab(_ sender: Any?) { - tabManager.addNewTab() - } - @IBAction func toggleGhosttyFullScreen(_ sender: Any) { guard let surface = focusedSurface?.surface else { return } ghostty.toggleFullscreen(surface: surface) @@ -490,6 +488,10 @@ class QuickTerminalController: BaseTerminalController { syncAppearance() } + @objc func onNewTab(_ sender: Any?) { + tabManager.newTab() + } + private struct DerivedConfig { let quickTerminalScreen: QuickTerminalScreen let quickTerminalAnimationDuration: Double diff --git a/macos/Sources/Features/QuickTerminal/Tab/QuickTerminalTabBarView.swift b/macos/Sources/Features/QuickTerminal/Tab/QuickTerminalTabBarView.swift index 4d89d98e7..fd0ae4972 100644 --- a/macos/Sources/Features/QuickTerminal/Tab/QuickTerminalTabBarView.swift +++ b/macos/Sources/Features/QuickTerminal/Tab/QuickTerminalTabBarView.swift @@ -45,7 +45,7 @@ struct TabBarView: View { .frame(width: 50) .contentShape(Rectangle()) // Make the entire frame clickable .onTapGesture { - tabManager.addNewTab() + tabManager.newTab() } .buttonStyle(PlainButtonStyle()) .help("New Tab") diff --git a/macos/Sources/Features/QuickTerminal/Tab/QuickTerminalTabManager.swift b/macos/Sources/Features/QuickTerminal/Tab/QuickTerminalTabManager.swift index c05638415..3b136c82f 100644 --- a/macos/Sources/Features/QuickTerminal/Tab/QuickTerminalTabManager.swift +++ b/macos/Sources/Features/QuickTerminal/Tab/QuickTerminalTabManager.swift @@ -11,7 +11,7 @@ class QuickTerminalTabManager: ObservableObject { self.controller = controller } - func addNewTab() { + func newTab() { guard let ghostty = controller?.ghostty else { return } let leaf: Ghostty.SplitNode.Leaf = .init(ghostty.app!, baseConfig: nil) @@ -40,7 +40,7 @@ class QuickTerminalTabManager: ObservableObject { if currentTab?.id == tab.id { if tabs.isEmpty { - addNewTab() + newTab() } else { let newIndex = min(index, tabs.count - 1) selectTab(tabs[newIndex])