vChewing-macOS/Source/Modules/PrefMgr_Extension.swift

59 lines
2.3 KiB
Swift

// (c) 2021 and onwards The vChewing Project (MIT-NTL License).
// ====================
// This code is released under the MIT license (SPDX-License-Identifier: MIT)
// ... with NTL restriction stating that:
// No trademark license is granted to use the trade names, trademarks, service
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Shared
// MARK: Auto parameter fix procedures, executed everytime on SessionCtl.activateServer().
extension PrefMgr {
public func fixOddPreferences() {
// macOS 10.15 使 SwiftUI
if #unavailable(macOS 10.15) {
useIMKCandidateWindow = true
handleDefaultCandidateFontsByLangIdentifier = false
shiftKeyAccommodationBehavior = 0
disableShiftTogglingAlphanumericalMode = true
togglingAlphanumericalModeWithLShift = false
showReverseLookupInCandidateUI = false
shareAlphanumericalModeStatusAcrossClients = false
}
// ( didSet )
candidateKeys = candidateKeys
//
clientsIMKTextInputIncapable = Array(Set(clientsIMKTextInputIncapable)).sorted()
//
var isKeyboardParserOptionValid = false
KeyboardParser.allCases.forEach {
if $0.rawValue == keyboardParser { isKeyboardParserOptionValid = true }
}
if !isKeyboardParserOptionValid {
keyboardParser = 0
}
//
if TISInputSource.generate(from: basicKeyboardLayout) == nil {
basicKeyboardLayout = Self.kDefaultBasicKeyboardLayout
}
if TISInputSource.generate(from: alphanumericalKeyboardLayout) == nil {
alphanumericalKeyboardLayout = Self.kDefaultAlphanumericalKeyboardLayout
}
//
if ![0, 1, 2].contains(specifyIntonationKeyBehavior) {
specifyIntonationKeyBehavior = 0
}
if ![0, 1, 2].contains(specifyShiftBackSpaceKeyBehavior) {
specifyShiftBackSpaceKeyBehavior = 0
}
if ![0, 1, 2].contains(upperCaseLetterKeyBehavior) {
upperCaseLetterKeyBehavior = 0
}
if ![0, 1, 2].contains(shiftKeyAccommodationBehavior) {
shiftKeyAccommodationBehavior = 0
}
}
}