Fixes the state from handling enter in plain BPMF mode.
This commit is contained in:
parent
439bb99ef5
commit
618065b881
|
@ -243,7 +243,7 @@ static inline NSString *LocalizationNotNeeded(NSString *s) {
|
|||
BOOL result = [_keyHandler handleInput:input state:_state stateCallback:^(InputState *state) {
|
||||
[self handleState:state client:client];
|
||||
} candidateSelectionCallback:^{
|
||||
// NSLog(@"candidate window updated.");
|
||||
NSLog(@"candidate window updated.");
|
||||
} errorCallback:^{
|
||||
NSBeep();
|
||||
}];
|
||||
|
@ -295,7 +295,7 @@ static inline NSString *LocalizationNotNeeded(NSString *s) {
|
|||
|
||||
- (void)handleState:(InputState *)newState client:(id)client
|
||||
{
|
||||
// NSLog(@"current state: %@ new state: %@", _state, newState );
|
||||
NSLog(@"new state: %@ / current state: %@", newState, _state);
|
||||
|
||||
// We need to set the state to the member variable since the candidate
|
||||
// window need to read the candidates from it.
|
||||
|
@ -408,15 +408,8 @@ static inline NSString *LocalizationNotNeeded(NSString *s) {
|
|||
// i.e. the client app needs to take care of where to put ths composing buffer
|
||||
[client setMarkedText:attrString selectionRange:NSMakeRange(cursorIndex, 0) replacementRange:NSMakeRange(NSNotFound, NSNotFound)];
|
||||
|
||||
if (_keyHandler.inputMode == kPlainBopomofoModeIdentifier && state.candidates.count == 1) {
|
||||
NSString *buffer = [self _convertToSimplifiedChineseIfRequired:state.candidates.firstObject];
|
||||
[client insertText:buffer replacementRange:NSMakeRange(NSNotFound, NSNotFound)];
|
||||
InputStateEmpty *empty = [[InputStateEmpty alloc] init];
|
||||
[self handleState:empty client:client];
|
||||
} else {
|
||||
if (![previous isKindOfClass:[InputStateChoosingCandidate class]]) {
|
||||
[self _showCandidateWindowWithState:state client:client];
|
||||
}
|
||||
if (![previous isKindOfClass:[InputStateChoosingCandidate class]]) {
|
||||
[self _showCandidateWindowWithState:state client:client];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -343,7 +343,15 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
|||
|
||||
if (_inputMode == kPlainBopomofoModeIdentifier) {
|
||||
InputStateChoosingCandidate *choosingCandidates = [self _buildCandidateState:inputting useVerticalMode:input.useVerticalMode];
|
||||
stateCallback(choosingCandidates);
|
||||
if (choosingCandidates.candidates.count == 1) {
|
||||
[self clear];
|
||||
InputStateCommitting *committing = [[InputStateCommitting alloc] initWithPoppedText:choosingCandidates.candidates.firstObject];
|
||||
stateCallback(committing);
|
||||
InputStateEmpty *empty = [[InputStateEmpty alloc] init];
|
||||
stateCallback(empty);
|
||||
} else {
|
||||
stateCallback(choosingCandidates);
|
||||
}
|
||||
}
|
||||
|
||||
// and tells the client that the key is consumed
|
||||
|
@ -699,13 +707,20 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
|||
- (BOOL)_handleEnterWithState:(InputState *)state stateCallback:(void (^)(InputState *))stateCallback errorCallback:(void (^)(void))errorCallback
|
||||
{
|
||||
if ([state isKindOfClass:[InputStateInputting class]]) {
|
||||
if (_inputMode == kPlainBopomofoModeIdentifier) {
|
||||
if (!_bpmfReadingBuffer->isEmpty()) {
|
||||
errorCallback();
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
[self clear];
|
||||
|
||||
InputStateInputting *current = (InputStateInputting *) state;
|
||||
NSString *composingBuffer = current.composingBuffer;
|
||||
InputStateCommitting *committing = [[InputStateCommitting alloc] initWithPoppedText:composingBuffer];
|
||||
stateCallback(committing);
|
||||
InputState *empty = [[InputState alloc] init];
|
||||
InputStateEmpty *empty = [[InputStateEmpty alloc] init];
|
||||
stateCallback(empty);
|
||||
return YES;
|
||||
}
|
||||
|
@ -991,7 +1006,8 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
|||
if (candidateIndex != NSUIntegerMax) {
|
||||
[self.delegate keyHandler:self didSelectCandidateAtIndex:candidateIndex candidateController:gCurrentCandidateController];
|
||||
[self clear];
|
||||
InputStateEmpty *empty = [[InputStateEmpty alloc] init];
|
||||
InputStateEmptyIgnoringPreviousState *empty = [[InputStateEmptyIgnoringPreviousState alloc] init];
|
||||
stateCallback(empty);
|
||||
[self handleInput:input state:empty stateCallback:stateCallback candidateSelectionCallback:candidateSelectionCallback errorCallback:errorCallback];
|
||||
}
|
||||
return YES;
|
||||
|
|
Loading…
Reference in New Issue