mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-05-05 05:14:40 +00:00
Add settings shortcut on MacOS
- Settings shortcut opens the config file in the default editor. Signed-off-by: Borja Clemente <borja.clemente@gmail.com>
This commit is contained in:
@@ -12,6 +12,7 @@ class AppDelegate: NSObject, ObservableObject, NSApplicationDelegate, UNUserNoti
|
||||
)
|
||||
|
||||
/// Various menu items so that we can programmatically sync the keyboard shortcut with the Ghostty config.
|
||||
@IBOutlet private var menuOpenConfig: NSMenuItem?
|
||||
@IBOutlet private var menuReloadConfig: NSMenuItem?
|
||||
@IBOutlet private var menuQuit: NSMenuItem?
|
||||
|
||||
@@ -211,6 +212,7 @@ class AppDelegate: NSObject, ObservableObject, NSApplicationDelegate, UNUserNoti
|
||||
private func syncMenuShortcuts() {
|
||||
guard ghostty.config != nil else { return }
|
||||
|
||||
syncMenuShortcut(action: "open_config", menuItem: self.menuOpenConfig)
|
||||
syncMenuShortcut(action: "reload_config", menuItem: self.menuReloadConfig)
|
||||
syncMenuShortcut(action: "quit", menuItem: self.menuQuit)
|
||||
|
||||
@@ -340,6 +342,10 @@ class AppDelegate: NSObject, ObservableObject, NSApplicationDelegate, UNUserNoti
|
||||
|
||||
//MARK: - IB Actions
|
||||
|
||||
@IBAction func openConfig(_ sender: Any?) {
|
||||
ghostty.openConfig()
|
||||
}
|
||||
|
||||
@IBAction func reloadConfig(_ sender: Any?) {
|
||||
ghostty.reloadConfig()
|
||||
}
|
||||
|
||||
@@ -146,6 +146,7 @@ extension Ghostty {
|
||||
userdata: Unmanaged.passUnretained(self).toOpaque(),
|
||||
supports_selection_clipboard: false,
|
||||
wakeup_cb: { userdata in AppState.wakeup(userdata) },
|
||||
open_config_cb: { userdata in AppState.openConfig(userdata) },
|
||||
reload_config_cb: { userdata in AppState.reloadConfig(userdata) },
|
||||
set_title_cb: { userdata, title in AppState.setTitle(userdata, title: title) },
|
||||
set_mouse_shape_cb: { userdata, shape in AppState.setMouseShape(userdata, shape: shape) },
|
||||
@@ -267,6 +268,11 @@ extension Ghostty {
|
||||
NSApplication.shared.terminate(nil)
|
||||
}
|
||||
|
||||
func openConfig() {
|
||||
guard let app = self.app else { return }
|
||||
ghostty_app_open_config(app)
|
||||
}
|
||||
|
||||
func reloadConfig() {
|
||||
guard let app = self.app else { return }
|
||||
ghostty_app_reload_config(app)
|
||||
@@ -489,6 +495,10 @@ extension Ghostty {
|
||||
)
|
||||
}
|
||||
|
||||
static func openConfig(_ userdata: UnsafeMutableRawPointer?) {
|
||||
ghostty_config_open();
|
||||
}
|
||||
|
||||
static func reloadConfig(_ userdata: UnsafeMutableRawPointer?) -> ghostty_config_t? {
|
||||
guard let newConfig = Self.loadConfig() else {
|
||||
AppDelegate.logger.warning("failed to reload configuration")
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
<outlet property="menuNewTab" destination="uTG-Vz-hJU" id="eMg-R3-SeS"/>
|
||||
<outlet property="menuNewWindow" destination="Was-JA-tGl" id="lK7-3I-CPG"/>
|
||||
<outlet property="menuNextSplit" destination="bD7-ei-wKU" id="LeT-xw-eh4"/>
|
||||
<outlet property="menuOpenConfig" destination="BOF-NM-1cW" id="Nze-Go-glw"/>
|
||||
<outlet property="menuPaste" destination="i27-pK-umN" id="ICc-X2-gV3"/>
|
||||
<outlet property="menuPreviousSplit" destination="Lic-px-1wg" id="Rto-CG-yRe"/>
|
||||
<outlet property="menuQuit" destination="4sb-4s-VLi" id="qYN-S1-6UW"/>
|
||||
@@ -57,7 +58,11 @@
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
|
||||
<menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW"/>
|
||||
<menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW">
|
||||
<connections>
|
||||
<action selector="openConfig:" target="bbz-4X-AYv" id="X65-fg-iWU"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Reload Configuration" id="KKH-XX-5py">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
|
||||
Reference in New Issue
Block a user