macOS: add cut menu
parent
72f4983b8a
commit
91f9152d34
|
|
@ -40,6 +40,7 @@ class AppDelegate: NSObject,
|
|||
|
||||
@IBOutlet private var menuUndo: NSMenuItem?
|
||||
@IBOutlet private var menuRedo: NSMenuItem?
|
||||
@IBOutlet private var menuCut: NSMenuItem?
|
||||
@IBOutlet private var menuCopy: NSMenuItem?
|
||||
@IBOutlet private var menuPaste: NSMenuItem?
|
||||
@IBOutlet private var menuPasteSelection: NSMenuItem?
|
||||
|
|
@ -1144,6 +1145,7 @@ extension AppDelegate {
|
|||
@MainActor private func saveRestorableMenuItems() {
|
||||
[
|
||||
menuUndo, menuRedo,
|
||||
menuCut,
|
||||
menuCopy, menuPaste, menuSelectAll,
|
||||
]
|
||||
.compactMap { $0 }
|
||||
|
|
@ -1185,6 +1187,7 @@ extension AppDelegate {
|
|||
|
||||
syncMenuShortcut(config, action: "undo", menuItem: self.menuUndo)
|
||||
syncMenuShortcut(config, action: "redo", menuItem: self.menuRedo)
|
||||
syncMenuShortcut(config, action: nil, menuItem: self.menuCut)
|
||||
syncMenuShortcut(config, action: "copy_to_clipboard", menuItem: self.menuCopy)
|
||||
syncMenuShortcut(config, action: "paste_from_clipboard", menuItem: self.menuPaste)
|
||||
syncMenuShortcut(config, action: "paste_from_selection", menuItem: self.menuPasteSelection)
|
||||
|
|
@ -1233,7 +1236,7 @@ extension AppDelegate {
|
|||
reloadDockMenu()
|
||||
}
|
||||
|
||||
@MainActor private func syncMenuShortcut(_ config: Ghostty.Config, action: String, menuItem: NSMenuItem?) {
|
||||
@MainActor private func syncMenuShortcut(_ config: Ghostty.Config, action: String?, menuItem: NSMenuItem?) {
|
||||
menuShortcutManager.syncMenuShortcut(config, action: action, menuItem: menuItem)
|
||||
}
|
||||
|
||||
|
|
@ -1346,7 +1349,8 @@ extension AppDelegate: NSMenuItemValidation {
|
|||
item.title = "Redo"
|
||||
}
|
||||
return undoManager.canRedo
|
||||
|
||||
case menuCut?.action:
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
<outlet property="menuCloseWindow" destination="W5w-UZ-crk" id="6ff-BT-ENV"/>
|
||||
<outlet property="menuCommandPalette" destination="et6-de-Mh7" id="53t-cu-dm5"/>
|
||||
<outlet property="menuCopy" destination="Jqf-pv-Zcu" id="bKd-1C-oy9"/>
|
||||
<outlet property="menuCut" destination="H0A-Vb-3cx" id="fby-cu-YhH"/>
|
||||
<outlet property="menuDecreaseFontSize" destination="kzb-SZ-dOA" id="Y1B-Vh-6Z2"/>
|
||||
<outlet property="menuEqualizeSplits" destination="3gH-VD-vL9" id="SiZ-ce-FOF"/>
|
||||
<outlet property="menuFind" destination="nwE-0w-30h" id="idg-Nc-apE"/>
|
||||
|
|
@ -234,6 +235,11 @@
|
|||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="4O9-zO-zB9"/>
|
||||
<menuItem title="Cut" keyEquivalent="x" id="H0A-Vb-3cx">
|
||||
<connections>
|
||||
<action selector="cut:" target="-1" id="iOR-ZB-8ZI"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Copy" keyEquivalent="c" id="Jqf-pv-Zcu">
|
||||
<connections>
|
||||
<action selector="copy:" target="-1" id="B4F-hg-R4T"/>
|
||||
|
|
|
|||
|
|
@ -116,8 +116,8 @@ extension Ghostty {
|
|||
/// configuration would be "quit" action.
|
||||
///
|
||||
/// Returns nil if there is no key equivalent for the given action.
|
||||
func keyboardShortcut(for action: String) -> KeyboardShortcut? {
|
||||
guard let cfg = self.config else { return nil }
|
||||
func keyboardShortcut(for action: String?) -> KeyboardShortcut? {
|
||||
guard let action, let cfg = self.config else { return nil }
|
||||
|
||||
let trigger = ghostty_config_trigger(cfg, action, UInt(action.lengthOfBytes(using: .utf8)))
|
||||
return Ghostty.keyboardShortcut(for: trigger)
|
||||
|
|
|
|||
Loading…
Reference in New Issue