macos: new tab implementation

This commit is contained in:
Mitchell Hashimoto
2023-02-19 09:04:51 -08:00
parent 94e678ed57
commit e92d90b8d5
3 changed files with 17 additions and 0 deletions

View File

@@ -23,6 +23,20 @@ struct GhosttyApp: App {
TerminalView(app: ghostty.app!)
.modifier(WindowObservationModifier())
}
}.commands {
CommandGroup(after: .newItem) {
Button("New Tab", action: newTab).keyboardShortcut("t", modifiers: [.command])
}
}
}
// Create a new tab in the currently active window
func newTab() {
guard let currentWindow = NSApp.keyWindow else { return }
guard let windowController = currentWindow.windowController else { return }
windowController.newWindowForTab(nil)
if let newWindow = NSApp.keyWindow, currentWindow != newWindow {
currentWindow.addTabbedWindow(newWindow, ordered: .above)
}
}
}