File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -458,16 +458,6 @@ class BopomofoReadingBuffer {
458458
459459 const BPMF syllable () const { return syllable_; }
460460
461- void setSyllableRemovingTone (BPMF syllable) {
462- BPMF ::Component masked = (syllable.consonantComponent () |
463- syllable.middleVowelComponent () |
464- syllable.vowelComponent ());
465- syllable_ = BPMF (masked);
466- if (pinyin_mode_) {
467- pinyin_sequence_ = syllable_.HanyuPinyinString (false , false );
468- }
469- }
470-
471461 const std::string standardLayoutQueryString () const {
472462 return BopomofoKeyboardLayout::StandardLayout ()->keySequenceFromSyllable (
473463 syllable_);
Original file line number Diff line number Diff line change @@ -468,13 +468,20 @@ - (BOOL)handleInput:(KeyHandlerInput *)input state:(InputState *)inState stateCa
468468 //
469469 // This allows users to use tone key to change an existing reading before
470470 // the current cursor.
471- if (_bpmfReadingBuffer->hasToneMarkerOnly () && _grid->readings ().size () > 0 && _grid->cursor () > 0 ) {
471+ if (Preferences.allowChangingPriorTone &&
472+ _bpmfReadingBuffer->hasToneMarkerOnly () &&
473+ _grid->readings ().size () > 0 &&
474+ _grid->cursor () > 0 ) {
472475 size_t cursor = _grid->cursor () - 1 ;
473- const std::string reading = _grid->readings ()[cursor];
476+ // const std::string reading = _grid->readings()[cursor];
477+ const std::string& reading = _grid->readings ()[cursor];
474478 if (!reading.empty () && reading[0 ] != ' _' ) {
475479 Formosa::Mandarin::BopomofoReadingBuffer tmpBuffer (_bpmfReadingBuffer->keyboardLayout ());
476- Formosa::Mandarin::BopomofoSyllable syllable = Formosa::Mandarin::BopomofoSyllable::FromComposedString (reading);
477- tmpBuffer.setSyllableRemovingTone (syllable);
480+ Formosa::Mandarin::BopomofoSyllable syllable = Formosa::Mandarin::BopomofoSyllable::FromComposedString (reading);
481+ std::string keys = _bpmfReadingBuffer->keyboardLayout ()->keySequenceFromSyllable (syllable);
482+ for (char k:keys) {
483+ tmpBuffer.combineKey (k);
484+ }
478485 tmpBuffer.combineKey ((char )charCode);
479486 std::string newReading = tmpBuffer.syllable ().composedString ();
480487 if (_languageModel->hasUnigrams (newReading)) {
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ private let kBig5InputEnabledKey = "Big5InputEnabled"
7474let kBeepUponInputErrorKey = " BeepUponInputError "
7575
7676private let kEnableUserPhrasesInPlainBopomofo = " EnableUserPhrasesInPlainBopomofo "
77+ private let kAllowChangingPriorTone = " AllowChangingPriorTone "
7778
7879// MARK: Property wrappers
7980
@@ -570,6 +571,11 @@ extension Preferences {
570571 @objc static var enableUserPhrasesInPlainBopomofo : Bool
571572}
572573
574+ extension Preferences {
575+ @UserDefault ( key: kAllowChangingPriorTone, defaultValue: false )
576+ @objc static var allowChangingPriorTone : Bool
577+ }
578+
573579extension Preferences {
574580 static func createReport( ) -> String {
575581 var lines : [ String ] = [ ]
You can’t perform that action at this time.
0 commit comments