LatinKeyboardMappings // Maintenance fix with Dvorak.QwertyCMD.

This commit is contained in:
ShikiSuen 2024-02-13 14:42:03 +08:00
parent e749e65627
commit 92b2ada9c5
2 changed files with 15 additions and 23 deletions

View File

@ -15,23 +15,13 @@ public enum IMKHelper {
///
/// SwiftUI 便使
public static let arrWhitelistedKeyLayoutsASCII: [String] = {
var result = [
"com.apple.keylayout.ABC",
"com.apple.keylayout.ABC-AZERTY",
"com.apple.keylayout.ABC-QWERTZ",
"com.apple.keylayout.British",
"com.apple.keylayout.Colemak",
"com.apple.keylayout.Dvorak",
"com.apple.keylayout.Dvorak-Left",
"com.apple.keylayout.DVORAK-QWERTYCMD",
"com.apple.keylayout.Dvorak-Right",
]
if #unavailable(macOS 10.13) {
result.insert("com.apple.keylayout.US", at: result.startIndex)
result.append("com.apple.keylayout.German")
result.append("com.apple.keylayout.French")
var results = LatinKeyboardMappings.allCases
if #available(macOS 10.13, *) {
results = results.filter {
![.qwertyUS, .qwertzGerman, .azertyFrench].contains($0)
}
}
return result
return results.map(\.rawValue)
}()
public static let arrDynamicBasicKeyLayouts: [String] = [

View File

@ -8,25 +8,27 @@
import Foundation
public enum LatinKeyboardMappings: String {
public enum LatinKeyboardMappings: String, CaseIterable {
case qwerty = "com.apple.keylayout.ABC"
case qwertyUS = "com.apple.keylayout.US"
case qwertyBritish = "com.apple.keylayout.British"
case qwertyUS = "com.apple.keylayout.US" // 10.9 - 10.12
case azerty = "com.apple.keylayout.ABC-AZERTY"
case azertyFrench = "com.apple.keylayout.French"
case qwertz = "com.apple.keylayout.ABC-QWERTZ"
case qwertyGerman = "com.apple.keylayout.German"
case azertyFrench = "com.apple.keylayout.French" // 10.9 - 10.12
case qwertzGerman = "com.apple.keylayout.German" // 10.9 - 10.12
case colemak = "com.apple.keylayout.Colemak"
case dvorak = "com.apple.keylayout.Dvorak"
case dvorakQwertyCMD = "com.apple.keylayout.DVORAK-QWERTYCMD"
case dvorakLeft = "com.apple.keylayout.Dvorak-Left"
case dvorakRight = "com.apple.keylayout.Dvorak-Right"
public var mapTable: [UInt16: (String, String)] {
switch self {
case .qwerty, .qwertyUS: return Self.dictQwerty
case .qwerty, .qwertyUS, .qwertyBritish: return Self.dictQwerty
case .azerty, .azertyFrench: return Self.dictAzerty
case .qwertz, .qwertyGerman: return Self.dictQwertz
case .qwertz, .qwertzGerman: return Self.dictQwertz
case .colemak: return Self.dictColemak
case .dvorak: return Self.dictDvorak
case .dvorak, .dvorakQwertyCMD: return Self.dictDvorak
case .dvorakLeft: return Self.dictDvorakLeft
case .dvorakRight: return Self.dictDvorakRight
}