Allows users to input letters when candidate window is open in plain BPMF mode.

This commit is contained in:
zonble 2022-01-28 19:10:01 +08:00
parent 43eef1fc1f
commit c3304bc5f7
1 changed files with 10 additions and 2 deletions

View File

@ -995,12 +995,20 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
if (_inputMode == kPlainBopomofoModeIdentifier) {
string layout = [self _currentLayout];
string customPunctuation = string("_punctuation_") + layout + string(1, (char) charCode);
string punctuation = string("_punctuation_") + string(1, (char) charCode);
string punctuationNamePrefix = Preferences.halfWidthPunctuationEnabled ? string("_half_punctuation_") : string("_punctuation_");
string customPunctuation = punctuationNamePrefix + layout + string(1, (char) charCode);
string punctuation = punctuationNamePrefix + string(1, (char) charCode);
BOOL shouldAutoSelectCandidate = _bpmfReadingBuffer->isValidKey((char) charCode) || _languageModel->hasUnigramsForKey(customPunctuation) ||
_languageModel->hasUnigramsForKey(punctuation);
if (!shouldAutoSelectCandidate && (char) charCode >= 'A' && (char) charCode <= 'Z') {
string letter = string("_letter_") + string(1, (char) charCode);
if (_languageModel->hasUnigramsForKey(letter)) {
shouldAutoSelectCandidate = YES;
}
}
if (shouldAutoSelectCandidate) {
NSUInteger candidateIndex = [gCurrentCandidateController candidateIndexAtKeyLabelIndex:0];
if (candidateIndex != NSUIntegerMax) {