AssoPhrases // Bind Menu Commands and Preferences.
This commit is contained in:
parent
ca0bd45f06
commit
5ea771f88a
|
@ -280,6 +280,11 @@ struct ComposingBufferSize {
|
|||
UserDefaults.standard.set(Preferences.useSCPCTypingMode, forKey: kUseSCPCTypingMode)
|
||||
}
|
||||
|
||||
// 預設禁用逐字選字模式時的聯想詞功能,所以設成 false
|
||||
if UserDefaults.standard.object(forKey: kAssociatedPhrasesEnabled) == nil {
|
||||
UserDefaults.standard.set(Preferences.associatedPhrasesEnabled, forKey: kAssociatedPhrasesEnabled)
|
||||
}
|
||||
|
||||
// 預設漢音風格選字,所以要設成 0
|
||||
if UserDefaults.standard.object(forKey: kSelectPhraseAfterCursorAsCandidatePreference) == nil {
|
||||
UserDefaults.standard.set(Preferences.selectPhraseAfterCursorAsCandidate, forKey: kSelectPhraseAfterCursorAsCandidatePreference)
|
||||
|
|
|
@ -73,6 +73,10 @@ class ctlInputMethod: IMKInputController {
|
|||
halfWidthPunctuationItem.keyEquivalentModifierMask = [.command, .control]
|
||||
halfWidthPunctuationItem.state = Preferences.halfWidthPunctuationEnabled.state
|
||||
|
||||
let userAssociatedPhrasesItem = menu.addItem(withTitle: NSLocalizedString("Per-Char Associated Phrases", comment: ""), action: #selector(toggleAssociatedPhrasesEnabled(_:)), keyEquivalent: "O")
|
||||
userAssociatedPhrasesItem.keyEquivalentModifierMask = [.command, .control]
|
||||
userAssociatedPhrasesItem.state = Preferences.associatedPhrasesEnabled.state
|
||||
|
||||
if optionKeyPressed {
|
||||
let phaseReplacementItem = menu.addItem(withTitle: NSLocalizedString("Use Phrase Replacement", comment: ""), action: #selector(togglePhraseReplacement(_:)), keyEquivalent: "")
|
||||
phaseReplacementItem.state = Preferences.phraseReplacementEnabled.state
|
||||
|
@ -86,6 +90,7 @@ class ctlInputMethod: IMKInputController {
|
|||
if optionKeyPressed {
|
||||
menu.addItem(withTitle: NSLocalizedString("Edit Excluded Phrases", comment: ""), action: #selector(openExcludedPhrases(_:)), keyEquivalent: "")
|
||||
menu.addItem(withTitle: NSLocalizedString("Edit Phrase Replacement Table", comment: ""), action: #selector(openPhraseReplacement(_:)), keyEquivalent: "")
|
||||
menu.addItem(withTitle: NSLocalizedString("Edit Associated Phrases", comment: ""), action: #selector(openAssociatedPhrases(_:)), keyEquivalent: "")
|
||||
}
|
||||
|
||||
if (optionKeyPressed || !Preferences.shouldAutoReloadUserDataFiles) {
|
||||
|
@ -218,7 +223,7 @@ class ctlInputMethod: IMKInputController {
|
|||
}
|
||||
|
||||
@objc func toggleAssociatedPhrasesEnabled(_ sender: Any?) {
|
||||
_ = Preferences.toggleAssociatedPhrasesEnabled()
|
||||
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Per-Char Associated Phrases", comment: ""), "\n", Preferences.toggleAssociatedPhrasesEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||
}
|
||||
|
||||
@objc func togglePhraseReplacement(_ sender: Any?) {
|
||||
|
@ -268,6 +273,10 @@ class ctlInputMethod: IMKInputController {
|
|||
open(userFileAt: mgrLangModel.phraseReplacementDataPath(keyHandler.inputMode))
|
||||
}
|
||||
|
||||
@objc func openAssociatedPhrases(_ sender: Any?) {
|
||||
open(userFileAt: mgrLangModel.userAssociatedPhrasesDataPath(keyHandler.inputMode))
|
||||
}
|
||||
|
||||
@objc func reloadUserPhrases(_ sender: Any?) {
|
||||
mgrLangModel.loadUserPhrases()
|
||||
mgrLangModel.loadUserPhraseReplacement()
|
||||
|
|
Loading…
Reference in New Issue