vChewing-macOS/Source/Modules/PrefMgr_Extension.swift

57 lines
2.4 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// (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.11 IMK macOS 10.13 IMK
// IMK macOS 10.09
// macOS 10.14 IMKCandidates
if #unavailable(macOS 12) { useIMKCandidateWindow = true }
if #unavailable(macOS 10.15) {
handleDefaultCandidateFontsByLangIdentifier = false
shiftKeyAccommodationBehavior = 0
disableShiftTogglingAlphanumericalMode = false
togglingAlphanumericalModeWithLShift = false
}
//
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
}
}
}