KeyHandler // Reenable upstream symbol menu when isOptionHold.

This commit is contained in:
ShikiSuen 2022-04-03 14:50:45 +08:00
parent 2e68df9db8
commit e8e04b8109
1 changed files with 31 additions and 23 deletions

View File

@ -638,30 +638,38 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
// MARK: Punctuation list
if ([input isSymbolMenuPhysicalKey] && ![input isShiftHold])
{
if (![input isOptionHold])
{
// 得在這裡先 commit buffer不然會導致「在摁 ESC 離開符號選單時會重複輸入上一次的組字區的內容」的不當行為。
// 於是這裡用「模擬一次 Enter 鍵的操作」使其代為執行這個 commit buffer 的動作。
[self _handleEnterWithState:state stateCallback:stateCallback errorCallback:errorCallback];
// 得在這裡先 commit buffer不然會導致「在摁 ESC 離開符號選單時會重複輸入上一次的組字區的內容」的不當行為。
// 於是這裡用「模擬一次 Enter 鍵的操作」使其代為執行這個 commit buffer 的動作。
[self _handleEnterWithState:state stateCallback:stateCallback errorCallback:errorCallback];
SymbolNode *root = [SymbolNode root];
InputStateSymbolTable *symbolState = [[InputStateSymbolTable alloc] initWithNode:root
useVerticalMode:input.useVerticalMode];
stateCallback(symbolState);
return YES;
// if (_languageModel->hasUnigramsForKey("_punctuation_list"))) {
// if (_bpmfReadingBuffer->isEmpty()) {
// _builder->insertReadingAtCursor(string("_punctuation_list"));
// NSString *poppedText = [self _popOverflowComposingTextAndWalk];
// InputStateInputting *inputting = (InputStateInputting *)[self buildInputtingState];
// inputting.poppedText = poppedText;
// stateCallback(inputting);
// InputStateChoosingCandidate *choosingCandidate = [self _buildCandidateState:inputting
// useVerticalMode:input.useVerticalMode]; stateCallback(choosingCandidate);
// } else { // If there is still unfinished bpmf reading, ignore the punctuation
// errorCallback();
// }
// return YES;
// }
SymbolNode *root = [SymbolNode root];
InputStateSymbolTable *symbolState = [[InputStateSymbolTable alloc] initWithNode:root
useVerticalMode:input.useVerticalMode];
stateCallback(symbolState);
return YES;
}
// 摁 Alt(Option) 的情況下,叫出小麥注音原版的符號選單。
else if (_languageModel->hasUnigramsForKey("_punctuation_list"))
{
if (_bpmfReadingBuffer->isEmpty())
{
_builder->insertReadingAtCursor(string("_punctuation_list"));
NSString *poppedText = [self _popOverflowComposingTextAndWalk];
InputStateInputting *inputting = (InputStateInputting *)[self buildInputtingState];
inputting.poppedText = poppedText;
stateCallback(inputting);
InputStateChoosingCandidate *choosingCandidate = [self _buildCandidateState:inputting
useVerticalMode:input.useVerticalMode];
stateCallback(choosingCandidate);
}
else
{ // If there is still unfinished bpmf reading, ignore the punctuation
errorCallback();
}
return YES;
}
}
// MARK: Punctuation