Rename maximize notification and refine handler
parent
1ec3e331de
commit
13f776d483
|
|
@ -117,8 +117,8 @@ class BaseTerminalController: NSWindowController,
|
||||||
object: nil)
|
object: nil)
|
||||||
center.addObserver(
|
center.addObserver(
|
||||||
self,
|
self,
|
||||||
selector: #selector(toggleMaximize),
|
selector: #selector(ghosttyMaximizeDidToggle(_:)),
|
||||||
name: .ghosttyToggleMaximize,
|
name: .ghosttyMaximizeDidToggle,
|
||||||
object: nil)
|
object: nil)
|
||||||
|
|
||||||
// Listen for local events that we need to know of outside of
|
// Listen for local events that we need to know of outside of
|
||||||
|
|
@ -239,6 +239,13 @@ class BaseTerminalController: NSWindowController,
|
||||||
toggleCommandPalette(nil)
|
toggleCommandPalette(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc private func ghosttyMaximizeDidToggle(_ notification: Notification) {
|
||||||
|
guard let window else { return }
|
||||||
|
guard let surfaceView = notification.object as? Ghostty.SurfaceView else { return }
|
||||||
|
guard surfaceTree?.contains(view: surfaceView) ?? false else { return }
|
||||||
|
window.zoom(nil)
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: Local Events
|
// MARK: Local Events
|
||||||
|
|
||||||
private func localEventHandler(_ event: NSEvent) -> NSEvent? {
|
private func localEventHandler(_ event: NSEvent) -> NSEvent? {
|
||||||
|
|
@ -553,11 +560,6 @@ class BaseTerminalController: NSWindowController,
|
||||||
window.performClose(sender)
|
window.performClose(sender)
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func toggleMaximize(_ sender: Any) {
|
|
||||||
guard let window = window else { return }
|
|
||||||
window.zoom(self)
|
|
||||||
}
|
|
||||||
|
|
||||||
@IBAction func splitRight(_ sender: Any) {
|
@IBAction func splitRight(_ sender: Any) {
|
||||||
guard let surface = focusedSurface?.surface else { return }
|
guard let surface = focusedSurface?.surface else { return }
|
||||||
ghostty.split(surface: surface, direction: GHOSTTY_SPLIT_DIRECTION_RIGHT)
|
ghostty.split(surface: surface, direction: GHOSTTY_SPLIT_DIRECTION_RIGHT)
|
||||||
|
|
|
||||||
|
|
@ -783,7 +783,7 @@ extension Ghostty {
|
||||||
guard let surface = target.target.surface else { return }
|
guard let surface = target.target.surface else { return }
|
||||||
guard let surfaceView = self.surfaceView(from: surface) else { return }
|
guard let surfaceView = self.surfaceView(from: surface) else { return }
|
||||||
NotificationCenter.default.post(
|
NotificationCenter.default.post(
|
||||||
name: .ghosttyToggleMaximize,
|
name: .ghosttyMaximizeDidToggle,
|
||||||
object: surfaceView
|
object: surfaceView
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -259,7 +259,7 @@ extension Notification.Name {
|
||||||
static let ghosttyCommandPaletteDidToggle = Notification.Name("com.mitchellh.ghostty.commandPaletteDidToggle")
|
static let ghosttyCommandPaletteDidToggle = Notification.Name("com.mitchellh.ghostty.commandPaletteDidToggle")
|
||||||
|
|
||||||
/// Toggle maximize of current window
|
/// Toggle maximize of current window
|
||||||
static let ghosttyToggleMaximize = Notification.Name("com.mitchellh.ghostty.toggleMaximize")
|
static let ghosttyMaximizeDidToggle = Notification.Name("com.mitchellh.ghostty.maximizeDidToggle")
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: I am moving all of these to Notification.Name extensions over time. This
|
// NOTE: I am moving all of these to Notification.Name extensions over time. This
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue