Skip to content

Commit

Permalink
update preedit
Browse files Browse the repository at this point in the history
  • Loading branch information
luongthanhlam committed Nov 2, 2018
1 parent fea02bb commit 4aa47b3
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

.idea/
pkg/
test-data/
vendor/*/.git
*_linux
*.tar.gz
Expand Down
22 changes: 11 additions & 11 deletions ibus-bamboo.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ Files:

-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEEoozA1sTSISdMhVWO8M0iy4gZZiEFAlvbAqAACgkQ8M0iy4gZ
ZiF/igv/UFYN6bNqGUEhvSz922FjmDUAMP/xBlXMjc2WR4J+7BH0AGSCrmmy6O0u
j7fmt4To6Wdnj0jvVCxrTyvWLk6kFmGXvsy0LQTl1zaSibUzhW32+D5Ohd9zjS4V
mgdLGJQWrV3jS0puRWYpnz0guv6QSrTlKq5lUGI9gSPCnxCNeEPEs4juQdhL/mJw
wf4JaMMXgT/bz2S2dx0vxwkD/d9OH/bVzwhFZWu3/uHWgHb4QKLaOZjgIfvG8kdz
Y3zM/2CigwSs7AcR5pBrqEXBN8tSZWFQlrf89C6i00jqtGW+OB4xU8ftFezxfoJH
yDEK0D3+Jj46MNcUGKtKi5sGruMxMfOaFSLWR1IMJShWVle6CvNCApneUmrqDp3B
qqcWLDO52atndw8aSY6pryV/nelF4mDw/NsWWpiDYXwRnbs+A8EzkkMOVWqCAX/2
oXHqqQAkkOJBSbVIoo4RDE6eHIvEud/xVznPpTYSBoKOmyTljNyhrxlz3e/ilyw/
m3WfnHo3
=Km8N
iQGzBAEBCgAdFiEEoozA1sTSISdMhVWO8M0iy4gZZiEFAlvbo9sACgkQ8M0iy4gZ
ZiGGlwv9GBdf2ITzt+w4bG1nbSkmeEx1JyvaCVy0wkCmshXJWogte836S4uhYl0Z
K/Eiv6IEt16rdAIpJspf5twSI2V7rwykeeNscVFq8ctzQ+XZlwCB1VILmow6qWXg
4K/RI5e9Iy+mbuYaFSETJUO3nY+l8wLLc9StkT+WiAPOITTd/gTUWTZNwNf6MA2A
/XT3nXLkpcAdBjQkc8TIcXrCmL9xAtpSgJerw3mUWb8Pyl1mso5CeFIFDR8R0NOu
Cno5xhKO73gvefMlWyO2BBF44IwmYkfEjzDuCSJFeiGT9764kOnUxODXcFuF9syQ
oBdq78E2TMg3QoS//QzqGVlWI6p3bcsTIyWuhcr/6ROnkRaxU+ZgExcZHIEmkwC9
a4KoW4QXbcw5GzAVLC0Z30AwqauWLnE9MAuIH55GKwEuaaMlgjXbZI9yCrdnjBjc
p9wxkarj9naYUxjYNW78qZQB4f8JsyH+PqrJcYfr0PZnKl7JOoL9zEijuRI4JYZQ
DmAx9Z5w
=9hHu
-----END PGP SIGNATURE-----
29 changes: 26 additions & 3 deletions src/ibus-bamboo/engine_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (e *IBusBambooEngine) getRawKeyLen() int {
}

func (e *IBusBambooEngine) updatePreedit() {
var processedStr = e.getProcessedString()
var processedStr = e.getPreeditString()
var preeditLen = uint32(len([]rune(processedStr)))
if preeditLen > 0 {
var ibusText = ibus.NewText(processedStr)
Expand All @@ -132,7 +132,20 @@ func (e *IBusBambooEngine) updatePreedit() {
}
}

func (e *IBusBambooEngine) getProcessedString() string {
func (e *IBusBambooEngine) shouldFallbackToEnglish() bool {
if e.config.Flags&bamboo.EspellCheckEnabled == 0 {
return false
}
if e.preediter.IsSpellingCorrect(bamboo.NoTone) {
return false
}
if e.preediter.IsSpellingSensible(bamboo.NoTone) {
return false
}
return true
}

func (e *IBusBambooEngine) getCommitString() string {
var processedStr string
if e.config.Flags&bamboo.EspellCheckEnabled != 0 && !e.preediter.IsSpellingCorrect(bamboo.NoTone) {
processedStr = e.preediter.GetProcessedString(bamboo.EnglishMode)
Expand All @@ -143,10 +156,20 @@ func (e *IBusBambooEngine) getProcessedString() string {
return processedStr
}

func (e *IBusBambooEngine) getPreeditString() string {
var processedStr string
if e.shouldFallbackToEnglish() {
processedStr = e.preediter.GetProcessedString(bamboo.EnglishMode)
return processedStr
}
processedStr = e.preediter.GetProcessedString(bamboo.VietnameseMode)
return processedStr
}

func (e *IBusBambooEngine) commitPreedit(lastKey uint32) bool {
var keyAppended = false
var commitStr string
commitStr += e.getProcessedString()
commitStr += e.getCommitString()
e.preediter.Reset()

//Convert num-pad key to normal number
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4aa47b3

Please sign in to comment.