diff --git a/scim-wnn/src/preeditor.cpp b/scim-wnn/src/preeditor.cpp index f855805..f5b92fa 100644 --- a/scim-wnn/src/preeditor.cpp +++ b/scim-wnn/src/preeditor.cpp @@ -23,6 +23,8 @@ { iconvert.set_encoding ("EUC-JP"); config = cfg; + if (!convChars.size()) + iconvert.convert(convChars,String("���󥡥�!~�������")); } @@ -31,6 +33,7 @@ } WideString PreEditor::text = WideString(); +WideString PreEditor::convChars = WideString(); int PreEditor::pos = 0; IConvert PreEditor::iconvert; @@ -119,13 +122,9 @@ */ void PreEditor::convHiraKata(WideString &t) { - WideString start_c,end_c,conv_c; - iconvert.convert(start_c,String("��")); - iconvert.convert(end_c,String("��")); - iconvert.convert(conv_c,String("��")); for(unsigned int i = 0;i < t.size();i ++) { - if ((t[i] >= start_c[0]) && (t[i] <= end_c[0])) - t[i] = t[i] - start_c[0] + conv_c[0]; + if ((t[i] >= convChars[HIRA_START]) && (t[i] <= convChars[HIRA_END])) + t[i] = t[i] - convChars[HIRA_START] + convChars[KATA_START]; } return; } @@ -136,13 +135,9 @@ */ void PreEditor::convKataHira(WideString &t) { - WideString start_c,end_c,conv_c; - iconvert.convert(start_c,String("��")); - iconvert.convert(end_c,String("��")); - iconvert.convert(conv_c,String("��")); for(unsigned int i = 0;i < t.size();i ++) { - if ((t[i] >= start_c[0]) && (t[i] <= end_c[0])) - t[i] = t[i] - start_c[0] + conv_c[0]; + if ((t[i] >= convChars[KATA_START]) && (t[i] <= convChars[KATA_END])) + t[i] = t[i] - convChars[KATA_START] + convChars[HIRA_START]; } return; @@ -154,13 +149,9 @@ */ void PreEditor::convHanZen(WideString &t) { - WideString start_c,end_c,conv_c; - iconvert.convert(start_c,String("!")); - iconvert.convert(end_c,String("~")); - iconvert.convert(conv_c,String("��")); for(unsigned int i = 0;i < t.size();i ++) { - if ((t[i] >= start_c[0]) && (t[i] <= end_c[0])) - t[i] = t[i] - start_c[0] + conv_c[0]; + if ((t[i] >= convChars[ASCII_START]) && (t[i] <= convChars[ASCII_END])) + t[i] = t[i] - convChars[ASCII_START] + convChars[WASCII_START]; } return; @@ -172,13 +163,9 @@ */ void PreEditor::convZenHan(WideString &t) { - WideString start_c,end_c,conv_c; - iconvert.convert(start_c,String("��")); - iconvert.convert(end_c,String("��")); - iconvert.convert(conv_c,String("!")); for(unsigned int i = 0;i < t.size();i ++) { - if ((t[i] >= start_c[0]) && (t[i] <= end_c[0])) - t[i] = t[i] - start_c[0] + conv_c[0]; + if ((t[i] >= convChars[WASCII_START]) && (t[i] <= convChars[WASCII_START])) + t[i] = t[i] - convChars[WASCII_START] + convChars[ASCII_START]; } return; diff --git a/scim-wnn/src/preeditor.h b/scim-wnn/src/preeditor.h index cfd766c..7b9a0b5 100644 --- a/scim-wnn/src/preeditor.h +++ b/scim-wnn/src/preeditor.h @@ -26,6 +26,17 @@ #include #include +#define HIRA_START 0 +#define HIRA_END 1 +#define KATA_START 2 +#define KATA_END 3 +#define ASCII_START 4 +#define ASCII_END 5 +#define WASCII_START 6 +#define WASCII_END 7 +#define KANA_N 8 +#define KANA_XTU 9 + using namespace std; using namespace scim; @@ -69,6 +80,7 @@ static int pos; static IConvert iconvert; ConfigPointer config; + static WideString convChars; }; diff --git a/scim-wnn/src/romkan.cpp b/scim-wnn/src/romkan.cpp index 12753bd..b76c1a4 100644 --- a/scim-wnn/src/romkan.cpp +++ b/scim-wnn/src/romkan.cpp @@ -42,6 +42,18 @@ reset(); iconvert.set_encoding ("EUC-JP"); mode = ROMA; + + unsigned int i = 0; + while(strcmp(_RomkanTable[i],"") != 0) { + RomkanTableEntry e; + e.key = String(_RomkanTable[i]); + WideString w; + iconvert.convert(w,String(_RomkanTable[i + 1])); + e.kana = w; + RomkanTable.push_back(e); + i += 2; + } + } @@ -137,38 +149,30 @@ if (buf[1] == b[i]) boin = true; } if (!boin) { - WideString w; - iconvert.convert(w,String("��")); - text = text.substr(0,pos - 2) + w + text.substr(pos - 1); + text = text.substr(0,pos - 2) + convChars[KANA_N] + text.substr(pos - 1); buf = buf.substr(buf.length() - 1,1); } } // Ʊ��ʸ������ʸ��³���Ȥ���ϡ֤áסܻҲ��Ǥ��롣�첻��Ϣ�Ǥ�buf�˻ĤäƤϤ��ʤ��Ϥ��� else if (buf[0] == buf[1]) { - WideString w; - iconvert.convert(w,String("��")); - text = text.substr(0,pos - 2) + w + text.substr(pos - 1); + text = text.substr(0,pos - 2) + convChars[KANA_XTU] + text.substr(pos - 1); buf = buf.substr(buf.length() - 1,1); return(text); } } // �ơ��֥�򸡺��������Ϥ��롣 - unsigned int i = 0; - while(strcmp(RomkanTable[i],"") != 0) { - if (buf == String(RomkanTable[i])) { - if (String(RomkanTable[i + 1]) == "") { + for(unsigned int i = 0;i < RomkanTable.size();i ++) { + if (buf == RomkanTable[i].key) { + if (!RomkanTable[i].kana.size()) { return(text); // ��α���롣 } - WideString w; - iconvert.convert(w,String(RomkanTable[i + 1])); - text = text.substr(0,pos - buf.length()) + w + text.substr(pos); - pos = pos - buf.length() + w.length(); + text = text.substr(0,pos - buf.length()) + RomkanTable[i].kana + text.substr(pos); + pos = pos - buf.length() + RomkanTable[i].kana.length(); buf.clear(); return(text); } - i += 2; } if (buf.length()) { buf = buf.substr(1); @@ -209,9 +213,7 @@ if (hosei) { if (buf.length()) { if (buf.substr(buf.length() - 1,1) == "n") { - WideString w; - iconvert.convert(w,String("��")); - text = text.substr(0,pos - 1) + w; + text = text.substr(0,pos - 1) + convChars[KANA_N]; } } } diff --git a/scim-wnn/src/romkan.h b/scim-wnn/src/romkan.h index fb253b6..c47e542 100644 --- a/scim-wnn/src/romkan.h +++ b/scim-wnn/src/romkan.h @@ -34,6 +34,11 @@ /** @author TAM(Teppei Tamra) */ +struct RomkanTableEntry { + String key; + WideString kana; +}; + class Romkan : public PreEditor { public: Romkan(ConfigPointer cfg); @@ -64,6 +69,7 @@ String modeName; enum inputMode {ROMA,ASCII,WASCII}; inputMode mode; + vector RomkanTable; }; #endif diff --git a/scim-wnn/src/romkan_table.h b/scim-wnn/src/romkan_table.h index ea3eafa..4dd7254 100644 --- a/scim-wnn/src/romkan_table.h +++ b/scim-wnn/src/romkan_table.h @@ -21,7 +21,7 @@ // ���޻������Ѵ��ơ��֥롣 // �������ʤΤǥߥ�/��­�β�ǽ�����ꡣ -const char RomkanTable[][6] = { +const char _RomkanTable[][6] = { // "�ɤ�", "�Ѵ�", // ("�Ѵ�"������ξ�����α��"�ɤ�"����ϥ����ߥ͡���) "a", "��",