commit
732500b418
|
|
@ -29,7 +29,6 @@ struct TerminalCommandPaletteView: View {
|
|||
let key = String(cString: c.action_key)
|
||||
switch (key) {
|
||||
case "toggle_tab_overview",
|
||||
"toggle_maximize",
|
||||
"toggle_window_decorations":
|
||||
return false
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -115,6 +115,11 @@ class BaseTerminalController: NSWindowController,
|
|||
selector: #selector(ghosttyCommandPaletteDidToggle(_:)),
|
||||
name: .ghosttyCommandPaletteDidToggle,
|
||||
object: nil)
|
||||
center.addObserver(
|
||||
self,
|
||||
selector: #selector(ghosttyMaximizeDidToggle(_:)),
|
||||
name: .ghosttyMaximizeDidToggle,
|
||||
object: nil)
|
||||
|
||||
// Listen for local events that we need to know of outside of
|
||||
// single surface handlers.
|
||||
|
|
@ -234,6 +239,13 @@ class BaseTerminalController: NSWindowController,
|
|||
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
|
||||
|
||||
private func localEventHandler(_ event: NSEvent) -> NSEvent? {
|
||||
|
|
|
|||
|
|
@ -526,6 +526,9 @@ extension Ghostty {
|
|||
case GHOSTTY_ACTION_TOGGLE_COMMAND_PALETTE:
|
||||
toggleCommandPalette(app, target: target)
|
||||
|
||||
case GHOSTTY_ACTION_TOGGLE_MAXIMIZE:
|
||||
toggleMaximize(app, target: target)
|
||||
|
||||
case GHOSTTY_ACTION_TOGGLE_QUICK_TERMINAL:
|
||||
toggleQuickTerminal(app, target: target)
|
||||
|
||||
|
|
@ -770,6 +773,29 @@ extension Ghostty {
|
|||
}
|
||||
}
|
||||
|
||||
private static func toggleMaximize(
|
||||
_ app: ghostty_app_t,
|
||||
target: ghostty_target_s
|
||||
) {
|
||||
switch (target.tag) {
|
||||
case GHOSTTY_TARGET_APP:
|
||||
Ghostty.logger.warning("toggle maximize does nothing with an app target")
|
||||
return
|
||||
|
||||
case GHOSTTY_TARGET_SURFACE:
|
||||
guard let surface = target.target.surface else { return }
|
||||
guard let surfaceView = self.surfaceView(from: surface) else { return }
|
||||
NotificationCenter.default.post(
|
||||
name: .ghosttyMaximizeDidToggle,
|
||||
object: surfaceView
|
||||
)
|
||||
|
||||
|
||||
default:
|
||||
assertionFailure()
|
||||
}
|
||||
}
|
||||
|
||||
private static func toggleVisibility(
|
||||
_ app: ghostty_app_t,
|
||||
target: ghostty_target_s
|
||||
|
|
|
|||
|
|
@ -279,6 +279,9 @@ extension Notification.Name {
|
|||
/// Ring the bell
|
||||
static let ghosttyBellDidRing = Notification.Name("com.mitchellh.ghostty.ghosttyBellDidRing")
|
||||
static let ghosttyCommandPaletteDidToggle = Notification.Name("com.mitchellh.ghostty.commandPaletteDidToggle")
|
||||
|
||||
/// Toggle maximize of current window
|
||||
static let ghosttyMaximizeDidToggle = Notification.Name("com.mitchellh.ghostty.maximizeDidToggle")
|
||||
}
|
||||
|
||||
// NOTE: I am moving all of these to Notification.Name extensions over time. This
|
||||
|
|
|
|||
Loading…
Reference in New Issue