diff --git a/scim-wnn/src/preeditor.cpp b/scim-wnn/src/preeditor.cpp index 5fc0a4c..6ab43dd 100644 --- a/scim-wnn/src/preeditor.cpp +++ b/scim-wnn/src/preeditor.cpp @@ -181,9 +181,9 @@ /*! - \fn PreEditor::convHanZen(WideString &t) + \fn PreEditor::convHanZen(WideString &t,int &p) */ -void PreEditor::convHanZen(WideString &t) +void PreEditor::convHanZen(WideString &t,int &p) { for(unsigned int i = 0;i < t.size();i ++) { if ((t[i] >= convChars[ASCII_START]) && (t[i] <= convChars[ASCII_END])) @@ -195,9 +195,9 @@ /*! - \fn PreEditor::convZenHan(WideString &t) + \fn PreEditor::convZenHan(WideString &t,int &p) */ -void PreEditor::convZenHan(WideString &t) +void PreEditor::convZenHan(WideString &t,int &p) { for(unsigned int i = 0;i < t.size();i ++) { if ((t[i] >= convChars[WASCII_START]) && (t[i] <= convChars[WASCII_END])) @@ -209,6 +209,7 @@ WideString m1 = t.substr(0,i); WideString m2 = t.substr(i + 1); t = m1 + it->second + m2; + if (p > i) p += it->second.size() - 1; i += it->second.length() - 1; } } @@ -240,7 +241,7 @@ */ void PreEditor::toHalf() { - convZenHan(text); + convZenHan(text,pos); } /*! @@ -248,7 +249,7 @@ */ void PreEditor::toWide() { - convHanZen(text); + convHanZen(text,pos); } diff --git a/scim-wnn/src/preeditor.h b/scim-wnn/src/preeditor.h index 94837de..0925f61 100644 --- a/scim-wnn/src/preeditor.h +++ b/scim-wnn/src/preeditor.h @@ -70,8 +70,8 @@ virtual String getModeName(); static void convHiraKata(WideString &t); static void convKataHira(WideString &t); - static void convHanZen(WideString &t); - static void convZenHan(WideString &t); + static void convHanZen(WideString &t,int &p); + static void convZenHan(WideString &t,int &p); virtual bool cancelEvent(); virtual bool inputEvent(const KeyEvent &key); virtual String getName(); diff --git a/scim-wnn/src/romkan.cpp b/scim-wnn/src/romkan.cpp index b3ecf35..194304b 100644 --- a/scim-wnn/src/romkan.cpp +++ b/scim-wnn/src/romkan.cpp @@ -114,7 +114,7 @@ case WASCII: { buf.clear(); WideString w = utf8_mbstowcs(s); - convHanZen(w); + convHanZen(w,pos); text = text.substr(0,pos) + w + text.substr(pos); pos ++; return(text); @@ -277,10 +277,9 @@ */ void Romkan::toHalf() { - unsigned int p = text.length(); - convZenHan(text); - // �����åȰ���·�� - if (p != text.length()) setPos(getPos() + (text.length() - p)); + int p = getPos(); + convZenHan(text,p); + if (p != getPos()) setPos(p); buf.clear(); } @@ -289,7 +288,9 @@ */ void Romkan::toWide() { - convHanZen(text); + int p = getPos(); + convHanZen(text,pos); + if (p != getPos()) setPos(p); buf.clear(); }