1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-24 11:37:32 +03:00

GH-226 Enable or disable cut/copy/paste menu items

This commit is contained in:
Tae Won Ha 2016-08-04 23:34:09 +02:00
parent 74f5989ec3
commit 9885505a68
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44

View File

@ -17,7 +17,7 @@ private struct RowRun: CustomStringConvertible {
}
}
public class NeoVimView: NSView {
public class NeoVimView: NSView, NSUserInterfaceValidations {
public static let minFontSize = CGFloat(4)
public static let maxFontSize = CGFloat(128)
@ -346,23 +346,40 @@ public class NeoVimView: NSView {
}
}
// MARK: - NSUserInterfaceValidationsProtocol
extension NeoVimView {
public func validateUserInterfaceItem(item: NSValidatedUserInterfaceItem) -> Bool {
let canCopyOrCut = self.mode != .Insert && self.mode != .Cmdline
switch item.action() {
case NSSelectorFromString("copy:"), NSSelectorFromString("cut:"):
return canCopyOrCut
default:
return true
}
}
}
// MARK: - Edit Menu Items
extension NeoVimView {
@IBAction func cut(sender: AnyObject!) {
if self.mode == .Insert {
if self.mode == .Insert || self.mode == .Cmdline {
return
}
self.agent.vimCommand("norm! \"+d")
self.agent.vimInput(self.wrapNamedKeys(KeyUtils.specialKeys[NSRightArrowFunctionKey]!))
}
@IBAction func copy(sender: AnyObject!) {
if self.mode == .Insert {
if self.mode == .Insert || self.mode == .Cmdline {
return
}
self.agent.vimCommand("norm! \"+y")
self.agent.vimInput(self.wrapNamedKeys(KeyUtils.specialKeys[NSRightArrowFunctionKey]!))
}
@IBAction func paste(sender: AnyObject!) {