Skip to content
This repository has been archived by the owner on Apr 10, 2020. It is now read-only.

Commit

Permalink
Merge pull request #65 from teni-ime/dev
Browse files Browse the repository at this point in the history
release v1.5.0
  • Loading branch information
openhoangnc committed Nov 4, 2018
2 parents 107360f + 3a46eda commit 4d20726
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Expand Up @@ -25,7 +25,7 @@ Nếu cần thiết, hãy [đính kèm hình ảnh](https://help.github.com/arti
**Môi trường**
- OS và version: (ví dụ: Ubuntu 18.10)
- Desktop: (Xfce, KDE, Gnome,... hoặc **mặc định**)
- Phiên bản ibus-teni: (click chuột trái vào icon VI tại góc màn hình để xem phiên bản ibus-teni, bản mới nhất là v1.4.2)
- Phiên bản ibus-teni: (click chuột trái vào icon VI tại góc màn hình để xem phiên bản ibus-teni, bản mới nhất là v1.5.0)
- Phiên bản IBus: (chạy command `ibus version` để xem phiên bản ibus)
- Ứng dụng có lỗi khi gõ: (ví dụ: Chrome, Firefox,...)

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -20,7 +20,7 @@
engine_name=teni
ibus_e_name=ibus-engine-$(engine_name)
pkg_name=ibus-$(engine_name)
version=1.4.2
version=1.5.0

engine_dir=/usr/share/$(pkg_name)
ibus_dir=/usr/share/ibus
Expand Down
2 changes: 1 addition & 1 deletion PKGBUILD
Expand Up @@ -19,7 +19,7 @@

# Maintainer: Nguyen Cong Hoang <hoangnc.jp@gmail.com>
pkgname=ibus-teni
pkgver=1.4.2
pkgver=1.5.0
pkgrel=1
pkgdesc='A Vietnamese IME for IBus'
arch=(any)
Expand Down
9 changes: 9 additions & 0 deletions debian/changelog
@@ -1,3 +1,12 @@
ibus-teni (1.5.0-1) stable; urgency=low

* Release 1.5.0
- Thêm kiểu gõ [Telex] (kiểu gõ này cho phép dùng phím [])
- Sửa lỗi không xóa hết chữ trên Telegram
- Sửa lỗi con trỏ chuột nhảy về đầu dòng trên Facebook chat

-- Nguyen Cong Hoang <hoangnc.jp@gmail.com> Sun, 4 Nov 2018 00:00:00 +0900

ibus-teni (1.4.2-1) stable; urgency=low

* Release 1.4.2
Expand Down
2 changes: 1 addition & 1 deletion debian/control
Expand Up @@ -21,7 +21,7 @@ Section: utils
Priority: extra
Maintainer: Nguyen Cong Hoang <hoangnc.jp@gmail.com>
Build-Depends: debhelper, golang, libx11-dev
Standards-Version: 1.4.2
Standards-Version: 1.5.0
Homepage: https://github.com/teni-ime/ibus-teni

Package: ibus-teni
Expand Down
4 changes: 2 additions & 2 deletions ibus-teni.dsc
Expand Up @@ -20,9 +20,9 @@ Format: 1.0
Source: ibus-teni
Binary: ibus-teni
Architecture: any
Version: 1.4.2-0
Version: 1.5.0-0
Maintainer: Nguyen Cong Hoang <hoangnc.jp@gmail.com>
Homepage: https://github.com/teni-ime/ibus-teni
Build-Depends: debhelper, golang, libx11-dev
Files:
0 0 ibus-teni-1.4.2.tar.gz
0 0 ibus-teni-1.5.0.tar.gz
6 changes: 5 additions & 1 deletion ibus-teni.spec
Expand Up @@ -22,7 +22,7 @@

%define engine_name teni
%define package_name ibus-%{engine_name}
%define version 1.4.2
%define version 1.5.0


#install directories ----------------------------------------------------------
Expand Down Expand Up @@ -81,6 +81,10 @@ rm -rf %{buildroot}


%changelog
* Sun Nov 4 2018 Nguyen Cong Hoang <hoangnc.jp@gmail.com> - 1.5.0
- Thêm kiểu gõ [Telex] (kiểu gõ này cho phép dùng phím [])
- Sửa lỗi không xóa hết chữ trên Telegram
- Sửa lỗi con trỏ chuột nhảy về đầu dòng trên Facebook chat
* Mon Oct 22 2018 Nguyen Cong Hoang <hoangnc.jp@gmail.com> - 1.4.2
- Sửa lỗi mất chữ khi đang gõ
- Sửa lỗi con trỏ chuột nhảy về đầu dòng trên Facebook chat
Expand Down
57 changes: 20 additions & 37 deletions src/ibus-teni/engine.go
Expand Up @@ -31,10 +31,6 @@ import (
"time"
)

const (
DiffNumpadKeypad = IBUS_KP_0 - IBUS_0
)

type IBusTeniEngine struct {
sync.Mutex
ibus.Engine
Expand Down Expand Up @@ -126,16 +122,15 @@ func (e *IBusTeniEngine) updatePreedit() {
preeditLen := uint32(len(e.prevText))
preeditText += e.preediter.GetResultStr()
preeditLen += e.preediter.ResultLen()
if preeditLen > 0 {
e.UpdatePreeditTextWithMode(ibus.NewText(preeditText), preeditLen, true, ibus.IBUS_ENGINE_PREEDIT_COMMIT)
} else {
e.HidePreeditText()

e.UpdatePreeditTextWithMode(ibus.NewText(preeditText), preeditLen, true, ibus.IBUS_ENGINE_PREEDIT_COMMIT)

if preeditLen == 0 {
e.preediter.Reset()
}
}

func (e *IBusTeniEngine) commitPreedit(lastKey uint32) bool {
var keyAppended = false
func (e *IBusTeniEngine) commitPreedit(lastKey uint32) {
var commitStr = string(e.prevText)
if lastKey == IBUS_Escape {
commitStr += e.preediter.GetRawStr()
Expand All @@ -147,22 +142,8 @@ func (e *IBusTeniEngine) commitPreedit(lastKey uint32) bool {
e.preediter.Reset()
e.prevText = e.prevText[:0]

//Convert num-pad key to normal number
if (lastKey >= IBUS_KP_0 && lastKey <= IBUS_KP_9) ||
(lastKey >= IBUS_KP_Multiply && lastKey <= IBUS_KP_Divide) {
lastKey = lastKey - DiffNumpadKeypad
}

if lastKey >= 0x20 && lastKey <= 0xFF {
//append printable keys
commitStr += string(lastKey)
keyAppended = true
}

e.HidePreeditText()
e.CommitText(ibus.NewText(commitStr))

return keyAppended
}

func (e *IBusTeniEngine) ProcessKeyEvent(keyVal uint32, keyCode uint32, state uint32) (bool, *dbus.Error) {
Expand All @@ -177,11 +158,12 @@ func (e *IBusTeniEngine) ProcessKeyEvent(keyVal uint32, keyCode uint32, state ui
if state&IBUS_RELEASE_MASK != 0 {
//Ignore key-up event
if e.ignoreNextUp {
e.ignoreNextUp = false
return true, nil
} else {
return false, nil
}
} else {
e.ignoreNextUp = false
}

if state&IBUS_CONTROL_MASK != 0 ||
Expand Down Expand Up @@ -244,7 +226,8 @@ func (e *IBusTeniEngine) ProcessKeyEvent(keyVal uint32, keyCode uint32, state ui
if (keyVal >= 'a' && keyVal <= 'z') ||
(keyVal >= 'A' && keyVal <= 'Z') ||
(keyVal >= '0' && keyVal <= '9' && e.preediter.ResultLen() > 0) ||
(e.preediter.InputMethod == teni.IMTelex && teni.InChangeCharMap(rune(keyVal))) {
(e.preediter.InputMethod == teni.IMTelex && teni.InChangeCharMap(rune(keyVal))) ||
(e.preediter.InputMethod == teni.IMTelexEx && teni.InChangeCharMapEx(rune(keyVal))) {
if e.preediter.InputMethod == teni.IMTelex && state&IBUS_LOCK_MASK != 0 {
keyVal = teni.SwitchCaplock(keyVal)
}
Expand Down Expand Up @@ -273,18 +256,14 @@ func (e *IBusTeniEngine) ProcessKeyEvent(keyVal uint32, keyCode uint32, state ui
return true, nil
}

if e.commitPreedit(keyVal) {
//lastKey already appended to commit string
e.ignoreNextUp = true
return true, nil
} else {
//forward lastKey
if e.capSurrounding {
return false, nil
}
e.ForwardKeyEvent(keyVal, keyCode, state)
return true, nil
e.commitPreedit(keyVal)

//forward lastKey
if e.capSurrounding {
return false, nil
}
e.ForwardKeyEvent(keyVal, keyCode, state)
return true, nil
} else if e.config.EnableLongText == ibus.PROP_STATE_CHECKED && printableKeyCode[keyCode] && e.preediter.LenStateBack() > 0 {
e.preediter.PushStateBack()
e.prevText = append(e.prevText, rune(keyVal))
Expand Down Expand Up @@ -385,6 +364,7 @@ func (e *IBusTeniEngine) PropertyActivate(propName string, propState uint32) *db
(propName == PropKeyMethodTeni ||
propName == PropKeyMethodVni ||
propName == PropKeyMethodTelex ||
propName == PropKeyMethodTelexEx ||
propName == PropKeyToneStd ||
propName == PropKeyToneNew) {
switch propName {
Expand All @@ -397,6 +377,9 @@ func (e *IBusTeniEngine) PropertyActivate(propName string, propState uint32) *db
case PropKeyMethodTelex:
e.config.InputMethod = teni.IMTelex
e.preediter.InputMethod = teni.IMTelex
case PropKeyMethodTelexEx:
e.config.InputMethod = teni.IMTelexEx
e.preediter.InputMethod = teni.IMTelexEx
case PropKeyToneStd:
e.config.ToneType = ConfigToneStd
case PropKeyToneNew:
Expand Down
38 changes: 27 additions & 11 deletions src/ibus-teni/prop.go
Expand Up @@ -27,16 +27,17 @@ import (
)

const (
PropKeyAbout = "about"
PropKeyMethodTeni = "method_teni"
PropKeyMethodVni = "method_vni"
PropKeyMethodTelex = "method_telex"
PropKeyToneStd = "tone_std"
PropKeyToneNew = "tone_new"
PropKeyExcept = "except"
PropKeyExceptList = "except_list"
PropKeyLongText = "long_text"
PropKeyForceSpell = "force_spell"
PropKeyAbout = "about"
PropKeyMethodTeni = "method_teni"
PropKeyMethodVni = "method_vni"
PropKeyMethodTelex = "method_telex"
PropKeyMethodTelexEx = "method_telex_ex"
PropKeyToneStd = "tone_std"
PropKeyToneNew = "tone_new"
PropKeyExcept = "except"
PropKeyExceptList = "except_list"
PropKeyLongText = "long_text"
PropKeyForceSpell = "force_spell"
)

var runMode = ""
Expand All @@ -45,6 +46,7 @@ func GetPropListByConfig(c *Config) *ibus.PropList {
teniChecked := ibus.PROP_STATE_UNCHECKED
vniChecked := ibus.PROP_STATE_UNCHECKED
telexChecked := ibus.PROP_STATE_UNCHECKED
telexExChecked := ibus.PROP_STATE_UNCHECKED
toneStdChecked := ibus.PROP_STATE_UNCHECKED
toneNewChecked := ibus.PROP_STATE_UNCHECKED

Expand All @@ -55,6 +57,8 @@ func GetPropListByConfig(c *Config) *ibus.PropList {
vniChecked = ibus.PROP_STATE_CHECKED
case teni.IMTelex:
telexChecked = ibus.PROP_STATE_CHECKED
case teni.IMTelexEx:
telexExChecked = ibus.PROP_STATE_CHECKED
}
switch c.ToneType {
case ConfigToneStd:
Expand Down Expand Up @@ -116,13 +120,25 @@ func GetPropListByConfig(c *Config) *ibus.PropList {
Key: PropKeyMethodTelex,
Type: ibus.PROP_TYPE_RADIO,
Label: dbus.MakeVariant(ibus.NewText("Kiểu gõ Telex")),
Tooltip: dbus.MakeVariant(ibus.NewText("Chỉ kiểu gõ Telex")),
Tooltip: dbus.MakeVariant(ibus.NewText("Kiểu gõ Telex không dùng []")),
Sensitive: true,
Visible: true,
State: telexChecked,
Symbol: dbus.MakeVariant(ibus.NewText("X")),
SubProps: dbus.MakeVariant(*ibus.NewPropList()),
},
&ibus.Property{
Name: "IBusProperty",
Key: PropKeyMethodTelexEx,
Type: ibus.PROP_TYPE_RADIO,
Label: dbus.MakeVariant(ibus.NewText("Kiểu gõ [Telex]")),
Tooltip: dbus.MakeVariant(ibus.NewText("Kiểu gõ Telex có dùng []")),
Sensitive: true,
Visible: true,
State: telexExChecked,
Symbol: dbus.MakeVariant(ibus.NewText("[")),
SubProps: dbus.MakeVariant(*ibus.NewPropList()),
},
&ibus.Property{
Name: "IBusProperty",
Key: "-",
Expand Down
2 changes: 1 addition & 1 deletion src/ibus-teni/version.go
Expand Up @@ -20,4 +20,4 @@

package main

const Version = "v1.4.2"
const Version = "v1.5.0"
13 changes: 7 additions & 6 deletions src/teni/teni.go
Expand Up @@ -33,9 +33,10 @@ const (
type InputMethod int

const (
IMTeni InputMethod = iota << 0
IMVni InputMethod = iota
IMTelex InputMethod = iota
IMTeni InputMethod = iota << 0
IMVni InputMethod = iota
IMTelex InputMethod = iota
IMTelexEx InputMethod = iota
)

type EngineState struct {
Expand Down Expand Up @@ -259,8 +260,8 @@ func (pc *Engine) AddKey(key rune) {
if len(pc.rawKeys) > MaxWordLength ||
(pc.InputMethod == IMVni && (key < '0' || key > '9')) ||
(pc.InputMethod == IMTelex && (key >= '0' && key <= '9')) ||
(len(resultRunes) == 0 && (pc.InputMethod != IMTelex || !InChangeCharMap(key))) ||
(replaceCharMap[key] == nil && replaceStrMap[key] == nil && (pc.InputMethod == IMTelex && !InChangeCharMap(key))) {
(len(resultRunes) == 0 && (pc.InputMethod != IMTelex || !InChangeCharMap(key)) && (pc.InputMethod != IMTelexEx || !InChangeCharMapEx(key))) ||
(replaceCharMap[key] == nil && replaceStrMap[key] == nil && (pc.InputMethod == IMTelex && !InChangeCharMap(key)) && (pc.InputMethod != IMTelexEx || !InChangeCharMapEx(key))) {
appendCase := pc.appendChar(key, resultRunes)
resultRunes = appendCase.value
isCompleted = appendCase.findResult == FindResultMatchFull
Expand Down Expand Up @@ -397,7 +398,7 @@ func (pc *Engine) replaceChar(key rune, originalRunes []rune) *resultCase {
}

func (pc *Engine) changeChar(key rune, originalRunes []rune) *resultCase {
if changeTo, exist := changeCharMap[key]; exist {
if changeTo, exist := changeCharMapEx[key]; exist {
lr := len(originalRunes)
lrk := len(pc.rawKeys)
//revert mode
Expand Down
2 changes: 1 addition & 1 deletion src/teni/teni_type_rule_test.go
Expand Up @@ -105,7 +105,7 @@ func TestTeniTypeRule(t *testing.T) {
if strings.Contains(fo.Name(), vniTestDataFileSign) {
pc.InputMethod = IMVni
} else if strings.Contains(fo.Name(), telexTestDataFileSign) {
pc.InputMethod = IMTelex
pc.InputMethod = IMTelexEx
} else {
pc.InputMethod = IMTeni
}
Expand Down
10 changes: 10 additions & 0 deletions src/teni/typerule_change_char.go
Expand Up @@ -21,6 +21,11 @@
package teni

var changeCharMap = map[rune]rune{
'w': 'ư',
'W': 'Ư',
}

var changeCharMapEx = map[rune]rune{
'[': 'ơ',
'{': 'Ơ',
']': 'ư',
Expand All @@ -34,6 +39,11 @@ func InChangeCharMap(c rune) bool {
return exist
}

func InChangeCharMapEx(c rune) bool {
_, exist := changeCharMapEx[c]
return exist
}

var caplockSwitchMap = map[uint32]uint32{
'[': '{',
'{': '[',
Expand Down
2 changes: 1 addition & 1 deletion teni.xml
Expand Up @@ -23,7 +23,7 @@
<name>org.freedesktop.IBus.Teni</name>
<description>Vietnamese input engine for IBus</description>
<exec>/usr/lib/ibus-engine-teni cd /usr/share/ibus-teni</exec>
<version>1.4.2</version>
<version>1.5.0</version>
<author>Nguyễn Công Hoàng &lt;hoangnc.jp@gmail.com&gt;</author>
<license>GPLv3</license>
<homepage>https://github.com/teni-ime/ibus-teni/</homepage>
Expand Down

0 comments on commit 4d20726

Please sign in to comment.