Allows commit the first canidate while typing a punctuation in plain BPMF mode.
This commit is contained in:
parent
c17d991718
commit
385638c3b9
|
@ -547,6 +547,35 @@ public:
|
||||||
NSBeep();
|
NSBeep();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (string)currentLayout
|
||||||
|
{
|
||||||
|
string layout = string("Standard_");;
|
||||||
|
NSInteger keyboardLayout = [[NSUserDefaults standardUserDefaults] integerForKey:kKeyboardLayoutPreferenceKey];
|
||||||
|
switch (keyboardLayout) {
|
||||||
|
case 0:
|
||||||
|
layout = string("Standard_");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
layout = string("ETen_");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
layout = string("ETen26_");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
layout = string("Hsu_");
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
layout = string("HanyuPinyin_");
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
layout = string("IBM_");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return layout;
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)handleInputText:(NSString*)inputText key:(NSInteger)keyCode modifiers:(NSUInteger)flags client:(id)client
|
- (BOOL)handleInputText:(NSString*)inputText key:(NSInteger)keyCode modifiers:(NSUInteger)flags client:(id)client
|
||||||
{
|
{
|
||||||
NSRect textFrame = NSZeroRect;
|
NSRect textFrame = NSZeroRect;
|
||||||
|
@ -896,31 +925,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string layout = string("Standard_");;
|
string layout = [self currentLayout];
|
||||||
NSInteger keyboardLayout = [[NSUserDefaults standardUserDefaults] integerForKey:kKeyboardLayoutPreferenceKey];
|
|
||||||
switch (keyboardLayout) {
|
|
||||||
case 0:
|
|
||||||
layout = string("Standard_");
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
layout = string("ETen_");
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
layout = string("ETen26_");
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
layout = string("Hsu_");
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
layout = string("HanyuPinyin_");
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
layout = string("IBM_");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
string customPunctuation = string("_punctuation_") + layout + string(1, (char)charCode);
|
string customPunctuation = string("_punctuation_") + layout + string(1, (char)charCode);
|
||||||
if (_languageModel->hasUnigramsForKey(customPunctuation)) {
|
if (_languageModel->hasUnigramsForKey(customPunctuation)) {
|
||||||
if (_bpmfReadingBuffer->isEmpty()) {
|
if (_bpmfReadingBuffer->isEmpty()) {
|
||||||
|
@ -1138,7 +1143,15 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_inputMode == kPlainBopomofoModeIdentifier) {
|
if (_inputMode == kPlainBopomofoModeIdentifier) {
|
||||||
if (_bpmfReadingBuffer->isValidKey((char)charCode)) {
|
// TODO: also commit punctuation.
|
||||||
|
string layout = [self currentLayout];
|
||||||
|
string customPunctuation = string("_punctuation_") + layout + string(1, (char)charCode);
|
||||||
|
string punctuation = string("_punctuation_") + string(1, (char)charCode);
|
||||||
|
|
||||||
|
BOOL shouldAutoSelectCandidate = _bpmfReadingBuffer->isValidKey((char)charCode) || _languageModel->hasUnigramsForKey(customPunctuation) ||
|
||||||
|
_languageModel->hasUnigramsForKey(punctuation);
|
||||||
|
|
||||||
|
if (shouldAutoSelectCandidate) {
|
||||||
NSUInteger candidateIndex = [gCurrentCandidateController candidateIndexAtKeyLabelIndex:0];
|
NSUInteger candidateIndex = [gCurrentCandidateController candidateIndexAtKeyLabelIndex:0];
|
||||||
if (candidateIndex != NSUIntegerMax) {
|
if (candidateIndex != NSUIntegerMax) {
|
||||||
[self candidateController:gCurrentCandidateController didSelectCandidateAtIndex:candidateIndex];
|
[self candidateController:gCurrentCandidateController didSelectCandidateAtIndex:candidateIndex];
|
||||||
|
|
Loading…
Reference in New Issue