mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-06-22 07:18:45 +03:00
Select and uzoom when clicking button in unselected tab
This commit is contained in:
@ -17,7 +17,11 @@ class TerminalWindow: NSWindow {
|
|||||||
|
|
||||||
private lazy var resetZoomToolbarButton: NSButton = generateResetZoomButton()
|
private lazy var resetZoomToolbarButton: NSButton = generateResetZoomButton()
|
||||||
|
|
||||||
private lazy var resetZoomTabButton: NSButton = generateResetZoomButton()
|
private lazy var resetZoomTabButton: NSButton = {
|
||||||
|
let button = generateResetZoomButton()
|
||||||
|
button.action = #selector(selectTabAndZoom(_:))
|
||||||
|
return button
|
||||||
|
}()
|
||||||
|
|
||||||
private lazy var resetZoomTitlebarAccessoryViewController: NSTitlebarAccessoryViewController? = {
|
private lazy var resetZoomTitlebarAccessoryViewController: NSTitlebarAccessoryViewController? = {
|
||||||
guard let titlebarContainer = contentView?.superview?.subviews.first(where: { $0.className == "NSTitlebarContainerView" }) else { return nil }
|
guard let titlebarContainer = contentView?.superview?.subviews.first(where: { $0.className == "NSTitlebarContainerView" }) else { return nil }
|
||||||
@ -115,7 +119,6 @@ class TerminalWindow: NSWindow {
|
|||||||
super.becomeKey()
|
super.becomeKey()
|
||||||
|
|
||||||
updateNewTabButtonOpacity()
|
updateNewTabButtonOpacity()
|
||||||
resetZoomTabButton.isEnabled = true
|
|
||||||
resetZoomTabButton.contentTintColor = .controlAccentColor
|
resetZoomTabButton.contentTintColor = .controlAccentColor
|
||||||
resetZoomToolbarButton.contentTintColor = .controlAccentColor
|
resetZoomToolbarButton.contentTintColor = .controlAccentColor
|
||||||
}
|
}
|
||||||
@ -124,8 +127,7 @@ class TerminalWindow: NSWindow {
|
|||||||
super.resignKey()
|
super.resignKey()
|
||||||
|
|
||||||
updateNewTabButtonOpacity()
|
updateNewTabButtonOpacity()
|
||||||
resetZoomTabButton.isEnabled = false
|
resetZoomTabButton.contentTintColor = .secondaryLabelColor
|
||||||
resetZoomTabButton.contentTintColor = .labelColor
|
|
||||||
resetZoomToolbarButton.contentTintColor = .tertiaryLabelColor
|
resetZoomToolbarButton.contentTintColor = .tertiaryLabelColor
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,6 +261,20 @@ class TerminalWindow: NSWindow {
|
|||||||
return button
|
return button
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc private func selectTabAndZoom(_ sender: NSButton) {
|
||||||
|
guard let tabGroup else { return }
|
||||||
|
|
||||||
|
guard let associatedWindow = tabGroup.windows.first(where: {
|
||||||
|
guard let accessoryView = $0.tab.accessoryView else { return false }
|
||||||
|
return accessoryView.subviews.contains(sender)
|
||||||
|
}),
|
||||||
|
let windowController = associatedWindow.windowController as? TerminalController
|
||||||
|
else { return }
|
||||||
|
|
||||||
|
tabGroup.selectedWindow = associatedWindow
|
||||||
|
windowController.splitZoom(self)
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Titlebar Tabs
|
// MARK: - Titlebar Tabs
|
||||||
|
|
||||||
// Used by the window controller to enable/disable titlebar tabs.
|
// Used by the window controller to enable/disable titlebar tabs.
|
||||||
|
Reference in New Issue
Block a user