mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: attach various menu items to first responder, terminal
Fixes #758
This commit is contained in:
@ -236,11 +236,6 @@ class AppDelegate: NSObject, ObservableObject, NSApplicationDelegate, GhosttyApp
|
||||
return terminalManager.focusedSurface?.surface
|
||||
}
|
||||
|
||||
private func splitMoveFocus(direction: Ghostty.SplitFocusDirection) {
|
||||
guard let surface = focusedSurface() else { return }
|
||||
ghostty.splitMoveFocus(surface: surface, direction: direction)
|
||||
}
|
||||
|
||||
//MARK: - GhosttyAppStateDelegate
|
||||
|
||||
func configDidReload(_ state: Ghostty.AppState) {
|
||||
@ -311,86 +306,8 @@ class AppDelegate: NSObject, ObservableObject, NSApplicationDelegate, GhosttyApp
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
}
|
||||
|
||||
@IBAction func closeWindow(_ sender: Any) {
|
||||
guard let currentWindow = NSApp.keyWindow else { return }
|
||||
currentWindow.close()
|
||||
}
|
||||
|
||||
@IBAction func close(_ sender: Any) {
|
||||
guard let surface = focusedSurface() else {
|
||||
self.closeWindow(self)
|
||||
return
|
||||
}
|
||||
|
||||
ghostty.requestClose(surface: surface)
|
||||
}
|
||||
|
||||
@IBAction func splitHorizontally(_ sender: Any) {
|
||||
guard let surface = focusedSurface() else { return }
|
||||
ghostty.split(surface: surface, direction: GHOSTTY_SPLIT_RIGHT)
|
||||
}
|
||||
|
||||
@IBAction func splitVertically(_ sender: Any) {
|
||||
guard let surface = focusedSurface() else { return }
|
||||
ghostty.split(surface: surface, direction: GHOSTTY_SPLIT_DOWN)
|
||||
}
|
||||
|
||||
@IBAction func splitZoom(_ sender: Any) {
|
||||
guard let surface = focusedSurface() else { return }
|
||||
ghostty.splitToggleZoom(surface: surface)
|
||||
}
|
||||
|
||||
@IBAction func splitMoveFocusPrevious(_ sender: Any) {
|
||||
splitMoveFocus(direction: .previous)
|
||||
}
|
||||
|
||||
@IBAction func splitMoveFocusNext(_ sender: Any) {
|
||||
splitMoveFocus(direction: .next)
|
||||
}
|
||||
|
||||
@IBAction func splitMoveFocusAbove(_ sender: Any) {
|
||||
splitMoveFocus(direction: .top)
|
||||
}
|
||||
|
||||
@IBAction func splitMoveFocusBelow(_ sender: Any) {
|
||||
splitMoveFocus(direction: .bottom)
|
||||
}
|
||||
|
||||
@IBAction func splitMoveFocusLeft(_ sender: Any) {
|
||||
splitMoveFocus(direction: .left)
|
||||
}
|
||||
|
||||
@IBAction func splitMoveFocusRight(_ sender: Any) {
|
||||
splitMoveFocus(direction: .right)
|
||||
}
|
||||
|
||||
@IBAction func showHelp(_ sender: Any) {
|
||||
guard let url = URL(string: "https://github.com/mitchellh/ghostty") else { return }
|
||||
NSWorkspace.shared.open(url)
|
||||
}
|
||||
|
||||
@IBAction func toggleFullScreen(_ sender: Any) {
|
||||
guard let surface = focusedSurface() else { return }
|
||||
ghostty.toggleFullscreen(surface: surface)
|
||||
}
|
||||
|
||||
@IBAction func increaseFontSize(_ sender: Any) {
|
||||
guard let surface = focusedSurface() else { return }
|
||||
ghostty.changeFontSize(surface: surface, .increase(1))
|
||||
}
|
||||
|
||||
@IBAction func decreaseFontSize(_ sender: Any) {
|
||||
guard let surface = focusedSurface() else { return }
|
||||
ghostty.changeFontSize(surface: surface, .decrease(1))
|
||||
}
|
||||
|
||||
@IBAction func resetFontSize(_ sender: Any) {
|
||||
guard let surface = focusedSurface() else { return }
|
||||
ghostty.changeFontSize(surface: surface, .reset)
|
||||
}
|
||||
|
||||
@IBAction func toggleTerminalInspector(_ sender: Any) {
|
||||
guard let surface = focusedSurface() else { return }
|
||||
ghostty.toggleTerminalInspector(surface: surface)
|
||||
}
|
||||
}
|
||||
|
@ -150,6 +150,86 @@ class TerminalController: NSWindowController, NSWindowDelegate, TerminalViewDele
|
||||
self.window?.contentView = nil
|
||||
}
|
||||
|
||||
//MARK: - First Responder
|
||||
|
||||
@IBAction func close(_ sender: Any) {
|
||||
guard let surface = focusedSurface?.surface else { return }
|
||||
ghostty.requestClose(surface: surface)
|
||||
}
|
||||
|
||||
@IBAction func closeWindow(_ sender: Any) {
|
||||
self.window?.performClose(sender)
|
||||
}
|
||||
|
||||
@IBAction func splitHorizontally(_ sender: Any) {
|
||||
guard let surface = focusedSurface?.surface else { return }
|
||||
ghostty.split(surface: surface, direction: GHOSTTY_SPLIT_RIGHT)
|
||||
}
|
||||
|
||||
@IBAction func splitVertically(_ sender: Any) {
|
||||
guard let surface = focusedSurface?.surface else { return }
|
||||
ghostty.split(surface: surface, direction: GHOSTTY_SPLIT_DOWN)
|
||||
}
|
||||
|
||||
@IBAction func splitZoom(_ sender: Any) {
|
||||
guard let surface = focusedSurface?.surface else { return }
|
||||
ghostty.splitToggleZoom(surface: surface)
|
||||
}
|
||||
|
||||
@IBAction func splitMoveFocusPrevious(_ sender: Any) {
|
||||
splitMoveFocus(direction: .previous)
|
||||
}
|
||||
|
||||
@IBAction func splitMoveFocusNext(_ sender: Any) {
|
||||
splitMoveFocus(direction: .next)
|
||||
}
|
||||
|
||||
@IBAction func splitMoveFocusAbove(_ sender: Any) {
|
||||
splitMoveFocus(direction: .top)
|
||||
}
|
||||
|
||||
@IBAction func splitMoveFocusBelow(_ sender: Any) {
|
||||
splitMoveFocus(direction: .bottom)
|
||||
}
|
||||
|
||||
@IBAction func splitMoveFocusLeft(_ sender: Any) {
|
||||
splitMoveFocus(direction: .left)
|
||||
}
|
||||
|
||||
@IBAction func splitMoveFocusRight(_ sender: Any) {
|
||||
splitMoveFocus(direction: .right)
|
||||
}
|
||||
|
||||
private func splitMoveFocus(direction: Ghostty.SplitFocusDirection) {
|
||||
guard let surface = focusedSurface?.surface else { return }
|
||||
ghostty.splitMoveFocus(surface: surface, direction: direction)
|
||||
}
|
||||
|
||||
@IBAction func toggleFullScreen(_ sender: Any) {
|
||||
guard let surface = focusedSurface?.surface else { return }
|
||||
ghostty.toggleFullscreen(surface: surface)
|
||||
}
|
||||
|
||||
@IBAction func increaseFontSize(_ sender: Any) {
|
||||
guard let surface = focusedSurface?.surface else { return }
|
||||
ghostty.changeFontSize(surface: surface, .increase(1))
|
||||
}
|
||||
|
||||
@IBAction func decreaseFontSize(_ sender: Any) {
|
||||
guard let surface = focusedSurface?.surface else { return }
|
||||
ghostty.changeFontSize(surface: surface, .decrease(1))
|
||||
}
|
||||
|
||||
@IBAction func resetFontSize(_ sender: Any) {
|
||||
guard let surface = focusedSurface?.surface else { return }
|
||||
ghostty.changeFontSize(surface: surface, .reset)
|
||||
}
|
||||
|
||||
@IBAction func toggleTerminalInspector(_ sender: Any) {
|
||||
guard let surface = focusedSurface?.surface else { return }
|
||||
ghostty.toggleTerminalInspector(surface: surface)
|
||||
}
|
||||
|
||||
//MARK: - TerminalViewDelegate
|
||||
|
||||
func focusedSurfaceDidChange(to: Ghostty.SurfaceView?) {
|
||||
|
@ -107,26 +107,26 @@
|
||||
<menuItem title="Split Horizontally" id="VUR-Ld-nLx">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="splitHorizontally:" target="bbz-4X-AYv" id="QT1-Yt-gYJ"/>
|
||||
<action selector="splitHorizontally:" target="-1" id="cv2-Xg-FR4"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Split Vertically" id="UDZ-4y-6xL">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="splitVertically:" target="bbz-4X-AYv" id="ZZF-3f-OwW"/>
|
||||
<action selector="splitVertically:" target="-1" id="c6x-CF-u52"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="sjq-M1-UGS"/>
|
||||
<menuItem title="Close" id="DVo-aG-piG">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="close:" target="bbz-4X-AYv" id="Szc-Fu-9yk"/>
|
||||
<action selector="close:" target="-1" id="tTZ-2b-Mbm"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Close Window" id="W5w-UZ-crk">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="closeWindow:" target="bbz-4X-AYv" id="j4w-Nd-9bO"/>
|
||||
<action selector="closeWindow:" target="-1" id="ovs-xn-3ju"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
@ -139,26 +139,26 @@
|
||||
<menuItem title="Increase Font Size" id="CIH-ey-Z6x" userLabel="Increase Font Size">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="increaseFontSize:" target="bbz-4X-AYv" id="qbI-YJ-xuW"/>
|
||||
<action selector="increaseFontSize:" target="-1" id="361-5E-7PY"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Reset Font Size" id="Jah-MY-aLX">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="resetFontSize:" target="bbz-4X-AYv" id="2qT-E9-Qt1"/>
|
||||
<action selector="resetFontSize:" target="-1" id="3dh-T9-IkH"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Decrease Font Size" id="kzb-SZ-dOA">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="decreaseFontSize:" target="bbz-4X-AYv" id="rlw-0o-kA2"/>
|
||||
<action selector="decreaseFontSize:" target="-1" id="Zlz-QZ-t8K"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="L3L-I8-sqk"/>
|
||||
<menuItem title="Terminal Inspector" id="QwP-M5-fvh">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleTerminalInspector:" target="bbz-4X-AYv" id="DON-fR-wyr"/>
|
||||
<action selector="toggleTerminalInspector:" target="-1" id="87m-3R-fQl"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
@ -216,19 +216,19 @@
|
||||
<menuItem title="Zoom Split" id="oPd-mn-IEH">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="splitZoom:" target="bbz-4X-AYv" id="h3L-kI-kTJ"/>
|
||||
<action selector="splitZoom:" target="-1" id="g0e-Ls-D7L"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Select Previous Split" id="Lic-px-1wg">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="splitMoveFocusPrevious:" target="bbz-4X-AYv" id="mOs-gG-dAC"/>
|
||||
<action selector="splitMoveFocusPrevious:" target="-1" id="ip5-6M-66n"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Select Next Split" id="bD7-ei-wKU">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="splitMoveFocusNext:" target="bbz-4X-AYv" id="rU6-Vw-DoW"/>
|
||||
<action selector="splitMoveFocusNext:" target="-1" id="FSV-0l-3VR"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Select Split" id="dos-9S-LXC">
|
||||
@ -238,25 +238,25 @@
|
||||
<menuItem title="Select Split Above" id="0yU-hC-8xF">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="splitMoveFocusAbove:" target="bbz-4X-AYv" id="HDw-f2-RJY"/>
|
||||
<action selector="splitMoveFocusAbove:" target="-1" id="0Y7-7I-yQO"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Select Split Below" id="QDz-d9-CBr">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="splitMoveFocusBelow:" target="bbz-4X-AYv" id="fmW-hZ-uOA"/>
|
||||
<action selector="splitMoveFocusBelow:" target="-1" id="9yp-du-tEq"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Select Split Left" id="cTK-oy-KuV">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="splitMoveFocusLeft:" target="bbz-4X-AYv" id="N1i-a2-7N5"/>
|
||||
<action selector="splitMoveFocusLeft:" target="-1" id="BZI-DX-ly3"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Select Split Right" id="upj-mc-L7X">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="splitMoveFocusRight:" target="bbz-4X-AYv" id="Pgi-df-84r"/>
|
||||
<action selector="splitMoveFocusRight:" target="-1" id="ELo-QZ-O6q"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
|
Reference in New Issue
Block a user