1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-29 16:56:40 +03:00

Make special keys file private

This commit is contained in:
Tae Won Ha 2017-05-17 21:57:16 +02:00
parent 5430834773
commit 53bed4540a
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44

View File

@ -7,7 +7,28 @@ import Cocoa
class KeyUtils {
static let specialKeys = [
static func isSpecial(key: String) -> Bool {
guard key.characters.count == 1 else {
return false
}
if let firstChar = key.utf16.first {
return specialKeys.keys.contains(Int(firstChar))
}
return false
}
static func namedKeyFrom(key: String) -> String {
if let firstChar = key.utf16.first, specialKeys.keys.contains(Int(firstChar)) {
return specialKeys[Int(firstChar)]!
}
return key
}
}
fileprivate let specialKeys = [
NSUpArrowFunctionKey: "Up",
NSDownArrowFunctionKey: "Down",
NSLeftArrowFunctionKey: "Left",
@ -58,26 +79,3 @@ class KeyUtils {
NSF35FunctionKey: "F35",
0x19: "Tab",
]
static func isSpecial(key: String) -> Bool {
guard key.characters.count == 1 else {
return false
}
if let firstChar = key.utf16.first {
return KeyUtils.specialKeys.keys.contains(Int(firstChar))
}
return false
}
static func namedKeyFrom(key: String) -> String {
if let firstChar = key.utf16.first {
if KeyUtils.specialKeys.keys.contains(Int(firstChar)) {
return KeyUtils.specialKeys[Int(firstChar)]!
}
}
return key
}
}