KeyHandler(Input) // Revised conditioning of letter inputs.

- This is to fix an issue of mishandling letter input condition.
This commit is contained in:
ShikiSuen 2022-03-13 15:07:04 +08:00
parent 3ca382b35f
commit 8e174abb56
2 changed files with 7 additions and 2 deletions

View File

@ -585,7 +585,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
// Lukhnos 這裡的處理反而會使得 Apple 倚天注音動態鍵盤佈局「敲不了半形大寫英文」的缺點曝露無疑,所以注釋掉。 // Lukhnos 這裡的處理反而會使得 Apple 倚天注音動態鍵盤佈局「敲不了半形大寫英文」的缺點曝露無疑,所以注釋掉。
// 至於他試圖用這種處理來解決的上游 UPR293 的問題,其實針對詞庫檔案的排序做點手腳就可以解決。威注音本來也就是這麼做的。 // 至於他試圖用這種處理來解決的上游 UPR293 的問題,其實針對詞庫檔案的排序做點手腳就可以解決。威注音本來也就是這麼做的。
if (/*[state isKindOfClass:[InputStateNotEmpty class]] && */(char) charCode >= 'A' && (char) charCode <= 'Z') { if (/*[state isKindOfClass:[InputStateNotEmpty class]] && */[input isUpperCaseASCIILetterKey]) {
std::string letter = std::string("_letter_") + std::string(1, (char) charCode); std::string letter = std::string("_letter_") + std::string(1, (char) charCode);
if ([self _handlePunctuation:letter state:state usingVerticalMode:input.useVerticalMode stateCallback:stateCallback errorCallback:errorCallback]) { if ([self _handlePunctuation:letter state:state usingVerticalMode:input.useVerticalMode stateCallback:stateCallback errorCallback:errorCallback]) {
return YES; return YES;
@ -1253,7 +1253,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
BOOL shouldAutoSelectCandidate = _bpmfReadingBuffer->isValidKey((char) charCode) || _languageModel->hasUnigramsForKey(customPunctuation) || BOOL shouldAutoSelectCandidate = _bpmfReadingBuffer->isValidKey((char) charCode) || _languageModel->hasUnigramsForKey(customPunctuation) ||
_languageModel->hasUnigramsForKey(punctuation); _languageModel->hasUnigramsForKey(punctuation);
if (!shouldAutoSelectCandidate && (char) charCode >= 'A' && (char) charCode <= 'Z') { if (!shouldAutoSelectCandidate && [input isUpperCaseASCIILetterKey]) {
std::string letter = std::string("_letter_") + std::string(1, (char) charCode); std::string letter = std::string("_letter_") + std::string(1, (char) charCode);
if (_languageModel->hasUnigramsForKey(letter)) { if (_languageModel->hasUnigramsForKey(letter)) {
shouldAutoSelectCandidate = YES; shouldAutoSelectCandidate = YES;

View File

@ -233,6 +233,11 @@ class KeyHandlerInput: NSObject {
KeyCode(rawValue: keyCode) == verticalModeOnlyChooseCandidateKey KeyCode(rawValue: keyCode) == verticalModeOnlyChooseCandidateKey
} }
@objc var isUpperCaseASCIILetterKey: Bool {
// flags == .shift Shift
self.charCode >= 65 && self.charCode <= 90 && flags == .shift
}
@objc var isSymbolMenuPhysicalKey: Bool { @objc var isSymbolMenuPhysicalKey: Bool {
// KeyCode macOS Apple // KeyCode macOS Apple
// ![input isShift] 使 Shift // ![input isShift] 使 Shift