diff --git a/scim-wnn/src/Makefile.am b/scim-wnn/src/Makefile.am index 41688df..efe11ff 100644 --- a/scim-wnn/src/Makefile.am +++ b/scim-wnn/src/Makefile.am @@ -25,13 +25,13 @@ -DSCIM_WNN_ICON_FILE=\"@SCIM_ICONDIR@/scim-wnn.png\" noinst_HEADERS = scim_wnn_imengine.h wnnproto.h romkan.h romkan_table.h \ - wnnconversion.h scim_wnn_def.h preeditor.h + wnnconversion.h scim_wnn_def.h preeditor.h kanainput.h moduledir = @SCIM_MODULEDIR@/IMEngine module_LTLIBRARIES = wnn.la wnn_la_SOURCES = scim_wnn_imengine.cpp romkan.cpp wnnconversion.cpp \ - preeditor.cpp + preeditor.cpp kanainput.cpp wnn_la_CFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ wnn_la_CXXFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ diff --git a/scim-wnn/src/kanainput.cpp b/scim-wnn/src/kanainput.cpp new file mode 100644 index 0000000..32e3a27 --- /dev/null +++ b/scim-wnn/src/kanainput.cpp @@ -0,0 +1,200 @@ +/*************************************************************************** + * Copyright (C) 2004 by TAM(Teppei Tamra) * + * tam-t@par.odn.ne.jp * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "kanainput.h" + +#ifdef HAVE_CONFIG_H + #include +#endif + +// ��ݲ��Τ��ޤ��ʤ��� +#ifdef HAVE_GETTEXT + #include + #define _(String) dgettext(GETTEXT_PACKAGE,String) + #define N_(String) (String) +#else + #define _(String) (String) + #define N_(String) (String) + #define bindtextdomain(Package,Directory) + #define textdomain(domain) + #define bind_textdomain_codeset(domain,codeset) +#endif + +struct KanaInputKey { + int code; + const char kana[6]; +}; + +const KanaInputKey KanaInputTable[] = { + {SCIM_KEY_kana_fullstop, "��"}, + {SCIM_KEY_kana_openingbracket, "��"}, + {SCIM_KEY_kana_closingbracket, "��"}, + {SCIM_KEY_kana_comma, "��"}, + {SCIM_KEY_kana_conjunctive, "��"}, + {SCIM_KEY_kana_middledot, "��"}, + {SCIM_KEY_kana_WO, "��"}, + {SCIM_KEY_kana_a, "��"}, + {SCIM_KEY_kana_i, "��"}, + {SCIM_KEY_kana_u, "��"}, + {SCIM_KEY_kana_e, "��"}, + {SCIM_KEY_kana_o, "��"}, + {SCIM_KEY_kana_ya, "��"}, + {SCIM_KEY_kana_yu, "��"}, + {SCIM_KEY_kana_yo, "��"}, + {SCIM_KEY_kana_tsu, "��"}, + {SCIM_KEY_kana_tu, "��"}, + {SCIM_KEY_prolongedsound, "��"}, + {SCIM_KEY_kana_A, "��"}, + {SCIM_KEY_kana_I, "��"}, + {SCIM_KEY_kana_U, "��"}, + {SCIM_KEY_kana_E, "��"}, + {SCIM_KEY_kana_O, "��"}, + {SCIM_KEY_kana_KA, "��"}, + {SCIM_KEY_kana_KI, "��"}, + {SCIM_KEY_kana_KU, "��"}, + {SCIM_KEY_kana_KE, "��"}, + {SCIM_KEY_kana_KO, "��"}, + {SCIM_KEY_kana_SA, "��"}, + {SCIM_KEY_kana_SHI, "��"}, + {SCIM_KEY_kana_SU, "��"}, + {SCIM_KEY_kana_SE, "��"}, + {SCIM_KEY_kana_SO, "��"}, + {SCIM_KEY_kana_TA, "��"}, + {SCIM_KEY_kana_CHI, "��"}, + {SCIM_KEY_kana_TI, "��"}, + {SCIM_KEY_kana_TSU, "��"}, + {SCIM_KEY_kana_TU, "��"}, + {SCIM_KEY_kana_TE, "��"}, + {SCIM_KEY_kana_TO, "��"}, + {SCIM_KEY_kana_NA, "��"}, + {SCIM_KEY_kana_NI, "��"}, + {SCIM_KEY_kana_NU, "��"}, + {SCIM_KEY_kana_NE, "��"}, + {SCIM_KEY_kana_NO, "��"}, + {SCIM_KEY_kana_HA, "��"}, + {SCIM_KEY_kana_HI, "��"}, + {SCIM_KEY_kana_FU, "��"}, + {SCIM_KEY_kana_HU, "��"}, + {SCIM_KEY_kana_HE, "��"}, + {SCIM_KEY_kana_HO, "��"}, + {SCIM_KEY_kana_MA, "��"}, + {SCIM_KEY_kana_MI, "��"}, + {SCIM_KEY_kana_MU, "��"}, + {SCIM_KEY_kana_ME, "��"}, + {SCIM_KEY_kana_MO, "��"}, + {SCIM_KEY_kana_YA, "��"}, + {SCIM_KEY_kana_YU, "��"}, + {SCIM_KEY_kana_YO, "��"}, + {SCIM_KEY_kana_RA, "��"}, + {SCIM_KEY_kana_RI, "��"}, + {SCIM_KEY_kana_RU, "��"}, + {SCIM_KEY_kana_RE, "��"}, + {SCIM_KEY_kana_RO, "��"}, + {SCIM_KEY_kana_WA, "��"}, + {SCIM_KEY_kana_N, "��"}, + + {0,""} +}; + + +KanaInput::KanaInput(ConfigPointer cfg) : PreEditor(cfg) +{ +} + + +KanaInput::~KanaInput() +{ +} + +bool KanaInput::fakeKanaInput = true; + +/*! + \fn KanaInput::getModeName() + */ +String KanaInput::getModeName() +{ + return(_("KANA")); +} + +/*! + \fn KanaInput::getName() + */ +String KanaInput::getName() +{ + return(String(_("Kana"))); +} + + +/*! + \fn KanaInput::inputEvent(const KeyEvent &key) + */ +bool KanaInput::inputEvent(const KeyEvent &key) +{ + if (key.is_alt_down() || key.is_control_down()) { + return(false); + } + for(unsigned int i = 0;KanaInputTable[i].code != 0;++ i) { + if (key.code == KanaInputTable[i].code) { + WideString w; + iconvert.convert(w,String(KanaInputTable[i].kana)); + text = text.substr(0,pos) + w + text.substr(pos); + pos ++; + return(true); + } + } + if ((((key.get_ascii_code() == '@') && (fakeKanaInput)) || (key.code == SCIM_KEY_voicedsound )) && (pos > 0)) { + WideString vs1,vs2; + iconvert.convert(vs1,String("���������������������������ƤȤϤҤդؤۤѤԤפڤ�")); + iconvert.convert(vs2,String("�����������������������¤ŤǤɤФӤ֤٤ܤФӤ֤٤�")); + for(unsigned int i = 0;i < vs1.length();i ++) { + if (vs1[i] == text[pos - 1]) text = text.substr(0,pos - 1) + vs2[i] + text.substr(pos); + } + return(true); + } + if ((((key.get_ascii_code() == '[') && (fakeKanaInput)) || (key.code == SCIM_KEY_semivoicedsound )) && (pos > 0)) { + WideString vs1,vs2; + iconvert.convert(vs1,String("�ϤҤդؤۤФӤ֤٤�")); + iconvert.convert(vs2,String("�ѤԤפڤݤѤԤפڤ�")); + for(unsigned int i = 0;i < vs1.length();i ++) { + if (vs1[i] == text[pos - 1]) text = text.substr(0,pos - 1) + vs2[i] + text.substr(pos); + } + return(true); + } + if (fakeKanaInput) { + char f1[] = "1234567890-^qwertyuiopasdfghjkl;:]zxcvbnm,./\\!\"#$%&'()~=~|QWERTYUIOP`{ASDFGHJKL+*}ZXCVBNM<>?_"; + WideString f2; + iconvert.convert(f2,String("�̤դ������������ۤؤ��Ƥ�������ʤˤ餻���Ȥ��Ϥ����ޤΤ�줱��Ĥ����Ҥ��ߤ�ͤ����ɤ�������������������Ƥ�������ʤˤ餻���֤��Ȥ��Ϥ����ޤΤ�ܡ��פä����Ҥ��ߤ⡢������")); + for(unsigned i = 0;f1[i] != 0;i ++) { + if (key.get_ascii_code() == f1[i]) { + text = text.substr(0,pos) + f2[i] + text.substr(pos); + pos ++; + return(true); + } + } + } + if (isprint(key.code)) { + String s; + s += key.get_ascii_code(); + text = text.substr(0,pos) + utf8_mbstowcs(s) + text.substr(pos); + pos ++; + return(true); + } + return(false); +} + diff --git a/scim-wnn/src/kanainput.h b/scim-wnn/src/kanainput.h new file mode 100644 index 0000000..ad13afa --- /dev/null +++ b/scim-wnn/src/kanainput.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2004 by TAM(Teppei Tamra) * + * tam-t@par.odn.ne.jp * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef KANAINPUT_H +#define KANAINPUT_H + +#define Uses_SCIM_ICONV +#define Uses_SCIM_CONFIG_BASE +#include +#include +#include +#include +#include "preeditor.h" + +using namespace std; +using namespace scim; + +/** +@author TAM(Teppei Tamra) +*/ +class KanaInput : public PreEditor { +public: + KanaInput(ConfigPointer cfg); + + ~KanaInput(); + virtual bool inputEvent(const KeyEvent &key); + virtual String getName(); + virtual String getModeName(); + +protected: + static bool fakeKanaInput; +}; + +#endif diff --git a/scim-wnn/src/preeditor.cpp b/scim-wnn/src/preeditor.cpp index 87f1836..17d3677 100644 --- a/scim-wnn/src/preeditor.cpp +++ b/scim-wnn/src/preeditor.cpp @@ -247,3 +247,12 @@ } return(false); } + + +/*! + \fn PreEditor::getName() + */ +String PreEditor::getName() +{ + return(String("PreEditor")); +} diff --git a/scim-wnn/src/preeditor.h b/scim-wnn/src/preeditor.h index ac46da6..3ec1912 100644 --- a/scim-wnn/src/preeditor.h +++ b/scim-wnn/src/preeditor.h @@ -60,6 +60,7 @@ static void convZenHan(WideString &t); virtual bool cancelEvent(); virtual bool inputEvent(const KeyEvent &key); + virtual String getName(); protected: static WideString text; diff --git a/scim-wnn/src/romkan.cpp b/scim-wnn/src/romkan.cpp index 332384c..8511297 100644 --- a/scim-wnn/src/romkan.cpp +++ b/scim-wnn/src/romkan.cpp @@ -351,3 +351,12 @@ } return(false); } + + +/*! + \fn Romkan::getName() + */ +String Romkan::getName() +{ + return(String(_("Roma-Kana"))); +} diff --git a/scim-wnn/src/romkan.h b/scim-wnn/src/romkan.h index affc310..cf13952 100644 --- a/scim-wnn/src/romkan.h +++ b/scim-wnn/src/romkan.h @@ -51,6 +51,7 @@ virtual String getModeName(); virtual bool cancelEvent(); virtual bool inputEvent(const KeyEvent &key); + virtual String getName(); protected: WideString eval(); diff --git a/scim-wnn/src/scim_wnn_imengine.cpp b/scim-wnn/src/scim_wnn_imengine.cpp index f189377..d8320db 100644 --- a/scim-wnn/src/scim_wnn_imengine.cpp +++ b/scim-wnn/src/scim_wnn_imengine.cpp @@ -179,6 +179,7 @@ m_iconv.set_encoding ("EUC-JP"); m_connected = false; preeditors.push_back(new Romkan(_scim_config)); + preeditors.push_back(new KanaInput(_scim_config)); m_preeditor = preeditors.at(0); init(); } diff --git a/scim-wnn/src/scim_wnn_imengine.h b/scim-wnn/src/scim_wnn_imengine.h index c78b6a9..f43ee19 100644 --- a/scim-wnn/src/scim_wnn_imengine.h +++ b/scim-wnn/src/scim_wnn_imengine.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #define Uses_SCIM_ICONV #include