ctlIME // + Debug Mode with Error Numbers.

This commit is contained in:
ShikiSuen 2022-02-22 18:37:52 +08:00
parent de552cdf5c
commit 0ad4ab0888
2 changed files with 54 additions and 2 deletions

View File

@ -346,6 +346,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
// see if we have a unigram for this // see if we have a unigram for this
if (!_languageModel->hasUnigramsForKey(reading)) { if (!_languageModel->hasUnigramsForKey(reading)) {
[self errorCallbackConsolePrint:@"B49C0979"];
errorCallback(); errorCallback();
InputStateInputting *inputting = (InputStateInputting *)[self buildInputtingState]; InputStateInputting *inputting = (InputStateInputting *)[self buildInputtingState];
stateCallback(inputting); 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 // strange behavior if we don't do this, "thinking" the key is not
// actually consumed) // actually consumed)
if ([state isKindOfClass:[InputStateNotEmpty class]] || !_bpmfReadingBuffer->isEmpty()) { if ([state isKindOfClass:[InputStateNotEmpty class]] || !_bpmfReadingBuffer->isEmpty()) {
[self errorCallbackConsolePrint:@"A9BFF20E"];
errorCallback(); errorCallback();
stateCallback(state); stateCallback(state);
return YES; return YES;
@ -617,6 +619,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
} }
if (!_bpmfReadingBuffer->isEmpty()) { if (!_bpmfReadingBuffer->isEmpty()) {
[self errorCallbackConsolePrint:@"6ED95318"];
errorCallback(); errorCallback();
stateCallback(state); stateCallback(state);
return YES; return YES;
@ -632,6 +635,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
marking.tooltipForInputting = currentState.tooltip; marking.tooltipForInputting = currentState.tooltip;
stateCallback(marking); stateCallback(marking);
} else { } else {
[self errorCallbackConsolePrint:@"D326DEA3"];
errorCallback(); errorCallback();
stateCallback(state); stateCallback(state);
} }
@ -641,6 +645,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
InputStateInputting *inputting = (InputStateInputting *)[self buildInputtingState]; InputStateInputting *inputting = (InputStateInputting *)[self buildInputtingState];
stateCallback(inputting); stateCallback(inputting);
} else { } else {
[self errorCallbackConsolePrint:@"7045E6F3"];
errorCallback(); errorCallback();
stateCallback(state); stateCallback(state);
} }
@ -655,6 +660,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
} }
if (!_bpmfReadingBuffer->isEmpty()) { if (!_bpmfReadingBuffer->isEmpty()) {
[self errorCallbackConsolePrint:@"B3BA5257"];
errorCallback(); errorCallback();
stateCallback(state); stateCallback(state);
return YES; return YES;
@ -670,6 +676,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
marking.tooltipForInputting = currentState.tooltip; marking.tooltipForInputting = currentState.tooltip;
stateCallback(marking); stateCallback(marking);
} else { } else {
[self errorCallbackConsolePrint:@"BB7F6DB9"];
errorCallback(); errorCallback();
stateCallback(state); stateCallback(state);
} }
@ -679,6 +686,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
InputStateInputting *inputting = (InputStateInputting *)[self buildInputtingState]; InputStateInputting *inputting = (InputStateInputting *)[self buildInputtingState];
stateCallback(inputting); stateCallback(inputting);
} else { } else {
[self errorCallbackConsolePrint:@"A96AAD58"];
errorCallback(); errorCallback();
stateCallback(state); stateCallback(state);
} }
@ -694,6 +702,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
} }
if (!_bpmfReadingBuffer->isEmpty()) { if (!_bpmfReadingBuffer->isEmpty()) {
[self errorCallbackConsolePrint:@"ABC44080"];
errorCallback(); errorCallback();
stateCallback(state); stateCallback(state);
return YES; return YES;
@ -704,6 +713,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
InputStateInputting *inputting = (InputStateInputting *)[self buildInputtingState]; InputStateInputting *inputting = (InputStateInputting *)[self buildInputtingState];
stateCallback(inputting); stateCallback(inputting);
} else { } else {
[self errorCallbackConsolePrint:@"66D97F90"];
errorCallback(); errorCallback();
stateCallback(state); stateCallback(state);
} }
@ -718,6 +728,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
} }
if (!_bpmfReadingBuffer->isEmpty()) { if (!_bpmfReadingBuffer->isEmpty()) {
[self errorCallbackConsolePrint:@"9B69908D"];
errorCallback(); errorCallback();
stateCallback(state); stateCallback(state);
return YES; return YES;
@ -728,6 +739,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
InputStateInputting *inputting = (InputStateInputting *)[self buildInputtingState]; InputStateInputting *inputting = (InputStateInputting *)[self buildInputtingState];
stateCallback(inputting); stateCallback(inputting);
} else { } else {
[self errorCallbackConsolePrint:@"9B69908E"];
errorCallback(); errorCallback();
stateCallback(state); stateCallback(state);
} }
@ -742,6 +754,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
} }
if (!_bpmfReadingBuffer->isEmpty()) { if (!_bpmfReadingBuffer->isEmpty()) {
[self errorCallbackConsolePrint:@"9B6F908D"];
errorCallback(); errorCallback();
} }
stateCallback(state); stateCallback(state);
@ -759,6 +772,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
_builder->deleteReadingBeforeCursor(); _builder->deleteReadingBeforeCursor();
[self _walk]; [self _walk];
} else { } else {
[self errorCallbackConsolePrint:@"9D69908D"];
errorCallback(); errorCallback();
stateCallback(state); stateCallback(state);
return YES; return YES;
@ -795,10 +809,12 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
stateCallback(inputting); stateCallback(inputting);
} }
} else { } else {
[self errorCallbackConsolePrint:@"9B69938D"];
errorCallback(); errorCallback();
stateCallback(state); stateCallback(state);
} }
} else { } else {
[self errorCallbackConsolePrint:@"9C69908D"];
errorCallback(); errorCallback();
stateCallback(state); stateCallback(state);
} }
@ -852,6 +868,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
_builder->insertReadingAtCursor(customPunctuation); _builder->insertReadingAtCursor(customPunctuation);
poppedText = [self _popOverflowComposingTextAndWalk]; poppedText = [self _popOverflowComposingTextAndWalk];
} else { // If there is still unfinished bpmf reading, ignore the punctuation } else { // If there is still unfinished bpmf reading, ignore the punctuation
[self errorCallbackConsolePrint:@"A9B69908D"];
errorCallback(); errorCallback();
stateCallback(state); stateCallback(state);
return YES; return YES;
@ -893,6 +910,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
// Enter // Enter
if ([input isEnter] || [input isEnterCharCode]) { if ([input isEnter] || [input isEnterCharCode]) {
if (![self.delegate keyHandler:self didRequestWriteUserPhraseWithState:state]) { if (![self.delegate keyHandler:self didRequestWriteUserPhraseWithState:state]) {
[self errorCallbackConsolePrint:@"5B69CC8D"];
errorCallback(); errorCallback();
return YES; return YES;
} }
@ -917,6 +935,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
stateCallback(marking); stateCallback(marking);
} }
} else { } else {
[self errorCallbackConsolePrint:@"1149908D"];
errorCallback(); errorCallback();
stateCallback(state); stateCallback(state);
} }
@ -938,6 +957,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
stateCallback(marking); stateCallback(marking);
} }
} else { } else {
[self errorCallbackConsolePrint:@"9B51408D"];
errorCallback(); errorCallback();
stateCallback(state); stateCallback(state);
} }
@ -991,6 +1011,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if ([input isSpace] || [input isPageDown] || input.emacsKey == vChewingEmacsKeyNextPage) { if ([input isSpace] || [input isPageDown] || input.emacsKey == vChewingEmacsKeyNextPage) {
BOOL updated = [gCurrentCandidateController showNextPage]; BOOL updated = [gCurrentCandidateController showNextPage];
if (!updated) { if (!updated) {
[self errorCallbackConsolePrint:@"9B691919"];
errorCallback(); errorCallback();
} }
return YES; return YES;
@ -999,6 +1020,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if ([input isPageUp]) { if ([input isPageUp]) {
BOOL updated = [gCurrentCandidateController showPreviousPage]; BOOL updated = [gCurrentCandidateController showPreviousPage];
if (!updated) { if (!updated) {
[self errorCallbackConsolePrint:@"9569955D"];
errorCallback(); errorCallback();
} }
return YES; return YES;
@ -1008,11 +1030,13 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if ([gCurrentCandidateController isKindOfClass:[VTHorizontalCandidateController class]]) { if ([gCurrentCandidateController isKindOfClass:[VTHorizontalCandidateController class]]) {
BOOL updated = [gCurrentCandidateController highlightPreviousCandidate]; BOOL updated = [gCurrentCandidateController highlightPreviousCandidate];
if (!updated) { if (!updated) {
[self errorCallbackConsolePrint:@"1145148D"];
errorCallback(); errorCallback();
} }
} else { } else {
BOOL updated = [gCurrentCandidateController showPreviousPage]; BOOL updated = [gCurrentCandidateController showPreviousPage];
if (!updated) { if (!updated) {
[self errorCallbackConsolePrint:@"1919810D"];
errorCallback(); errorCallback();
} }
} }
@ -1022,6 +1046,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if (input.emacsKey == vChewingEmacsKeyBackward) { if (input.emacsKey == vChewingEmacsKeyBackward) {
BOOL updated = [gCurrentCandidateController highlightPreviousCandidate]; BOOL updated = [gCurrentCandidateController highlightPreviousCandidate];
if (!updated) { if (!updated) {
[self errorCallbackConsolePrint:@"9B89308D"];
errorCallback(); errorCallback();
} }
return YES; return YES;
@ -1031,11 +1056,13 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if ([gCurrentCandidateController isKindOfClass:[VTHorizontalCandidateController class]]) { if ([gCurrentCandidateController isKindOfClass:[VTHorizontalCandidateController class]]) {
BOOL updated = [gCurrentCandidateController highlightNextCandidate]; BOOL updated = [gCurrentCandidateController highlightNextCandidate];
if (!updated) { if (!updated) {
[self errorCallbackConsolePrint:@"9B65138D"];
errorCallback(); errorCallback();
} }
} else { } else {
BOOL updated = [gCurrentCandidateController showNextPage]; BOOL updated = [gCurrentCandidateController showNextPage];
if (!updated) { if (!updated) {
[self errorCallbackConsolePrint:@"9244908D"];
errorCallback(); errorCallback();
} }
} }
@ -1045,6 +1072,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if (input.emacsKey == vChewingEmacsKeyForward) { if (input.emacsKey == vChewingEmacsKeyForward) {
BOOL updated = [gCurrentCandidateController highlightNextCandidate]; BOOL updated = [gCurrentCandidateController highlightNextCandidate];
if (!updated) { if (!updated) {
[self errorCallbackConsolePrint:@"9B2428D"];
errorCallback(); errorCallback();
} }
return YES; return YES;
@ -1054,11 +1082,13 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if ([gCurrentCandidateController isKindOfClass:[VTHorizontalCandidateController class]]) { if ([gCurrentCandidateController isKindOfClass:[VTHorizontalCandidateController class]]) {
BOOL updated = [gCurrentCandidateController showPreviousPage]; BOOL updated = [gCurrentCandidateController showPreviousPage];
if (!updated) { if (!updated) {
[self errorCallbackConsolePrint:@"9B614524"];
errorCallback(); errorCallback();
} }
} else { } else {
BOOL updated = [gCurrentCandidateController highlightPreviousCandidate]; BOOL updated = [gCurrentCandidateController highlightPreviousCandidate];
if (!updated) { if (!updated) {
[self errorCallbackConsolePrint:@"ASD9908D"];
errorCallback(); errorCallback();
} }
} }
@ -1069,11 +1099,13 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if ([gCurrentCandidateController isKindOfClass:[VTHorizontalCandidateController class]]) { if ([gCurrentCandidateController isKindOfClass:[VTHorizontalCandidateController class]]) {
BOOL updated = [gCurrentCandidateController showNextPage]; BOOL updated = [gCurrentCandidateController showNextPage];
if (!updated) { if (!updated) {
[self errorCallbackConsolePrint:@"92B990DD"];
errorCallback(); errorCallback();
} }
} else { } else {
BOOL updated = [gCurrentCandidateController highlightNextCandidate]; BOOL updated = [gCurrentCandidateController highlightNextCandidate];
if (!updated) { if (!updated) {
[self errorCallbackConsolePrint:@"6B99908D"];
errorCallback(); errorCallback();
} }
} }
@ -1082,6 +1114,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if ([input isHome] || input.emacsKey == vChewingEmacsKeyHome) { if ([input isHome] || input.emacsKey == vChewingEmacsKeyHome) {
if (gCurrentCandidateController.selectedCandidateIndex == 0) { if (gCurrentCandidateController.selectedCandidateIndex == 0) {
[self errorCallbackConsolePrint:@"9B6EDE8D"];
errorCallback(); errorCallback();
} else { } else {
gCurrentCandidateController.selectedCandidateIndex = 0; 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 (([input isEnd] || input.emacsKey == vChewingEmacsKeyEnd) && candidates.count > 0) {
if (gCurrentCandidateController.selectedCandidateIndex == candidates.count - 1) { if (gCurrentCandidateController.selectedCandidateIndex == candidates.count - 1) {
[self errorCallbackConsolePrint:@"9B69AAAD"];
errorCallback(); errorCallback();
} else { } else {
gCurrentCandidateController.selectedCandidateIndex = candidates.count - 1; gCurrentCandidateController.selectedCandidateIndex = candidates.count - 1;
@ -1181,6 +1215,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
} }
} }
[self errorCallbackConsolePrint:@"172A0F81"];
errorCallback(); errorCallback();
return YES; return YES;
} }
@ -1378,4 +1413,11 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
return nil; return nil;
} }
-(void)errorCallbackConsolePrint:(NSString *)strPrint
{
if (Preferences.isDebugModeEnabled) {
NSLog(@"vChewingErrorCallback: %@", strPrint);
}
}
@end @end

View File

@ -19,6 +19,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
import Cocoa import Cocoa
private let kIsDebugModeEnabled = "_DebugMode"
private let kCheckUpdateAutomatically = "CheckUpdateAutomatically" private let kCheckUpdateAutomatically = "CheckUpdateAutomatically"
private let kKeyboardLayoutPreference = "KeyboardLayout" private let kKeyboardLayoutPreference = "KeyboardLayout"
private let kBasisKeyboardLayoutPreference = "BasisKeyboardLayout" private let kBasisKeyboardLayoutPreference = "BasisKeyboardLayout"
@ -213,7 +214,8 @@ struct ComposingBufferSize {
// MARK: - // MARK: -
@objc public class Preferences: NSObject { @objc public class Preferences: NSObject {
static var allKeys:[String] { static var allKeys:[String] {
[kKeyboardLayoutPreference, [kIsDebugModeEnabled,
kKeyboardLayoutPreference,
kBasisKeyboardLayoutPreference, kBasisKeyboardLayoutPreference,
kFunctionKeyKeyboardLayoutPreference, kFunctionKeyKeyboardLayoutPreference,
kFunctionKeyKeyboardLayoutOverrideIncludeShift, kFunctionKeyKeyboardLayoutOverrideIncludeShift,
@ -248,11 +250,16 @@ struct ComposingBufferSize {
@objc public static func setMissingDefaults () { @objc public static func setMissingDefaults () {
// Preferences Module plist private // 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 { if UserDefaults.standard.object(forKey: kCheckUpdateAutomatically) == nil {
UserDefaults.standard.set(false, forKey: kCheckUpdateAutomatically) UserDefaults.standard.set(false, forKey: kCheckUpdateAutomatically)
} }
// 18 // 18
if UserDefaults.standard.object(forKey: kCandidateListTextSize) == nil { if UserDefaults.standard.object(forKey: kCandidateListTextSize) == nil {
UserDefaults.standard.set(Preferences.candidateListTextSize, forKey: kCandidateListTextSize) UserDefaults.standard.set(Preferences.candidateListTextSize, forKey: kCandidateListTextSize)
@ -336,6 +343,9 @@ struct ComposingBufferSize {
UserDefaults.standard.synchronize() UserDefaults.standard.synchronize()
} }
@UserDefault(key: kIsDebugModeEnabled, defaultValue: false)
@objc static var isDebugModeEnabled: Bool
@UserDefault(key: kAppleLanguagesPreferences, defaultValue: []) @UserDefault(key: kAppleLanguagesPreferences, defaultValue: [])
@objc static var appleLanguages: Array<String> @objc static var appleLanguages: Array<String>