macos: allow renaming tab title on double-click

This commit is contained in:
MiUPa
2026-02-23 11:18:16 +09:00
committed by Mitchell Hashimoto
parent d186613ca4
commit daa2a9d0d5

View File

@@ -174,6 +174,14 @@ class TerminalWindow: NSWindow {
override var canBecomeKey: Bool { return true }
override var canBecomeMain: Bool { return true }
override func sendEvent(_ event: NSEvent) {
if promptTabTitleForDoubleClick(event) {
return
}
super.sendEvent(event)
}
override func close() {
NotificationCenter.default.post(name: Self.terminalWillCloseNotification, object: self)
super.close()
@@ -207,6 +215,19 @@ class TerminalWindow: NSWindow {
viewModel.isMainWindow = false
}
private func promptTabTitleForDoubleClick(_ event: NSEvent) -> Bool {
guard event.type == .leftMouseDown, event.clickCount == 2 else { return false }
let locationInScreen = convertPoint(toScreen: event.locationInWindow)
guard let tabIndex = tabIndex(atScreenPoint: locationInScreen) else { return false }
guard let targetWindow = tabbedWindows?[safe: tabIndex] else { return false }
guard let targetController = targetWindow.windowController as? BaseTerminalController else { return false }
targetController.promptTabTitle()
return true
}
override func mergeAllWindows(_ sender: Any?) {
super.mergeAllWindows(sender)