From bff4c5c89141ce005a7b6d2da5d641c3b7b63e8b Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 21 Feb 2022 23:59:18 +0800 Subject: [PATCH 01/18] Data Update - 20220222 --- Source/Data | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Data b/Source/Data index 6dc73cd3..70342c40 160000 --- a/Source/Data +++ b/Source/Data @@ -1 +1 @@ -Subproject commit 6dc73cd3edd47c85089db8f58e92f0c821e67ed6 +Subproject commit 70342c4047c1402c97bde98a51e961e82fa29f60 From 3527cd839ece7865875ae84c0fe76b3b98bd2760 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 22 Feb 2022 18:37:52 +0800 Subject: [PATCH 02/18] ctlIME // + Debug Mode with Error Numbers. --- .../Modules/ControllerModules/KeyHandler.mm | 42 +++++++++++++++++++ .../IMEModules/PreferencesModule.swift | 14 ++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/Source/Modules/ControllerModules/KeyHandler.mm b/Source/Modules/ControllerModules/KeyHandler.mm index 2fb6d2be..1986cb0a 100644 --- a/Source/Modules/ControllerModules/KeyHandler.mm +++ b/Source/Modules/ControllerModules/KeyHandler.mm @@ -346,6 +346,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; // see if we have a unigram for this if (!_languageModel->hasUnigramsForKey(reading)) { + [self errorCallbackConsolePrint:@"B49C0979"]; errorCallback(); InputStateInputting *inputting = (InputStateInputting *)[self buildInputtingState]; stateCallback(inputting); @@ -567,6 +568,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; // strange behavior if we don't do this, "thinking" the key is not // actually consumed) if ([state isKindOfClass:[InputStateNotEmpty class]] || !_bpmfReadingBuffer->isEmpty()) { + [self errorCallbackConsolePrint:@"A9BFF20E"]; errorCallback(); stateCallback(state); return YES; @@ -617,6 +619,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; } if (!_bpmfReadingBuffer->isEmpty()) { + [self errorCallbackConsolePrint:@"6ED95318"]; errorCallback(); stateCallback(state); return YES; @@ -632,6 +635,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; marking.tooltipForInputting = currentState.tooltip; stateCallback(marking); } else { + [self errorCallbackConsolePrint:@"D326DEA3"]; errorCallback(); stateCallback(state); } @@ -641,6 +645,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; InputStateInputting *inputting = (InputStateInputting *)[self buildInputtingState]; stateCallback(inputting); } else { + [self errorCallbackConsolePrint:@"7045E6F3"]; errorCallback(); stateCallback(state); } @@ -655,6 +660,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; } if (!_bpmfReadingBuffer->isEmpty()) { + [self errorCallbackConsolePrint:@"B3BA5257"]; errorCallback(); stateCallback(state); return YES; @@ -670,6 +676,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; marking.tooltipForInputting = currentState.tooltip; stateCallback(marking); } else { + [self errorCallbackConsolePrint:@"BB7F6DB9"]; errorCallback(); stateCallback(state); } @@ -679,6 +686,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; InputStateInputting *inputting = (InputStateInputting *)[self buildInputtingState]; stateCallback(inputting); } else { + [self errorCallbackConsolePrint:@"A96AAD58"]; errorCallback(); stateCallback(state); } @@ -694,6 +702,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; } if (!_bpmfReadingBuffer->isEmpty()) { + [self errorCallbackConsolePrint:@"ABC44080"]; errorCallback(); stateCallback(state); return YES; @@ -704,6 +713,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; InputStateInputting *inputting = (InputStateInputting *)[self buildInputtingState]; stateCallback(inputting); } else { + [self errorCallbackConsolePrint:@"66D97F90"]; errorCallback(); stateCallback(state); } @@ -718,6 +728,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; } if (!_bpmfReadingBuffer->isEmpty()) { + [self errorCallbackConsolePrint:@"9B69908D"]; errorCallback(); stateCallback(state); return YES; @@ -728,6 +739,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; InputStateInputting *inputting = (InputStateInputting *)[self buildInputtingState]; stateCallback(inputting); } else { + [self errorCallbackConsolePrint:@"9B69908E"]; errorCallback(); stateCallback(state); } @@ -742,6 +754,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; } if (!_bpmfReadingBuffer->isEmpty()) { + [self errorCallbackConsolePrint:@"9B6F908D"]; errorCallback(); } stateCallback(state); @@ -759,6 +772,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; _builder->deleteReadingBeforeCursor(); [self _walk]; } else { + [self errorCallbackConsolePrint:@"9D69908D"]; errorCallback(); stateCallback(state); return YES; @@ -795,10 +809,12 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; stateCallback(inputting); } } else { + [self errorCallbackConsolePrint:@"9B69938D"]; errorCallback(); stateCallback(state); } } else { + [self errorCallbackConsolePrint:@"9C69908D"]; errorCallback(); stateCallback(state); } @@ -852,6 +868,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; _builder->insertReadingAtCursor(customPunctuation); poppedText = [self _popOverflowComposingTextAndWalk]; } else { // If there is still unfinished bpmf reading, ignore the punctuation + [self errorCallbackConsolePrint:@"A9B69908D"]; errorCallback(); stateCallback(state); return YES; @@ -893,6 +910,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; // Enter if ([input isEnter] || [input isEnterCharCode]) { if (![self.delegate keyHandler:self didRequestWriteUserPhraseWithState:state]) { + [self errorCallbackConsolePrint:@"5B69CC8D"]; errorCallback(); return YES; } @@ -917,6 +935,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; stateCallback(marking); } } else { + [self errorCallbackConsolePrint:@"1149908D"]; errorCallback(); stateCallback(state); } @@ -938,6 +957,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; stateCallback(marking); } } else { + [self errorCallbackConsolePrint:@"9B51408D"]; errorCallback(); stateCallback(state); } @@ -991,6 +1011,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; if ([input isSpace] || [input isPageDown] || input.emacsKey == vChewingEmacsKeyNextPage) { BOOL updated = [gCurrentCandidateController showNextPage]; if (!updated) { + [self errorCallbackConsolePrint:@"9B691919"]; errorCallback(); } return YES; @@ -999,6 +1020,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; if ([input isPageUp]) { BOOL updated = [gCurrentCandidateController showPreviousPage]; if (!updated) { + [self errorCallbackConsolePrint:@"9569955D"]; errorCallback(); } return YES; @@ -1008,11 +1030,13 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; if ([gCurrentCandidateController isKindOfClass:[VTHorizontalCandidateController class]]) { BOOL updated = [gCurrentCandidateController highlightPreviousCandidate]; if (!updated) { + [self errorCallbackConsolePrint:@"1145148D"]; errorCallback(); } } else { BOOL updated = [gCurrentCandidateController showPreviousPage]; if (!updated) { + [self errorCallbackConsolePrint:@"1919810D"]; errorCallback(); } } @@ -1022,6 +1046,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; if (input.emacsKey == vChewingEmacsKeyBackward) { BOOL updated = [gCurrentCandidateController highlightPreviousCandidate]; if (!updated) { + [self errorCallbackConsolePrint:@"9B89308D"]; errorCallback(); } return YES; @@ -1031,11 +1056,13 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; if ([gCurrentCandidateController isKindOfClass:[VTHorizontalCandidateController class]]) { BOOL updated = [gCurrentCandidateController highlightNextCandidate]; if (!updated) { + [self errorCallbackConsolePrint:@"9B65138D"]; errorCallback(); } } else { BOOL updated = [gCurrentCandidateController showNextPage]; if (!updated) { + [self errorCallbackConsolePrint:@"9244908D"]; errorCallback(); } } @@ -1045,6 +1072,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; if (input.emacsKey == vChewingEmacsKeyForward) { BOOL updated = [gCurrentCandidateController highlightNextCandidate]; if (!updated) { + [self errorCallbackConsolePrint:@"9B2428D"]; errorCallback(); } return YES; @@ -1054,11 +1082,13 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; if ([gCurrentCandidateController isKindOfClass:[VTHorizontalCandidateController class]]) { BOOL updated = [gCurrentCandidateController showPreviousPage]; if (!updated) { + [self errorCallbackConsolePrint:@"9B614524"]; errorCallback(); } } else { BOOL updated = [gCurrentCandidateController highlightPreviousCandidate]; if (!updated) { + [self errorCallbackConsolePrint:@"ASD9908D"]; errorCallback(); } } @@ -1069,11 +1099,13 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; if ([gCurrentCandidateController isKindOfClass:[VTHorizontalCandidateController class]]) { BOOL updated = [gCurrentCandidateController showNextPage]; if (!updated) { + [self errorCallbackConsolePrint:@"92B990DD"]; errorCallback(); } } else { BOOL updated = [gCurrentCandidateController highlightNextCandidate]; if (!updated) { + [self errorCallbackConsolePrint:@"6B99908D"]; errorCallback(); } } @@ -1082,6 +1114,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; if ([input isHome] || input.emacsKey == vChewingEmacsKeyHome) { if (gCurrentCandidateController.selectedCandidateIndex == 0) { + [self errorCallbackConsolePrint:@"9B6EDE8D"]; errorCallback(); } else { gCurrentCandidateController.selectedCandidateIndex = 0; @@ -1104,6 +1137,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; if (([input isEnd] || input.emacsKey == vChewingEmacsKeyEnd) && candidates.count > 0) { if (gCurrentCandidateController.selectedCandidateIndex == candidates.count - 1) { + [self errorCallbackConsolePrint:@"9B69AAAD"]; errorCallback(); } else { gCurrentCandidateController.selectedCandidateIndex = candidates.count - 1; @@ -1181,6 +1215,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; } } + [self errorCallbackConsolePrint:@"172A0F81"]; errorCallback(); return YES; } @@ -1378,4 +1413,11 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; return nil; } +-(void)errorCallbackConsolePrint:(NSString *)strPrint +{ + if (Preferences.isDebugModeEnabled) { + NSLog(@"vChewingErrorCallback: %@", strPrint); + } +} + @end diff --git a/Source/Modules/IMEModules/PreferencesModule.swift b/Source/Modules/IMEModules/PreferencesModule.swift index aed90dd5..9774cce4 100644 --- a/Source/Modules/IMEModules/PreferencesModule.swift +++ b/Source/Modules/IMEModules/PreferencesModule.swift @@ -19,6 +19,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH import Cocoa +private let kIsDebugModeEnabled = "_DebugMode" private let kCheckUpdateAutomatically = "CheckUpdateAutomatically" private let kKeyboardLayoutPreference = "KeyboardLayout" private let kBasisKeyboardLayoutPreference = "BasisKeyboardLayout" @@ -213,7 +214,8 @@ struct ComposingBufferSize { // MARK: - @objc public class Preferences: NSObject { static var allKeys:[String] { - [kKeyboardLayoutPreference, + [kIsDebugModeEnabled, + kKeyboardLayoutPreference, kBasisKeyboardLayoutPreference, kFunctionKeyKeyboardLayoutPreference, kFunctionKeyKeyboardLayoutOverrideIncludeShift, @@ -248,11 +250,16 @@ struct ComposingBufferSize { @objc public static func setMissingDefaults () { // 既然 Preferences Module 的預設屬性不自動寫入 plist、而且還是 private,那這邊就先寫入了。 + // 首次啟用輸入法時不要啟用偵錯模式。 + if UserDefaults.standard.object(forKey: kIsDebugModeEnabled) == nil { + UserDefaults.standard.set(Preferences.isDebugModeEnabled, forKey: kIsDebugModeEnabled) + } + // 首次啟用輸入法時設定不要自動更新,免得在某些要隔絕外部網路連線的保密機構內觸犯資安規則。 if UserDefaults.standard.object(forKey: kCheckUpdateAutomatically) == nil { UserDefaults.standard.set(false, forKey: kCheckUpdateAutomatically) } - + // 預設選字窗字詞文字尺寸,設成 18 剛剛好 if UserDefaults.standard.object(forKey: kCandidateListTextSize) == nil { UserDefaults.standard.set(Preferences.candidateListTextSize, forKey: kCandidateListTextSize) @@ -336,6 +343,9 @@ struct ComposingBufferSize { UserDefaults.standard.synchronize() } + @UserDefault(key: kIsDebugModeEnabled, defaultValue: false) + @objc static var isDebugModeEnabled: Bool + @UserDefault(key: kAppleLanguagesPreferences, defaultValue: []) @objc static var appleLanguages: Array From 2363fc40b304a3c288b3f3750c8783d8760ba3b8 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 22 Feb 2022 23:07:32 +0800 Subject: [PATCH 03/18] IME // Bind Debug Mode Switch to PrefWindow. --- Source/Modules/IMEModules/ctlInputMethod.swift | 4 +++- .../Source/WindowNIBs/Base.lproj/frmPrefWindow.xib | 14 ++++++++++++++ .../WindowNIBs/en.lproj/frmPrefWindow.strings | 3 +++ .../WindowNIBs/ja.lproj/frmPrefWindow.strings | 3 +++ .../WindowNIBs/zh-Hans.lproj/frmPrefWindow.strings | 3 +++ .../WindowNIBs/zh-Hant.lproj/frmPrefWindow.strings | 3 +++ 6 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Source/Modules/IMEModules/ctlInputMethod.swift b/Source/Modules/IMEModules/ctlInputMethod.swift index 48af8aa4..5a04837a 100644 --- a/Source/Modules/IMEModules/ctlInputMethod.swift +++ b/Source/Modules/IMEModules/ctlInputMethod.swift @@ -115,7 +115,9 @@ class ctlInputMethod: IMKInputController { menu.addItem(NSMenuItem.separator()) // --------------------- menu.addItem(withTitle: NSLocalizedString("vChewing Preferences…", comment: ""), action: #selector(showPreferences(_:)), keyEquivalent: "") - menu.addItem(withTitle: NSLocalizedString("Check for Updates…", comment: ""), action: #selector(checkForUpdate(_:)), keyEquivalent: "") + if !optionKeyPressed { + menu.addItem(withTitle: NSLocalizedString("Check for Updates…", comment: ""), action: #selector(checkForUpdate(_:)), keyEquivalent: "") + } menu.addItem(withTitle: NSLocalizedString("About vChewing…", comment: ""), action: #selector(showAbout(_:)), keyEquivalent: "") if optionKeyPressed { menu.addItem(withTitle: NSLocalizedString("Reboot vChewing…", comment: ""), action: #selector(selfTerminate(_:)), keyEquivalent: "") diff --git a/Source/WindowNIBs/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib b/Source/WindowNIBs/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib index 9e6e2d40..0af096a0 100644 --- a/Source/WindowNIBs/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib +++ b/Source/WindowNIBs/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib @@ -300,15 +300,29 @@ + + + + + diff --git a/Source/WindowNIBs/Source/WindowNIBs/en.lproj/frmPrefWindow.strings b/Source/WindowNIBs/Source/WindowNIBs/en.lproj/frmPrefWindow.strings index 8d36bb1c..e1933b5c 100644 --- a/Source/WindowNIBs/Source/WindowNIBs/en.lproj/frmPrefWindow.strings +++ b/Source/WindowNIBs/Source/WindowNIBs/en.lproj/frmPrefWindow.strings @@ -2,6 +2,9 @@ /* Class = "NSWindow"; title = "vChewing Preferences"; ObjectID = "1"; */ "1.title" = "vChewing Preferences"; +/* Class = "NSButtonCell"; title = "Debug Mode"; ObjectID = "sZx-18-8dO"; */ +"sZx-18-8dO.title" = "Debug Mode"; + /* Class = "NSMenu"; title = "OtherViews"; ObjectID = "5"; */ "5.title" = "OtherViews"; diff --git a/Source/WindowNIBs/Source/WindowNIBs/ja.lproj/frmPrefWindow.strings b/Source/WindowNIBs/Source/WindowNIBs/ja.lproj/frmPrefWindow.strings index f7c41959..0594d687 100644 --- a/Source/WindowNIBs/Source/WindowNIBs/ja.lproj/frmPrefWindow.strings +++ b/Source/WindowNIBs/Source/WindowNIBs/ja.lproj/frmPrefWindow.strings @@ -2,6 +2,9 @@ /* Class = "NSWindow"; title = "vChewing Preferences"; ObjectID = "1"; */ "1.title" = "威注音アプリ機能設定"; +/* Class = "NSButtonCell"; title = "Debug Mode"; ObjectID = "sZx-18-8dO"; */ +"sZx-18-8dO.title" = "欠陥辿着モード"; + /* Class = "NSMenu"; title = "OtherViews"; ObjectID = "5"; */ "5.title" = "OtherViews"; diff --git a/Source/WindowNIBs/Source/WindowNIBs/zh-Hans.lproj/frmPrefWindow.strings b/Source/WindowNIBs/Source/WindowNIBs/zh-Hans.lproj/frmPrefWindow.strings index 55278482..c0825a05 100644 --- a/Source/WindowNIBs/Source/WindowNIBs/zh-Hans.lproj/frmPrefWindow.strings +++ b/Source/WindowNIBs/Source/WindowNIBs/zh-Hans.lproj/frmPrefWindow.strings @@ -2,6 +2,9 @@ /* Class = "NSWindow"; title = "vChewing Preferences"; ObjectID = "1"; */ "1.title" = "威注音偏好设定"; +/* Class = "NSButtonCell"; title = "Debug Mode"; ObjectID = "sZx-18-8dO"; */ +"sZx-18-8dO.title" = "侦错模式"; + /* Class = "NSMenu"; title = "OtherViews"; ObjectID = "5"; */ "5.title" = "OtherViews"; diff --git a/Source/WindowNIBs/Source/WindowNIBs/zh-Hant.lproj/frmPrefWindow.strings b/Source/WindowNIBs/Source/WindowNIBs/zh-Hant.lproj/frmPrefWindow.strings index 29a8b8c4..eb060103 100644 --- a/Source/WindowNIBs/Source/WindowNIBs/zh-Hant.lproj/frmPrefWindow.strings +++ b/Source/WindowNIBs/Source/WindowNIBs/zh-Hant.lproj/frmPrefWindow.strings @@ -2,6 +2,9 @@ /* Class = "NSWindow"; title = "vChewing Preferences"; ObjectID = "1"; */ "1.title" = "威注音偏好設定"; +/* Class = "NSButtonCell"; title = "Debug Mode"; ObjectID = "sZx-18-8dO"; */ +"sZx-18-8dO.title" = "偵錯模式"; + /* Class = "NSMenu"; title = "OtherViews"; ObjectID = "5"; */ "5.title" = "OtherViews"; From 211a4c8f5cb101104d1709821437ef9f4320e934 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 22 Feb 2022 17:31:39 +0800 Subject: [PATCH 04/18] KeyHandler // Commit buffer on calling the symbol menu. - Otherwise, the buffer content will be duplicated (a misbehavior) when pressing ESC to exit the symbol menu. --- Source/Modules/ControllerModules/KeyHandler.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/Modules/ControllerModules/KeyHandler.mm b/Source/Modules/ControllerModules/KeyHandler.mm index 1986cb0a..eb042f1c 100644 --- a/Source/Modules/ControllerModules/KeyHandler.mm +++ b/Source/Modules/ControllerModules/KeyHandler.mm @@ -509,8 +509,10 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; // MARK: Punctuation list if ([input isSymbolMenuKey]) { - InputStateEmpty *empty = [[InputStateEmpty alloc] init]; - stateCallback(empty); + + // 得在這裡先 commit buffer,不然會導致「在摁 ESC 離開符號選單時會重複輸入上一次的組字區的內容」的不當行為。 + // 於是這裡用「模擬一次 Enter 鍵的操作」使其代為執行這個 commit buffer 的動作。 + [self _handleEnterWithState:state stateCallback:stateCallback errorCallback:errorCallback]; SymbolNode *root = [SymbolNode root]; InputStateSymbolTable *symbolState = [[InputStateSymbolTable alloc] initWithNode:root useVerticalMode:input.useVerticalMode]; From c6e143441415872bdde16363a07f11488c50dc9f Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 22 Feb 2022 21:21:58 +0800 Subject: [PATCH 05/18] KeyHandler // Add -(Bool)IsBuilderEmpty. --- Source/Modules/ControllerModules/KeyHandler.h | 1 + Source/Modules/ControllerModules/KeyHandler.mm | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/Source/Modules/ControllerModules/KeyHandler.h b/Source/Modules/ControllerModules/KeyHandler.h index 4aa5bd4a..730ab28a 100644 --- a/Source/Modules/ControllerModules/KeyHandler.h +++ b/Source/Modules/ControllerModules/KeyHandler.h @@ -39,6 +39,7 @@ extern InputMode imeModeNULL; @interface KeyHandler : NSObject +- (BOOL)isBuilderEmpty; - (BOOL)handleInput:(KeyHandlerInput *)input state:(InputState *)state stateCallback:(void (^)(InputState *))stateCallback diff --git a/Source/Modules/ControllerModules/KeyHandler.mm b/Source/Modules/ControllerModules/KeyHandler.mm index eb042f1c..44cd1383 100644 --- a/Source/Modules/ControllerModules/KeyHandler.mm +++ b/Source/Modules/ControllerModules/KeyHandler.mm @@ -87,6 +87,14 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; return _inputMode; } +- (BOOL)isBuilderEmpty { + if (_builder->grid().width() == 0) { + return YES; + } else { + return NO; + } +} + - (void)setInputMode:(NSString *)value { NSString *newInputMode; From 9d0fe41650a5e752c9b99679a2779353464f5615 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 22 Feb 2022 22:06:08 +0800 Subject: [PATCH 06/18] KeyHandler // Cancel the CandidateState when Builder is Empty. --- Source/Modules/ControllerModules/KeyHandler.mm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Modules/ControllerModules/KeyHandler.mm b/Source/Modules/ControllerModules/KeyHandler.mm index 44cd1383..3007bd69 100644 --- a/Source/Modules/ControllerModules/KeyHandler.mm +++ b/Source/Modules/ControllerModules/KeyHandler.mm @@ -1000,6 +1000,12 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; [self clear]; InputStateEmptyIgnoringPreviousState *empty = [[InputStateEmptyIgnoringPreviousState alloc] init]; stateCallback(empty); + } else if ([self isBuilderEmpty]) { + // 如果此時發現當前組字緩衝區為真空的情況的話,就將當前的組字緩衝區析構處理、強制重設輸入狀態。 + // 不然的話,一個本不該出現的真空組字緩衝區會使前後方向鍵與 BackSpace 鍵失靈。 + [self clear]; + InputStateEmptyIgnoringPreviousState *empty = [[InputStateEmptyIgnoringPreviousState alloc] init]; + stateCallback(empty); } else { InputStateInputting *inputting = (InputStateInputting *)[self buildInputtingState]; stateCallback(inputting); From b8aea8e1105879fde525bddac7bc2b491fe89d95 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 23 Feb 2022 12:31:00 +0800 Subject: [PATCH 07/18] LMConsolidator // Removing Sorting Feature. - This feature is now considered troublesome, considering that there is no way to control the sorting method in Cpp: Some people prefer sorting things alphabetically, and some prefer counting strokes, etc. --- Source/Modules/FileHandlers/LMConsolidator.h | 2 +- Source/Modules/FileHandlers/LMConsolidator.mm | 7 ++-- .../IMEModules/PreferencesModule.swift | 32 +-------------- .../SubLanguageModels/AssociatedPhrases.mm | 2 +- .../SubLanguageModels/PhraseReplacementMap.mm | 2 +- .../SubLanguageModels/UserPhrasesLM.mm | 2 +- .../Modules/LangModelRelated/mgrLangModel.mm | 2 +- .../WindowNIBs/Base.lproj/frmPrefWindow.xib | 40 ++----------------- .../WindowNIBs/en.lproj/frmPrefWindow.strings | 6 --- .../WindowNIBs/ja.lproj/frmPrefWindow.strings | 6 --- .../zh-Hans.lproj/frmPrefWindow.strings | 6 --- .../zh-Hant.lproj/frmPrefWindow.strings | 6 --- 12 files changed, 12 insertions(+), 101 deletions(-) diff --git a/Source/Modules/FileHandlers/LMConsolidator.h b/Source/Modules/FileHandlers/LMConsolidator.h index 3dd481ca..38b25ae8 100644 --- a/Source/Modules/FileHandlers/LMConsolidator.h +++ b/Source/Modules/FileHandlers/LMConsolidator.h @@ -37,7 +37,7 @@ class LMConsolidator public: static bool CheckPragma(const char *path); static bool FixEOF(const char *path); - static bool ConsolidateContent(const char *path, bool shouldsort, bool shouldCheckPragma); + static bool ConsolidateContent(const char *path, bool shouldCheckPragma); }; } // namespace vChewing diff --git a/Source/Modules/FileHandlers/LMConsolidator.mm b/Source/Modules/FileHandlers/LMConsolidator.mm index d3350e2f..1cb685df 100644 --- a/Source/Modules/FileHandlers/LMConsolidator.mm +++ b/Source/Modules/FileHandlers/LMConsolidator.mm @@ -71,8 +71,8 @@ bool LMConsolidator::FixEOF(const char *path) } // END: EOF FIXER. // CONTENT CONSOLIDATOR. CREDIT: Shiki Suen. -bool LMConsolidator::ConsolidateContent(const char *path, bool shouldsort, bool shouldCheckPragma) { - if (LMConsolidator::CheckPragma(path) && !shouldsort && shouldCheckPragma){ +bool LMConsolidator::ConsolidateContent(const char *path, bool shouldCheckPragma) { + if (LMConsolidator::CheckPragma(path) && shouldCheckPragma){ return true; } @@ -97,8 +97,7 @@ bool LMConsolidator::ConsolidateContent(const char *path, bool shouldsort, bool vecEntry[i] = regex_replace(vecEntry[i], sedTrailingSpace, "").c_str(); // 去掉行尾空格。 } } - // 在第二遍 for 運算之前,針對 vecEntry 排序+去除重複條目。 - if (shouldsort) {sort(vecEntry.begin(), vecEntry.end());} // 要不要排序,得做成開關。 + // 在第二遍 for 運算之前,針對 vecEntry 去除重複條目。 vecEntry.erase(unique(vecEntry.begin(), vecEntry.end()), vecEntry.end()); // 去重複。 // 統整完畢。開始將統整過的內容寫入檔案。 ofstream zfdContentConsolidatorOutput(path); // 這裡是要從頭開始重寫檔案內容,所以不需要「 ios_base::app 」。 diff --git a/Source/Modules/IMEModules/PreferencesModule.swift b/Source/Modules/IMEModules/PreferencesModule.swift index 9774cce4..ff67acb3 100644 --- a/Source/Modules/IMEModules/PreferencesModule.swift +++ b/Source/Modules/IMEModules/PreferencesModule.swift @@ -28,9 +28,6 @@ private let kFunctionKeyKeyboardLayoutOverrideIncludeShift = "FunctionKeyKeyboar private let kCandidateListTextSize = "CandidateListTextSize" private let kAppleLanguagesPreferences = "AppleLanguages" private let kShouldAutoReloadUserDataFiles = "ShouldAutoReloadUserDataFiles" -private let kShouldAutoSortUserPhrasesAndExclListOnLoad = "ShouldAutoSortUserPhrasesAndExclListOnLoad" -private let kShouldAutoSortPhraseReplacementMapOnLoad = "ShouldAutoSortPhraseReplacementMapOnLoad" -private let kShouldAutoSortAssociatedPhrasesOnLoad = "ShouldAutoSortAssociatedPhrasesOnLoad" private let kSelectPhraseAfterCursorAsCandidatePreference = "SelectPhraseAfterCursorAsCandidate" private let kUseHorizontalCandidateListPreference = "UseHorizontalCandidateList" private let kComposingBufferSizePreference = "ComposingBufferSize" @@ -222,9 +219,6 @@ struct ComposingBufferSize { kCandidateListTextSize, kAppleLanguagesPreferences, kShouldAutoReloadUserDataFiles, - kShouldAutoSortUserPhrasesAndExclListOnLoad, - kShouldAutoSortPhraseReplacementMapOnLoad, - kShouldAutoSortAssociatedPhrasesOnLoad, kSelectPhraseAfterCursorAsCandidatePreference, kUseHorizontalCandidateListPreference, kComposingBufferSizePreference, @@ -270,26 +264,11 @@ struct ComposingBufferSize { UserDefaults.standard.set(Preferences.chooseCandidateUsingSpace, forKey: kChooseCandidateUsingSpace) } - // 在檔案載入時,預設不啟用使用者自訂語彙表與語彙排除表的內容排序。 + // 自動檢測使用者自訂語彙數據的變動並載入。 if UserDefaults.standard.object(forKey: kShouldAutoReloadUserDataFiles) == nil { UserDefaults.standard.set(Preferences.shouldAutoReloadUserDataFiles, forKey: kShouldAutoReloadUserDataFiles) } - // 在檔案載入時,預設不啟用語彙置換表的內容排序。 - if UserDefaults.standard.object(forKey: kShouldAutoSortUserPhrasesAndExclListOnLoad) == nil { - UserDefaults.standard.set(Preferences.shouldAutoSortUserPhrasesAndExclListOnLoad, forKey: kShouldAutoSortUserPhrasesAndExclListOnLoad) - } - - // 在檔案載入時,預設不啟用自訂聯想詞表的內容排序。 - if UserDefaults.standard.object(forKey: kShouldAutoSortAssociatedPhrasesOnLoad) == nil { - UserDefaults.standard.set(Preferences.shouldAutoSortAssociatedPhrasesOnLoad, forKey: kShouldAutoSortAssociatedPhrasesOnLoad) - } - - // 自動檢測使用者自訂語彙數據的變動並載入。 - if UserDefaults.standard.object(forKey: kShouldAutoSortPhraseReplacementMapOnLoad) == nil { - UserDefaults.standard.set(Preferences.shouldAutoSortPhraseReplacementMapOnLoad, forKey: kShouldAutoSortPhraseReplacementMapOnLoad) - } - // 預設禁用逐字選字模式(就是每個字都要選的那種),所以設成 false if UserDefaults.standard.object(forKey: kUseSCPCTypingMode) == nil { UserDefaults.standard.set(Preferences.useSCPCTypingMode, forKey: kUseSCPCTypingMode) @@ -371,15 +350,6 @@ struct ComposingBufferSize { @UserDefault(key: kShouldAutoReloadUserDataFiles, defaultValue: true) @objc static var shouldAutoReloadUserDataFiles: Bool - @UserDefault(key: kShouldAutoSortUserPhrasesAndExclListOnLoad, defaultValue: false) - @objc static var shouldAutoSortUserPhrasesAndExclListOnLoad: Bool - - @UserDefault(key: kShouldAutoSortPhraseReplacementMapOnLoad, defaultValue: false) - @objc static var shouldAutoSortPhraseReplacementMapOnLoad: Bool - - @UserDefault(key: kShouldAutoSortAssociatedPhrasesOnLoad, defaultValue: false) - @objc static var shouldAutoSortAssociatedPhrasesOnLoad: Bool - @UserDefault(key: kSelectPhraseAfterCursorAsCandidatePreference, defaultValue: true) @objc static var selectPhraseAfterCursorAsCandidate: Bool diff --git a/Source/Modules/LangModelRelated/SubLanguageModels/AssociatedPhrases.mm b/Source/Modules/LangModelRelated/SubLanguageModels/AssociatedPhrases.mm index 4970f8a3..1af8c9d0 100644 --- a/Source/Modules/LangModelRelated/SubLanguageModels/AssociatedPhrases.mm +++ b/Source/Modules/LangModelRelated/SubLanguageModels/AssociatedPhrases.mm @@ -59,7 +59,7 @@ bool AssociatedPhrases::open(const char *path) } LMConsolidator::FixEOF(path); - LMConsolidator::ConsolidateContent(path, Preferences.shouldAutoSortAssociatedPhrasesOnLoad, true); + LMConsolidator::ConsolidateContent(path, true); fd = ::open(path, O_RDONLY); if (fd == -1) { diff --git a/Source/Modules/LangModelRelated/SubLanguageModels/PhraseReplacementMap.mm b/Source/Modules/LangModelRelated/SubLanguageModels/PhraseReplacementMap.mm index 64d2071e..835c24b6 100644 --- a/Source/Modules/LangModelRelated/SubLanguageModels/PhraseReplacementMap.mm +++ b/Source/Modules/LangModelRelated/SubLanguageModels/PhraseReplacementMap.mm @@ -54,7 +54,7 @@ bool PhraseReplacementMap::open(const char *path) } LMConsolidator::FixEOF(path); - LMConsolidator::ConsolidateContent(path, Preferences.shouldAutoSortPhraseReplacementMapOnLoad, true); + LMConsolidator::ConsolidateContent(path, true); fd = ::open(path, O_RDONLY); if (fd == -1) { diff --git a/Source/Modules/LangModelRelated/SubLanguageModels/UserPhrasesLM.mm b/Source/Modules/LangModelRelated/SubLanguageModels/UserPhrasesLM.mm index f23206f8..cd82d11c 100644 --- a/Source/Modules/LangModelRelated/SubLanguageModels/UserPhrasesLM.mm +++ b/Source/Modules/LangModelRelated/SubLanguageModels/UserPhrasesLM.mm @@ -60,7 +60,7 @@ bool UserPhrasesLM::open(const char *path) } LMConsolidator::FixEOF(path); - LMConsolidator::ConsolidateContent(path, Preferences.shouldAutoSortUserPhrasesAndExclListOnLoad, true); + LMConsolidator::ConsolidateContent(path, true); fd = ::open(path, O_RDONLY); if (fd == -1) { diff --git a/Source/Modules/LangModelRelated/mgrLangModel.mm b/Source/Modules/LangModelRelated/mgrLangModel.mm index 2564a8e5..c6f830f6 100644 --- a/Source/Modules/LangModelRelated/mgrLangModel.mm +++ b/Source/Modules/LangModelRelated/mgrLangModel.mm @@ -266,7 +266,7 @@ static void LTLoadLanguageModelFile(NSString *filenameWithoutExtension, vChewing [writeFile closeFile]; // We enforce the format consolidation here, since the pragma header will let the UserPhraseLM bypasses the consolidating process on load. - vChewing::LMConsolidator::ConsolidateContent([path UTF8String], Preferences.shouldAutoSortUserPhrasesAndExclListOnLoad, false); + vChewing::LMConsolidator::ConsolidateContent([path UTF8String], false); // 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. diff --git a/Source/WindowNIBs/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib b/Source/WindowNIBs/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib index 0af096a0..e4395504 100644 --- a/Source/WindowNIBs/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib +++ b/Source/WindowNIBs/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib @@ -503,36 +503,8 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + - - - + + + + - - - + + + - - - + - - + + - + - + - - - - - - - - - - - - - + - - - + - + diff --git a/Source/WindowNIBs/Source/WindowNIBs/en.lproj/frmPrefWindow.strings b/Source/WindowNIBs/Source/WindowNIBs/en.lproj/frmPrefWindow.strings index dd51ecfe..8e72240f 100644 --- a/Source/WindowNIBs/Source/WindowNIBs/en.lproj/frmPrefWindow.strings +++ b/Source/WindowNIBs/Source/WindowNIBs/en.lproj/frmPrefWindow.strings @@ -173,9 +173,6 @@ /* Class = "NSTextFieldCell"; title = "Change UI font size of candidate window for a better visual clarity."; ObjectID = "iRg-wx-Nx2"; */ "iRg-wx-Nx2.title" = "Change UI font size of candidate window for a better visual clarity."; -/* Class = "NSTextFieldCell"; title = "Define your preferred action when user data files reload."; ObjectID = "j48-5a-cEs"; */ -"j48-5a-cEs.title" = "Define your preferred action when user data files reload."; - /* Class = "NSComboBoxCell"; jQC-12-UuK.ibShadowedObjectValues[0] = "Item 1"; ObjectID = "jQC-12-UuK"; */ "jQC-12-UuK.ibShadowedObjectValues[0]" = "Item 1"; diff --git a/Source/WindowNIBs/Source/WindowNIBs/ja.lproj/frmPrefWindow.strings b/Source/WindowNIBs/Source/WindowNIBs/ja.lproj/frmPrefWindow.strings index f12b05c8..859f850c 100644 --- a/Source/WindowNIBs/Source/WindowNIBs/ja.lproj/frmPrefWindow.strings +++ b/Source/WindowNIBs/Source/WindowNIBs/ja.lproj/frmPrefWindow.strings @@ -173,9 +173,6 @@ /* Class = "NSTextFieldCell"; title = "Change UI font size of candidate window for a better visual clarity."; ObjectID = "iRg-wx-Nx2"; */ "iRg-wx-Nx2.title" = "入力候補陣列の候補文字の字号をご指定ください。"; -/* Class = "NSTextFieldCell"; title = "Define your preferred action when user data files reload."; ObjectID = "j48-5a-cEs"; */ -"j48-5a-cEs.title" = "ユーザー辞書データの読み込む時のやることをご指示ください。"; - /* Class = "NSComboBoxCell"; jQC-12-UuK.ibShadowedObjectValues[0] = "Item 1"; ObjectID = "jQC-12-UuK"; */ "jQC-12-UuK.ibShadowedObjectValues[0]" = "Item 1"; diff --git a/Source/WindowNIBs/Source/WindowNIBs/zh-Hans.lproj/frmPrefWindow.strings b/Source/WindowNIBs/Source/WindowNIBs/zh-Hans.lproj/frmPrefWindow.strings index c3454a60..c2a38827 100644 --- a/Source/WindowNIBs/Source/WindowNIBs/zh-Hans.lproj/frmPrefWindow.strings +++ b/Source/WindowNIBs/Source/WindowNIBs/zh-Hans.lproj/frmPrefWindow.strings @@ -173,9 +173,6 @@ /* Class = "NSTextFieldCell"; title = "Change UI font size of candidate window for a better visual clarity."; ObjectID = "iRg-wx-Nx2"; */ "iRg-wx-Nx2.title" = "变更候选字窗的字型大小。"; -/* Class = "NSTextFieldCell"; title = "Define your preferred action when user data files reload."; ObjectID = "j48-5a-cEs"; */ -"j48-5a-cEs.title" = "请指定在使用者资料重载时要启用的功能。"; - /* Class = "NSComboBoxCell"; jQC-12-UuK.ibShadowedObjectValues[0] = "Item 1"; ObjectID = "jQC-12-UuK"; */ "jQC-12-UuK.ibShadowedObjectValues[0]" = "Item 1"; diff --git a/Source/WindowNIBs/Source/WindowNIBs/zh-Hant.lproj/frmPrefWindow.strings b/Source/WindowNIBs/Source/WindowNIBs/zh-Hant.lproj/frmPrefWindow.strings index 0b5f090d..7032b8c9 100644 --- a/Source/WindowNIBs/Source/WindowNIBs/zh-Hant.lproj/frmPrefWindow.strings +++ b/Source/WindowNIBs/Source/WindowNIBs/zh-Hant.lproj/frmPrefWindow.strings @@ -173,9 +173,6 @@ /* Class = "NSTextFieldCell"; title = "Change UI font size of candidate window for a better visual clarity."; ObjectID = "iRg-wx-Nx2"; */ "iRg-wx-Nx2.title" = "變更候選字窗的字型大小。"; -/* Class = "NSTextFieldCell"; title = "Define your preferred action when user data files reload."; ObjectID = "j48-5a-cEs"; */ -"j48-5a-cEs.title" = "請指定在使用者數據重載時要啟用的功能。"; - /* Class = "NSComboBoxCell"; jQC-12-UuK.ibShadowedObjectValues[0] = "Item 1"; ObjectID = "jQC-12-UuK"; */ "jQC-12-UuK.ibShadowedObjectValues[0]" = "Item 1"; From 131d442bbc002c692d0048b5c9e30bae1f5b609f Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 23 Feb 2022 14:05:31 +0800 Subject: [PATCH 14/18] KeyHandler // Use (Shift+)Tab Key to handle candidates. --- Source/Modules/ControllerModules/KeyHandler.mm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Source/Modules/ControllerModules/KeyHandler.mm b/Source/Modules/ControllerModules/KeyHandler.mm index c0e55c38..e81d5b5d 100644 --- a/Source/Modules/ControllerModules/KeyHandler.mm +++ b/Source/Modules/ControllerModules/KeyHandler.mm @@ -1024,6 +1024,20 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; return YES; } + if ([input isTab]) { + BOOL updated = + Preferences.specifyTabKeyBehavior? + ([input isShiftHold] ? [gCurrentCandidateController showPreviousPage] : [gCurrentCandidateController showNextPage]) + : + ([input isShiftHold] ? [gCurrentCandidateController highlightPreviousCandidate] : [gCurrentCandidateController highlightNextCandidate]) + ; + if (!updated) { + [self errorCallbackConsolePrint:@"9B691919"]; + errorCallback(); + } + return YES; + } + if ([input isSpace] || [input isPageDown] || input.emacsKey == vChewingEmacsKeyNextPage) { BOOL updated = [gCurrentCandidateController showNextPage]; if (!updated) { From 322febfa016f45c05753688586666d9de1f81b8a Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 23 Feb 2022 17:18:15 +0800 Subject: [PATCH 15/18] InputState // Fix the term used for overriding candidate rates. --- Source/Modules/ControllerModules/InputState.swift | 2 +- Source/Resources/Base.lproj/Localizable.strings | 2 +- Source/Resources/en.lproj/Localizable.strings | 2 +- Source/Resources/ja.lproj/Localizable.strings | 2 +- Source/Resources/zh-Hans.lproj/Localizable.strings | 2 +- Source/Resources/zh-Hant.lproj/Localizable.strings | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Modules/ControllerModules/InputState.swift b/Source/Modules/ControllerModules/InputState.swift index e488c15e..babd93b4 100644 --- a/Source/Modules/ControllerModules/InputState.swift +++ b/Source/Modules/ControllerModules/InputState.swift @@ -184,7 +184,7 @@ class InputState: NSObject { let joined = selectedReadings.joined(separator: "-") let exist = mgrLangModel.checkIfUserPhraseExist(userPhrase: text, mode: ctlInputMethod.currentKeyHandler.inputMode, key: joined) if exist { - return String(format: NSLocalizedString("\"%@\" already exists, ENTER to boost its priority.", comment: ""), text) + return String(format: NSLocalizedString("\"%@\" already exists, ENTER to override its priority.", comment: ""), text) } return String(format: NSLocalizedString("\"%@\" selected. ENTER to add user phrase.", comment: ""), text) diff --git a/Source/Resources/Base.lproj/Localizable.strings b/Source/Resources/Base.lproj/Localizable.strings index fac28d72..0600f2b2 100644 --- a/Source/Resources/Base.lproj/Localizable.strings +++ b/Source/Resources/Base.lproj/Localizable.strings @@ -24,7 +24,7 @@ "\"%@\" length must ≥ 2 for a user phrase." = "\"%@\" length must ≥ 2 for a user phrase."; "\"%@\" length should ≤ %d for a user phrase." = "\"%@\" length should ≤ %d for a user phrase."; "\"%@\" selected. ENTER to add user phrase." = "\"%@\" selected. ENTER to add user phrase."; -"\"%@\" already exists, ENTER to boost its priority." = "\"%@\" already exists, ENTER to boost its priority."; +"\"%@\" already exists, ENTER to override its priority." = "\"%@\" already exists, ENTER to override its priority."; "Edit Phrase Replacement Table…" = "Edit Phrase Replacement Table…"; "Use Phrase Replacement" = "Use Phrase Replacement"; "Candidates keys cannot be empty." = "Candidates keys cannot be empty."; diff --git a/Source/Resources/en.lproj/Localizable.strings b/Source/Resources/en.lproj/Localizable.strings index fac28d72..0600f2b2 100644 --- a/Source/Resources/en.lproj/Localizable.strings +++ b/Source/Resources/en.lproj/Localizable.strings @@ -24,7 +24,7 @@ "\"%@\" length must ≥ 2 for a user phrase." = "\"%@\" length must ≥ 2 for a user phrase."; "\"%@\" length should ≤ %d for a user phrase." = "\"%@\" length should ≤ %d for a user phrase."; "\"%@\" selected. ENTER to add user phrase." = "\"%@\" selected. ENTER to add user phrase."; -"\"%@\" already exists, ENTER to boost its priority." = "\"%@\" already exists, ENTER to boost its priority."; +"\"%@\" already exists, ENTER to override its priority." = "\"%@\" already exists, ENTER to override its priority."; "Edit Phrase Replacement Table…" = "Edit Phrase Replacement Table…"; "Use Phrase Replacement" = "Use Phrase Replacement"; "Candidates keys cannot be empty." = "Candidates keys cannot be empty."; diff --git a/Source/Resources/ja.lproj/Localizable.strings b/Source/Resources/ja.lproj/Localizable.strings index 00026872..6d599f13 100644 --- a/Source/Resources/ja.lproj/Localizable.strings +++ b/Source/Resources/ja.lproj/Localizable.strings @@ -24,7 +24,7 @@ "\"%@\" length must ≥ 2 for a user phrase." = "「%@」もう1つ文字のお選びを。"; "\"%@\" length should ≤ %d for a user phrase." = "「%@」文字数過剰で登録不可、%d 文字以内にして下さい。"; "\"%@\" selected. ENTER to add user phrase." = "「%@」を ENTER で辞書に登録。"; -"\"%@\" already exists, ENTER to boost its priority." = "「%@」は既存語彙であり、ENTER で最優先にする。"; +"\"%@\" already exists, ENTER to override its priority." = "「%@」は既存語彙であり、ENTER で優先順位を再調整。"; "Edit Phrase Replacement Table…" = "言葉置換表を編集…"; "Use Phrase Replacement" = "言葉置換機能"; "Candidates keys cannot be empty." = "言選り用キー陣列に何かキーをご登録ください。"; diff --git a/Source/Resources/zh-Hans.lproj/Localizable.strings b/Source/Resources/zh-Hans.lproj/Localizable.strings index bee4cf8e..8d811d21 100644 --- a/Source/Resources/zh-Hans.lproj/Localizable.strings +++ b/Source/Resources/zh-Hans.lproj/Localizable.strings @@ -24,7 +24,7 @@ "\"%@\" length must ≥ 2 for a user phrase." = "「%@」字数不足以自订语汇。"; "\"%@\" length should ≤ %d for a user phrase." = "「%@」字数超过 %d、无法自订。"; "\"%@\" selected. ENTER to add user phrase." = "「%@」敲 Enter 添入自订语汇。"; -"\"%@\" already exists, ENTER to boost its priority." = "「%@」已存在,敲 ENTER 以提升其权重。"; +"\"%@\" already exists, ENTER to override its priority." = "「%@」已存在,敲 ENTER 以覆写其权重。"; "Edit Phrase Replacement Table…" = "编辑语汇置换表…"; "Use Phrase Replacement" = "使用语汇置换"; "Candidates keys cannot be empty." = "您必须指定选字键。"; diff --git a/Source/Resources/zh-Hant.lproj/Localizable.strings b/Source/Resources/zh-Hant.lproj/Localizable.strings index 3a1b9998..44db7b42 100644 --- a/Source/Resources/zh-Hant.lproj/Localizable.strings +++ b/Source/Resources/zh-Hant.lproj/Localizable.strings @@ -24,7 +24,7 @@ "\"%@\" length must ≥ 2 for a user phrase." = "「%@」字數不足以自訂語彙。"; "\"%@\" length should ≤ %d for a user phrase." = "「%@」字數超過 %d、無法自訂。"; "\"%@\" selected. ENTER to add user phrase." = "「%@」敲 Enter 添入自訂語彙。"; -"\"%@\" already exists, ENTER to boost its priority." = "「%@」已存在,敲 ENTER 以提升其權重。"; +"\"%@\" already exists, ENTER to override its priority." = "「%@」已存在,敲 ENTER 以覆寫其權重。"; "Edit Phrase Replacement Table…" = "編輯語彙置換表…"; "Use Phrase Replacement" = "使用語彙置換"; "Candidates keys cannot be empty." = "您必須指定選字鍵。"; From 23792e7162c9feffecb8c9a666223216142b1e95 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 23 Feb 2022 20:33:04 +0800 Subject: [PATCH 16/18] Voltaire // New PgDn/Up functions with single page. - When candidates take only one page, PgDn/PgUp functions like arrow keys. --- Source/UI/CandidateUI/HorizontalCandidateController.swift | 8 ++++++++ Source/UI/CandidateUI/VerticalCandidateController.swift | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/Source/UI/CandidateUI/HorizontalCandidateController.swift b/Source/UI/CandidateUI/HorizontalCandidateController.swift index a6494bb7..35e8e6e8 100644 --- a/Source/UI/CandidateUI/HorizontalCandidateController.swift +++ b/Source/UI/CandidateUI/HorizontalCandidateController.swift @@ -259,6 +259,10 @@ public class HorizontalCandidateController: CandidateController { return false } + if pageCount == 1 { + return highlightNextCandidate() + } + if currentPage + 1 >= pageCount { currentPage = 0 } else { @@ -275,6 +279,10 @@ public class HorizontalCandidateController: CandidateController { return false } + if pageCount == 1 { + return highlightPreviousCandidate() + } + if currentPage == 0 { currentPage = pageCount - 1 } else { diff --git a/Source/UI/CandidateUI/VerticalCandidateController.swift b/Source/UI/CandidateUI/VerticalCandidateController.swift index 05a9b4dd..4cae2144 100644 --- a/Source/UI/CandidateUI/VerticalCandidateController.swift +++ b/Source/UI/CandidateUI/VerticalCandidateController.swift @@ -265,6 +265,10 @@ public class VerticalCandidateController: CandidateController { return false } + if pageCount == 1 { + return highlightNextCandidate() + } + if currentPage + 1 >= pageCount { currentPage = 0 } else { @@ -281,6 +285,10 @@ public class VerticalCandidateController: CandidateController { return false } + if pageCount == 1 { + return highlightPreviousCandidate() + } + if currentPage == 0 { currentPage = pageCount - 1 } else { From dab97145678137c3a211cbd56e90c3728eb2a56e Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 23 Feb 2022 20:44:43 +0800 Subject: [PATCH 17/18] Voltaire // Simplify the conditioning used for page looping. --- .../HorizontalCandidateController.swift | 34 ++++--------------- .../VerticalCandidateController.swift | 34 ++++--------------- 2 files changed, 12 insertions(+), 56 deletions(-) diff --git a/Source/UI/CandidateUI/HorizontalCandidateController.swift b/Source/UI/CandidateUI/HorizontalCandidateController.swift index 35e8e6e8..dfe54f82 100644 --- a/Source/UI/CandidateUI/HorizontalCandidateController.swift +++ b/Source/UI/CandidateUI/HorizontalCandidateController.swift @@ -255,40 +255,18 @@ public class HorizontalCandidateController: CandidateController { } public override func showNextPage() -> Bool { - guard delegate != nil else { - return false - } - - if pageCount == 1 { - return highlightNextCandidate() - } - - if currentPage + 1 >= pageCount { - currentPage = 0 - } else { - currentPage += 1 - } - + guard delegate != nil else {return false} + if pageCount == 1 {return highlightNextCandidate()} + currentPage = (currentPage + 1 >= pageCount) ? 0 : currentPage + 1 candidateView.highlightedIndex = 0 layoutCandidateView() return true } public override func showPreviousPage() -> Bool { - guard delegate != nil else { - return false - } - - if pageCount == 1 { - return highlightPreviousCandidate() - } - - if currentPage == 0 { - currentPage = pageCount - 1 - } else { - currentPage -= 1 - } - + guard delegate != nil else {return false} + if pageCount == 1 {return highlightPreviousCandidate()} + currentPage = (currentPage == 0) ? pageCount - 1 : currentPage - 1 candidateView.highlightedIndex = 0 layoutCandidateView() return true diff --git a/Source/UI/CandidateUI/VerticalCandidateController.swift b/Source/UI/CandidateUI/VerticalCandidateController.swift index 4cae2144..762d178c 100644 --- a/Source/UI/CandidateUI/VerticalCandidateController.swift +++ b/Source/UI/CandidateUI/VerticalCandidateController.swift @@ -261,40 +261,18 @@ public class VerticalCandidateController: CandidateController { } public override func showNextPage() -> Bool { - guard delegate != nil else { - return false - } - - if pageCount == 1 { - return highlightNextCandidate() - } - - if currentPage + 1 >= pageCount { - currentPage = 0 - } else { - currentPage += 1 - } - + guard delegate != nil else {return false} + if pageCount == 1 {return highlightNextCandidate()} + currentPage = (currentPage + 1 >= pageCount) ? 0 : currentPage + 1 candidateView.highlightedIndex = 0 layoutCandidateView() return true } public override func showPreviousPage() -> Bool { - guard delegate != nil else { - return false - } - - if pageCount == 1 { - return highlightPreviousCandidate() - } - - if currentPage == 0 { - currentPage = pageCount - 1 - } else { - currentPage -= 1 - } - + guard delegate != nil else {return false} + if pageCount == 1 {return highlightPreviousCandidate()} + currentPage = (currentPage == 0) ? pageCount - 1 : currentPage - 1 candidateView.highlightedIndex = 0 layoutCandidateView() return true From 2fd8e1d8331038bd60ddf64dcc234b3a61171481 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 23 Feb 2022 21:08:31 +0800 Subject: [PATCH 18/18] Voltaire // Allow back/forward keys to loop candidates. --- .../HorizontalCandidateController.swift | 23 ++++--------------- .../VerticalCandidateController.swift | 23 ++++--------------- 2 files changed, 8 insertions(+), 38 deletions(-) diff --git a/Source/UI/CandidateUI/HorizontalCandidateController.swift b/Source/UI/CandidateUI/HorizontalCandidateController.swift index dfe54f82..ffe8ee48 100644 --- a/Source/UI/CandidateUI/HorizontalCandidateController.swift +++ b/Source/UI/CandidateUI/HorizontalCandidateController.swift @@ -273,29 +273,14 @@ public class HorizontalCandidateController: CandidateController { } public override func highlightNextCandidate() -> Bool { - guard let delegate = delegate else { - return false - } - - let currentIndex = selectedCandidateIndex - if currentIndex + 1 >= delegate.candidateCountForController(self) { - return false - } - selectedCandidateIndex = currentIndex + 1 + guard let delegate = delegate else {return false} + selectedCandidateIndex = (selectedCandidateIndex + 1 >= delegate.candidateCountForController(self)) ? 0 : selectedCandidateIndex + 1 return true } public override func highlightPreviousCandidate() -> Bool { - guard delegate != nil else { - return false - } - - let currentIndex = selectedCandidateIndex - if currentIndex == 0 { - return false - } - - selectedCandidateIndex = currentIndex - 1 + guard let delegate = delegate else {return false} + selectedCandidateIndex = (selectedCandidateIndex == 0) ? delegate.candidateCountForController(self) - 1 : selectedCandidateIndex - 1 return true } diff --git a/Source/UI/CandidateUI/VerticalCandidateController.swift b/Source/UI/CandidateUI/VerticalCandidateController.swift index 762d178c..50fe09f7 100644 --- a/Source/UI/CandidateUI/VerticalCandidateController.swift +++ b/Source/UI/CandidateUI/VerticalCandidateController.swift @@ -279,29 +279,14 @@ public class VerticalCandidateController: CandidateController { } public override func highlightNextCandidate() -> Bool { - guard let delegate = delegate else { - return false - } - - let currentIndex = selectedCandidateIndex - if currentIndex + 1 >= delegate.candidateCountForController(self) { - return false - } - selectedCandidateIndex = currentIndex + 1 + guard let delegate = delegate else {return false} + selectedCandidateIndex = (selectedCandidateIndex + 1 >= delegate.candidateCountForController(self)) ? 0 : selectedCandidateIndex + 1 return true } public override func highlightPreviousCandidate() -> Bool { - guard delegate != nil else { - return false - } - - let currentIndex = selectedCandidateIndex - if currentIndex == 0 { - return false - } - - selectedCandidateIndex = currentIndex - 1 + guard let delegate = delegate else {return false} + selectedCandidateIndex = (selectedCandidateIndex == 0) ? delegate.candidateCountForController(self) - 1 : selectedCandidateIndex - 1 return true }