mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
Add onNewTab & Rename addNewTab to newTab
This commit is contained in:
@ -58,8 +58,11 @@ class QuickTerminalController: BaseTerminalController {
|
|||||||
selector: #selector(ghosttyConfigDidChange(_:)),
|
selector: #selector(ghosttyConfigDidChange(_:)),
|
||||||
name: .ghosttyConfigDidChange,
|
name: .ghosttyConfigDidChange,
|
||||||
object: nil)
|
object: nil)
|
||||||
|
center.addObserver(
|
||||||
// Setup our notifications for tab behaviors
|
self,
|
||||||
|
selector: #selector(onNewTab(_:)),
|
||||||
|
name: Ghostty.Notification.ghosttyNewTab,
|
||||||
|
object: nil)
|
||||||
center.addObserver(
|
center.addObserver(
|
||||||
tabManager,
|
tabManager,
|
||||||
selector: #selector(tabManager.onMoveTab(_:)),
|
selector: #selector(tabManager.onMoveTab(_:)),
|
||||||
@ -452,11 +455,6 @@ class QuickTerminalController: BaseTerminalController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: First Responder
|
// MARK: First Responder
|
||||||
|
|
||||||
@IBAction func newTab(_ sender: Any?) {
|
|
||||||
tabManager.addNewTab()
|
|
||||||
}
|
|
||||||
|
|
||||||
@IBAction func toggleGhosttyFullScreen(_ sender: Any) {
|
@IBAction func toggleGhosttyFullScreen(_ sender: Any) {
|
||||||
guard let surface = focusedSurface?.surface else { return }
|
guard let surface = focusedSurface?.surface else { return }
|
||||||
ghostty.toggleFullscreen(surface: surface)
|
ghostty.toggleFullscreen(surface: surface)
|
||||||
@ -490,6 +488,10 @@ class QuickTerminalController: BaseTerminalController {
|
|||||||
syncAppearance()
|
syncAppearance()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc func onNewTab(_ sender: Any?) {
|
||||||
|
tabManager.newTab()
|
||||||
|
}
|
||||||
|
|
||||||
private struct DerivedConfig {
|
private struct DerivedConfig {
|
||||||
let quickTerminalScreen: QuickTerminalScreen
|
let quickTerminalScreen: QuickTerminalScreen
|
||||||
let quickTerminalAnimationDuration: Double
|
let quickTerminalAnimationDuration: Double
|
||||||
|
@ -45,7 +45,7 @@ struct TabBarView: View {
|
|||||||
.frame(width: 50)
|
.frame(width: 50)
|
||||||
.contentShape(Rectangle()) // Make the entire frame clickable
|
.contentShape(Rectangle()) // Make the entire frame clickable
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
tabManager.addNewTab()
|
tabManager.newTab()
|
||||||
}
|
}
|
||||||
.buttonStyle(PlainButtonStyle())
|
.buttonStyle(PlainButtonStyle())
|
||||||
.help("New Tab")
|
.help("New Tab")
|
||||||
|
@ -11,7 +11,7 @@ class QuickTerminalTabManager: ObservableObject {
|
|||||||
self.controller = controller
|
self.controller = controller
|
||||||
}
|
}
|
||||||
|
|
||||||
func addNewTab() {
|
func newTab() {
|
||||||
guard let ghostty = controller?.ghostty else { return }
|
guard let ghostty = controller?.ghostty else { return }
|
||||||
|
|
||||||
let leaf: Ghostty.SplitNode.Leaf = .init(ghostty.app!, baseConfig: nil)
|
let leaf: Ghostty.SplitNode.Leaf = .init(ghostty.app!, baseConfig: nil)
|
||||||
@ -40,7 +40,7 @@ class QuickTerminalTabManager: ObservableObject {
|
|||||||
|
|
||||||
if currentTab?.id == tab.id {
|
if currentTab?.id == tab.id {
|
||||||
if tabs.isEmpty {
|
if tabs.isEmpty {
|
||||||
addNewTab()
|
newTab()
|
||||||
} else {
|
} else {
|
||||||
let newIndex = min(index, tabs.count - 1)
|
let newIndex = min(index, tabs.count - 1)
|
||||||
selectTab(tabs[newIndex])
|
selectTab(tabs[newIndex])
|
||||||
|
Reference in New Issue
Block a user