Pref // Rename the Pref module to mgrPrefs.
This commit is contained in:
parent
f6f3bf8dc0
commit
85f8d75b45
|
@ -148,7 +148,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, ctlNonModalAlertWindowDelega
|
|||
func helper(_ helper: FSEventStreamHelper, didReceive events: [FSEventStreamHelper.Event]) {
|
||||
// 拖 100ms 再重載,畢竟有些有特殊需求的使用者可能會想使用巨型自訂語彙檔案。
|
||||
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1) {
|
||||
if Preferences.shouldAutoReloadUserDataFiles {
|
||||
if mgrPrefs.shouldAutoReloadUserDataFiles {
|
||||
mgrLangModel.loadUserPhrases()
|
||||
mgrLangModel.loadUserPhraseReplacement()
|
||||
mgrLangModel.loadUserAssociatedPhrases()
|
||||
|
@ -184,7 +184,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, ctlNonModalAlertWindowDelega
|
|||
fsStreamHelper.delegate = self
|
||||
_ = fsStreamHelper.start()
|
||||
|
||||
Preferences.setMissingDefaults()
|
||||
mgrPrefs.setMissingDefaults()
|
||||
|
||||
// 只要使用者沒有勾選檢查更新、沒有主動做出要檢查更新的操作,就不要檢查更新。
|
||||
if (UserDefaults.standard.object(forKey: kCheckUpdateAutomatically) != nil) == true {
|
||||
|
@ -296,7 +296,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, ctlNonModalAlertWindowDelega
|
|||
@objc public class IME: NSObject {
|
||||
// Print debug information to the console.
|
||||
@objc static func prtDebugIntel(_ strPrint: String) {
|
||||
if Preferences.isDebugModeEnabled {
|
||||
if mgrPrefs.isDebugModeEnabled {
|
||||
NSLog("vChewingErrorCallback: %@", strPrint)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import Cocoa
|
|||
|
||||
@objc class AppleKeyboardConverter: NSObject {
|
||||
@objc class func isDynamicBaseKeyboardLayoutEnabled() -> Bool {
|
||||
switch Preferences.basisKeyboardLayout {
|
||||
switch mgrPrefs.basisKeyboardLayout {
|
||||
case "com.apple.keylayout.ZhuyinBopomofo":
|
||||
return true
|
||||
case "com.apple.keylayout.ZhuyinEten":
|
||||
|
@ -45,7 +45,7 @@ import Cocoa
|
|||
// 在按鍵資訊被送往 OVMandarin 之前,先轉換為可以被 OVMandarin 正常處理的資訊。
|
||||
if self.isDynamicBaseKeyboardLayoutEnabled() {
|
||||
// 針對不同的 Apple 動態鍵盤佈局糾正大寫英文輸入。
|
||||
switch Preferences.basisKeyboardLayout {
|
||||
switch mgrPrefs.basisKeyboardLayout {
|
||||
case "com.apple.keylayout.ZhuyinBopomofo": do {
|
||||
if (charCode == 97) {charCode = UniChar(65)}
|
||||
if (charCode == 98) {charCode = UniChar(66)}
|
||||
|
@ -166,7 +166,7 @@ import Cocoa
|
|||
if (charCode == 65288) {charCode = UniChar(40)}
|
||||
if (charCode == 65289) {charCode = UniChar(41)}
|
||||
// Apple 倚天注音佈局追加符號糾正項目。
|
||||
if Preferences.basisKeyboardLayout == "com.apple.keylayout.ZhuyinEten" {
|
||||
if mgrPrefs.basisKeyboardLayout == "com.apple.keylayout.ZhuyinEten" {
|
||||
if (charCode == 65343) {charCode = UniChar(95)}
|
||||
if (charCode == 65306) {charCode = UniChar(58)}
|
||||
if (charCode == 65311) {charCode = UniChar(63)}
|
||||
|
@ -181,7 +181,7 @@ import Cocoa
|
|||
var strProcessed = strProcessed
|
||||
if self.isDynamicBaseKeyboardLayoutEnabled() {
|
||||
// 針對不同的 Apple 動態鍵盤佈局糾正大寫英文輸入。
|
||||
switch Preferences.basisKeyboardLayout {
|
||||
switch mgrPrefs.basisKeyboardLayout {
|
||||
case "com.apple.keylayout.ZhuyinBopomofo": do {
|
||||
if (strProcessed == "a") {strProcessed = "A"}
|
||||
if (strProcessed == "b") {strProcessed = "B"}
|
||||
|
@ -302,7 +302,7 @@ import Cocoa
|
|||
if (strProcessed == "(") {strProcessed = "("}
|
||||
if (strProcessed == ")") {strProcessed = ")"}
|
||||
// Apple 倚天注音佈局追加符號糾正項目。
|
||||
if Preferences.basisKeyboardLayout == "com.apple.keylayout.ZhuyinEten" {
|
||||
if mgrPrefs.basisKeyboardLayout == "com.apple.keylayout.ZhuyinEten" {
|
||||
if (strProcessed == "_") {strProcessed = "_"}
|
||||
if (strProcessed == ":") {strProcessed = ":"}
|
||||
if (strProcessed == "?") {strProcessed = "?"}
|
||||
|
|
|
@ -150,7 +150,7 @@ class InputState: NSObject {
|
|||
// MARK: -
|
||||
|
||||
private let kMinMarkRangeLength = 2
|
||||
private let kMaxMarkRangeLength = Preferences.maxCandidateLength
|
||||
private let kMaxMarkRangeLength = mgrPrefs.maxCandidateLength
|
||||
|
||||
/// Represents that the user is marking a range in the composing buffer.
|
||||
@objc (InputStateMarking)
|
||||
|
@ -166,7 +166,7 @@ class InputState: NSObject {
|
|||
return NSLocalizedString("⚠︎ Unhandlable char selected for user phrases.", comment: "")
|
||||
}
|
||||
|
||||
if Preferences.phraseReplacementEnabled {
|
||||
if mgrPrefs.phraseReplacementEnabled {
|
||||
TooltipController.backgroundColor = NSColor.purple
|
||||
TooltipController.textColor = NSColor.white
|
||||
return NSLocalizedString("⚠︎ Phrase replacement mode enabled, interfering user phrase entry.", comment: "")
|
||||
|
|
|
@ -115,10 +115,10 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
|||
ctlInputMethod.currentInputMode = newInputMode;
|
||||
|
||||
// Synchronize the Preference Setting "setPhraseReplacementEnabled" to the new LM.
|
||||
newLanguageModel->setPhraseReplacementEnabled(Preferences.phraseReplacementEnabled);
|
||||
newLanguageModel->setPhraseReplacementEnabled(mgrPrefs.phraseReplacementEnabled);
|
||||
// Also other sub language models:
|
||||
newLanguageModel->setSymbolEnabled(Preferences.symbolInputEnabled);
|
||||
newLanguageModel->setCNSEnabled(Preferences.cns11643Enabled);
|
||||
newLanguageModel->setSymbolEnabled(mgrPrefs.symbolInputEnabled);
|
||||
newLanguageModel->setCNSEnabled(mgrPrefs.cns11643Enabled);
|
||||
|
||||
// Only apply the changes if the value is changed
|
||||
if (![_inputMode isEqualToString:newInputMode]) {
|
||||
|
@ -158,9 +158,9 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
|||
|
||||
// create the lattice builder
|
||||
_languageModel = [mgrLangModel lmCHT];
|
||||
_languageModel->setPhraseReplacementEnabled(Preferences.phraseReplacementEnabled);
|
||||
_languageModel->setCNSEnabled(Preferences.cns11643Enabled);
|
||||
_languageModel->setSymbolEnabled(Preferences.symbolInputEnabled);
|
||||
_languageModel->setPhraseReplacementEnabled(mgrPrefs.phraseReplacementEnabled);
|
||||
_languageModel->setCNSEnabled(mgrPrefs.cns11643Enabled);
|
||||
_languageModel->setSymbolEnabled(mgrPrefs.symbolInputEnabled);
|
||||
_userOverrideModel = [mgrLangModel userOverrideModelCHT];
|
||||
|
||||
_builder = new Gramambular::BlockReadingBuilder(_languageModel);
|
||||
|
@ -174,7 +174,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
|||
|
||||
- (void)syncWithPreferences
|
||||
{
|
||||
NSInteger layout = Preferences.keyboardLayout;
|
||||
NSInteger layout = mgrPrefs.keyboardLayout;
|
||||
switch (layout) {
|
||||
case KeyboardLayoutStandard:
|
||||
_bpmfReadingBuffer->setKeyboardLayout(Mandarin::BopomofoKeyboardLayout::StandardLayout());
|
||||
|
@ -202,7 +202,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
|||
break;
|
||||
default:
|
||||
_bpmfReadingBuffer->setKeyboardLayout(Mandarin::BopomofoKeyboardLayout::StandardLayout());
|
||||
Preferences.keyboardLayout = KeyboardLayoutStandard;
|
||||
mgrPrefs.keyboardLayout = KeyboardLayoutStandard;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
|||
size_t cursorIndex = [self _actualCandidateCursorIndex];
|
||||
std::string stringValue(value.UTF8String);
|
||||
Gramambular::NodeAnchor selectedNode = _builder->grid().fixNodeSelectedCandidate(cursorIndex, stringValue);
|
||||
if (!Preferences.useSCPCTypingMode) { // 不要針對逐字選字模式啟用臨時半衰記憶模型。
|
||||
if (!mgrPrefs.useSCPCTypingMode) { // 不要針對逐字選字模式啟用臨時半衰記憶模型。
|
||||
// If the length of the readings and the characters do not match,
|
||||
// it often means it is a special symbol and it should not be stored
|
||||
// in the user override model.
|
||||
|
@ -231,8 +231,8 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
|||
}
|
||||
[self _walk];
|
||||
|
||||
if (Preferences.selectPhraseAfterCursorAsCandidate &&
|
||||
Preferences.moveCursorAfterSelectingCandidate) {
|
||||
if (mgrPrefs.selectPhraseAfterCursorAsCandidate &&
|
||||
mgrPrefs.moveCursorAfterSelectingCandidate) {
|
||||
size_t nextPosition = 0;
|
||||
for (auto node: _walkedNodes) {
|
||||
if (nextPosition >= cursorIndex) {
|
||||
|
@ -255,7 +255,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
|||
|
||||
- (std::string)_currentLayout
|
||||
{
|
||||
NSString *keyboardLayoutName = Preferences.keyboardLayoutName;
|
||||
NSString *keyboardLayoutName = mgrPrefs.keyboardLayoutName;
|
||||
std::string layout = std::string(keyboardLayoutName.UTF8String) + std::string("_");
|
||||
return layout;
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
|||
NSString *poppedText = [self _popOverflowComposingTextAndWalk];
|
||||
|
||||
// get user override model suggestion
|
||||
std::string overrideValue = (Preferences.useSCPCTypingMode) ? "" :
|
||||
std::string overrideValue = (mgrPrefs.useSCPCTypingMode) ? "" :
|
||||
_userOverrideModel->suggest(_walkedNodes, _builder->cursorIndex(), [[NSDate date] timeIntervalSince1970]);
|
||||
|
||||
if (!overrideValue.empty()) {
|
||||
|
@ -404,7 +404,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
|||
inputting.poppedText = poppedText;
|
||||
stateCallback(inputting);
|
||||
|
||||
if (Preferences.useSCPCTypingMode) {
|
||||
if (mgrPrefs.useSCPCTypingMode) {
|
||||
InputStateChoosingCandidate *choosingCandidates = [self _buildCandidateState:inputting useVerticalMode:input.useVerticalMode];
|
||||
if (choosingCandidates.candidates.count == 1) {
|
||||
[self clear];
|
||||
|
@ -412,7 +412,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
|||
InputStateCommitting *committing = [[InputStateCommitting alloc] initWithPoppedText:text];
|
||||
stateCallback(committing);
|
||||
|
||||
if (!Preferences.associatedPhrasesEnabled) {
|
||||
if (!mgrPrefs.associatedPhrasesEnabled) {
|
||||
InputStateEmpty *empty = [[InputStateEmpty alloc] init];
|
||||
stateCallback(empty);
|
||||
} else {
|
||||
|
@ -441,7 +441,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
|||
|| (input.useVerticalMode && ([input isVerticalModeOnlyChooseCandidateKey])))) {
|
||||
if ([input isSpace]) {
|
||||
// if the spacebar is NOT set to be a selection key
|
||||
if ([input isShiftHold] || !Preferences.chooseCandidateUsingSpace) {
|
||||
if ([input isShiftHold] || !mgrPrefs.chooseCandidateUsingSpace) {
|
||||
if (_builder->cursorIndex() >= _builder->length()) {
|
||||
NSString *composingBuffer = [(InputStateNotEmpty*) state composingBuffer];
|
||||
if (composingBuffer.length) {
|
||||
|
@ -566,7 +566,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
|||
std::string punctuationNamePrefix;
|
||||
if ([input isControlHold]) {
|
||||
punctuationNamePrefix = std::string("_ctrl_punctuation_");
|
||||
} else if (Preferences.halfWidthPunctuationEnabled) {
|
||||
} else if (mgrPrefs.halfWidthPunctuationEnabled) {
|
||||
punctuationNamePrefix = std::string("_half_punctuation_");
|
||||
} else {
|
||||
punctuationNamePrefix = std::string("_punctuation_");
|
||||
|
@ -611,7 +611,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
|||
return NO;
|
||||
}
|
||||
|
||||
BOOL escToClearInputBufferEnabled = Preferences.escToCleanInputBuffer;
|
||||
BOOL escToClearInputBufferEnabled = mgrPrefs.escToCleanInputBuffer;
|
||||
|
||||
if (escToClearInputBufferEnabled) {
|
||||
// if the option is enabled, we clear everything including the composing
|
||||
|
@ -904,7 +904,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
|||
inputting.poppedText = poppedText;
|
||||
stateCallback(inputting);
|
||||
|
||||
if (Preferences.useSCPCTypingMode && _bpmfReadingBuffer->isEmpty()) {
|
||||
if (mgrPrefs.useSCPCTypingMode && _bpmfReadingBuffer->isEmpty()) {
|
||||
InputStateChoosingCandidate *candidateState = [self _buildCandidateState:inputting useVerticalMode:useVerticalMode];
|
||||
|
||||
if ([candidateState.candidates count] == 1) {
|
||||
|
@ -1010,7 +1010,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
|||
InputStateEmptyIgnoringPreviousState *empty = [[InputStateEmptyIgnoringPreviousState alloc] init];
|
||||
stateCallback(empty);
|
||||
}
|
||||
else if (Preferences.useSCPCTypingMode) {
|
||||
else if (mgrPrefs.useSCPCTypingMode) {
|
||||
[self clear];
|
||||
InputStateEmptyIgnoringPreviousState *empty = [[InputStateEmptyIgnoringPreviousState alloc] init];
|
||||
stateCallback(empty);
|
||||
|
@ -1040,7 +1040,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
|||
|
||||
if ([input isTab]) {
|
||||
BOOL updated =
|
||||
Preferences.specifyTabKeyBehavior?
|
||||
mgrPrefs.specifyTabKeyBehavior?
|
||||
([input isShiftHold] ? [gCurrentCandidateController showPreviousPage] : [gCurrentCandidateController showNextPage])
|
||||
:
|
||||
([input isShiftHold] ? [gCurrentCandidateController highlightPreviousCandidate] : [gCurrentCandidateController highlightNextCandidate])
|
||||
|
@ -1054,7 +1054,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
|||
|
||||
if ([input isSpace]) {
|
||||
BOOL updated =
|
||||
Preferences.specifySpaceKeyBehavior?
|
||||
mgrPrefs.specifySpaceKeyBehavior?
|
||||
([input isShiftHold] ? [gCurrentCandidateController highlightNextCandidate] : [gCurrentCandidateController showNextPage])
|
||||
:
|
||||
([input isShiftHold] ? [gCurrentCandidateController showNextPage] : [gCurrentCandidateController highlightNextCandidate])
|
||||
|
@ -1237,12 +1237,12 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
|||
return NO;
|
||||
}
|
||||
|
||||
if (Preferences.useSCPCTypingMode) {
|
||||
if (mgrPrefs.useSCPCTypingMode) {
|
||||
std::string layout = [self _currentLayout];
|
||||
std::string punctuationNamePrefix;
|
||||
if ([input isControlHold]) {
|
||||
punctuationNamePrefix = std::string("_ctrl_punctuation_");
|
||||
} else if (Preferences.halfWidthPunctuationEnabled) {
|
||||
} else if (mgrPrefs.halfWidthPunctuationEnabled) {
|
||||
punctuationNamePrefix = std::string("_half_punctuation_");
|
||||
} else {
|
||||
punctuationNamePrefix = std::string("_punctuation_");
|
||||
|
@ -1392,7 +1392,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
|||
// be popped out
|
||||
|
||||
NSString *poppedText = @"";
|
||||
NSInteger composingBufferSize = Preferences.composingBufferSize;
|
||||
NSInteger composingBufferSize = mgrPrefs.composingBufferSize;
|
||||
|
||||
if (_builder->grid().width() > (size_t) composingBufferSize) {
|
||||
if (_walkedNodes.size() > 0) {
|
||||
|
@ -1432,7 +1432,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
|||
{
|
||||
size_t cursorIndex = _builder->cursorIndex();
|
||||
// MS Phonetics IME style, phrase is *after* the cursor, i.e. cursor is always *before* the phrase
|
||||
if ((Preferences.selectPhraseAfterCursorAsCandidate && (cursorIndex < _builder->length()))
|
||||
if ((mgrPrefs.selectPhraseAfterCursorAsCandidate && (cursorIndex < _builder->length()))
|
||||
|| !cursorIndex) {
|
||||
++cursorIndex;
|
||||
}
|
||||
|
|
|
@ -73,36 +73,36 @@ class ctlInputMethod: IMKInputController {
|
|||
|
||||
let useSCPCTypingModeItem = menu.addItem(withTitle: NSLocalizedString("Per-Char Select Mode", comment: ""), action: #selector(toggleSCPCTypingMode(_:)), keyEquivalent: "P")
|
||||
useSCPCTypingModeItem.keyEquivalentModifierMask = [.command, .control]
|
||||
useSCPCTypingModeItem.state = Preferences.useSCPCTypingMode.state
|
||||
useSCPCTypingModeItem.state = mgrPrefs.useSCPCTypingMode.state
|
||||
|
||||
let useCNS11643SupportItem = menu.addItem(withTitle: NSLocalizedString("CNS11643 Mode", comment: ""), action: #selector(toggleCNS11643Enabled(_:)), keyEquivalent: "L")
|
||||
useCNS11643SupportItem.keyEquivalentModifierMask = [.command, .control]
|
||||
useCNS11643SupportItem.state = Preferences.cns11643Enabled.state
|
||||
useCNS11643SupportItem.state = mgrPrefs.cns11643Enabled.state
|
||||
|
||||
if keyHandler.inputMode == InputMode.imeModeCHT {
|
||||
let chineseConversionItem = menu.addItem(withTitle: NSLocalizedString("Force KangXi Writing", comment: ""), action: #selector(toggleChineseConverter(_:)), keyEquivalent: "K")
|
||||
chineseConversionItem.keyEquivalentModifierMask = [.command, .control]
|
||||
chineseConversionItem.state = Preferences.chineseConversionEnabled.state
|
||||
chineseConversionItem.state = mgrPrefs.chineseConversionEnabled.state
|
||||
|
||||
let shiftJISConversionItem = menu.addItem(withTitle: NSLocalizedString("JIS Shinjitai Output", comment: ""), action: #selector(toggleShiftJISShinjitaiOutput(_:)), keyEquivalent: "J")
|
||||
shiftJISConversionItem.keyEquivalentModifierMask = [.command, .control]
|
||||
shiftJISConversionItem.state = Preferences.shiftJISShinjitaiOutputEnabled.state
|
||||
shiftJISConversionItem.state = mgrPrefs.shiftJISShinjitaiOutputEnabled.state
|
||||
}
|
||||
|
||||
let halfWidthPunctuationItem = menu.addItem(withTitle: NSLocalizedString("Half-Width Punctuation Mode", comment: ""), action: #selector(toggleHalfWidthPunctuation(_:)), keyEquivalent: "H")
|
||||
halfWidthPunctuationItem.keyEquivalentModifierMask = [.command, .control]
|
||||
halfWidthPunctuationItem.state = Preferences.halfWidthPunctuationEnabled.state
|
||||
halfWidthPunctuationItem.state = mgrPrefs.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
|
||||
userAssociatedPhrasesItem.state = mgrPrefs.associatedPhrasesEnabled.state
|
||||
|
||||
if optionKeyPressed {
|
||||
let phaseReplacementItem = menu.addItem(withTitle: NSLocalizedString("Use Phrase Replacement", comment: ""), action: #selector(togglePhraseReplacement(_:)), keyEquivalent: "")
|
||||
phaseReplacementItem.state = Preferences.phraseReplacementEnabled.state
|
||||
phaseReplacementItem.state = mgrPrefs.phraseReplacementEnabled.state
|
||||
|
||||
let toggleSymbolInputItem = menu.addItem(withTitle: NSLocalizedString("Symbol & Emoji Input", comment: ""), action: #selector(toggleSymbolEnabled(_:)), keyEquivalent: "")
|
||||
toggleSymbolInputItem.state = Preferences.symbolInputEnabled.state
|
||||
toggleSymbolInputItem.state = mgrPrefs.symbolInputEnabled.state
|
||||
}
|
||||
|
||||
menu.addItem(NSMenuItem.separator()) // ---------------------
|
||||
|
@ -117,7 +117,7 @@ class ctlInputMethod: IMKInputController {
|
|||
menu.addItem(withTitle: NSLocalizedString("Edit User Symbol & Emoji Data…", comment: ""), action: #selector(openUserSymbols(_:)), keyEquivalent: "")
|
||||
}
|
||||
|
||||
if (optionKeyPressed || !Preferences.shouldAutoReloadUserDataFiles) {
|
||||
if (optionKeyPressed || !mgrPrefs.shouldAutoReloadUserDataFiles) {
|
||||
menu.addItem(withTitle: NSLocalizedString("Reload User Phrases", comment: ""), action: #selector(reloadUserPhrases(_:)), keyEquivalent: "")
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ class ctlInputMethod: IMKInputController {
|
|||
UserDefaults.standard.synchronize()
|
||||
|
||||
// Override the keyboard layout. Use US if not set.
|
||||
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: Preferences.basisKeyboardLayout)
|
||||
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: mgrPrefs.basisKeyboardLayout)
|
||||
// reset the state
|
||||
currentCandidateClient = nil
|
||||
|
||||
|
@ -170,7 +170,7 @@ class ctlInputMethod: IMKInputController {
|
|||
if keyHandler.inputMode != newInputMode {
|
||||
UserDefaults.standard.synchronize()
|
||||
// Remember to override the keyboard layout again -- treat this as an activate event.
|
||||
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: Preferences.basisKeyboardLayout)
|
||||
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: mgrPrefs.basisKeyboardLayout)
|
||||
keyHandler.clear()
|
||||
keyHandler.inputMode = newInputMode
|
||||
self.handle(state: .Empty(), client: client)
|
||||
|
@ -189,14 +189,14 @@ class ctlInputMethod: IMKInputController {
|
|||
override func handle(_ event: NSEvent!, client: Any!) -> Bool {
|
||||
|
||||
if event.type == .flagsChanged {
|
||||
let functionKeyKeyboardLayoutID = Preferences.functionKeyboardLayout
|
||||
let basisKeyboardLayoutID = Preferences.basisKeyboardLayout
|
||||
let functionKeyKeyboardLayoutID = mgrPrefs.functionKeyboardLayout
|
||||
let basisKeyboardLayoutID = mgrPrefs.basisKeyboardLayout
|
||||
|
||||
if functionKeyKeyboardLayoutID == basisKeyboardLayoutID {
|
||||
return false
|
||||
}
|
||||
|
||||
let includeShift = Preferences.functionKeyKeyboardLayoutOverrideIncludeShiftKey
|
||||
let includeShift = mgrPrefs.functionKeyKeyboardLayoutOverrideIncludeShiftKey
|
||||
|
||||
if event.modifierFlags.contains(.capsLock) ||
|
||||
event.modifierFlags.contains(.option) ||
|
||||
|
@ -238,35 +238,35 @@ class ctlInputMethod: IMKInputController {
|
|||
}
|
||||
|
||||
@objc func toggleSCPCTypingMode(_ sender: Any?) {
|
||||
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Per-Char Select Mode", comment: ""), "\n", Preferences.toggleSCPCTypingModeEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Per-Char Select Mode", comment: ""), "\n", mgrPrefs.toggleSCPCTypingModeEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||
}
|
||||
|
||||
@objc func toggleChineseConverter(_ sender: Any?) {
|
||||
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Force KangXi Writing", comment: ""), "\n", Preferences.toggleChineseConversionEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Force KangXi Writing", comment: ""), "\n", mgrPrefs.toggleChineseConversionEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||
}
|
||||
|
||||
@objc func toggleShiftJISShinjitaiOutput(_ sender: Any?) {
|
||||
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("JIS Shinjitai Output", comment: ""), "\n", Preferences.toggleShiftJISShinjitaiOutputEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("JIS Shinjitai Output", comment: ""), "\n", mgrPrefs.toggleShiftJISShinjitaiOutputEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||
}
|
||||
|
||||
@objc func toggleHalfWidthPunctuation(_ sender: Any?) {
|
||||
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Half-Width Punctuation Mode", comment: ""), "\n", Preferences.toggleHalfWidthPunctuationEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Half-Width Punctuation Mode", comment: ""), "\n", mgrPrefs.toggleHalfWidthPunctuationEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||
}
|
||||
|
||||
@objc func toggleCNS11643Enabled(_ sender: Any?) {
|
||||
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("CNS11643 Mode", comment: ""), "\n", Preferences.toggleCNS11643Enabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("CNS11643 Mode", comment: ""), "\n", mgrPrefs.toggleCNS11643Enabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||
}
|
||||
|
||||
@objc func toggleSymbolEnabled(_ sender: Any?) {
|
||||
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Symbol & Emoji Input", comment: ""), "\n", Preferences.toggleSymbolInputEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Symbol & Emoji Input", comment: ""), "\n", mgrPrefs.toggleSymbolInputEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||
}
|
||||
|
||||
@objc func toggleAssociatedPhrasesEnabled(_ sender: Any?) {
|
||||
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Per-Char Associated Phrases", comment: ""), "\n", Preferences.toggleAssociatedPhrasesEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Per-Char Associated Phrases", comment: ""), "\n", mgrPrefs.toggleAssociatedPhrasesEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||
}
|
||||
|
||||
@objc func togglePhraseReplacement(_ sender: Any?) {
|
||||
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Use Phrase Replacement", comment: ""), "\n", Preferences.togglePhraseReplacementEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Use Phrase Replacement", comment: ""), "\n", mgrPrefs.togglePhraseReplacementEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
|
||||
}
|
||||
|
||||
@objc func selfTerminate(_ sender: Any?) {
|
||||
|
@ -363,17 +363,17 @@ extension ctlInputMethod {
|
|||
|
||||
func kanjiConversionIfRequired(_ text: String) -> String {
|
||||
if keyHandler.inputMode == InputMode.imeModeCHT {
|
||||
if !Preferences.chineseConversionEnabled && Preferences.shiftJISShinjitaiOutputEnabled {
|
||||
if !mgrPrefs.chineseConversionEnabled && mgrPrefs.shiftJISShinjitaiOutputEnabled {
|
||||
return vChewingKanjiConverter.cnvTradToJIS(text)
|
||||
}
|
||||
if Preferences.chineseConversionEnabled && !Preferences.shiftJISShinjitaiOutputEnabled {
|
||||
if mgrPrefs.chineseConversionEnabled && !mgrPrefs.shiftJISShinjitaiOutputEnabled {
|
||||
return vChewingKanjiConverter.cnvTradToKangXi(text)
|
||||
}
|
||||
// 本來這兩個開關不該同時開啟的,但萬一被開啟了的話就這樣處理:
|
||||
if Preferences.chineseConversionEnabled && Preferences.shiftJISShinjitaiOutputEnabled {
|
||||
if mgrPrefs.chineseConversionEnabled && mgrPrefs.shiftJISShinjitaiOutputEnabled {
|
||||
return vChewingKanjiConverter.cnvTradToJIS(text)
|
||||
}
|
||||
// if (!Preferences.chineseConversionEnabled && !Preferences.shiftJISShinjitaiOutputEnabled) || (keyHandler.inputMode != InputMode.imeModeCHT);
|
||||
// if (!mgrPrefs.chineseConversionEnabled && !mgrPrefs.shiftJISShinjitaiOutputEnabled) || (keyHandler.inputMode != InputMode.imeModeCHT);
|
||||
return text
|
||||
}
|
||||
return text
|
||||
|
@ -535,14 +535,14 @@ extension ctlInputMethod {
|
|||
|
||||
if useVerticalMode {
|
||||
gCurrentCandidateController = .vertical
|
||||
} else if Preferences.useHorizontalCandidateList {
|
||||
} else if mgrPrefs.useHorizontalCandidateList {
|
||||
gCurrentCandidateController = .horizontal
|
||||
} else {
|
||||
gCurrentCandidateController = .vertical
|
||||
}
|
||||
|
||||
// set the attributes for the candidate panel (which uses NSAttributedString)
|
||||
let textSize = Preferences.candidateListTextSize
|
||||
let textSize = mgrPrefs.candidateListTextSize
|
||||
let keyLabelSize = max(textSize / 2, kMinKeyLabelSize)
|
||||
|
||||
func labelFont(name: String?, size: CGFloat) -> NSFont {
|
||||
|
@ -563,11 +563,11 @@ extension ctlInputMethod {
|
|||
return finalReturnFont
|
||||
}
|
||||
|
||||
gCurrentCandidateController?.keyLabelFont = labelFont(name: Preferences.candidateKeyLabelFontName, size: keyLabelSize)
|
||||
gCurrentCandidateController?.candidateFont = candidateFont(name: Preferences.candidateTextFontName, size: textSize)
|
||||
gCurrentCandidateController?.keyLabelFont = labelFont(name: mgrPrefs.candidateKeyLabelFontName, size: keyLabelSize)
|
||||
gCurrentCandidateController?.candidateFont = candidateFont(name: mgrPrefs.candidateTextFontName, size: textSize)
|
||||
|
||||
let candidateKeys = Preferences.candidateKeys
|
||||
let keyLabels = candidateKeys.count > 4 ? Array(candidateKeys) : Array(Preferences.defaultCandidateKeys)
|
||||
let candidateKeys = mgrPrefs.candidateKeys
|
||||
let keyLabels = candidateKeys.count > 4 ? Array(candidateKeys) : Array(mgrPrefs.defaultCandidateKeys)
|
||||
let keyLabelSuffix = state is InputState.AssociatedPhrases ? "^" : ""
|
||||
gCurrentCandidateController?.keyLabels = keyLabels.map {
|
||||
CandidateKeyLabel(key: String($0), displayedText: String($0) + keyLabelSuffix)
|
||||
|
@ -695,11 +695,11 @@ extension ctlInputMethod: CandidateControllerDelegate {
|
|||
return
|
||||
}
|
||||
|
||||
if Preferences.useSCPCTypingMode {
|
||||
if mgrPrefs.useSCPCTypingMode {
|
||||
keyHandler.clear()
|
||||
let composingBuffer = inputting.composingBuffer
|
||||
handle(state: .Committing(poppedText: composingBuffer), client: client)
|
||||
if Preferences.associatedPhrasesEnabled,
|
||||
if mgrPrefs.associatedPhrasesEnabled,
|
||||
let associatePhrases = keyHandler.buildAssociatePhraseState(withKey: composingBuffer, useVerticalMode: state.useVerticalMode) as? InputState.AssociatedPhrases {
|
||||
self.handle(state: associatePhrases, client: client)
|
||||
} else {
|
||||
|
@ -714,7 +714,7 @@ extension ctlInputMethod: CandidateControllerDelegate {
|
|||
if let state = state as? InputState.AssociatedPhrases {
|
||||
let selectedValue = state.candidates[Int(index)]
|
||||
handle(state: .Committing(poppedText: selectedValue), client: currentCandidateClient)
|
||||
if Preferences.associatedPhrasesEnabled,
|
||||
if mgrPrefs.associatedPhrasesEnabled,
|
||||
let associatePhrases = keyHandler.buildAssociatePhraseState(withKey: selectedValue, useVerticalMode: state.useVerticalMode) as? InputState.AssociatedPhrases {
|
||||
self.handle(state: associatePhrases, client: client)
|
||||
} else {
|
||||
|
|
|
@ -212,7 +212,7 @@ struct ComposingBufferSize {
|
|||
}
|
||||
|
||||
// MARK: -
|
||||
@objc public class Preferences: NSObject {
|
||||
@objc public class mgrPrefs: NSObject {
|
||||
static var allKeys:[String] {
|
||||
[kIsDebugModeEnabled,
|
||||
kKeyboardLayoutPreference,
|
||||
|
@ -253,7 +253,7 @@ struct ComposingBufferSize {
|
|||
|
||||
// 首次啟用輸入法時不要啟用偵錯模式。
|
||||
if UserDefaults.standard.object(forKey: kIsDebugModeEnabled) == nil {
|
||||
UserDefaults.standard.set(Preferences.isDebugModeEnabled, forKey: kIsDebugModeEnabled)
|
||||
UserDefaults.standard.set(mgrPrefs.isDebugModeEnabled, forKey: kIsDebugModeEnabled)
|
||||
}
|
||||
|
||||
// 首次啟用輸入法時設定不要自動更新,免得在某些要隔絕外部網路連線的保密機構內觸犯資安規則。
|
||||
|
@ -263,87 +263,87 @@ struct ComposingBufferSize {
|
|||
|
||||
// 預設不顯示選字窗翻頁按鈕
|
||||
if UserDefaults.standard.object(forKey: kShowPageButtonsInCandidateWindow) == nil {
|
||||
UserDefaults.standard.set(Preferences.showPageButtonsInCandidateWindow, forKey: kShowPageButtonsInCandidateWindow)
|
||||
UserDefaults.standard.set(mgrPrefs.showPageButtonsInCandidateWindow, forKey: kShowPageButtonsInCandidateWindow)
|
||||
}
|
||||
|
||||
// 預設啟用繪文字與符號輸入
|
||||
if UserDefaults.standard.object(forKey: kSymbolInputEnabled) == nil {
|
||||
UserDefaults.standard.set(Preferences.symbolInputEnabled, forKey: kSymbolInputEnabled)
|
||||
UserDefaults.standard.set(mgrPrefs.symbolInputEnabled, forKey: kSymbolInputEnabled)
|
||||
}
|
||||
|
||||
// 預設選字窗字詞文字尺寸,設成 18 剛剛好
|
||||
if UserDefaults.standard.object(forKey: kCandidateListTextSize) == nil {
|
||||
UserDefaults.standard.set(Preferences.candidateListTextSize, forKey: kCandidateListTextSize)
|
||||
UserDefaults.standard.set(mgrPrefs.candidateListTextSize, forKey: kCandidateListTextSize)
|
||||
}
|
||||
|
||||
// 預設摁空格鍵來選字,所以設成 true
|
||||
if UserDefaults.standard.object(forKey: kChooseCandidateUsingSpace) == nil {
|
||||
UserDefaults.standard.set(Preferences.chooseCandidateUsingSpace, forKey: kChooseCandidateUsingSpace)
|
||||
UserDefaults.standard.set(mgrPrefs.chooseCandidateUsingSpace, forKey: kChooseCandidateUsingSpace)
|
||||
}
|
||||
|
||||
// 自動檢測使用者自訂語彙數據的變動並載入。
|
||||
if UserDefaults.standard.object(forKey: kShouldAutoReloadUserDataFiles) == nil {
|
||||
UserDefaults.standard.set(Preferences.shouldAutoReloadUserDataFiles, forKey: kShouldAutoReloadUserDataFiles)
|
||||
UserDefaults.standard.set(mgrPrefs.shouldAutoReloadUserDataFiles, forKey: kShouldAutoReloadUserDataFiles)
|
||||
}
|
||||
|
||||
// 預設情況下讓 Tab 鍵在選字窗內切換候選字、而不是用來換頁。
|
||||
if UserDefaults.standard.object(forKey: kSpecifyTabKeyBehavior) == nil {
|
||||
UserDefaults.standard.set(Preferences.specifyTabKeyBehavior, forKey: kSpecifyTabKeyBehavior)
|
||||
UserDefaults.standard.set(mgrPrefs.specifyTabKeyBehavior, forKey: kSpecifyTabKeyBehavior)
|
||||
}
|
||||
|
||||
// 預設情況下讓 Space 鍵在選字窗內切換候選字、而不是用來換頁。
|
||||
if UserDefaults.standard.object(forKey: kSpecifySpaceKeyBehavior) == nil {
|
||||
UserDefaults.standard.set(Preferences.specifySpaceKeyBehavior, forKey: kSpecifySpaceKeyBehavior)
|
||||
UserDefaults.standard.set(mgrPrefs.specifySpaceKeyBehavior, forKey: kSpecifySpaceKeyBehavior)
|
||||
}
|
||||
|
||||
// 預設禁用逐字選字模式(就是每個字都要選的那種),所以設成 false
|
||||
if UserDefaults.standard.object(forKey: kUseSCPCTypingMode) == nil {
|
||||
UserDefaults.standard.set(Preferences.useSCPCTypingMode, forKey: kUseSCPCTypingMode)
|
||||
UserDefaults.standard.set(mgrPrefs.useSCPCTypingMode, forKey: kUseSCPCTypingMode)
|
||||
}
|
||||
|
||||
// 預設禁用逐字選字模式時的聯想詞功能,所以設成 false
|
||||
if UserDefaults.standard.object(forKey: kAssociatedPhrasesEnabled) == nil {
|
||||
UserDefaults.standard.set(Preferences.associatedPhrasesEnabled, forKey: kAssociatedPhrasesEnabled)
|
||||
UserDefaults.standard.set(mgrPrefs.associatedPhrasesEnabled, forKey: kAssociatedPhrasesEnabled)
|
||||
}
|
||||
|
||||
// 預設漢音風格選字,所以要設成 0
|
||||
if UserDefaults.standard.object(forKey: kSelectPhraseAfterCursorAsCandidatePreference) == nil {
|
||||
UserDefaults.standard.set(Preferences.selectPhraseAfterCursorAsCandidate, forKey: kSelectPhraseAfterCursorAsCandidatePreference)
|
||||
UserDefaults.standard.set(mgrPrefs.selectPhraseAfterCursorAsCandidate, forKey: kSelectPhraseAfterCursorAsCandidatePreference)
|
||||
}
|
||||
|
||||
// 預設在選字後自動移動游標
|
||||
if UserDefaults.standard.object(forKey: kMoveCursorAfterSelectingCandidate) == nil {
|
||||
UserDefaults.standard.set(Preferences.moveCursorAfterSelectingCandidate, forKey: kMoveCursorAfterSelectingCandidate)
|
||||
UserDefaults.standard.set(mgrPrefs.moveCursorAfterSelectingCandidate, forKey: kMoveCursorAfterSelectingCandidate)
|
||||
}
|
||||
|
||||
// 預設橫向選字窗,不爽請自行改成縱向選字窗
|
||||
if UserDefaults.standard.object(forKey: kUseHorizontalCandidateListPreference) == nil {
|
||||
UserDefaults.standard.set(Preferences.useHorizontalCandidateList, forKey: kUseHorizontalCandidateListPreference)
|
||||
UserDefaults.standard.set(mgrPrefs.useHorizontalCandidateList, forKey: kUseHorizontalCandidateListPreference)
|
||||
}
|
||||
|
||||
// 預設停用全字庫支援
|
||||
if UserDefaults.standard.object(forKey: kCNS11643Enabled) == nil {
|
||||
UserDefaults.standard.set(Preferences.cns11643Enabled, forKey: kCNS11643Enabled)
|
||||
UserDefaults.standard.set(mgrPrefs.cns11643Enabled, forKey: kCNS11643Enabled)
|
||||
}
|
||||
|
||||
// 預設停用繁體轉康熙模組
|
||||
if UserDefaults.standard.object(forKey: kChineseConversionEnabled) == nil {
|
||||
UserDefaults.standard.set(Preferences.chineseConversionEnabled, forKey: kChineseConversionEnabled)
|
||||
UserDefaults.standard.set(mgrPrefs.chineseConversionEnabled, forKey: kChineseConversionEnabled)
|
||||
}
|
||||
|
||||
// 預設停用繁體轉 JIS 當用新字體模組
|
||||
if UserDefaults.standard.object(forKey: kShiftJISShinjitaiOutputEnabled) == nil {
|
||||
UserDefaults.standard.set(Preferences.shiftJISShinjitaiOutputEnabled, forKey: kShiftJISShinjitaiOutputEnabled)
|
||||
UserDefaults.standard.set(mgrPrefs.shiftJISShinjitaiOutputEnabled, forKey: kShiftJISShinjitaiOutputEnabled)
|
||||
}
|
||||
|
||||
// 預設停用自訂語彙置換
|
||||
if UserDefaults.standard.object(forKey: kPhraseReplacementEnabled) == nil {
|
||||
UserDefaults.standard.set(Preferences.phraseReplacementEnabled, forKey: kPhraseReplacementEnabled)
|
||||
UserDefaults.standard.set(mgrPrefs.phraseReplacementEnabled, forKey: kPhraseReplacementEnabled)
|
||||
}
|
||||
|
||||
// 預設沒事不要在那裡放屁
|
||||
if UserDefaults.standard.object(forKey: kShouldNotFartInLieuOfBeep) == nil {
|
||||
UserDefaults.standard.set(Preferences.shouldNotFartInLieuOfBeep, forKey: kShouldNotFartInLieuOfBeep)
|
||||
UserDefaults.standard.set(mgrPrefs.shouldNotFartInLieuOfBeep, forKey: kShouldNotFartInLieuOfBeep)
|
||||
}
|
||||
|
||||
UserDefaults.standard.synchronize()
|
|
@ -137,16 +137,16 @@ static void LTLoadLanguageModelFile(NSString *filenameWithoutExtension, vChewing
|
|||
+ (void)setupDataModelValueConverter
|
||||
{
|
||||
auto converter = [] (string input) {
|
||||
// if (!Preferences.chineseConversionEnabled) {
|
||||
// if (!mgrPrefs.chineseConversionEnabled) {
|
||||
// return input;
|
||||
// }
|
||||
//
|
||||
// if (Preferences.chineseConversionStyle == 0) {
|
||||
// if (mgrPrefs.chineseConversionStyle == 0) {
|
||||
// return input;
|
||||
// }
|
||||
//
|
||||
// NSString *text = [NSString stringWithUTF8String:input.c_str()];
|
||||
// if (Preferences.chineseConversionEngine == 1) {
|
||||
// if (mgrPrefs.chineseConversionEngine == 1) {
|
||||
// text = [VXHanConvert convertToKangXiFrom:text];
|
||||
// }
|
||||
// else {
|
||||
|
@ -288,7 +288,7 @@ static void LTLoadLanguageModelFile(NSString *filenameWithoutExtension, vChewing
|
|||
|
||||
// We use FSEventStream to monitor the change of the user phrase folder,
|
||||
// so we don't have to load data here unless FSEventStream is disabled by user.
|
||||
if (!Preferences.shouldAutoReloadUserDataFiles) {
|
||||
if (!mgrPrefs.shouldAutoReloadUserDataFiles) {
|
||||
[self loadUserPhrases];
|
||||
}
|
||||
return YES;
|
||||
|
|
|
@ -34,7 +34,7 @@ import Cocoa
|
|||
}
|
||||
// Create a new beep sound if possible
|
||||
var sndBeep:String
|
||||
if Preferences.shouldNotFartInLieuOfBeep == false {
|
||||
if mgrPrefs.shouldNotFartInLieuOfBeep == false {
|
||||
sndBeep = "Fart"
|
||||
} else {
|
||||
sndBeep = "Beep"
|
||||
|
|
|
@ -363,7 +363,7 @@ extension HorizontalCandidateController {
|
|||
frameRect.size = newSize
|
||||
candidateView.frame = frameRect
|
||||
|
||||
if pageCount > 1 && Preferences.showPageButtonsInCandidateWindow {
|
||||
if pageCount > 1 && mgrPrefs.showPageButtonsInCandidateWindow {
|
||||
var buttonRect = nextPageButton.frame
|
||||
let spacing:CGFloat = 0.0
|
||||
|
||||
|
|
|
@ -369,7 +369,7 @@ extension VerticalCandidateController {
|
|||
frameRect.size = newSize
|
||||
candidateView.frame = frameRect
|
||||
|
||||
if pageCount > 1 && Preferences.showPageButtonsInCandidateWindow {
|
||||
if pageCount > 1 && mgrPrefs.showPageButtonsInCandidateWindow {
|
||||
var buttonRect = nextPageButton.frame
|
||||
let spacing:CGFloat = 0.0
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ extension RangeReplaceableCollection where Element: Hashable {
|
|||
var chosenLanguageItem: NSMenuItem? = nil
|
||||
uiLanguageButton.menu?.removeAllItems()
|
||||
|
||||
let appleLanguages = Preferences.appleLanguages
|
||||
let appleLanguages = mgrPrefs.appleLanguages
|
||||
for language in languages {
|
||||
let menuItem = NSMenuItem()
|
||||
menuItem.title = NSLocalizedString(language, comment: "")
|
||||
|
@ -86,7 +86,7 @@ extension RangeReplaceableCollection where Element: Hashable {
|
|||
menuItem_AppleZhuyinEten.representedObject = String("com.apple.keylayout.ZhuyinEten")
|
||||
basisKeyboardLayoutButton.menu?.addItem(menuItem_AppleZhuyinEten)
|
||||
|
||||
let basisKeyboardLayoutID = Preferences.basisKeyboardLayout
|
||||
let basisKeyboardLayoutID = mgrPrefs.basisKeyboardLayout
|
||||
|
||||
for source in list {
|
||||
if let categoryPtr = TISGetInputSourceProperty(source, kTISPropertyInputSourceCategory) {
|
||||
|
@ -150,11 +150,11 @@ extension RangeReplaceableCollection where Element: Hashable {
|
|||
|
||||
selectionKeyComboBox.usesDataSource = false
|
||||
selectionKeyComboBox.removeAllItems()
|
||||
selectionKeyComboBox.addItems(withObjectValues: Preferences.suggestedCandidateKeys)
|
||||
selectionKeyComboBox.addItems(withObjectValues: mgrPrefs.suggestedCandidateKeys)
|
||||
|
||||
var candidateSelectionKeys = Preferences.candidateKeys
|
||||
var candidateSelectionKeys = mgrPrefs.candidateKeys
|
||||
if candidateSelectionKeys.isEmpty {
|
||||
candidateSelectionKeys = Preferences.defaultCandidateKeys
|
||||
candidateSelectionKeys = mgrPrefs.defaultCandidateKeys
|
||||
}
|
||||
|
||||
selectionKeyComboBox.stringValue = candidateSelectionKeys
|
||||
|
@ -163,28 +163,28 @@ extension RangeReplaceableCollection where Element: Hashable {
|
|||
// 這裡有必要加上這段處理,用來確保藉由偏好設定介面動過的 CNS 開關能夠立刻生效。
|
||||
// 所有涉及到語言模型開關的內容均需要這樣處理。
|
||||
@IBAction func toggleCNSSupport(_ sender: Any) {
|
||||
mgrLangModel.setCNSEnabled(Preferences.cns11643Enabled)
|
||||
mgrLangModel.setCNSEnabled(mgrPrefs.cns11643Enabled)
|
||||
}
|
||||
|
||||
@IBAction func toggleSymbolInputEnabled(_ sender: Any) {
|
||||
mgrLangModel.setSymbolEnabled(Preferences.symbolInputEnabled)
|
||||
mgrLangModel.setSymbolEnabled(mgrPrefs.symbolInputEnabled)
|
||||
}
|
||||
|
||||
@IBAction func toggleTrad2KangXiAction(_ sender: Any) {
|
||||
if chkTrad2KangXi.state == .on && chkTrad2JISShinjitai.state == .on {
|
||||
Preferences.toggleShiftJISShinjitaiOutputEnabled()
|
||||
mgrPrefs.toggleShiftJISShinjitaiOutputEnabled()
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func toggleTrad2JISShinjitaiAction(_ sender: Any) {
|
||||
if chkTrad2KangXi.state == .on && chkTrad2JISShinjitai.state == .on {
|
||||
Preferences.toggleChineseConversionEnabled()
|
||||
mgrPrefs.toggleChineseConversionEnabled()
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func updateBasisKeyboardLayoutAction(_ sender: Any) {
|
||||
if let sourceID = basisKeyboardLayoutButton.selectedItem?.representedObject as? String {
|
||||
Preferences.basisKeyboardLayout = sourceID
|
||||
mgrPrefs.basisKeyboardLayout = sourceID
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ extension RangeReplaceableCollection where Element: Hashable {
|
|||
}
|
||||
if let language = uiLanguageButton.selectedItem?.representedObject as? String {
|
||||
if (language != "auto") {
|
||||
Preferences.appleLanguages = [language]
|
||||
mgrPrefs.appleLanguages = [language]
|
||||
}
|
||||
else {
|
||||
UserDefaults.standard.removeObject(forKey: "AppleLanguages")
|
||||
|
@ -216,18 +216,18 @@ extension RangeReplaceableCollection where Element: Hashable {
|
|||
return
|
||||
}
|
||||
do {
|
||||
try Preferences.validate(candidateKeys: keys)
|
||||
Preferences.candidateKeys = keys
|
||||
selectionKeyComboBox.stringValue = Preferences.candidateKeys
|
||||
try mgrPrefs.validate(candidateKeys: keys)
|
||||
mgrPrefs.candidateKeys = keys
|
||||
selectionKeyComboBox.stringValue = mgrPrefs.candidateKeys
|
||||
}
|
||||
catch Preferences.CandidateKeyError.empty {
|
||||
selectionKeyComboBox.stringValue = Preferences.candidateKeys
|
||||
catch mgrPrefs.CandidateKeyError.empty {
|
||||
selectionKeyComboBox.stringValue = mgrPrefs.candidateKeys
|
||||
}
|
||||
catch {
|
||||
if let window = window {
|
||||
let alert = NSAlert(error: error)
|
||||
alert.beginSheetModal(for: window) { response in
|
||||
self.selectionKeyComboBox.stringValue = Preferences.candidateKeys
|
||||
self.selectionKeyComboBox.stringValue = mgrPrefs.candidateKeys
|
||||
}
|
||||
clsSFX.beep()
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
5B62A32927AE77D100A19448 /* FSEventStreamHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A32827AE77D100A19448 /* FSEventStreamHelper.swift */; };
|
||||
5B62A32F27AE78B000A19448 /* CoreLM.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A32D27AE78B000A19448 /* CoreLM.mm */; };
|
||||
5B62A33227AE792F00A19448 /* InputSourceHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33127AE792F00A19448 /* InputSourceHelper.swift */; };
|
||||
5B62A33627AE795800A19448 /* PreferencesModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33527AE795800A19448 /* PreferencesModule.swift */; };
|
||||
5B62A33627AE795800A19448 /* mgrPrefs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33527AE795800A19448 /* mgrPrefs.swift */; };
|
||||
5B62A33827AE79CD00A19448 /* NSStringUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33727AE79CD00A19448 /* NSStringUtils.swift */; };
|
||||
5B62A33D27AE7CC100A19448 /* ctlAboutWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33C27AE7CC100A19448 /* ctlAboutWindow.swift */; };
|
||||
5B62A34627AE7CD900A19448 /* HorizontalCandidateController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33F27AE7CD900A19448 /* HorizontalCandidateController.swift */; };
|
||||
|
@ -188,7 +188,7 @@
|
|||
5B62A32C27AE78B000A19448 /* CoreLM.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CoreLM.h; sourceTree = "<group>"; };
|
||||
5B62A32D27AE78B000A19448 /* CoreLM.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CoreLM.mm; sourceTree = "<group>"; };
|
||||
5B62A33127AE792F00A19448 /* InputSourceHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputSourceHelper.swift; sourceTree = "<group>"; };
|
||||
5B62A33527AE795800A19448 /* PreferencesModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesModule.swift; sourceTree = "<group>"; };
|
||||
5B62A33527AE795800A19448 /* mgrPrefs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = mgrPrefs.swift; sourceTree = "<group>"; };
|
||||
5B62A33727AE79CD00A19448 /* NSStringUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSStringUtils.swift; sourceTree = "<group>"; };
|
||||
5B62A33C27AE7CC100A19448 /* ctlAboutWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ctlAboutWindow.swift; sourceTree = "<group>"; };
|
||||
5B62A33F27AE7CD900A19448 /* HorizontalCandidateController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HorizontalCandidateController.swift; sourceTree = "<group>"; };
|
||||
|
@ -462,7 +462,7 @@
|
|||
children = (
|
||||
D4A13D5927A59D5C003BE359 /* ctlInputMethod.swift */,
|
||||
5B62A33127AE792F00A19448 /* InputSourceHelper.swift */,
|
||||
5B62A33527AE795800A19448 /* PreferencesModule.swift */,
|
||||
5B62A33527AE795800A19448 /* mgrPrefs.swift */,
|
||||
);
|
||||
path = IMEModules;
|
||||
sourceTree = "<group>";
|
||||
|
@ -1031,7 +1031,7 @@
|
|||
5B62A31A27AE73A700A19448 /* mztools.m in Sources */,
|
||||
5B62A32927AE77D100A19448 /* FSEventStreamHelper.swift in Sources */,
|
||||
D47F7DD3278C1263002F9DD7 /* UserOverrideModel.cpp in Sources */,
|
||||
5B62A33627AE795800A19448 /* PreferencesModule.swift in Sources */,
|
||||
5B62A33627AE795800A19448 /* mgrPrefs.swift in Sources */,
|
||||
5B62A33827AE79CD00A19448 /* NSStringUtils.swift in Sources */,
|
||||
5B62A33227AE792F00A19448 /* InputSourceHelper.swift in Sources */,
|
||||
5B62A34927AE7CD900A19448 /* TooltipController.swift in Sources */,
|
||||
|
|
Loading…
Reference in New Issue