diff --git a/honoka/plugins/nicolainput.cpp b/honoka/plugins/nicolainput.cpp new file mode 100644 index 0000000..2c1ada8 --- /dev/null +++ b/honoka/plugins/nicolainput.cpp @@ -0,0 +1,199 @@ +/*************************************************************************** + * 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 "nicolainput.h" +#include "honoka_plugin_def.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 + +// �ץ饤�����󲽤Τ��ޤ��ʤ��Ǥ��� +HonokaPluginRegister(NicolaInput); + +struct { + KeyCode key; + char noShift[6]; + char leftShift[6]; + char rightShift[6]; +} _nicolaTable[] = { + {SCIM_KEY_1,"1","?",""}, + {SCIM_KEY_2,"2","/",""}, + {SCIM_KEY_3,"3","~",""}, + {SCIM_KEY_4,"4","��",""}, + {SCIM_KEY_5,"5","��",""}, + + {SCIM_KEY_6,"6","","["}, + {SCIM_KEY_7,"7","","]"}, + {SCIM_KEY_8,"8","","("}, + {SCIM_KEY_9,"9","",")"}, + {SCIM_KEY_0,"0","","��"}, + {SCIM_KEY_minus,"-","","��"}, + {SCIM_KEY_backslash,"\\","",""}, + + {SCIM_KEY_q,"��","��",""}, + {SCIM_KEY_w,"��","��","��"}, + {SCIM_KEY_e,"��","��","��"}, + {SCIM_KEY_r,"��","��","��"}, + {SCIM_KEY_t,"��","��","��"}, + + {SCIM_KEY_y,"��","��","��"}, + {SCIM_KEY_u,"��","��","��"}, + {SCIM_KEY_i,"��","��","��"}, + {SCIM_KEY_o,"��","��","��"}, + {SCIM_KEY_p,",","","��"}, + {SCIM_KEY_at,"��","",""}, + {SCIM_KEY_bracketleft,"��","","��"}, + + + {SCIM_KEY_a,"��","��",""}, + {SCIM_KEY_s,"��","��","��"}, + {SCIM_KEY_d,"��","��","��"}, + {SCIM_KEY_f,"��","��","��"}, + {SCIM_KEY_g,"��","��","��"}, + + {SCIM_KEY_h,"��","��","��"}, + {SCIM_KEY_j,"��","��","��"}, + {SCIM_KEY_k,"��","��","��"}, + {SCIM_KEY_l,"��","��","��"}, + {SCIM_KEY_semicolon,"��","","��"}, + + {SCIM_KEY_z,".","��",""}, + {SCIM_KEY_x,"��","��","��"}, + {SCIM_KEY_c,"��","��","��"}, + {SCIM_KEY_v,"��","��","��"}, + {SCIM_KEY_b,"��","��","��"}, + + {SCIM_KEY_n,"��","��","��"}, + {SCIM_KEY_m,"��","","��"}, + {SCIM_KEY_comma,"��","��","��"}, + {SCIM_KEY_period,"��","��","��"}, + {SCIM_KEY_slash,"��","","��"}, + + {SCIM_KEY_NullKey,"","",""} // terminator +}; + +NicolaInput::NicolaInput(ConfigPointer cfg) : PreEditor(cfg) +{ + //fakeNicolaInput = cfg->read(HONOKA_CONFIG_KANAINPUT_FAKEKANA,HONOKA_DEFAULT_KANAINPUT_FAKEKANA); + LShift = false; + RShift = false; + for(unsigned int i = 0;_nicolaTable[i].key != SCIM_KEY_NullKey;i ++) { + NicolaKey k; + iconvert.convert(k.noShift,_nicolaTable[i].noShift); + iconvert.convert(k.leftShift,_nicolaTable[i].leftShift); + iconvert.convert(k.rightShift,_nicolaTable[i].rightShift); + keymap.insert(pair(_nicolaTable[i].key,k)); + } +} + + +NicolaInput::~NicolaInput() +{ +} + +/*! + \fn NicolaInput::getModeName() + */ +String NicolaInput::getModeName() +{ + return String(_("KANA")); +} + +/*! + \fn NicolaInput::getName() + */ +String NicolaInput::getName() +{ + return String("Nicola"); +} + +/*! + \fn NicolaInput::getPropertyName() + */ +String NicolaInput::getPropertyName() +{ + return String(_("NICOLA")); +} + + +/*! + \fn NicolaInput::inputEvent(const KeyEvent &key) + */ +bool NicolaInput::inputEvent(const KeyEvent &key) +{ + // ���äƤ����٤���Ρ� + if ((key.code == SCIM_KEY_Shift_L) || + (key.code == SCIM_KEY_Shift_R) || + (key.code == SCIM_KEY_Control_L) || + (key.code == SCIM_KEY_Control_R) || + (key.code == SCIM_KEY_Alt_L) || + (key.code == SCIM_KEY_Alt_R) || + (key.code == SCIM_KEY_Super_L) || + (key.code == SCIM_KEY_Super_R) || + (key.code == SCIM_KEY_Hyper_L) || + (key.code == SCIM_KEY_Hyper_R)) return true; + + map::iterator it = keymap.find(key.code); + if (it == keymap.end()) return true; + WideString w; + if (LShift) w = it->second.leftShift; + else if (RShift) w = it->second.rightShift; + else w = it->second.noShift; + if (w.length()) { + text = text.substr(0,pos) + w + text.substr(pos); + pos ++; + } + return true; + //return false; +} + + + +/*! + \fn NicolaInput::keyEventHook(const KeyEvent &key) + */ +bool NicolaInput::keyEventHook(const KeyEvent &key) +{ + if (key.code == SCIM_KEY_Henkan) { + if (key.is_key_press()) RShift = true; + else if (key.is_key_release()) RShift = false; + return true; + } + if (key.code == SCIM_KEY_Muhenkan) { + if (key.is_key_press()) LShift = true; + else if (key.is_key_release()) LShift = false; + return true; + } + + return false; +} diff --git a/honoka/plugins/nicolainput.h b/honoka/plugins/nicolainput.h new file mode 100644 index 0000000..6392def --- /dev/null +++ b/honoka/plugins/nicolainput.h @@ -0,0 +1,63 @@ +/*************************************************************************** + * 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 NICOLAINPUT_H +#define NICOLAINPUT_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) +*/ +namespace Honoka { + +class NicolaKey { +public: + WideString noShift; + WideString leftShift; + WideString rightShift; +}; + +class NicolaInput : public PreEditor { +public: + NicolaInput(ConfigPointer cfg); + + ~NicolaInput(); + virtual bool inputEvent(const KeyEvent &key); + virtual String getName(); + virtual String getModeName(); + virtual String getPropertyName(); + virtual bool keyEventHook(const KeyEvent &key); + +protected: + bool LShift; + bool RShift; + map keymap; +}; +} +#endif