diff --git a/bamboo.xml b/bamboo.xml index b73fd20a..fcece277 100644 --- a/bamboo.xml +++ b/bamboo.xml @@ -23,22 +23,22 @@ Vietnamese input engine for IBus /usr/lib/ibus-engine-bamboo --ibus 0.6.2 - Luong Thanh Lam <ltlam93@gmail.com> + Luong Thanh Lam <ltlam93@gmail.com> GPLv3 https://github.com/BambooEngine/ibus-bamboo/ ibus-bamboo - - - vi - Bamboo - vi - GPLv3 - Luong Thanh Lam <ltlam93@gmail.com> - /usr/share/ibus-bamboo/viet-on.png - us - Bamboo - Vietnamese input method editor - 1 - - + + + vi + Bamboo + vi + GPLv3 + Luong Thanh Lam <ltlam93@gmail.com> + /usr/share/ibus-bamboo/viet-on.png + us + Bamboo + Vietnamese input method editor + 1 + + diff --git a/src/github.com/BambooEngine/bamboo-core/bamboo_utils.go b/src/github.com/BambooEngine/bamboo-core/bamboo_utils.go index 40616009..3a4231b8 100644 --- a/src/github.com/BambooEngine/bamboo-core/bamboo_utils.go +++ b/src/github.com/BambooEngine/bamboo-core/bamboo_utils.go @@ -243,7 +243,7 @@ func extractCvcTrans(composition []*Transformation) ([]*Transformation, []*Trans func extractLastWord(composition []*Transformation, effectKeys []rune) ([]*Transformation, []*Transformation) { for i := len(composition) - 1; i >= 0; i-- { - var canvas = getCanvas(composition[i:], VietnameseMode) + var canvas = getCanvas(composition[i:], VietnameseMode|LowerCase) if len(canvas) == 0 { continue } @@ -302,12 +302,12 @@ func findTarget(composition []*Transformation, applicableRules []Rule, flags uin if applicableRule.EffectType != ToneTransformation { continue } - var target *Transformation + var target *Transformation if flags&EfreeToneMarking != 0 { if hasValidTone(composition, Tone(applicableRule.Effect)) { target = findToneTarget(composition, flags&EstdToneStyle != 0) } - } else if lastAppending := findLastAppendingTrans(composition); lastAppending != nil && IsVowel(lastAppending.Rule.EffectOn) { + } else if lastAppending := findLastAppendingTrans(composition); lastAppending != nil && IsVowel(lastAppending.Rule.EffectOn) { target = lastAppending } if str == Flatten(append(composition, &Transformation{Target: target, Rule: applicableRule}), VietnameseMode) { @@ -332,7 +332,7 @@ func generateUndoTransformations(composition []*Transformation, rules []Rule, fl if hasValidTone(composition, Tone(rule.Effect)) { target = findToneTarget(composition, flags&EstdToneStyle != 0) } - } else if lastAppending := findLastAppendingTrans(composition); lastAppending != nil && IsVowel(lastAppending.Rule.EffectOn) { + } else if lastAppending := findLastAppendingTrans(composition); lastAppending != nil && IsVowel(lastAppending.Rule.EffectOn) { target = lastAppending } if target == nil { diff --git a/src/github.com/BambooEngine/bamboo-core/utils.go b/src/github.com/BambooEngine/bamboo-core/utils.go index 34be8566..020d9785 100644 --- a/src/github.com/BambooEngine/bamboo-core/utils.go +++ b/src/github.com/BambooEngine/bamboo-core/utils.go @@ -8,7 +8,9 @@ package bamboo -import "unicode" +import ( + "unicode" +) var Vowels = []rune("aàáảãạăằắẳẵặâầấẩẫậeèéẻẽẹêềếểễệiìíỉĩịoòóỏõọôồốổỗộơờớởỡợuùúủũụưừứửữựyỳýỷỹỵ") @@ -150,13 +152,14 @@ func canProcessKey(lowerKey rune, effectKeys []rune) bool { if IsAlpha(lowerKey) || inKeyList(effectKeys, lowerKey) { return true } - if IsWordBreakSymbol(lowerKey) { - return false - } + if IsWordBreakSymbol(lowerKey) { + return false + } return IsVietnameseRune(lowerKey) } func IsVietnameseRune(lowerKey rune) bool { + // lowerKey = unicode.ToLower(lowerKey) if FindToneFromChar(lowerKey) != ToneNone { return true } diff --git a/src/ibus-bamboo/engine_utils.go b/src/ibus-bamboo/engine_utils.go index 1d2dcd00..a94ef0e2 100644 --- a/src/ibus-bamboo/engine_utils.go +++ b/src/ibus-bamboo/engine_utils.go @@ -324,13 +324,14 @@ func (e *IBusBambooEngine) isValidState(state uint32) bool { } func (e *IBusBambooEngine) canProcessKey(keyVal uint32) bool { - if keyVal == IBusSpace || keyVal == IBusBackSpace { + var keyRune = rune(keyVal) + if keyVal == IBusSpace || keyVal == IBusBackSpace || bamboo.IsWordBreakSymbol(keyRune) { return true } if e.config.IBflags&IBmacroEnabled != 0 && keyVal == IBusTab { return true } - return e.preeditor.CanProcessKey(rune(keyVal)) + return e.preeditor.CanProcessKey(keyRune) } func (e *IBusBambooEngine) inBackspaceWhiteList() bool {