-
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
Changes from 4 commits
086d4d9
87e961b
eb9adcd
bdf2c3b
68364ac
98d0943
4edc27a
6d5d624
dcd403e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -458,6 +458,16 @@ class BopomofoReadingBuffer { | |
|
|
||
| const BPMF syllable() const { return syllable_; } | ||
|
|
||
| void setSyllableRemovingTone(BPMF syllable) { | ||
|
Contributor
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. 為了這個只會用到一次的 feature 而在底層程式庫加入這個 helper,似乎沒有必要。請看我下面的留言。
Contributor
Author
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. Updates in 4edc27a |
||
| BPMF::Component masked = (syllable.consonantComponent() | | ||
| syllable.middleVowelComponent() | | ||
| syllable.vowelComponent()); | ||
| syllable_ = BPMF(masked); | ||
| if (pinyin_mode_) { | ||
| pinyin_sequence_ = syllable_.HanyuPinyinString(false, false); | ||
| } | ||
| } | ||
|
|
||
| const std::string standardLayoutQueryString() const { | ||
| return BopomofoKeyboardLayout::StandardLayout()->keySequenceFromSyllable( | ||
| syllable_); | ||
|
|
@@ -482,3 +492,4 @@ class BopomofoReadingBuffer { | |
| } // namespace Formosa | ||
|
|
||
| #endif // SRC_ENGINE_MANDARIN_MANDARIN_H_ | ||
|
|
||
| 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,32 @@ - (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.empty() && reading[0] != '_') { | ||
| Formosa::Mandarin::BopomofoReadingBuffer tmpBuffer(_bpmfReadingBuffer->keyboardLayout()); | ||
| Formosa::Mandarin::BopomofoSyllable syllable = Formosa::Mandarin::BopomofoSyllable::FromComposedString(reading); | ||
| tmpBuffer.setSyllableRemovingTone(syllable); | ||
|
Contributor
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. 我會考慮換一個作法,這樣就不需要在
無論哪種作法,倚天 26 鍵、許氏跟拼音都無法支援(請看我頂層的留言),但至少上述作法可以免除在
Contributor
Author
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. Updated in 4edc27a |
||
| tmpBuffer.combineKey((char)charCode); | ||
| std::string newReading = tmpBuffer.syllable().composedString(); | ||
| if (_languageModel->hasUnigrams(newReading)) { | ||
| _bpmfReadingBuffer->clear(); | ||
| _grid->deleteReadingBeforeCursor(); | ||
| _grid->insertReading(newReading); | ||
| [self _walk]; | ||
| InputStateInputting *inputting = (InputStateInputting *)[self buildInputtingState]; | ||
| stateCallback(inputting); | ||
| return YES; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| 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 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.