Repo // Pack InputMode typedefs into Shared package.

This commit is contained in:
ShikiSuen 2022-09-21 12:31:51 +08:00
parent a4a37feb16
commit f80c13331d
10 changed files with 85 additions and 83 deletions

View File

@ -238,4 +238,21 @@ public enum Shared {
] ]
public static let arrSupportedLocales: [String] = ["en", "zh-Hant", "zh-Hans", "ja"] public static let arrSupportedLocales: [String] = ["en", "zh-Hant", "zh-Hans", "ja"]
// The type of input modes.
public enum InputMode: String, CaseIterable {
case imeModeCHS = "org.atelierInmu.inputmethod.vChewing.IMECHS"
case imeModeCHT = "org.atelierInmu.inputmethod.vChewing.IMECHT"
case imeModeNULL = ""
public var reversed: Shared.InputMode {
switch self {
case .imeModeCHS:
return .imeModeCHT
case .imeModeCHT:
return .imeModeCHS
case .imeModeNULL:
return .imeModeNULL
}
}
}
} }

View File

@ -57,7 +57,7 @@ public enum ChineseConverter {
if !PrefMgr.shared.currencyNumeralsEnabled { return } if !PrefMgr.shared.currencyNumeralsEnabled { return }
for key in currencyNumeralDictTable.keys { for key in currencyNumeralDictTable.keys {
guard let result = currencyNumeralDictTable[key] else { continue } guard let result = currencyNumeralDictTable[key] else { continue }
if IMEApp.currentInputMode == InputMode.imeModeCHS { if IMEApp.currentInputMode == .imeModeCHS {
target = target.replacingOccurrences(of: key, with: result.3) // Simplified Chinese target = target.replacingOccurrences(of: key, with: result.3) // Simplified Chinese
continue continue
} }
@ -75,9 +75,9 @@ public enum ChineseConverter {
/// - Returns: Text converted to Different Script. /// - Returns: Text converted to Different Script.
public static func crossConvert(_ string: String) -> String? { public static func crossConvert(_ string: String) -> String? {
switch IMEApp.currentInputMode { switch IMEApp.currentInputMode {
case InputMode.imeModeCHS: case .imeModeCHS:
return shared.convert(string, to: .zhHantTW) return shared.convert(string, to: .zhHantTW)
case InputMode.imeModeCHT: case .imeModeCHT:
return shared.convert(string, to: .zhHansCN) return shared.convert(string, to: .zhHansCN)
default: default:
return string return string
@ -97,7 +97,7 @@ public enum ChineseConverter {
} }
static func kanjiConversionIfRequired(_ text: String) -> String { static func kanjiConversionIfRequired(_ text: String) -> String {
guard IMEApp.currentInputMode == InputMode.imeModeCHT else { return text } guard IMEApp.currentInputMode == .imeModeCHT else { return text }
switch (PrefMgr.shared.chineseConversionEnabled, PrefMgr.shared.shiftJISShinjitaiOutputEnabled) { switch (PrefMgr.shared.chineseConversionEnabled, PrefMgr.shared.shiftJISShinjitaiOutputEnabled) {
case (false, true): return ChineseConverter.cnvTradToJIS(text) case (false, true): return ChineseConverter.cnvTradToJIS(text)
case (true, false): return ChineseConverter.cnvTradToKangXi(text) case (true, false): return ChineseConverter.cnvTradToKangXi(text)

View File

@ -109,7 +109,7 @@ public enum LMMgr {
} }
} }
public static func loadDataModel(_ mode: InputMode) { public static func loadDataModel(_ mode: Shared.InputMode) {
switch mode { switch mode {
case .imeModeCHS: case .imeModeCHS:
if !Self.lmCHS.isMiscDataLoaded { if !Self.lmCHS.isMiscDataLoaded {
@ -156,56 +156,56 @@ public enum LMMgr {
public static func loadUserPhrasesData() { public static func loadUserPhrasesData() {
Self.lmCHT.loadUserPhrasesData( Self.lmCHT.loadUserPhrasesData(
path: userPhrasesDataURL(InputMode.imeModeCHT).path, path: userPhrasesDataURL(.imeModeCHT).path,
filterPath: userFilteredDataURL(InputMode.imeModeCHT).path filterPath: userFilteredDataURL(.imeModeCHT).path
) )
Self.lmCHS.loadUserPhrasesData( Self.lmCHS.loadUserPhrasesData(
path: userPhrasesDataURL(InputMode.imeModeCHS).path, path: userPhrasesDataURL(.imeModeCHS).path,
filterPath: userFilteredDataURL(InputMode.imeModeCHS).path filterPath: userFilteredDataURL(.imeModeCHS).path
) )
Self.lmCHT.loadUserSymbolData(path: userSymbolDataURL(InputMode.imeModeCHT).path) Self.lmCHT.loadUserSymbolData(path: userSymbolDataURL(.imeModeCHT).path)
Self.lmCHS.loadUserSymbolData(path: userSymbolDataURL(InputMode.imeModeCHS).path) Self.lmCHS.loadUserSymbolData(path: userSymbolDataURL(.imeModeCHS).path)
Self.uomCHT.loadData(fromURL: userOverrideModelDataURL(InputMode.imeModeCHT)) Self.uomCHT.loadData(fromURL: userOverrideModelDataURL(.imeModeCHT))
Self.uomCHS.loadData(fromURL: userOverrideModelDataURL(InputMode.imeModeCHS)) Self.uomCHS.loadData(fromURL: userOverrideModelDataURL(.imeModeCHS))
CandidateNode.load(url: Self.userSymbolMenuDataURL()) CandidateNode.load(url: Self.userSymbolMenuDataURL())
} }
public static func loadUserAssociatesData() { public static func loadUserAssociatesData() {
Self.lmCHT.loadUserAssociatesData( Self.lmCHT.loadUserAssociatesData(
path: Self.userAssociatesDataURL(InputMode.imeModeCHT).path path: Self.userAssociatesDataURL(.imeModeCHT).path
) )
Self.lmCHS.loadUserAssociatesData( Self.lmCHS.loadUserAssociatesData(
path: Self.userAssociatesDataURL(InputMode.imeModeCHS).path path: Self.userAssociatesDataURL(.imeModeCHS).path
) )
} }
public static func loadUserPhraseReplacement() { public static func loadUserPhraseReplacement() {
Self.lmCHT.loadReplacementsData( Self.lmCHT.loadReplacementsData(
path: Self.userReplacementsDataURL(InputMode.imeModeCHT).path path: Self.userReplacementsDataURL(.imeModeCHT).path
) )
Self.lmCHS.loadReplacementsData( Self.lmCHS.loadReplacementsData(
path: Self.userReplacementsDataURL(InputMode.imeModeCHS).path path: Self.userReplacementsDataURL(.imeModeCHS).path
) )
} }
public static func loadUserSCPCSequencesData() { public static func loadUserSCPCSequencesData() {
Self.lmCHT.loadUserSCPCSequencesData( Self.lmCHT.loadUserSCPCSequencesData(
path: Self.userSCPCSequencesURL(InputMode.imeModeCHT).path path: Self.userSCPCSequencesURL(.imeModeCHT).path
) )
Self.lmCHS.loadUserSCPCSequencesData( Self.lmCHS.loadUserSCPCSequencesData(
path: Self.userSCPCSequencesURL(InputMode.imeModeCHS).path path: Self.userSCPCSequencesURL(.imeModeCHS).path
) )
} }
public static func checkIfUserPhraseExist( public static func checkIfUserPhraseExist(
userPhrase: String, userPhrase: String,
mode: InputMode, mode: Shared.InputMode,
key unigramKey: String key unigramKey: String
) -> Bool { ) -> Bool {
let unigrams: [Megrez.Unigram] = let unigrams: [Megrez.Unigram] =
(mode == InputMode.imeModeCHT) (mode == .imeModeCHT)
? Self.lmCHT.unigramsFor(key: unigramKey) : Self.lmCHS.unigramsFor(key: unigramKey) ? Self.lmCHT.unigramsFor(key: unigramKey) : Self.lmCHS.unigramsFor(key: unigramKey)
for unigram in unigrams { for unigram in unigrams {
if unigram.value == userPhrase { if unigram.value == userPhrase {
@ -253,48 +253,48 @@ public enum LMMgr {
/// 使 /// 使
/// - Parameter mode: /// - Parameter mode:
/// - Returns: URL /// - Returns: URL
public static func userPhrasesDataURL(_ mode: InputMode) -> URL { public static func userPhrasesDataURL(_ mode: Shared.InputMode) -> URL {
let fileName = (mode == InputMode.imeModeCHT) ? "userdata-cht.txt" : "userdata-chs.txt" let fileName = (mode == .imeModeCHT) ? "userdata-cht.txt" : "userdata-chs.txt"
return URL(fileURLWithPath: dataFolderPath(isDefaultFolder: false)).appendingPathComponent(fileName) return URL(fileURLWithPath: dataFolderPath(isDefaultFolder: false)).appendingPathComponent(fileName)
} }
/// 使 /// 使
/// - Parameter mode: /// - Parameter mode:
/// - Returns: URL /// - Returns: URL
public static func userSymbolDataURL(_ mode: InputMode) -> URL { public static func userSymbolDataURL(_ mode: Shared.InputMode) -> URL {
let fileName = (mode == InputMode.imeModeCHT) ? "usersymbolphrases-cht.txt" : "usersymbolphrases-chs.txt" let fileName = (mode == .imeModeCHT) ? "usersymbolphrases-cht.txt" : "usersymbolphrases-chs.txt"
return URL(fileURLWithPath: dataFolderPath(isDefaultFolder: false)).appendingPathComponent(fileName) return URL(fileURLWithPath: dataFolderPath(isDefaultFolder: false)).appendingPathComponent(fileName)
} }
/// 使 /// 使
/// - Parameter mode: /// - Parameter mode:
/// - Returns: URL /// - Returns: URL
public static func userAssociatesDataURL(_ mode: InputMode) -> URL { public static func userAssociatesDataURL(_ mode: Shared.InputMode) -> URL {
let fileName = (mode == InputMode.imeModeCHT) ? "associatedPhrases-cht.txt" : "associatedPhrases-chs.txt" let fileName = (mode == .imeModeCHT) ? "associatedPhrases-cht.txt" : "associatedPhrases-chs.txt"
return URL(fileURLWithPath: dataFolderPath(isDefaultFolder: false)).appendingPathComponent(fileName) return URL(fileURLWithPath: dataFolderPath(isDefaultFolder: false)).appendingPathComponent(fileName)
} }
/// 使 /// 使
/// - Parameter mode: /// - Parameter mode:
/// - Returns: URL /// - Returns: URL
public static func userFilteredDataURL(_ mode: InputMode) -> URL { public static func userFilteredDataURL(_ mode: Shared.InputMode) -> URL {
let fileName = (mode == InputMode.imeModeCHT) ? "exclude-phrases-cht.txt" : "exclude-phrases-chs.txt" let fileName = (mode == .imeModeCHT) ? "exclude-phrases-cht.txt" : "exclude-phrases-chs.txt"
return URL(fileURLWithPath: dataFolderPath(isDefaultFolder: false)).appendingPathComponent(fileName) return URL(fileURLWithPath: dataFolderPath(isDefaultFolder: false)).appendingPathComponent(fileName)
} }
/// 使 /// 使
/// - Parameter mode: /// - Parameter mode:
/// - Returns: URL /// - Returns: URL
public static func userReplacementsDataURL(_ mode: InputMode) -> URL { public static func userReplacementsDataURL(_ mode: Shared.InputMode) -> URL {
let fileName = (mode == InputMode.imeModeCHT) ? "phrases-replacement-cht.txt" : "phrases-replacement-chs.txt" let fileName = (mode == .imeModeCHT) ? "phrases-replacement-cht.txt" : "phrases-replacement-chs.txt"
return URL(fileURLWithPath: dataFolderPath(isDefaultFolder: false)).appendingPathComponent(fileName) return URL(fileURLWithPath: dataFolderPath(isDefaultFolder: false)).appendingPathComponent(fileName)
} }
/// 使 /// 使
/// - Parameter mode: /// - Parameter mode:
/// - Returns: URL /// - Returns: URL
public static func userSCPCSequencesURL(_ mode: InputMode) -> URL { public static func userSCPCSequencesURL(_ mode: Shared.InputMode) -> URL {
let fileName = (mode == InputMode.imeModeCHT) ? "data-plain-bpmf-cht.plist" : "data-plain-bpmf-chs.plist" let fileName = (mode == .imeModeCHT) ? "data-plain-bpmf-cht.plist" : "data-plain-bpmf-chs.plist"
return URL(fileURLWithPath: dataFolderPath(isDefaultFolder: false)).appendingPathComponent(fileName) return URL(fileURLWithPath: dataFolderPath(isDefaultFolder: false)).appendingPathComponent(fileName)
} }
@ -309,7 +309,7 @@ public enum LMMgr {
/// ~/Library/Application Support/vChewing/使 /// ~/Library/Application Support/vChewing/使
/// - Parameter mode: /// - Parameter mode:
/// - Returns: URL /// - Returns: URL
public static func userOverrideModelDataURL(_ mode: InputMode) -> URL { public static func userOverrideModelDataURL(_ mode: Shared.InputMode) -> URL {
let fileName: String = { let fileName: String = {
switch mode { switch mode {
case .imeModeCHS: return "vChewing_override-model-data-chs.dat" case .imeModeCHS: return "vChewing_override-model-data-chs.dat"
@ -350,7 +350,7 @@ public enum LMMgr {
return true return true
} }
@discardableResult public static func chkUserLMFilesExist(_ mode: InputMode) -> Bool { @discardableResult public static func chkUserLMFilesExist(_ mode: Shared.InputMode) -> Bool {
if !userDataFolderExists { if !userDataFolderExists {
return false return false
} }
@ -477,11 +477,11 @@ public enum LMMgr {
// MARK: - 使 // MARK: - 使
public static func writeUserPhrase( public static func writeUserPhrase(
_ userPhrase: String?, inputMode mode: InputMode, areWeDuplicating: Bool, areWeDeleting: Bool _ userPhrase: String?, inputMode mode: Shared.InputMode, areWeDuplicating: Bool, areWeDeleting: Bool
) -> Bool { ) -> Bool {
if var currentMarkedPhrase: String = userPhrase { if var currentMarkedPhrase: String = userPhrase {
if !chkUserLMFilesExist(InputMode.imeModeCHS) if !chkUserLMFilesExist(.imeModeCHS)
|| !chkUserLMFilesExist(InputMode.imeModeCHT) || !chkUserLMFilesExist(.imeModeCHT)
{ {
return false return false
} }
@ -526,8 +526,8 @@ public enum LMMgr {
// MARK: - 使 // MARK: - 使
public static func checkIfUserFilesExistBeforeOpening() -> Bool { public static func checkIfUserFilesExistBeforeOpening() -> Bool {
if !Self.chkUserLMFilesExist(InputMode.imeModeCHS) if !Self.chkUserLMFilesExist(.imeModeCHS)
|| !Self.chkUserLMFilesExist(InputMode.imeModeCHT) || !Self.chkUserLMFilesExist(.imeModeCHT)
{ {
let content = String( let content = String(
format: NSLocalizedString( format: NSLocalizedString(
@ -562,19 +562,19 @@ public enum LMMgr {
let group = DispatchGroup() let group = DispatchGroup()
group.enter() group.enter()
globalQuene.async { globalQuene.async {
Self.uomCHT.saveData(toURL: userOverrideModelDataURL(InputMode.imeModeCHT)) Self.uomCHT.saveData(toURL: userOverrideModelDataURL(.imeModeCHT))
group.leave() group.leave()
} }
group.enter() group.enter()
globalQuene.async { globalQuene.async {
Self.uomCHS.saveData(toURL: userOverrideModelDataURL(InputMode.imeModeCHS)) Self.uomCHS.saveData(toURL: userOverrideModelDataURL(.imeModeCHS))
group.leave() group.leave()
} }
_ = group.wait(timeout: .distantFuture) _ = group.wait(timeout: .distantFuture)
group.notify(queue: DispatchQueue.main) {} group.notify(queue: DispatchQueue.main) {}
} }
public static func removeUnigramsFromUserOverrideModel(_ mode: InputMode) { public static func removeUnigramsFromUserOverrideModel(_ mode: Shared.InputMode) {
switch mode { switch mode {
case .imeModeCHS: case .imeModeCHS:
Self.uomCHT.bleachUnigrams(saveCallback: { Self.uomCHT.saveData() }) Self.uomCHT.bleachUnigrams(saveCallback: { Self.uomCHT.saveData() })
@ -585,12 +585,12 @@ public enum LMMgr {
} }
} }
public static func clearUserOverrideModelData(_ mode: InputMode = .imeModeNULL) { public static func clearUserOverrideModelData(_ mode: Shared.InputMode = .imeModeNULL) {
switch mode { switch mode {
case .imeModeCHS: case .imeModeCHS:
Self.uomCHS.clearData(withURL: userOverrideModelDataURL(InputMode.imeModeCHS)) Self.uomCHS.clearData(withURL: userOverrideModelDataURL(.imeModeCHS))
case .imeModeCHT: case .imeModeCHT:
Self.uomCHT.clearData(withURL: userOverrideModelDataURL(InputMode.imeModeCHT)) Self.uomCHT.clearData(withURL: userOverrideModelDataURL(.imeModeCHT))
case .imeModeNULL: case .imeModeNULL:
break break
} }

View File

@ -48,11 +48,11 @@ public class ctlCandidateIMK: IMKCandidates, ctlCandidateProtocol {
attributes?[NSAttributedString.Key.font] = candidateFont attributes?[NSAttributedString.Key.font] = candidateFont
if PrefMgr.shared.handleDefaultCandidateFontsByLangIdentifier { if PrefMgr.shared.handleDefaultCandidateFontsByLangIdentifier {
switch IMEApp.currentInputMode { switch IMEApp.currentInputMode {
case InputMode.imeModeCHS: case .imeModeCHS:
if #available(macOS 12.0, *) { if #available(macOS 12.0, *) {
attributes?[NSAttributedString.Key.languageIdentifier] = "zh-Hans" as AnyObject attributes?[NSAttributedString.Key.languageIdentifier] = "zh-Hans" as AnyObject
} }
case InputMode.imeModeCHT: case .imeModeCHT:
if #available(macOS 12.0, *) { if #available(macOS 12.0, *) {
attributes?[NSAttributedString.Key.languageIdentifier] = attributes?[NSAttributedString.Key.languageIdentifier] =
(PrefMgr.shared.shiftJISShinjitaiOutputEnabled || PrefMgr.shared.chineseConversionEnabled) (PrefMgr.shared.shiftJISShinjitaiOutputEnabled || PrefMgr.shared.chineseConversionEnabled)

View File

@ -136,11 +136,11 @@ private class vwrCandidateUniversal: NSView {
func ensureLangIdentifier(for attr: inout [NSAttributedString.Key: AnyObject]) { func ensureLangIdentifier(for attr: inout [NSAttributedString.Key: AnyObject]) {
if PrefMgr.shared.handleDefaultCandidateFontsByLangIdentifier { if PrefMgr.shared.handleDefaultCandidateFontsByLangIdentifier {
switch IMEApp.currentInputMode { switch IMEApp.currentInputMode {
case InputMode.imeModeCHS: case .imeModeCHS:
if #available(macOS 12.0, *) { if #available(macOS 12.0, *) {
attr[.languageIdentifier] = "zh-Hans" as AnyObject attr[.languageIdentifier] = "zh-Hans" as AnyObject
} }
case InputMode.imeModeCHT: case .imeModeCHT:
if #available(macOS 12.0, *) { if #available(macOS 12.0, *) {
attr[.languageIdentifier] = attr[.languageIdentifier] =
(PrefMgr.shared.shiftJISShinjitaiOutputEnabled || PrefMgr.shared.chineseConversionEnabled) (PrefMgr.shared.shiftJISShinjitaiOutputEnabled || PrefMgr.shared.chineseConversionEnabled)
@ -160,9 +160,9 @@ private class vwrCandidateUniversal: NSView {
} }
// The background color of the highlightened candidate // The background color of the highlightened candidate
switch IMEApp.currentInputMode { switch IMEApp.currentInputMode {
case InputMode.imeModeCHS: case .imeModeCHS:
result = NSColor.systemRed result = NSColor.systemRed
case InputMode.imeModeCHT: case .imeModeCHT:
result = NSColor.systemBlue result = NSColor.systemBlue
default: break default: break
} }

View File

@ -168,14 +168,14 @@ class ctlInputMethod: IMKInputController {
override func setValue(_ value: Any!, forTag tag: Int, client sender: Any!) { override func setValue(_ value: Any!, forTag tag: Int, client sender: Any!) {
_ = tag // _ = tag //
_ = sender // _ = sender //
var newInputMode = InputMode(rawValue: value as? String ?? "") ?? InputMode.imeModeNULL var newInputMode = Shared.InputMode(rawValue: value as? String ?? "") ?? Shared.InputMode.imeModeNULL
switch newInputMode { switch newInputMode {
case InputMode.imeModeCHS: case .imeModeCHS:
newInputMode = InputMode.imeModeCHS newInputMode = .imeModeCHS
case InputMode.imeModeCHT: case .imeModeCHT:
newInputMode = InputMode.imeModeCHT newInputMode = .imeModeCHT
default: default:
newInputMode = InputMode.imeModeNULL newInputMode = .imeModeNULL
} }
LMMgr.loadDataModel(newInputMode) LMMgr.loadDataModel(newInputMode)
@ -195,7 +195,7 @@ class ctlInputMethod: IMKInputController {
/// InputMode /// InputMode
/// IME UserPrefs /// IME UserPrefs
var inputMode: InputMode = IMEApp.currentInputMode { var inputMode: Shared.InputMode = IMEApp.currentInputMode {
willSet { willSet {
/// Prefs IME /// Prefs IME
IMEApp.currentInputMode = newValue IMEApp.currentInputMode = newValue

View File

@ -8,6 +8,8 @@
// marks, or product names of Contributor, except as required to fulfill notice // marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License. // requirements defined in MIT License.
import Shared
// MARK: - KeyHandler Delegate // MARK: - KeyHandler Delegate
extension ctlInputMethod: KeyHandlerDelegate { extension ctlInputMethod: KeyHandlerDelegate {
@ -26,9 +28,8 @@ extension ctlInputMethod: KeyHandlerDelegate {
-> Bool -> Bool
{ {
guard state.type == .ofMarking else { return false } guard state.type == .ofMarking else { return false }
let refInputModeReversed: InputMode = let refInputModeReversed: Shared.InputMode =
(inputMode == InputMode.imeModeCHT) (inputMode == .imeModeCHT) ? .imeModeCHS : .imeModeCHT
? InputMode.imeModeCHS : InputMode.imeModeCHT
if !LMMgr.writeUserPhrase( if !LMMgr.writeUserPhrase(
state.data.userPhraseDumped, inputMode: inputMode, state.data.userPhraseDumped, inputMode: inputMode,
areWeDuplicating: state.data.chkIfUserPhraseExists, areWeDuplicating: state.data.chkIfUserPhraseExists,

View File

@ -192,9 +192,9 @@ extension ctlInputMethod {
let finalReturnFont: NSFont = let finalReturnFont: NSFont =
{ {
switch IMEApp.currentInputMode { switch IMEApp.currentInputMode {
case InputMode.imeModeCHS: case .imeModeCHS:
return CTFontCreateUIFontForLanguage(.system, size, "zh-Hans" as CFString) return CTFontCreateUIFontForLanguage(.system, size, "zh-Hans" as CFString)
case InputMode.imeModeCHT: case .imeModeCHT:
return (PrefMgr.shared.shiftJISShinjitaiOutputEnabled || PrefMgr.shared.chineseConversionEnabled) return (PrefMgr.shared.shiftJISShinjitaiOutputEnabled || PrefMgr.shared.chineseConversionEnabled)
? CTFontCreateUIFontForLanguage(.system, size, "ja" as CFString) ? CTFontCreateUIFontForLanguage(.system, size, "ja" as CFString)
: CTFontCreateUIFontForLanguage(.system, size, "zh-Hant" as CFString) : CTFontCreateUIFontForLanguage(.system, size, "zh-Hant" as CFString)

View File

@ -48,7 +48,7 @@ extension ctlInputMethod {
useCNS11643SupportItem.keyEquivalentModifierMask = [.command, .control] useCNS11643SupportItem.keyEquivalentModifierMask = [.command, .control]
useCNS11643SupportItem.state = PrefMgr.shared.cns11643Enabled.state useCNS11643SupportItem.state = PrefMgr.shared.cns11643Enabled.state
if IMEApp.currentInputMode == InputMode.imeModeCHT { if IMEApp.currentInputMode == .imeModeCHT {
let chineseConversionItem = menu.addItem( let chineseConversionItem = menu.addItem(
withTitle: NSLocalizedString("Force KangXi Writing", comment: ""), withTitle: NSLocalizedString("Force KangXi Writing", comment: ""),
action: #selector(toggleChineseConverter(_:)), keyEquivalent: PrefMgr.shared.usingHotKeyKangXi ? "K" : "" action: #selector(toggleChineseConverter(_:)), keyEquivalent: PrefMgr.shared.usingHotKeyKangXi ? "K" : ""

View File

@ -74,27 +74,11 @@ NSApp.run()
// MARK: - Top-level Enums relating to Input Mode and Language Supports. // MARK: - Top-level Enums relating to Input Mode and Language Supports.
// The type of input modes.
public enum InputMode: String, CaseIterable {
case imeModeCHS = "org.atelierInmu.inputmethod.vChewing.IMECHS"
case imeModeCHT = "org.atelierInmu.inputmethod.vChewing.IMECHT"
case imeModeNULL = ""
var reversed: InputMode {
switch self {
case .imeModeCHS:
return .imeModeCHT
case .imeModeCHT:
return .imeModeCHS
case .imeModeNULL:
return .imeModeNULL
}
}
}
public enum IMEApp { public enum IMEApp {
// MARK: - // MARK: -
public static var currentInputMode: InputMode = .init(rawValue: PrefMgr.shared.mostRecentInputMode) ?? .imeModeNULL public static var currentInputMode: Shared.InputMode =
.init(rawValue: PrefMgr.shared.mostRecentInputMode) ?? .imeModeNULL
/// Fart or Beep? /// Fart or Beep?
static func buzz() { static func buzz() {