-
Notifications
You must be signed in to change notification settings - Fork 94
Allow tone key to revise prior reading (#753) #754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+89
−2
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
086d4d9
fix(key-handler): allow tone key to revise prior reading (#753)
zonble 87e961b
refactor(engine): use stack reading buffer for syllable update
zonble eb9adcd
fix(input): guard reading before underscore check
zonble bdf2c3b
test(keyhandler): add tone key reading change tests
zonble 68364ac
refactor: consolidate repetitive tone key reading change tests into a…
zonble 98d0943
refactor: add const qualifier to local string variable
zonble 4edc27a
fix(input): gate prior tone change with preference
zonble 6d5d624
Fixes tests.
zonble dcd403e
refactor: Reorder `if` conditions in tone key handling logic.
zonble File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -450,7 +450,8 @@ - (BOOL)handleInput:(KeyHandlerInput *)input state:(InputState *)inState stateCa | |
| // MARK: Handle BPMF Keys | ||
|
|
||
| // see if it's valid BPMF reading | ||
| if (!skipBpmfHandling && _bpmfReadingBuffer->isValidKey((char)charCode)) { | ||
| bool isValidKey = _bpmfReadingBuffer->isValidKey((char)charCode); | ||
| if (!skipBpmfHandling && isValidKey) { | ||
| _bpmfReadingBuffer->combineKey((char)charCode); | ||
| keyConsumedByReading = YES; | ||
|
|
||
|
|
@@ -463,7 +464,34 @@ - (BOOL)handleInput:(KeyHandlerInput *)input state:(InputState *)inState stateCa | |
| } | ||
| } | ||
|
|
||
| BOOL composeReading = _bpmfReadingBuffer->isValidKey((char)charCode) && _bpmfReadingBuffer->hasToneMarker() && !_bpmfReadingBuffer->hasToneMarkerOnly(); | ||
| // Issue 753 | ||
| // | ||
| // This allows users to use tone key to change an existing reading before | ||
| // the current cursor. | ||
| if (_bpmfReadingBuffer->hasToneMarkerOnly() && _grid->readings().size() > 0 && _grid->cursor() > 0) { | ||
|
zonble marked this conversation as resolved.
Outdated
|
||
| size_t cursor = _grid->cursor() - 1; | ||
| std::string reading = _grid->readings()[cursor]; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| if (reading.rfind(std::string("_"), 0) != 0) { | ||
|
zonble marked this conversation as resolved.
Outdated
|
||
| Formosa::Mandarin::BopomofoReadingBuffer *tmpBuffer = new Formosa::Mandarin::BopomofoReadingBuffer(_bpmfReadingBuffer->keyboardLayout()); | ||
| Formosa::Mandarin::BopomofoSyllable syllable = Formosa::Mandarin::BopomofoSyllable::FromComposedString(reading); | ||
| tmpBuffer->setsSyllable(syllable); | ||
| tmpBuffer->combineKey((char)charCode); | ||
| std::string newReading = tmpBuffer->syllable().composedString(); | ||
| delete tmpBuffer; | ||
|
zonble marked this conversation as resolved.
Outdated
zonble marked this conversation as resolved.
Outdated
|
||
| if (_languageModel->hasUnigrams(newReading)) { | ||
| _bpmfReadingBuffer->clear(); | ||
| _grid->deleteReadingBeforeCursor(); | ||
| _grid->insertReading(newReading); | ||
| [self _walk]; | ||
| InputStateInputting *inputting = (InputStateInputting *)[self buildInputtingState]; | ||
| stateCallback(inputting); | ||
| return YES; | ||
| } | ||
| } | ||
| } | ||
|
zonble marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
|
zonble marked this conversation as resolved.
Outdated
|
||
| BOOL composeReading = isValidKey && _bpmfReadingBuffer->hasToneMarker() && !_bpmfReadingBuffer->hasToneMarkerOnly(); | ||
|
|
||
| // see if we have composition if Enter/Space is hit and buffer is not empty | ||
| // this is bit-OR'ed so that the tone marker key is also taken into account | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.