diff --git a/honoka/Makefile.am b/honoka/Makefile.am index d331a1d..f2e73fc 100644 --- a/honoka/Makefile.am +++ b/honoka/Makefile.am @@ -28,7 +28,7 @@ ## @end 1 AUTOMAKE_OPTIONS = gnu -SUBDIRS = libhonoka src intl po m4 data +SUBDIRS = libhonoka src plugins intl po m4 data ## @start 1 MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure config.h.in $(AUX_DIST) diff --git a/honoka/configure.ac b/honoka/configure.ac index 01c761f..a9e2ddc 100644 --- a/honoka/configure.ac +++ b/honoka/configure.ac @@ -194,5 +194,5 @@ AC_SUBST(SCIM_DATADIR) AC_CONFIG_FILES([Makefile intl/Makefile po/Makefile.in m4/Makefile - libhonoka/Makefile src/Makefile data/Makefile]) + libhonoka/Makefile src/Makefile plugins/Makefile data/Makefile]) AC_OUTPUT diff --git a/honoka/plugins/Makefile.am b/honoka/plugins/Makefile.am new file mode 100644 index 0000000..c542cb4 --- /dev/null +++ b/honoka/plugins/Makefile.am @@ -0,0 +1,76 @@ +## Makefile.am -- Process this file with automake to produce Makefile.in +## Copyright (C) 2002 James Su +## +## 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +MAINTAINERCLEANFILES = Makefile.in + +INCLUDES = -I$(top_builddir) \ + -I$(top_srcdir) \ + -I$(top_srcdir)/libhonoka \ + -DSCIM_ICONDIR=\"@SCIM_ICONDIR@\" \ + -DHONOKA_LOCALEDIR=\"$(datadir)/locale\" \ + -DHONOKA_DATADIR=\"@SCIM_DATADIR@/honoka\" \ + -DHONOKA_ICON_FILE=\"@SCIM_ICONDIR@/honoka.png\" \ + -DHONOKA_PLUGINDIR=\"@SCIM_MODULEDIR@/honoka\" + +noinst_HEADERS = wnnproto.h romkan.h \ + wnnconversion.h kanainput.h anthyconversion.h skkdic.h \ + skkdicconversion.h wnnplugin.h wnnprediction.h honoka_plugin_def.h + +moduledir = @SCIM_MODULEDIR@/IMEngine + + +if WNNCONVERSION +WNN_PLUGIN = plugin-wnn.la +endif + +if ANTHYCONVERSION +ANTHY_PLUGIN = plugin-anthy.la +endif + +plugindir = @SCIM_MODULEDIR@/honoka +plugin_LTLIBRARIES = $(ANTHY_PLUGIN) $(WNN_PLUGIN) plugin-skkdic.la plugin-romkan.la plugin-kanainput.la + +plugin_anthy_la_SOURCES = anthyconversion.cpp +plugin_anthy_la_CFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ +plugin_anthy_la_CXXFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ +plugin_anthy_la_LDFLAGS = -avoid-version -module -rpath $(plugindir) @LIBTOOL_EXPORT_OPTIONS@ @INTLLIBS@ @SCIM_LIBS@ @ANTHY_LIBS@ +plugin_anthy_la_LIBADD = $(top_builddir)/libhonoka/libhonoka_plugin.la + +plugin_wnn_la_SOURCES = wnnconversion.cpp wnnplugin.cpp wnnprediction.cpp +plugin_wnn_la_CFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ +plugin_wnn_la_CXXFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ +plugin_wnn_la_LDFLAGS = -avoid-version -module -rpath $(plugindir) @LIBTOOL_EXPORT_OPTIONS@ @INTLLIBS@ @SCIM_LIBS@ @WNN_LIBS@ +plugin_wnn_la_LIBADD = $(top_builddir)/libhonoka/libhonoka_plugin.la + +plugin_skkdic_la_SOURCES = skkdic.cpp skkdicconversion.cpp +plugin_skkdic_la_CFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ +plugin_skkdic_la_CXXFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ +plugin_skkdic_la_LDFLAGS = -avoid-version -module -rpath $(plugindir) @LIBTOOL_EXPORT_OPTIONS@ @INTLLIBS@ @SCIM_LIBS@ @ANTHY_LIBS@ +plugin_skkdic_la_LIBADD = $(top_builddir)/libhonoka/libhonoka_plugin.la + +plugin_romkan_la_SOURCES = romkan.cpp +plugin_romkan_la_CFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ +plugin_romkan_la_CXXFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ +plugin_romkan_la_LDFLAGS = -avoid-version -module -rpath $(plugindir) @LIBTOOL_EXPORT_OPTIONS@ @INTLLIBS@ @SCIM_LIBS@ +plugin_romkan_la_LIBADD = $(top_builddir)/libhonoka/libhonoka_plugin.la + +plugin_kanainput_la_SOURCES = kanainput.cpp +plugin_kanainput_la_CFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ +plugin_kanainput_la_CXXFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ +plugin_kanainput_la_LDFLAGS = -avoid-version -module -rpath $(plugindir) @LIBTOOL_EXPORT_OPTIONS@ @INTLLIBS@ @SCIM_LIBS@ +plugin_kanainput_la_LIBADD = $(top_builddir)/libhonoka/libhonoka_plugin.la + diff --git a/honoka/plugins/anthyconversion.cpp b/honoka/plugins/anthyconversion.cpp new file mode 100644 index 0000000..e26b31d --- /dev/null +++ b/honoka/plugins/anthyconversion.cpp @@ -0,0 +1,197 @@ +/*************************************************************************** + * 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 "anthyconversion.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(AnthyConversion); + + +AnthyConversion::AnthyConversion(ConfigPointer cfg) : Convertor(cfg) +{ + m_iconv.set_encoding ("EUC-JP"); + pos = 0; + anthy_init(); + context = anthy_create_context(); +} + + +AnthyConversion::~AnthyConversion() +{ +} + +bool AnthyConversion::isConnected() { + return true; +} + +void AnthyConversion::reset(){ + anthy_release_context(context); + anthy_init(); + context = anthy_create_context(); + return; +} + +void AnthyConversion::setYomiText(WideString yomi) { + yomiText = yomi; +} + +int AnthyConversion::ren_conversion() { + String y; + anthy_reset_context(context); + m_iconv.convert(y,yomiText); + anthy_set_string(context,y.c_str()); + struct anthy_conv_stat stat; + anthy_get_stat(context,&stat); + pos = 0; + buildResult(); + + return stat.nr_segment; +} + +WideString AnthyConversion::getText() { + WideString text; + for(unsigned int i = 0;i < convResult.size();i ++) { + text += convResult[i].kouho[convResult[i].pos].kanji; + } + return text; +} + +int AnthyConversion::setPos(int p){ + if ((p < convResult.size()) && (p >= 0)) pos = p; + return pos; +} + +int AnthyConversion::getPos() { + return pos; +} + +ResultList AnthyConversion::getResultList(int p,int kt){ + if (p == -1) p = pos; + if (p >= convResult.size()) return ResultList(); + if ((kt != 0) || (p >= convResult.size())) return ResultList(); + setPos(p); + return convResult[p]; +} + +bool AnthyConversion::select(int p) { + if (p < convResult[pos].count()) { + convResult[pos].pos = p; + } +} + +AttributeList AnthyConversion::getAttributeList() { + AttributeList attr; + int l = 0; + for(unsigned int i = 0;i < convResult.size();i ++) { + if (pos == i) { + Attribute a(l,convResult[i].kouho[convResult[i].pos].kanji.length(),SCIM_ATTR_DECORATE,SCIM_ATTR_DECORATE_REVERSE); + attr.push_back(a); + } + l += convResult[i].kouho[convResult[i].pos].kanji.length(); + } + return attr; +} + +bool AnthyConversion::resizeRegion(int w) { + //if ((convResult[pos].kouho[convResult[pos].pos].length() + w) < 1) return false; + if ((convResult[pos].Yomi.length() + w) < 1) return false; + if ((pos >= (convResult.size() - 1)) && (w > 0)) return false; + anthy_resize_segment(context,pos,w); + buildResult(); + return true; +} + +void AnthyConversion::updateFrequency() { + for(unsigned int i = 0;i < convResult.size();i ++) { + anthy_commit_segment(context,i,convResult[i].pos); + } + return; +} + +bool AnthyConversion::connect() { + return true; +} +void AnthyConversion::disconnect() { + return; +} + +int AnthyConversion::getCaretPos() { + int l = 0; + for(unsigned int i = 0;i < convResult.size();i ++) { + if (pos == i) return l; + l += convResult[i].kouho[convResult[i].pos].kanji.length(); + } + return 0; +} + +void AnthyConversion::buildResult() { + struct anthy_conv_stat stat; + anthy_get_stat(context,&stat); + int slen = 0; + convResult.clear(); + for(int i = 0;i < stat.nr_segment;i ++) { + ResultList l; + l.kType = 0; + l.Title = utf8_mbstowcs(String(_("lookup result"))); + struct anthy_segment_stat sstat; + anthy_get_segment_stat(context,i,&sstat); + //l.count = sstat.nr_candidate; + l.Yomi = yomiText.substr(slen,sstat.seg_len); + slen += sstat.seg_len; + l.pos = 0; + for(int j = 0;j < sstat.nr_candidate;j ++) { + char res[256]; + int c = anthy_get_segment(context,i,j,0,0); + if (c > 255) c = 255; + anthy_get_segment(context,i,j,res,c + 1); + WideString w; + m_iconv.convert(w,String(res)); + l.kouho.push_back(w); + } + convResult.push_back(l); + } +} + +String AnthyConversion::getName() +{ + return String("Anthy"); +} + +String AnthyConversion::getPropertyName() +{ + return String("Anthy"); +} + + diff --git a/honoka/plugins/anthyconversion.h b/honoka/plugins/anthyconversion.h new file mode 100644 index 0000000..5fe04d7 --- /dev/null +++ b/honoka/plugins/anthyconversion.h @@ -0,0 +1,76 @@ +/*************************************************************************** + * 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 ANTHYCONVERSION_H +#define ANTHYCONVERSION_H + +#define Uses_SCIM_CONFIG_BASE + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace scim; + +/** +@author TAM (Teppei Tamra) +*/ +class AnthyConversion : public Convertor { +public: + AnthyConversion(ConfigPointer cfg); + + ~AnthyConversion(); + virtual bool isConnected(); + virtual void reset(); + virtual void setYomiText(WideString yomi); + virtual int ren_conversion(); + virtual WideString getText(); + virtual int setPos(int p); + virtual int getPos(); + virtual ResultList getResultList(int p = -1 ,int kt = 0); + virtual bool select(int p); + virtual AttributeList getAttributeList(); + virtual bool resizeRegion(int w); + virtual void updateFrequency(); + virtual bool connect(); + virtual void disconnect(); + virtual int getCaretPos(); + virtual String getName(); + virtual String getPropertyName(); + + +protected: + void buildResult(); +protected: + anthy_context_t context; + IConvert m_iconv; + WideString yomiText; + vector convResult; + int pos; + +}; + + +#endif diff --git a/honoka/plugins/honoka_plugin_def.h b/honoka/plugins/honoka_plugin_def.h new file mode 100644 index 0000000..f990ffa --- /dev/null +++ b/honoka/plugins/honoka_plugin_def.h @@ -0,0 +1,52 @@ +/*************************************************************************** + * Copyright (C) 2005 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 HONOKA_PLUGIN_DEF_H +#define HONOKA_PLUGIN_DEF_H + +#define HONOKA_CONFIG_JSERVERTYPE "/IMEngine/Honoka/Wnn/JServerType" +#ifdef HAVE_LIBWNN7 + #define HONOKA_DEFAULT_JSERVERTYPE "Wnn7" +#else + #define HONOKA_DEFAULT_JSERVERTYPE "Wnn4" +#endif + +#define HONOKA_CONFIG_JSERVER "/IMEngine/Honoka/Wnn/JServer" +#define HONOKA_DEFAULT_JSERVER "localhost" +#define HONOKA_CONFIG_WNNENVRC "/IMEngine/Honoka/Wnn/Wnnenvrc" +#define HONOKA_DEFAULT_WNNENVRC "/usr/lib/wnn7/ja_JP/wnnenvrc" + +#define HONOKA_CONFIG_WNNYOSOKU "/IMEngine/Honoka/Wnn/Yosoku" +#ifdef HAVE_LIBWNN7 + #define HONOKA_DEFAULT_WNNYOSOKU true +#else + #define HONOKA_DEFAULT_WNNYOSOKU false +#endif + + +// Romkan + +#define HONOKA_CONFIG_ROMKAN_TABLE_FILE "/IMEngine/Honoka/Romkan/TableFile" +#define HONOKA_DEFAULT_ROMKAN_TABLE_FILE "honoka-def.rkt" + +// KanaInput +#define HONOKA_CONFIG_KANAINPUT_FAKEKANA "/IMEngine/Honoka/KanaInput/FakeKanaKey" +#define HONOKA_DEFAULT_KANAINPUT_FAKEKANA true + +#endif diff --git a/honoka/plugins/kanainput.cpp b/honoka/plugins/kanainput.cpp new file mode 100644 index 0000000..ee2e2b1 --- /dev/null +++ b/honoka/plugins/kanainput.cpp @@ -0,0 +1,212 @@ +/*************************************************************************** + * 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" +#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(KanaInput); + +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) +{ + fakeKanaInput = cfg->read(HONOKA_CONFIG_KANAINPUT_FAKEKANA,HONOKA_DEFAULT_KANAINPUT_FAKEKANA); +} + + +KanaInput::~KanaInput() +{ +} + +/*! + \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.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; + + 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/honoka/plugins/kanainput.h b/honoka/plugins/kanainput.h new file mode 100644 index 0000000..fb7f70e --- /dev/null +++ b/honoka/plugins/kanainput.h @@ -0,0 +1,51 @@ +/*************************************************************************** + * 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(); + virtual String getPropertyName() {return String("KanaInput");}; + +protected: + bool fakeKanaInput; +}; + +#endif diff --git a/honoka/plugins/romkan.cpp b/honoka/plugins/romkan.cpp new file mode 100644 index 0000000..138bb83 --- /dev/null +++ b/honoka/plugins/romkan.cpp @@ -0,0 +1,632 @@ +/*************************************************************************** + * 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 "romkan.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(Romkan); + +Romkan::Romkan(ConfigPointer cfg) : PreEditor(cfg) +{ + reset(); + iconvert.set_encoding ("EUC-JP"); + mode = ROMA; + init(); +} + + +Romkan::~Romkan() +{ +} + + +/*! + \fn Romkan::loadTable(const String &filename, bool inc) + */ +void Romkan::loadTable(const String &filename, bool inc) +{ + FILE *f = fopen(filename.c_str(),"r"); + if (!f) { + #ifdef HONOKA_DATADIR + String fn = HONOKA_DATADIR; + fn += "/" + filename; + f = fopen(fn.c_str(),"r"); + if (!f) return; + #else + return; + #endif + } + + while(-1) { + char s[256]; + if(fgets(s,256,f) == NULL) break; + String k,r; + unsigned int i = 0; + bool ex = false; + for(;s[i];i ++) { + if (s[i] == ' ') { + if (k.size()) break; + else continue; + } + if (s[i] == '\n') break; + if ((s[i] == '!') || (s[i] == '$') ||(s[i] == '%')) { + if (!k.size()) ex = true; + } + if (s[i] == '#') break; + if ((s[i] == '\\') && (s[i + 1] != 0)) { + i ++; + } + k += s[i]; + } + if ((!k.size()) || (s[i] == '#')) continue; + if (s[i] != 0) { + i ++; + for(;s[i];i ++) { + if ((s[i] == '#') || (s[i] == '\n')) break; + if (s[i] == ' ') { + if (r.size()) break; + else continue; + } + if ((s[i] == '\\') && (s[i + 1] != 0)) { + i ++; + } + r += s[i]; + } + } + if (ex && (k[0] == '%')) { + loadTable(k.substr(1),true); + continue; + } + if ((k[0] == '$') && (!inc) && ex) { + tableConfig.insert(pair(k.substr(1),r)); + continue; + } + if ((k[0] == '!') && (!inc) && ex) { + RomkanKeyEventList kev; + scim_string_to_key_list(kev,k.substr(1)); + kev.p = utf8_mbstowcs(r); + hookKey.push_back(kev); + continue; + } + if (!r.size()) continue; + RomkanTable.insert(pair(k,utf8_mbstowcs(r))); + + for(unsigned int j = k.length();j > 1;j --) { + String keep = k.substr(0,j - 1); + if ((keepTable.find(keep) == keepTable.end()) && (RomkanTable.find(keep) == RomkanTable.end())) { + keepTable.insert(keep); + } + } + } + fclose(f); + +} + + +/*! + \fn Romkan::string2bool(const String &s) + */ +bool Romkan::string2bool(const String &s) +{ + if ((s == "FALSE") || (s == "false") || (s == "False") || (s == "0") || (!s.size())) return false; + else return true; +} + + +/*! + \fn Romkan::init() + */ +void Romkan::init() +{ + RomkanTable.clear(); + keepTable.clear(); + tableConfig.clear(); + + String rk_table = config->read(HONOKA_CONFIG_ROMKAN_TABLE_FILE,String(HONOKA_DEFAULT_ROMKAN_TABLE_FILE)); + + if (rk_table.size()) { + loadTable(rk_table); + } + + if (tableConfig.find("nnMode") != tableConfig.end()) + nnMode = string2bool(tableConfig["nnMode"]); + else nnMode = false; + if (tableConfig.find("AsciiModeCancel") != tableConfig.end()) + asciiCancel = string2bool(tableConfig["AsciiModeCancel"]); + else asciiCancel = true; + if (tableConfig.find("RemoveRemainder") != tableConfig.end()) + removeRemainder = string2bool(tableConfig["RemoveRemainder"]); + else removeRemainder = false; + if (tableConfig.find("Key/Ascii") != tableConfig.end()) + scim_string_to_key_list(key_ascii_mode,tableConfig["Key/Ascii"]); + if (tableConfig.find("Key/WideAscii") != tableConfig.end()) + scim_string_to_key_list(key_wascii_mode,tableConfig["Key/WideAscii"]); + if (tableConfig.find("Key/ToggleHalfOrWide") != tableConfig.end()) + scim_string_to_key_list(key_toggle_hw,tableConfig["Key/ToggleHalfOrWide"]); + if (tableConfig.find("Key/ToggleHiraOrKata") != tableConfig.end()) + scim_string_to_key_list(key_toggle_hk,tableConfig["Key/ToggleHiraOrKata"]); + if (tableConfig.find("Hook") != tableConfig.end()) + hookp = tableConfig["Hook"]; + else hookp = ""; + +} + + + + +/*! + \fn Romkan::setPos(int p) + */ +void Romkan::setPos(int p) +{ + if (p < 0) p = 0; + else if (p > getTextLength()) p = getTextLength(); + pos = p; + buf.clear(); + rmChars.clear(); +} + + +/*! + \fn Romkan::clear() + */ +void Romkan::clear() +{ + text.clear(); + buf.clear(); + rmChars.clear(); +} + + +/*! + \fn Romkan::insert(char k) + */ +WideString Romkan::insert(char k) +{ + String s; + s = k; + if (k == 0) return text; + switch(mode) { + case ASCII: { + buf.clear(); + rmChars.clear(); + text = text.substr(0,pos) + utf8_mbstowcs(s) + text.substr(pos); + pos ++; + return text; + break; + } + case WASCII: { + buf.clear(); + rmChars.clear(); + WideString w = utf8_mbstowcs(s); + convHanZen(w,pos); + text = text.substr(0,pos) + w + text.substr(pos); + pos ++; + return text; + break; + } + case ROMA: { + buf += s; + text = text.substr(0,pos) + utf8_mbstowcs(s) + text.substr(pos); + pos ++; + return eval(); + break; + } + case KROMA: { + buf += s; + text = text.substr(0,pos) + utf8_mbstowcs(s) + text.substr(pos); + pos ++; + return eval(); + break; + } + case HROMA: { + buf += s; + text = text.substr(0,pos) + utf8_mbstowcs(s) + text.substr(pos); + pos ++; + return eval(); + break; + } + } + return text; +} + + +/*! + \fn Romkan::eval() + */ +WideString Romkan::eval() +{ + // �������롣 + + if (buf.length() == 2) { + + // n���첻�ʳ��ϡ֤�סܻҲ��Ǥ��� + // ��������ny�Ͻ����Ǥ��롣 + if (buf[0] == 'n') { + String b = "aiueoy"; + if (nnMode) b += "n"; + bool boin = false; + for(unsigned int i = 0;i < b.length();i ++) { + if (buf[1] == b[i]) boin = true; + } + if (!boin) { + WideString r; + r += convChars[KANA_N]; + if (mode == HROMA) convZenHan(r,0); + else if (mode == KROMA) convHiraKata(r); + text = text.substr(0,pos - 2) + r + text.substr(pos - 1); + buf = buf.substr(buf.length() - 1,1); + rmChars.clear(); + } + } + + // Ʊ��ʸ������ʸ��³���Ȥ���ϡ֤áסܻҲ��Ǥ��롣�첻��Ϣ�Ǥ�buf�˻ĤäƤϤ��ʤ��Ϥ��� + else if (buf[0] == buf[1]) { + WideString r; + r += convChars[KANA_XTU]; + if (mode == HROMA) convZenHan(r,0); + else if (mode == KROMA) convHiraKata(r); + text = text.substr(0,pos - 2) + r + text.substr(pos - 1); + buf = buf.substr(buf.length() - 1,1); + rmChars.clear(); + return text; + } + } + + // ��α�ơ��֥�򸡺����롣 + if (keepTable.find(buf) != keepTable.end()) return text; + // �ơ��֥�򸡺��������Ϥ��롣 + map::iterator it = RomkanTable.find(buf); + if (it != RomkanTable.end()) { + WideString r; + r += it->second; + if (mode == HROMA) convZenHan(r,0); + else if (mode == KROMA) convHiraKata(r); + text = text.substr(0,pos - buf.length()) + r + text.substr(pos); + pos = pos - buf.length() + r.length(); + buf.clear(); + rmChars.clear(); + return text; + } + if (buf.length()) { + if (removeRemainder) { + text = text.substr(0,pos - buf.length()) + text.substr(pos - buf.length() + 1); + pos --; + } + rmChars = rmChars + buf.substr(0,1); + buf = buf.substr(1); + return eval(); + } + + return text; +} + + + + +/*! + \fn Romkan::reset() + */ +void Romkan::reset() +{ + clear(); + pos = 0; + mode = ROMA; +} + +/*! + \fn PreEditor::setText(const WideString &t) + */ +void Romkan::setText(const WideString &t) +{ + text = t; + buf.clear(); + rmChars.clear(); +} + + +/*! + \fn Romkan::getText(bool hosei) + */ +WideString Romkan::getText(bool hosei) +{ + if (hosei) { + if (buf.length()) { + if (removeRemainder) { + text = text.substr(0,pos - buf.length()) + text.substr(pos); + pos -= buf.length(); + if (buf.substr(buf.length() - 1,1) == "n") { + WideString r; + r += convChars[KANA_N]; + if (mode == HROMA) convZenHan(r,0); + else if (mode ==KROMA) convHiraKata(r); + text = text.substr(0,pos) + r + text.substr(pos); + pos ++; + } + } else + if (buf.substr(buf.length() - 1,1) == "n") { + WideString r; + r += convChars[KANA_N]; + if (mode == HROMA) convZenHan(r,0); + else if (mode ==KROMA) convHiraKata(r); + text = text.substr(0,pos - 1) + r + text.substr(pos); + } + } + } + return text; +} + + +/*! + \fn Romkan::backspace() + */ +void Romkan::backspace() +{ + if (getPos() == 0) return; + text = text.substr(0,pos - 1) + text.substr(pos); + pos --; + // BS�Ͼ��Хåե���BS���륾�� + if (buf.length()) buf = buf.substr(0,buf.length() - 1); + // BS���˥Хåե���Ƭ��ʸ���������� + // ���ΰ�ʸ�������󥰥�Х��ȤǤʤ��ä������˴��� + if (pos && (!removeRemainder) && rmChars.size()) { + /* + while((pos - buf.size()) > 0) { + String s = utf8_wcstombs(text.substr(pos - (buf.length() + 1),1)); + if (s.length() == 1) { + buf = s + buf; + } else break; + }*/ + buf = rmChars + buf; + rmChars.clear(); + eval(); + return; + + } +} + + + +/*! + \fn Romkan::del() + */ +void Romkan::del() +{ + if (getPos() == getTextLength()) return; + text = text.substr(0,pos) + text.substr(pos + 1); +} + + + +/*! + \fn Romkan::hiraKata() + */ +void Romkan::hiraKata() +{ + convHiraKata(text); +} + + +/*! + \fn Romkan::kataHira() + */ +void Romkan::kataHira() +{ + convKataHira(text); +} + +/*! + \fn Romkan::toHalf() + */ +void Romkan::toHalf() +{ + setPos(convZenHan(text,getPos())); + buf.clear(); + rmChars.clear(); +} + +/*! + \fn Romkan::toWide() + */ +void Romkan::toWide() +{ + setPos(convHanZen(text,getPos())); + buf.clear(); + rmChars.clear(); +} + + + +/*! + \fn Romkan::keyEventHook(const KeyEvent &key) + */ +bool Romkan::keyEventHook(const KeyEvent &key) +{ + if (key_toggle_hw.comp(key)) { + switch (mode) { + case ASCII: { + mode = WASCII; + break; + } + case WASCII: { + mode = ASCII; + break; + } + case ROMA: { + mode = HROMA; + break; + } + case HROMA: { + mode = ROMA; + break; + } + } + return true; + } + if (key_toggle_hk.comp(key)) { + if (mode == ROMA) mode = KROMA; + else if (mode == KROMA) mode = ROMA; + return true; + } + + if ((isprint(key.code)) && ((mode == ASCII) || (mode == WASCII))) { + if ((!key.is_alt_down()) && (!key.is_control_down())) { + insert(key.get_ascii_code()); + return true; + } + } + + for(vector::iterator it = hookKey.begin();it != hookKey.end();it ++) { + if (it->comp(key)) { + text = text.substr(0,pos) + it->p + text.substr(pos); + pos += it->p.length(); + return true; + } + } + + if ((buf.length() < hookp.length()) || (!hookp.length())) return false; + else if (buf.substr(0,hookp.length()) == hookp) { + return inputEvent(key); + } + return false; +} + + +/*! + \fn Romkan::getModeName() + */ +String Romkan::getModeName() +{ + switch(mode) { + case ROMA: { + return String(_("Roma-Kana")); + break; + } + case KROMA: { + return String(_("Roma-Katakana")); + break; + } + case HROMA: { + return String(_("Half Roma-Kana")); + break; + } + case ASCII: { + return String(_("Ascii")); + break; + } + case WASCII: { + return String(_("Wide Ascii")); + break; + } + } +} + + +/*! + \fn Romkan::cancelEvent() + */ +bool Romkan::cancelEvent() +{ + if (((mode == ASCII) || (mode == WASCII)) && (asciiCancel)) { + mode = ROMA; + return true; + } + return false; +} + + +/*! + \fn Romkan::inputEvent(const KeyEvent &key) + */ +bool Romkan::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; + if (key_ascii_mode.comp(key)) { + mode = ASCII; + return true; + } + if (key_wascii_mode.comp(key)) { + mode = WASCII; + return true; + } + + if (key.get_ascii_code() && (!key.is_alt_down()) && (!key.is_control_down())) { + if ((key.get_ascii_code() == ' ') && (!getTextLength())) return false; + // ��ľ���֤��٤���� + if ((key.code == SCIM_KEY_Return) || + (key.code == SCIM_KEY_Linefeed) || + (key.code == SCIM_KEY_Tab)) return false; + insert(key.get_ascii_code()); + return true; + } + return false; +} + + +/*! + \fn Romkan::getName() + */ +String Romkan::getName() +{ + return String(_("Roma")); +} + + + + +/*! + \fn Romkan::getAttributeList() + */ +AttributeList Romkan::getAttributeList() +{ + AttributeList l; + if (buf.length()) { + Attribute a(pos - buf.length(),buf.length(),SCIM_ATTR_FOREGROUND,SCIM_RGB_COLOR(255,0,0)); + l.push_back(a); + } + return l; +} diff --git a/honoka/plugins/romkan.h b/honoka/plugins/romkan.h new file mode 100644 index 0000000..f107c56 --- /dev/null +++ b/honoka/plugins/romkan.h @@ -0,0 +1,99 @@ +/*************************************************************************** + * 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 ROMKAN_H +#define ROMKAN_H + +#define Uses_SCIM_ICONV +#define Uses_SCIM_CONFIG_BASE +#include +#include +#include +#include +#include +#include +#include "preeditor.h" + +using namespace std; +using namespace scim; + +/** +@author TAM(Teppei Tamra) +*/ +struct RomkanTableEntry { + String key; + WideString kana; +}; + +class RomkanKeyEventList : public HonokaKeyEventList +{ +public: + WideString p; +}; + + +class Romkan : public PreEditor { +public: + Romkan(ConfigPointer cfg); + + ~Romkan(); + virtual void clear(); + virtual void setPos(int p); + virtual void reset(); + virtual WideString getText(bool hosei = false); + virtual void backspace(); + virtual void del(); + virtual void hiraKata(); + virtual void kataHira(); + virtual void toWide(); + virtual void toHalf(); + virtual bool keyEventHook(const KeyEvent &key); + virtual String getModeName(); + virtual bool cancelEvent(); + virtual bool inputEvent(const KeyEvent &key); + virtual String getName(); + virtual String getPropertyName() {return String("Romkan");}; + virtual void setText(const WideString &t); + virtual AttributeList getAttributeList(); + +protected: + WideString eval(); + WideString insert(char k); + void init(); + void loadTable(const String &filename, bool inc = false); + bool string2bool(const String &s); + +protected: + String buf; + String rmChars; + String modeName; + enum inputMode {ROMA,HROMA,KROMA,ASCII,WASCII}; + inputMode mode; + bool nnMode; + bool asciiCancel; + bool removeRemainder; + HonokaKeyEventList key_ascii_mode,key_wascii_mode,key_toggle_hw,key_toggle_hk; + map RomkanTable; + set keepTable; + map tableConfig; + String hookp; + vector hookKey; +}; + +#endif diff --git a/honoka/plugins/skkdic.cpp b/honoka/plugins/skkdic.cpp new file mode 100644 index 0000000..197023a --- /dev/null +++ b/honoka/plugins/skkdic.cpp @@ -0,0 +1,139 @@ +/*************************************************************************** + * Copyright (C) 2005 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 "skkdic.h" + +SKKDic::SKKDic(String file) +{ + filename = file; + iconv.set_encoding("EUC-JP"); + init(); +} + + +SKKDic::~SKKDic() +{ +} + + + + +/*! + \fn SKKDic::init() + */ +void SKKDic::init() +{ + bool okuri = true; + FILE *f = fopen(filename.c_str(),"r"); + if (!f) return; + while(-1) { + char s[1024]; + if(fgets(s,1024,f) == NULL) break; + if (String(s) == String(";; okuri-ari entries.")) { + okuri = true; + continue; + } else if (String(s) == String(";; okuri-nasi entries.")) { + okuri = false; + continue; + } + if (String(s).length() >= 2) + if (String(s).substr(0,2) == ";;") continue; + + WideString wstr,ent; + iconv.convert(wstr,String(s)); + if (!wstr.length()) continue; + for(unsigned int i = 0;i < wstr.length();i ++) { + if (wstr.substr(i,1) == utf8_mbstowcs(String(" "))) { + ent = wstr.substr(0,i); + break; + } + } + + SKKDicEntry dic; + vector sList = parser(wstr); + for(unsigned int i = 1;i < sList.size();i ++) { + SKKDicEntryData e = annotationParser(sList[i]); + dic.data.push_back(e); + } + dic.cache = true; + dic.okuri = okuri; + dic_data.insert(pair(ent,dic)); + } + fclose(f); +} + + +/*! + \fn SKKDic::parser(const WideString data) + */ +vector SKKDic::parser(const WideString data) +{ + uint pos = 0,count = 0; + vector sList; + // "/"��split�� + while(-1) { + if ((pos + count) >= data.length()) break; + if (data.at(pos + count) == utf8_mbstowcs(String("/"))[0]) { + if (count) sList.push_back(data.substr(pos,count)); + pos += (count + 1); + count = 0; + continue; + } + count ++; + } + return sList; +} + + +/*! + \fn SKKDic::find(WideString text) + */ +const vector SKKDic::find(WideString text) +{ + vector d; + map::iterator it = dic_data.find(text); + if (it == dic_data.end()) return d; + if (it->second.cache) return it->second.data; + return d; +} + + +/*! + \fn SKKDic::annotationParser(WideString) + */ +SKKDicEntryData SKKDic::annotationParser(WideString l) +{ + SKKDicEntryData e; + if (l.length() <= 2) { + e.kouho = l; + return e; + } + for(unsigned int j = 1;j < (l.length() - 1);j ++) { + if (l.at(j) == utf8_mbstowcs(String(";"))[0]) { + e.annotation = l.substr(j + 1); + e.kouho = l.substr(0,j); + break; + } + } + if (!e.kouho.length()) e.kouho = l; + return e; + +} + diff --git a/honoka/plugins/skkdic.h b/honoka/plugins/skkdic.h new file mode 100644 index 0000000..65ccfa4 --- /dev/null +++ b/honoka/plugins/skkdic.h @@ -0,0 +1,71 @@ +/*************************************************************************** + * Copyright (C) 2005 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 SKKDIC_H +#define SKKDIC_H + +#include +#include +#include +#include +#include +#include + +#define Uses_SCIM_UTILITY +#define Uses_SCIM_ICONV + +using namespace std; +using namespace scim; + + +/** +@author TAM (Teppei Tamra) +*/ +class SKKDicEntryData { +public: + WideString annotation; + WideString kouho; +}; + +class SKKDicEntry { +public: + vector data; + bool cache; + bool okuri; +}; + +class SKKDic{ +public: + SKKDic(String file); + + ~SKKDic(); + const vector find(WideString text); + SKKDicEntryData annotationParser(WideString l); + +protected: + String filename; + IConvert iconv; + map dic_data; +protected: + void init(); + vector parser(const WideString data); +}; + +#endif diff --git a/honoka/plugins/skkdicconversion.cpp b/honoka/plugins/skkdicconversion.cpp new file mode 100644 index 0000000..8d5409c --- /dev/null +++ b/honoka/plugins/skkdicconversion.cpp @@ -0,0 +1,196 @@ +/*************************************************************************** + * Copyright (C) 2005 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 "skkdicconversion.h" + +#include + +#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(SKKDicConversion); + +SKKDicConversion::SKKDicConversion(ConfigPointer cfg) : Convertor(cfg) +{ + String file = cfg->read(String(HONOKA_SKKDIC_CONFIG_DICFILE), + String("")); + dic = new SKKDic(file); + pos = 0; +} + + +SKKDicConversion::~SKKDicConversion() +{ + delete(dic); +} + +bool SKKDicConversion::isConnected() { + return true; +} + +void SKKDicConversion::reset(){ + buns.clear(); + texts.clear(); + pos = 0; + return; +} + +void SKKDicConversion::setYomiText(WideString yomi) { + buns.clear(); + texts.clear(); + pos = 0; + buns.push_back(yomi); + return; +} + +int SKKDicConversion::ren_conversion() { + texts.push_back(buns[0]); + pos = 0; + return 1; +} + +WideString SKKDicConversion::getText() { + WideString t; + for(unsigned int i = 0;i < texts.size();i ++) { + t = t + texts[i]; + } + return t; +} + +int SKKDicConversion::setPos(int p){ + if ((p >= 0) && (p < buns.size())) pos = p; + return pos; +} + +int SKKDicConversion::getPos() { + return pos; +} + +ResultList SKKDicConversion::getResultList(int p,int kt){ + list.Yomi.clear(); + list.kouho.clear(); + list.Title = utf8_mbstowcs(String(_("lookup result"))); + //list.count = 0; + ResultEntry e; + if (kt != 0) return list; + if (p == -1) p = pos; + else if (setPos(p) != p) return list; + e.kanji = buns[pos]; + list.Yomi = buns[pos]; + list.kouho.push_back(e); + //list.count = 1; + vector es = dic->find(buns[p]); + for(unsigned int i = 0;i < es.size();i ++) { + e.kanji = es[i].kouho; + if (es[i].annotation.length()) { + e.label = es[i].kouho + utf8_mbstowcs(" (") + es[i].annotation + utf8_mbstowcs(")"); + } + list.kouho.push_back(e); + } + //list.count = list.kouho.size(); + return list; +} + + +bool SKKDicConversion::select(int p) { + if ((p < list.kouho.size()) && (p >= 0)) { + texts[pos] = list.kouho[p].kanji; + return true; + } + return false; +} + +AttributeList SKKDicConversion::getAttributeList() { + AttributeList attr; + int l = 0; + for(unsigned int i = 0;i < texts.size();i ++) { + if (pos == i) { + Attribute a(l,texts[i].length(),SCIM_ATTR_DECORATE,SCIM_ATTR_DECORATE_REVERSE); + attr.push_back(a); + } + l += texts[i].length(); + } + return attr; +} + +bool SKKDicConversion::resizeRegion(int w) { + if ((buns[pos].length() + w) < 1) return false; + if ((pos >= (buns.size() - 1)) && (w > 0)) return false; + + int s = buns[pos].length(); + WideString t; + vector ws; + for(unsigned int i = pos;i < buns.size();i ++) t = t + buns[i]; + for(unsigned int i = 0;i < pos;i ++) { + ws.push_back(buns[i]); + } + ws.push_back(t.substr(0,s + w)); + if ((s + w) < t.length()) ws.push_back(t.substr(s + w)); + buns.clear(); + texts.clear(); + buns = ws; + texts = ws; + return true; +} + +void SKKDicConversion::updateFrequency() { + return; +} + +bool SKKDicConversion::connect() { + return true; +} +void SKKDicConversion::disconnect() { + return; +} + +int SKKDicConversion::getCaretPos() { + int l = 0; + for(unsigned int i = 0;i < texts.size();i ++) { + if (pos == i) return l; + l += texts[i].length(); + } + return 0; +} + + +String SKKDicConversion::getName() +{ + return String("SKKDic"); +} + +String SKKDicConversion::getPropertyName() +{ + return getName(); +} diff --git a/honoka/plugins/skkdicconversion.h b/honoka/plugins/skkdicconversion.h new file mode 100644 index 0000000..d4c26ef --- /dev/null +++ b/honoka/plugins/skkdicconversion.h @@ -0,0 +1,75 @@ +/*************************************************************************** + * Copyright (C) 2005 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 SKKDICCONVERSION_H +#define SKKDICCONVERSION_H + +#define Uses_SCIM_CONFIG_BASE + +#include +#include +#include +#include +#include +#include +#include +#include + +#define HONOKA_SKKDIC_CONFIG_DICFILE "/IMEngine/Honoka/SKKDic/File" + +using namespace std; +using namespace scim; + +/** +@author TAM (Teppei Tamra) +*/ +class SKKDicConversion : public Convertor { +public: + SKKDicConversion(ConfigPointer cfg); + + ~SKKDicConversion(); + virtual bool isConnected(); + virtual void reset(); + virtual void setYomiText(WideString yomi); + virtual int ren_conversion(); + virtual WideString getText(); + virtual int setPos(int p); + virtual int getPos(); + virtual ResultList getResultList(int p = -1 ,int kt = 0); + virtual bool select(int p); + virtual AttributeList getAttributeList(); + virtual bool resizeRegion(int w); + virtual void updateFrequency(); + virtual bool connect(); + virtual void disconnect(); + virtual int getCaretPos(); + virtual String getName(); + virtual String getPropertyName(); + +protected: + SKKDic *dic; + vector buns; + vector texts; + ResultList list; + int pos; + +}; + +#endif diff --git a/honoka/plugins/wnnconversion.cpp b/honoka/plugins/wnnconversion.cpp new file mode 100644 index 0000000..0b39667 --- /dev/null +++ b/honoka/plugins/wnnconversion.cpp @@ -0,0 +1,539 @@ +/*************************************************************************** + * 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 "wnnconversion.h" + + +#include + +#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(WnnConversion); + +WnnConversion::WnnConversion(ConfigPointer cfg) : Convertor(cfg) +{ + // �Ȥꤢ������ᤦ���Ǥ����ޤ��� + m_iconv.set_encoding ("EUC-JP"); + pos = 0; + bunsetu = 0; + wnn = 0; + sType = Wnn4; +} + + +WnnConversion::~WnnConversion() +{ +} + + + /* w_char����EUC���Ѵ����륢�� */ +void WnnConversion::wstostr(unsigned char *e,w_char *u) { + w_char x; + for(;*u;) { + x = *u ++; + if (x & 0x8000) { + *e ++ = x >> 8; + *e ++ = x; + } else + if (x & 0x80) { + *e ++ = 0x8e; + *e ++ = x & 0xff; + } else + *e++ = x; + } + *e ++ = 0; +} + + /* EUC����w_char���Ѵ�����ʥ� */ +void WnnConversion::strtows(w_char *u,unsigned char *e) { + w_char x; + for(;*e;) { + x = *e ++; + // ���줤��ʤ��� + //if (x == 0x8e) x = 0x80 | *e ++; + if (x & 0x80) + x = ((x << 8) & 0xff00) | *e ++; + *u ++ = x; + } + *u = 0; +} + +/*! + \fn WnnConversion::connect() + */ +bool WnnConversion::connect() +{ + String host = config->read(String(HONOKA_CONFIG_JSERVER),String(HONOKA_DEFAULT_JSERVER)); + String rc = config->read(String(HONOKA_CONFIG_WNNENVRC),String(HONOKA_DEFAULT_WNNENVRC)); + String t = config->read(String(HONOKA_CONFIG_JSERVERTYPE),String(HONOKA_DEFAULT_JSERVERTYPE)); + + if (t == "Wnn6") { + sType = Wnn6; + } else if (t == "Wnn7") { + sType = Wnn7; + } else if (t == "Wnn8") { + sType = Wnn8; + } else { + sType = Wnn4; + } + + wnnConnect(String("scim-wnn"),host,rc,sType,0); +} + +/*! + \fn WnnConversion::disconnect() + */ +void WnnConversion::disconnect() +{ + wnnDisconnect(); +} + + +/*! + \fn WnnConversion::wnnConnect(String name,String host,String rc,JServerType type,int timeout) + */ +bool WnnConversion::wnnConnect(String name,String host,String rc,JServerType type,int timeout) +{ + wnn = jl_open((char *)name.c_str(),(char *)host.c_str(),(char *)rc.c_str(),wnn_error,wnn_message,timeout); + //wnn = jl_open_lang("test","localhost","jp_JP","/usr/lib/wnn7/ja_JP/wnnenvrc",wnn_error,wnn_message,10); + if (wnn == NULL) return false; + #ifdef HAVE_LIBWNN7 + // ͽ¬���Ϥ��������Ƥ����� + jl_yosoku_init(wnn); + #endif + sType = type; + return true; +} + +/*! + \fn WnnConversion::wnnDisconnect() + */ +void WnnConversion::wnnDisconnect() +{ + if (wnn != NULL) { + #ifdef HAVE_LIBWNN7 + jl_yosoku_free(wnn); + #endif + jl_close(wnn); + wnn = NULL; + } +} + + + + +/*! + \fn WnnConversion::isConnected() + */ +bool WnnConversion::isConnected() +{ + if (wnn) return true; + else (false); +} + + + + +/*! + \fn WnnConversion::wnn_message (char *s) + */ +int WnnConversion::wnn_message (char *s) +{ + + SCIM_DEBUG_IMENGINE(1) << s << "\n"; +} + +/*! + \fn WnnConversion::wnn_error (char *s) + */ +int WnnConversion::wnn_error (char *s) +{ + + SCIM_DEBUG_IMENGINE(1) << s << "\n"; +} + + + + +/*! + \fn WnnConversion::reset() + */ +void WnnConversion::reset() +{ + yomiText.clear(); + bunList.clear(); + yomiList.clear(); + text.clear(); + attr.clear(); + pos = 0; + jl_kill(wnn,0,-1); +} + + +/*! + \fn WnnConversion::setYomiText(WideString yomi) + */ +void WnnConversion::setYomiText(WideString yomi) +{ + yomiText = yomi; +} + + + +/*! + \fn WnnConversion::ren_conversion() + */ +int WnnConversion::ren_conversion() +{ + convList.Yomi.clear(); + convList.kouho.clear(); + bunList.clear(); + yomiList.clear(); + pos = 0; + w_char ws[1024]; + char c[2048]; + String y; + m_iconv.convert(y,yomiText); + strtows(ws,(unsigned char*)y.c_str()); + bunsetu = jl_fi_ren_conv(wnn,ws,0,-1,WNN_USE_ZENGO); + if (bunsetu == -1) return -1; + for(unsigned int i = 0;i < bunsetu;i ++) { + WideString w; + jl_get_kanji(wnn,i,i + 1,ws); + wstostr((unsigned char*)c,ws); + m_iconv.convert(w,c,strlen(c)); + bunList.push_back(w); + jl_get_yomi(wnn,i,i + 1,ws); + wstostr((unsigned char*)c,ws); + m_iconv.convert(w,c,strlen(c)); + yomiList.push_back(w); + } + createText(); + return bunsetu; +} + + +/*! + \fn WnnConversion::resizeRegion(int w) + */ +bool WnnConversion::resizeRegion(int w) +{ + if (w == 0) return false; + if ((yomiList[pos].length() + w) <= 0) return false; + if (((pos + 1) >= yomiList.size()) && (w > 0)) return false; + + w_char ws[1024]; + char c[2048]; + int s; + int h = WNN_NO_USE; + if (pos > 0) h = WNN_USE_MAE; + else if (pos < bunsetu - 1) h = WNN_USE_ATO; + bunsetu = jl_fi_nobi_conv(wnn,pos,yomiList[pos].length() + w,-1,h,WNN_SHO); + convList.kouho.clear(); + bunList.clear(); + yomiList.clear(); + for(unsigned int i = 0;i < bunsetu;i ++) { + WideString w; + jl_get_kanji(wnn,i,i + 1,ws); + wstostr((unsigned char*)c,ws); + m_iconv.convert(w,c,strlen(c)); + bunList.push_back(w); + jl_get_yomi(wnn,i,i + 1,ws); + wstostr((unsigned char*)c,ws); + m_iconv.convert(w,c,strlen(c)); + yomiList.push_back(w); + } + createText(); + return true; +} + + +/*! + \fn WnnConversion::createText() + */ +void WnnConversion::createText() +{ + WideString w; + caretPos = 0; + for(unsigned int i = 0;i < bunsetu;i ++) { + if (pos == i) { + caretPos = w.length(); + attr.clear(); + Attribute a(w.length(),bunList[i].length(),SCIM_ATTR_DECORATE,SCIM_ATTR_DECORATE_REVERSE); + attr.push_back(a); + } + w = w + bunList[i]; + } + text = w; +} + +/*! + \fn WnnConversion::getText() + */ +WideString WnnConversion::getText() +{ + return text; +} + + +/*! + \fn WnnConversion::getAttributeList() + */ +AttributeList WnnConversion::getAttributeList() +{ + return attr; +} + + +/*! + \fn WnnConversion::setPos(int p) + */ +int WnnConversion::setPos(int p) +{ + /*if (p >= bunsetu) p = (p % bunsetu); + else if (p < 0) p = bunsetu - (abs(p) % bunsetu);*/ + if ((p < bunsetu) && (p >= 0)) pos = p; + + //pos = p; + createText(); + return pos; +} + + +/*! + \fn WnnConversion::getPos() + */ +int WnnConversion::getPos() +{ + return pos; +} + + +/*! + \fn WnnConversion::getYosokuList(const WideString &str) + */ +ResultList WnnConversion::getYosokuList(const WideString &str) +{ + convList.Yomi = str; + convList.kouho.clear(); + //convList.count = 0; + convList.pos = 0; + convList.kType = YOSOKU; + convList.Title = utf8_mbstowcs(String(_("yosoku lookup result"))); + #ifdef HAVE_LIBWNN7 + String s; + m_iconv.convert(s,convList.Yomi); + // @todo ������mbstowcs�����ۤ����ɤ��󤫡� + char c[1024]; + strcpy(c,s.c_str()); + if (jl_yosoku_yosoku(wnn,c) != 0) return convList; + //convList.count = ykYosokuKouhoNum; + for(unsigned int i = 0;i < ykYosokuKouhoNum;i ++) { + WideString w; + m_iconv.convert(w,ykYosokuKouho[i],strlen(ykYosokuKouho[i])); + convList.kouho.push_back(ResultEntry(w)); + } + //jl_yosoku_free(wnn); + #endif + return convList; +} + + +/*! + \fn WnnConversion::getResultList(int p,int kt) + */ +ResultList WnnConversion::getResultList(int p,int kt) +{ + w_char k[1024]; + char buf[2048]; + WideString u; + convList.kouho.clear(); + convList.Yomi.clear(); + convList.pos = 0; + //convList.count = 0; + if ((sType != Wnn8) && (sType != Wnn7) && (kt != DEFAULT)) return convList; + + if (p == -1) p = pos; + //if ((p >= bunsetu) || (p < 0)) p = p % bunsetu; + if (p >= bunsetu) return convList; + pos = p; + jl_get_yomi(wnn,pos,pos + 1,k); + wstostr((unsigned char*)buf,k); + m_iconv.convert(u,buf,strlen(buf)); + convList.Yomi = u; + + // bunsetu connection control + int conn = WNN_USE_ZENGO; + if (bunsetu == 1) conn = WNN_NO_USE; + else if (pos == 0) conn = WNN_USE_ATO; + else if (pos == (bunsetu - 1)) conn = WNN_USE_MAE; + switch (kt) { + #ifdef HAVE_LIBWNN7 + case IKEIJI: { + convList.pos = jl_zenikeiji_dai(wnn,pos,pos + 1,conn,WNN_UNIQ); + convList.kType = IKEIJI; + convList.Title = utf8_mbstowcs(String(_("Ikeiji lookup result"))); + break; + } + case RENSOU: { + convList.pos = jl_zenassoc_dai(wnn,pos,pos + 1,conn,WNN_UNIQ); + convList.kType = RENSOU; + convList.Title = utf8_mbstowcs(String(_("association lookup result"))); + break; + } + #endif + default: { + convList.pos = jl_zenkouho_dai(wnn,pos,pos + 1,conn,WNN_UNIQ); + convList.kType = DEFAULT; + convList.Title = utf8_mbstowcs(String(_("lookup result"))); + break; + } + } + + // @todo be implement to ikeiji conversion using "jl_zenikeiji_dai()". + // @todo be implement to rensou conversion using "jl_zenassoc_dai()". + // @todo jl_zenkouho should change to jl_zenkouho_dai. + //convList.pos = jl_zenassoc_dai(wnn,pos,pos + 1,WNN_USE_ZENGO,WNN_UNIQ); + //convList.pos = jl_zenkouho(wnn,pos,conn,WNN_UNIQ); + if (convList.pos == -1) return convList; + int count = jl_zenkouho_suu(wnn); + + for (unsigned int i = 0;i < count; i ++) { + jl_get_zenkouho_kanji(wnn,i,k); + wstostr((unsigned char*)buf,k); + m_iconv.convert(u,buf,strlen(buf)); + convList.kouho.push_back(u); + } + select(convList.pos); + createText(); + return convList; + +} + + +/*! + \fn WnnConversion::select(int p) + */ +bool WnnConversion::select(int p) +{ + if (p > convList.count()) p = 0; + convList.pos = p; + switch(convList.kType) { + case DEFAULT: { + jl_set_jikouho_dai(wnn,p); + break; + } + case YOSOKU: { + #ifdef HAVE_LIBWNN7 + jl_yosoku_selected_cand(wnn,p); + #endif + return true; + } + default: { + break; + } + } + + bunList.at(pos) = convList.kouho.at(p).kanji; + createText(); + + return true; + +} + + + + + + +/*! + \fn WnnConversion::updateFrequency() + */ +void WnnConversion::updateFrequency() +{ + if (bunsetu) { + #ifdef HAVE_LIBWNN7 + w_char ws[1024]; + int c = jl_get_kanji(wnn,0,bunsetu,ws); + jl_yosoku_toroku(wnn,ws,c); + #endif + jl_optimize_fi(wnn,0,-1); + pretext = getText(); + } +} + + + +/*! + \fn WnnConversion::getCaretPos() + */ +int WnnConversion::getCaretPos() +{ + return caretPos; +} + + +String WnnConversion::getName() +{ + return String("Wnn"); +} + +String WnnConversion::getPropertyName() +{ + return String("Wnn"); +} + + + +/*! + \fn WnnConversion::updateYosoku(WideString text,const WideString yomi) + */ +void WnnConversion::updateYosoku(WideString text,const WideString yomi) +{ + #ifdef HAVE_LIBWNN7 + if (text == pretext) return; + reset(); + setYomiText(yomi); + ren_conversion(); + w_char ws[1024]; + char c[2048]; + String y; + m_iconv.convert(y,text); + strtows(ws,(unsigned char*)y.c_str()); + jl_yosoku_toroku(wnn,ws,text.length()); + reset(); + #endif + return; + +} diff --git a/honoka/plugins/wnnconversion.h b/honoka/plugins/wnnconversion.h new file mode 100644 index 0000000..c80ecc6 --- /dev/null +++ b/honoka/plugins/wnnconversion.h @@ -0,0 +1,110 @@ +/*************************************************************************** + * 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 WNNCONVERSION_H +#define WNNCONVERSION_H + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#define Uses_SCIM_ICONV +#include +#include +#include +#include + + + + +using namespace scim; +using namespace std; + + +/** +@author TAM(Teppei Tamra) +*/ +enum JServerType { Wnn4, Wnn6, Wnn7, Wnn8 }; + +#define DEFAULT 0 +#define IKEIJI 1 +#define RENSOU 2 +#define YOSOKU 3 + + +class WnnConversion : public Convertor { +public: + WnnConversion(ConfigPointer cfg); + + ~WnnConversion(); + virtual bool isConnected(); + virtual void reset(); + virtual void setYomiText(WideString yomi); + virtual int ren_conversion(); + virtual WideString getText(); + virtual int setPos(int p); + virtual int getPos(); + virtual ResultList getResultList(int p = -1 ,int kt = DEFAULT); + ResultList getYosokuList(const WideString &str); + virtual bool select(int p); + virtual AttributeList getAttributeList(); + virtual bool resizeRegion(int w); + virtual void updateFrequency(); + virtual bool connect(); + virtual void disconnect(); + virtual int getCaretPos(); + virtual String getName(); + virtual String getPropertyName(); + void updateYosoku(WideString text,const WideString yomi); + + +protected: + bool wnnConnect(String name,String host,String rc,JServerType type,int timeout); + void wnnDisconnect(); + void wstostr(unsigned char *e,w_char *u); + void strtows(w_char *u,unsigned char *e); + static int wnn_message (char *s); + static int wnn_error (char *s); + void createText(); + +protected: + struct wnn_buf *wnn; + String wnn_server; + String wnn_rc; + JServerType sType; + int wnn_timeout; + IConvert m_iconv; + WideString yomiText; + int pos; + int bunsetu; + int caretPos; + WideString text; + vector bunList; + vector yomiList; + AttributeList attr; + ResultList convList; + WideString pretext; + +}; + +#endif diff --git a/honoka/plugins/wnnplugin.cpp b/honoka/plugins/wnnplugin.cpp new file mode 100644 index 0000000..4accd15 --- /dev/null +++ b/honoka/plugins/wnnplugin.cpp @@ -0,0 +1,71 @@ +/*************************************************************************** + * Copyright (C) 2005 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 "wnnplugin.h" + +HonokaPluginRegister(WnnPlugin); + +WnnPlugin::WnnPlugin(ConfigPointer cfg) : HonokaMultiplePluginBase(cfg) +{ + predictor = 0; + convertor = new WnnConversion(cfg); + + bool yosoku = cfg->read(String(HONOKA_CONFIG_WNNYOSOKU),HONOKA_DEFAULT_WNNYOSOKU); + String sType = cfg->read(String(HONOKA_CONFIG_JSERVERTYPE),String(HONOKA_DEFAULT_JSERVERTYPE)); + if (yosoku && (sType == String("Wnn7"))) { + predictor = new WnnPrediction(cfg,convertor); + } +} + + +WnnPlugin::~WnnPlugin() +{ + if (predictor) delete predictor; + delete convertor; +} + +/*! + \fn WnnPlugin::getPluginInstanceAt(int p) + */ +HonokaPluginBase * WnnPlugin::getPluginInstanceAt(int p) +{ + if (p == 0) return convertor; + if ((p == 1) && predictor) return predictor; + return 0; +} + + +/*! + \fn WnnPlugin::getPluginCount() + */ +int WnnPlugin::getPluginCount() +{ + if (predictor) return 2; + return 1; +} + +/*! + \fn WnnPlugin::getName() + */ +String WnnPlugin::getName() +{ + return String("WnnPlugin"); +} + diff --git a/honoka/plugins/wnnplugin.h b/honoka/plugins/wnnplugin.h new file mode 100644 index 0000000..c793f2f --- /dev/null +++ b/honoka/plugins/wnnplugin.h @@ -0,0 +1,58 @@ +/*************************************************************************** + * Copyright (C) 2005 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 WNNPLUGIN_H +#define WNNPLUGIN_H + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +using namespace std; +using namespace scim; + + +/** +@author TAM (Teppei Tamra) +*/ +class WnnPlugin; + +class WnnPlugin : public HonokaMultiplePluginBase { +public: + WnnPlugin(ConfigPointer cfg); + + ~WnnPlugin(); + virtual HonokaPluginBase * getPluginInstanceAt(int p); + virtual int getPluginCount(); + virtual String getName(); + +protected: + WnnConversion * convertor; + WnnPrediction * predictor; +}; + +#endif diff --git a/honoka/plugins/wnnprediction.cpp b/honoka/plugins/wnnprediction.cpp new file mode 100644 index 0000000..f0632ea --- /dev/null +++ b/honoka/plugins/wnnprediction.cpp @@ -0,0 +1,109 @@ +/*************************************************************************** + * Copyright (C) 2005 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 "wnnprediction.h" + +#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 + + +WnnPrediction::WnnPrediction(ConfigPointer cfg,WnnConversion *wnn) : Predictor(cfg) +{ + convertor = wnn; +} + + +WnnPrediction::~WnnPrediction() +{ +} + + + +/*! + \fn WnnPrediction::getPredictionList(const WideString &str) + */ +ResultList WnnPrediction::getPredictionList(const WideString &str) +{ + return convertor->getYosokuList(str); +} + + +/*! + \fn WnnPrediction::disconnect() + */ +void WnnPrediction::disconnect() +{ + // disconnect��WnnConversion¦�˰�Ǥ�� + return; +} + + +/*! + \fn WnnPrediction::connect() + */ +bool WnnPrediction::connect() +{ + return convertor->connect(); +} + + +/*! + \fn WnnPrediction::isConnected() + */ +bool WnnPrediction::isConnected() +{ + return convertor->isConnected(); +} + + +/*! + \fn WnnPrediction::getPropertyName() + */ +String WnnPrediction::getPropertyName() +{ + return getName(); +} + +/*! + \fn WnnPrediction::getName() + */ +String WnnPrediction::getName() +{ + return String(_("WnnPrediction")); +} + +/*! + \fn WnnPrediction::update(const WideString str,const WideString yomi) + */ +void WnnPrediction::update(const WideString str,const WideString yomi) +{ + convertor->updateYosoku(str,yomi); + return; +} + diff --git a/honoka/plugins/wnnprediction.h b/honoka/plugins/wnnprediction.h new file mode 100644 index 0000000..9b17f93 --- /dev/null +++ b/honoka/plugins/wnnprediction.h @@ -0,0 +1,58 @@ +/*************************************************************************** + * Copyright (C) 2005 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 WNNPREDICTION_H +#define WNNPREDICTION_H + +#define Uses_SCIM_CONFIG_BASE + +#include +#include + +#include +#include +#include +#include +#include +#include + + +/** +@author TAM (Teppei Tamra) +*/ +class WnnPrediction : public Predictor { +public: + WnnPrediction(ConfigPointer cfg,WnnConversion *wnn); + + ~WnnPrediction(); + virtual ResultList getPredictionList(const WideString &str); + virtual void disconnect(); + virtual bool connect(); + virtual bool isConnected(); + virtual String getPropertyName(); + virtual String getName(); + virtual void update(const WideString str,const WideString yomi); + +protected: + WnnConversion *convertor; + +}; + +#endif diff --git a/honoka/plugins/wnnproto.h b/honoka/plugins/wnnproto.h new file mode 100644 index 0000000..c6efaa7 --- /dev/null +++ b/honoka/plugins/wnnproto.h @@ -0,0 +1,106 @@ +/*************************************************************************** + * 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 WNNPROTO_H +#define WNNPROTO_H + +#ifdef HAVE_CONFIG_H +#include +#endif + +extern "C" { + + /* ����Ū�ʤ� */ + #define w_char unsigned short + struct wnn_buf *jl_open_lang(char *,char *,char *,char *,int (*)(char *),int(*)(char *),int); + #define jl_open(a,b,c,d,e,f) jl_open_lang(a,b,NULL,c,d,e,f) + void jl_close(struct wnn_buf*); + + + + + /* conversion */ + int jl_fi_ren_conv(struct wnn_buf*,w_char*,int,int,int); + int jl_optimize_fi(struct wnn_buf*,int,int); + int jl_fi_nobi_conv(struct wnn_buf*,int,int,int,int,int); + int jl_zenkouho_suu(struct wnn_buf*); + int jl_kill(struct wnn_buf*,int,int); + int jl_zenkouho(struct wnn_buf*,int,int,int); + int jl_zenkouho_dai(struct wnn_buf*,int,int,int,int); + + int jl_set_jikouho(struct wnn_buf*,int); + int jl_set_jikouho_dai(struct wnn_buf*,int); + + #ifdef HAVE_LIBWNN7 + /* wnn6sdk is not having it.*/ + int jl_zenikeiji_dai(struct wnn_buf*,int,int,int,int); + int jl_zenassoc_dai(struct wnn_buf*,int,int,int,int); + int wnn_get_area(struct wnn_buf*,int,int,w_char*,int,int); + void jl_get_zenkouho_kanji(struct wnn_buf*,int ,w_char *,int); + #define jl_get_zenkouho_kanji(a,b,c) jl_get_zenkouho_kanji(a,b,c,512) + #define jl_get_kanji(buf,bun1,bun2,area) wnn_get_area(buf,bun1,bun2,area,1,512) + #define jl_get_yomi(buf,bun1,bun2,area) wnn_get_area(buf,bun1,bun2,area,0,512) + + // input completion for Wnn7 + extern int ykYosokuKouhoNum; + extern char **ykYosokuKouho; + extern int jl_yosoku_init(struct wnn_buf*); + extern int jl_yosoku_set_param(struct wnn_buf*,int,int,int); + extern int jl_yosoku_free(struct wnn_buf*); + extern int jl_yosoku_yosoku(struct wnn_buf*,char *); + extern int jl_yosoku_toroku(struct wnn_buf*,w_char*,short); + extern int jl_yosoku_selected_cand(struct wnn_buf*,int); + extern int jl_yosoku_delete_cand(struct wnn_buf*,int); + extern int jl_yosoku_save_datalist(struct wnn_buf*); + extern int jl_yosoku_cancel_toroku(struct wnn_buf *); + extern int jl_yosoku_ikkatsu_toroku(struct wnn_buf *,char *,int); + extern int jl_yosoku_ikkatsu_toroku_init(struct wnn_buf *); + extern int jl_yosoku_ikkatsu_toroku_end(struct wnn_buf *); + extern int jl_yosoku_toroku(struct wnn_buf *,w_char *,short); + + #else + int wnn_get_area(struct wnn_buf*,int,int,w_char*,int); + void jl_get_zenkouho_kanji(struct wnn_buf*,int ,w_char *); + #define jl_get_kanji(buf,bun1,bun2,area) wnn_get_area(buf,bun1,bun2,area,1) + #define jl_get_yomi(buf,bun1,bun2,area) wnn_get_area(buf,bun1,bun2,area,0) + #endif + + + #define WNN_NO_USE 0 + #define WNN_USE_MAE 1 + #define WNN_USE_ATO 2 + #define WNN_USE_ZENGO (WNN_USE_MAE | WNN_USE_ATO) + + #define WNN_UNIQ_KNJ 2 + #define WNN_UNIQ 1 + #define WNN_NO_UNIQ 0 + + #define WNN_NO_CREATE 0 + #define WNN_CREATE (-1) + + #define WNN_SHO 0 + #define WNN_DAI 1 + + +} + +#endif + diff --git a/honoka/src/Makefile.am b/honoka/src/Makefile.am index 4aa287f..d0795cd 100644 --- a/honoka/src/Makefile.am +++ b/honoka/src/Makefile.am @@ -26,9 +26,8 @@ -DHONOKA_ICON_FILE=\"@SCIM_ICONDIR@/honoka.png\" \ -DHONOKA_PLUGINDIR=\"@SCIM_MODULEDIR@/honoka\" -noinst_HEADERS = honoka_imengine.h wnnproto.h romkan.h romkan_table.h \ - wnnconversion.h honoka_def.h kanainput.h anthyconversion.h multiconvertor.h skkdic.h \ - skkdicconversion.h wnnplugin.h wnnprediction.h honoka_plugin_def.h +noinst_HEADERS = honoka_imengine.h \ + multiconvertor.h moduledir = @SCIM_MODULEDIR@/IMEngine module_LTLIBRARIES = honoka.la @@ -64,44 +63,4 @@ @INTLLIBS@ \ @SCIM_LIBS@ -if WNNCONVERSION -WNN_PLUGIN = plugin-wnn.la -endif - -if ANTHYCONVERSION -ANTHY_PLUGIN = plugin-anthy.la -endif - -plugindir = @SCIM_MODULEDIR@/honoka -plugin_LTLIBRARIES = $(ANTHY_PLUGIN) $(WNN_PLUGIN) plugin-skkdic.la plugin-romkan.la plugin-kanainput.la - -plugin_anthy_la_SOURCES = anthyconversion.cpp -plugin_anthy_la_CFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ -plugin_anthy_la_CXXFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ -plugin_anthy_la_LDFLAGS = -avoid-version -module -rpath $(plugindir) @LIBTOOL_EXPORT_OPTIONS@ @INTLLIBS@ @SCIM_LIBS@ @ANTHY_LIBS@ -plugin_anthy_la_LIBADD = $(top_builddir)/libhonoka/libhonoka_plugin.la - -plugin_wnn_la_SOURCES = wnnconversion.cpp wnnplugin.cpp wnnprediction.cpp -plugin_wnn_la_CFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ -plugin_wnn_la_CXXFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ -plugin_wnn_la_LDFLAGS = -avoid-version -module -rpath $(plugindir) @LIBTOOL_EXPORT_OPTIONS@ @INTLLIBS@ @SCIM_LIBS@ @WNN_LIBS@ -plugin_wnn_la_LIBADD = $(top_builddir)/libhonoka/libhonoka_plugin.la - -plugin_skkdic_la_SOURCES = skkdic.cpp skkdicconversion.cpp -plugin_skkdic_la_CFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ -plugin_skkdic_la_CXXFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ -plugin_skkdic_la_LDFLAGS = -avoid-version -module -rpath $(plugindir) @LIBTOOL_EXPORT_OPTIONS@ @INTLLIBS@ @SCIM_LIBS@ @ANTHY_LIBS@ -plugin_skkdic_la_LIBADD = $(top_builddir)/libhonoka/libhonoka_plugin.la - -plugin_romkan_la_SOURCES = romkan.cpp -plugin_romkan_la_CFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ -plugin_romkan_la_CXXFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ -plugin_romkan_la_LDFLAGS = -avoid-version -module -rpath $(plugindir) @LIBTOOL_EXPORT_OPTIONS@ @INTLLIBS@ @SCIM_LIBS@ -plugin_romkan_la_LIBADD = $(top_builddir)/libhonoka/libhonoka_plugin.la - -plugin_kanainput_la_SOURCES = kanainput.cpp -plugin_kanainput_la_CFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ -plugin_kanainput_la_CXXFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ -plugin_kanainput_la_LDFLAGS = -avoid-version -module -rpath $(plugindir) @LIBTOOL_EXPORT_OPTIONS@ @INTLLIBS@ @SCIM_LIBS@ -plugin_kanainput_la_LIBADD = $(top_builddir)/libhonoka/libhonoka_plugin.la diff --git a/honoka/src/anthyconversion.cpp b/honoka/src/anthyconversion.cpp deleted file mode 100644 index e26b31d..0000000 --- a/honoka/src/anthyconversion.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/*************************************************************************** - * 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 "anthyconversion.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(AnthyConversion); - - -AnthyConversion::AnthyConversion(ConfigPointer cfg) : Convertor(cfg) -{ - m_iconv.set_encoding ("EUC-JP"); - pos = 0; - anthy_init(); - context = anthy_create_context(); -} - - -AnthyConversion::~AnthyConversion() -{ -} - -bool AnthyConversion::isConnected() { - return true; -} - -void AnthyConversion::reset(){ - anthy_release_context(context); - anthy_init(); - context = anthy_create_context(); - return; -} - -void AnthyConversion::setYomiText(WideString yomi) { - yomiText = yomi; -} - -int AnthyConversion::ren_conversion() { - String y; - anthy_reset_context(context); - m_iconv.convert(y,yomiText); - anthy_set_string(context,y.c_str()); - struct anthy_conv_stat stat; - anthy_get_stat(context,&stat); - pos = 0; - buildResult(); - - return stat.nr_segment; -} - -WideString AnthyConversion::getText() { - WideString text; - for(unsigned int i = 0;i < convResult.size();i ++) { - text += convResult[i].kouho[convResult[i].pos].kanji; - } - return text; -} - -int AnthyConversion::setPos(int p){ - if ((p < convResult.size()) && (p >= 0)) pos = p; - return pos; -} - -int AnthyConversion::getPos() { - return pos; -} - -ResultList AnthyConversion::getResultList(int p,int kt){ - if (p == -1) p = pos; - if (p >= convResult.size()) return ResultList(); - if ((kt != 0) || (p >= convResult.size())) return ResultList(); - setPos(p); - return convResult[p]; -} - -bool AnthyConversion::select(int p) { - if (p < convResult[pos].count()) { - convResult[pos].pos = p; - } -} - -AttributeList AnthyConversion::getAttributeList() { - AttributeList attr; - int l = 0; - for(unsigned int i = 0;i < convResult.size();i ++) { - if (pos == i) { - Attribute a(l,convResult[i].kouho[convResult[i].pos].kanji.length(),SCIM_ATTR_DECORATE,SCIM_ATTR_DECORATE_REVERSE); - attr.push_back(a); - } - l += convResult[i].kouho[convResult[i].pos].kanji.length(); - } - return attr; -} - -bool AnthyConversion::resizeRegion(int w) { - //if ((convResult[pos].kouho[convResult[pos].pos].length() + w) < 1) return false; - if ((convResult[pos].Yomi.length() + w) < 1) return false; - if ((pos >= (convResult.size() - 1)) && (w > 0)) return false; - anthy_resize_segment(context,pos,w); - buildResult(); - return true; -} - -void AnthyConversion::updateFrequency() { - for(unsigned int i = 0;i < convResult.size();i ++) { - anthy_commit_segment(context,i,convResult[i].pos); - } - return; -} - -bool AnthyConversion::connect() { - return true; -} -void AnthyConversion::disconnect() { - return; -} - -int AnthyConversion::getCaretPos() { - int l = 0; - for(unsigned int i = 0;i < convResult.size();i ++) { - if (pos == i) return l; - l += convResult[i].kouho[convResult[i].pos].kanji.length(); - } - return 0; -} - -void AnthyConversion::buildResult() { - struct anthy_conv_stat stat; - anthy_get_stat(context,&stat); - int slen = 0; - convResult.clear(); - for(int i = 0;i < stat.nr_segment;i ++) { - ResultList l; - l.kType = 0; - l.Title = utf8_mbstowcs(String(_("lookup result"))); - struct anthy_segment_stat sstat; - anthy_get_segment_stat(context,i,&sstat); - //l.count = sstat.nr_candidate; - l.Yomi = yomiText.substr(slen,sstat.seg_len); - slen += sstat.seg_len; - l.pos = 0; - for(int j = 0;j < sstat.nr_candidate;j ++) { - char res[256]; - int c = anthy_get_segment(context,i,j,0,0); - if (c > 255) c = 255; - anthy_get_segment(context,i,j,res,c + 1); - WideString w; - m_iconv.convert(w,String(res)); - l.kouho.push_back(w); - } - convResult.push_back(l); - } -} - -String AnthyConversion::getName() -{ - return String("Anthy"); -} - -String AnthyConversion::getPropertyName() -{ - return String("Anthy"); -} - - diff --git a/honoka/src/anthyconversion.h b/honoka/src/anthyconversion.h deleted file mode 100644 index 5fe04d7..0000000 --- a/honoka/src/anthyconversion.h +++ /dev/null @@ -1,76 +0,0 @@ -/*************************************************************************** - * 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 ANTHYCONVERSION_H -#define ANTHYCONVERSION_H - -#define Uses_SCIM_CONFIG_BASE - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; -using namespace scim; - -/** -@author TAM (Teppei Tamra) -*/ -class AnthyConversion : public Convertor { -public: - AnthyConversion(ConfigPointer cfg); - - ~AnthyConversion(); - virtual bool isConnected(); - virtual void reset(); - virtual void setYomiText(WideString yomi); - virtual int ren_conversion(); - virtual WideString getText(); - virtual int setPos(int p); - virtual int getPos(); - virtual ResultList getResultList(int p = -1 ,int kt = 0); - virtual bool select(int p); - virtual AttributeList getAttributeList(); - virtual bool resizeRegion(int w); - virtual void updateFrequency(); - virtual bool connect(); - virtual void disconnect(); - virtual int getCaretPos(); - virtual String getName(); - virtual String getPropertyName(); - - -protected: - void buildResult(); -protected: - anthy_context_t context; - IConvert m_iconv; - WideString yomiText; - vector convResult; - int pos; - -}; - - -#endif diff --git a/honoka/src/honoka_imengine_setup.cpp b/honoka/src/honoka_imengine_setup.cpp index 8986678..51b3c89 100644 --- a/honoka/src/honoka_imengine_setup.cpp +++ b/honoka/src/honoka_imengine_setup.cpp @@ -35,7 +35,7 @@ #include #include #include "honoka_def.h" -#include "honoka_plugin_def.h" +#include "../plugins/honoka_plugin_def.h" #ifdef HAVE_GETTEXT #include diff --git a/honoka/src/honoka_plugin_def.h b/honoka/src/honoka_plugin_def.h deleted file mode 100644 index f990ffa..0000000 --- a/honoka/src/honoka_plugin_def.h +++ /dev/null @@ -1,52 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 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 HONOKA_PLUGIN_DEF_H -#define HONOKA_PLUGIN_DEF_H - -#define HONOKA_CONFIG_JSERVERTYPE "/IMEngine/Honoka/Wnn/JServerType" -#ifdef HAVE_LIBWNN7 - #define HONOKA_DEFAULT_JSERVERTYPE "Wnn7" -#else - #define HONOKA_DEFAULT_JSERVERTYPE "Wnn4" -#endif - -#define HONOKA_CONFIG_JSERVER "/IMEngine/Honoka/Wnn/JServer" -#define HONOKA_DEFAULT_JSERVER "localhost" -#define HONOKA_CONFIG_WNNENVRC "/IMEngine/Honoka/Wnn/Wnnenvrc" -#define HONOKA_DEFAULT_WNNENVRC "/usr/lib/wnn7/ja_JP/wnnenvrc" - -#define HONOKA_CONFIG_WNNYOSOKU "/IMEngine/Honoka/Wnn/Yosoku" -#ifdef HAVE_LIBWNN7 - #define HONOKA_DEFAULT_WNNYOSOKU true -#else - #define HONOKA_DEFAULT_WNNYOSOKU false -#endif - - -// Romkan - -#define HONOKA_CONFIG_ROMKAN_TABLE_FILE "/IMEngine/Honoka/Romkan/TableFile" -#define HONOKA_DEFAULT_ROMKAN_TABLE_FILE "honoka-def.rkt" - -// KanaInput -#define HONOKA_CONFIG_KANAINPUT_FAKEKANA "/IMEngine/Honoka/KanaInput/FakeKanaKey" -#define HONOKA_DEFAULT_KANAINPUT_FAKEKANA true - -#endif diff --git a/honoka/src/kanainput.cpp b/honoka/src/kanainput.cpp deleted file mode 100644 index ee2e2b1..0000000 --- a/honoka/src/kanainput.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/*************************************************************************** - * 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" -#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(KanaInput); - -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) -{ - fakeKanaInput = cfg->read(HONOKA_CONFIG_KANAINPUT_FAKEKANA,HONOKA_DEFAULT_KANAINPUT_FAKEKANA); -} - - -KanaInput::~KanaInput() -{ -} - -/*! - \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.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; - - 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/honoka/src/kanainput.h b/honoka/src/kanainput.h deleted file mode 100644 index fb7f70e..0000000 --- a/honoka/src/kanainput.h +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************** - * 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(); - virtual String getPropertyName() {return String("KanaInput");}; - -protected: - bool fakeKanaInput; -}; - -#endif diff --git a/honoka/src/romkan.cpp b/honoka/src/romkan.cpp deleted file mode 100644 index 138bb83..0000000 --- a/honoka/src/romkan.cpp +++ /dev/null @@ -1,632 +0,0 @@ -/*************************************************************************** - * 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 "romkan.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(Romkan); - -Romkan::Romkan(ConfigPointer cfg) : PreEditor(cfg) -{ - reset(); - iconvert.set_encoding ("EUC-JP"); - mode = ROMA; - init(); -} - - -Romkan::~Romkan() -{ -} - - -/*! - \fn Romkan::loadTable(const String &filename, bool inc) - */ -void Romkan::loadTable(const String &filename, bool inc) -{ - FILE *f = fopen(filename.c_str(),"r"); - if (!f) { - #ifdef HONOKA_DATADIR - String fn = HONOKA_DATADIR; - fn += "/" + filename; - f = fopen(fn.c_str(),"r"); - if (!f) return; - #else - return; - #endif - } - - while(-1) { - char s[256]; - if(fgets(s,256,f) == NULL) break; - String k,r; - unsigned int i = 0; - bool ex = false; - for(;s[i];i ++) { - if (s[i] == ' ') { - if (k.size()) break; - else continue; - } - if (s[i] == '\n') break; - if ((s[i] == '!') || (s[i] == '$') ||(s[i] == '%')) { - if (!k.size()) ex = true; - } - if (s[i] == '#') break; - if ((s[i] == '\\') && (s[i + 1] != 0)) { - i ++; - } - k += s[i]; - } - if ((!k.size()) || (s[i] == '#')) continue; - if (s[i] != 0) { - i ++; - for(;s[i];i ++) { - if ((s[i] == '#') || (s[i] == '\n')) break; - if (s[i] == ' ') { - if (r.size()) break; - else continue; - } - if ((s[i] == '\\') && (s[i + 1] != 0)) { - i ++; - } - r += s[i]; - } - } - if (ex && (k[0] == '%')) { - loadTable(k.substr(1),true); - continue; - } - if ((k[0] == '$') && (!inc) && ex) { - tableConfig.insert(pair(k.substr(1),r)); - continue; - } - if ((k[0] == '!') && (!inc) && ex) { - RomkanKeyEventList kev; - scim_string_to_key_list(kev,k.substr(1)); - kev.p = utf8_mbstowcs(r); - hookKey.push_back(kev); - continue; - } - if (!r.size()) continue; - RomkanTable.insert(pair(k,utf8_mbstowcs(r))); - - for(unsigned int j = k.length();j > 1;j --) { - String keep = k.substr(0,j - 1); - if ((keepTable.find(keep) == keepTable.end()) && (RomkanTable.find(keep) == RomkanTable.end())) { - keepTable.insert(keep); - } - } - } - fclose(f); - -} - - -/*! - \fn Romkan::string2bool(const String &s) - */ -bool Romkan::string2bool(const String &s) -{ - if ((s == "FALSE") || (s == "false") || (s == "False") || (s == "0") || (!s.size())) return false; - else return true; -} - - -/*! - \fn Romkan::init() - */ -void Romkan::init() -{ - RomkanTable.clear(); - keepTable.clear(); - tableConfig.clear(); - - String rk_table = config->read(HONOKA_CONFIG_ROMKAN_TABLE_FILE,String(HONOKA_DEFAULT_ROMKAN_TABLE_FILE)); - - if (rk_table.size()) { - loadTable(rk_table); - } - - if (tableConfig.find("nnMode") != tableConfig.end()) - nnMode = string2bool(tableConfig["nnMode"]); - else nnMode = false; - if (tableConfig.find("AsciiModeCancel") != tableConfig.end()) - asciiCancel = string2bool(tableConfig["AsciiModeCancel"]); - else asciiCancel = true; - if (tableConfig.find("RemoveRemainder") != tableConfig.end()) - removeRemainder = string2bool(tableConfig["RemoveRemainder"]); - else removeRemainder = false; - if (tableConfig.find("Key/Ascii") != tableConfig.end()) - scim_string_to_key_list(key_ascii_mode,tableConfig["Key/Ascii"]); - if (tableConfig.find("Key/WideAscii") != tableConfig.end()) - scim_string_to_key_list(key_wascii_mode,tableConfig["Key/WideAscii"]); - if (tableConfig.find("Key/ToggleHalfOrWide") != tableConfig.end()) - scim_string_to_key_list(key_toggle_hw,tableConfig["Key/ToggleHalfOrWide"]); - if (tableConfig.find("Key/ToggleHiraOrKata") != tableConfig.end()) - scim_string_to_key_list(key_toggle_hk,tableConfig["Key/ToggleHiraOrKata"]); - if (tableConfig.find("Hook") != tableConfig.end()) - hookp = tableConfig["Hook"]; - else hookp = ""; - -} - - - - -/*! - \fn Romkan::setPos(int p) - */ -void Romkan::setPos(int p) -{ - if (p < 0) p = 0; - else if (p > getTextLength()) p = getTextLength(); - pos = p; - buf.clear(); - rmChars.clear(); -} - - -/*! - \fn Romkan::clear() - */ -void Romkan::clear() -{ - text.clear(); - buf.clear(); - rmChars.clear(); -} - - -/*! - \fn Romkan::insert(char k) - */ -WideString Romkan::insert(char k) -{ - String s; - s = k; - if (k == 0) return text; - switch(mode) { - case ASCII: { - buf.clear(); - rmChars.clear(); - text = text.substr(0,pos) + utf8_mbstowcs(s) + text.substr(pos); - pos ++; - return text; - break; - } - case WASCII: { - buf.clear(); - rmChars.clear(); - WideString w = utf8_mbstowcs(s); - convHanZen(w,pos); - text = text.substr(0,pos) + w + text.substr(pos); - pos ++; - return text; - break; - } - case ROMA: { - buf += s; - text = text.substr(0,pos) + utf8_mbstowcs(s) + text.substr(pos); - pos ++; - return eval(); - break; - } - case KROMA: { - buf += s; - text = text.substr(0,pos) + utf8_mbstowcs(s) + text.substr(pos); - pos ++; - return eval(); - break; - } - case HROMA: { - buf += s; - text = text.substr(0,pos) + utf8_mbstowcs(s) + text.substr(pos); - pos ++; - return eval(); - break; - } - } - return text; -} - - -/*! - \fn Romkan::eval() - */ -WideString Romkan::eval() -{ - // �������롣 - - if (buf.length() == 2) { - - // n���첻�ʳ��ϡ֤�סܻҲ��Ǥ��� - // ��������ny�Ͻ����Ǥ��롣 - if (buf[0] == 'n') { - String b = "aiueoy"; - if (nnMode) b += "n"; - bool boin = false; - for(unsigned int i = 0;i < b.length();i ++) { - if (buf[1] == b[i]) boin = true; - } - if (!boin) { - WideString r; - r += convChars[KANA_N]; - if (mode == HROMA) convZenHan(r,0); - else if (mode == KROMA) convHiraKata(r); - text = text.substr(0,pos - 2) + r + text.substr(pos - 1); - buf = buf.substr(buf.length() - 1,1); - rmChars.clear(); - } - } - - // Ʊ��ʸ������ʸ��³���Ȥ���ϡ֤áסܻҲ��Ǥ��롣�첻��Ϣ�Ǥ�buf�˻ĤäƤϤ��ʤ��Ϥ��� - else if (buf[0] == buf[1]) { - WideString r; - r += convChars[KANA_XTU]; - if (mode == HROMA) convZenHan(r,0); - else if (mode == KROMA) convHiraKata(r); - text = text.substr(0,pos - 2) + r + text.substr(pos - 1); - buf = buf.substr(buf.length() - 1,1); - rmChars.clear(); - return text; - } - } - - // ��α�ơ��֥�򸡺����롣 - if (keepTable.find(buf) != keepTable.end()) return text; - // �ơ��֥�򸡺��������Ϥ��롣 - map::iterator it = RomkanTable.find(buf); - if (it != RomkanTable.end()) { - WideString r; - r += it->second; - if (mode == HROMA) convZenHan(r,0); - else if (mode == KROMA) convHiraKata(r); - text = text.substr(0,pos - buf.length()) + r + text.substr(pos); - pos = pos - buf.length() + r.length(); - buf.clear(); - rmChars.clear(); - return text; - } - if (buf.length()) { - if (removeRemainder) { - text = text.substr(0,pos - buf.length()) + text.substr(pos - buf.length() + 1); - pos --; - } - rmChars = rmChars + buf.substr(0,1); - buf = buf.substr(1); - return eval(); - } - - return text; -} - - - - -/*! - \fn Romkan::reset() - */ -void Romkan::reset() -{ - clear(); - pos = 0; - mode = ROMA; -} - -/*! - \fn PreEditor::setText(const WideString &t) - */ -void Romkan::setText(const WideString &t) -{ - text = t; - buf.clear(); - rmChars.clear(); -} - - -/*! - \fn Romkan::getText(bool hosei) - */ -WideString Romkan::getText(bool hosei) -{ - if (hosei) { - if (buf.length()) { - if (removeRemainder) { - text = text.substr(0,pos - buf.length()) + text.substr(pos); - pos -= buf.length(); - if (buf.substr(buf.length() - 1,1) == "n") { - WideString r; - r += convChars[KANA_N]; - if (mode == HROMA) convZenHan(r,0); - else if (mode ==KROMA) convHiraKata(r); - text = text.substr(0,pos) + r + text.substr(pos); - pos ++; - } - } else - if (buf.substr(buf.length() - 1,1) == "n") { - WideString r; - r += convChars[KANA_N]; - if (mode == HROMA) convZenHan(r,0); - else if (mode ==KROMA) convHiraKata(r); - text = text.substr(0,pos - 1) + r + text.substr(pos); - } - } - } - return text; -} - - -/*! - \fn Romkan::backspace() - */ -void Romkan::backspace() -{ - if (getPos() == 0) return; - text = text.substr(0,pos - 1) + text.substr(pos); - pos --; - // BS�Ͼ��Хåե���BS���륾�� - if (buf.length()) buf = buf.substr(0,buf.length() - 1); - // BS���˥Хåե���Ƭ��ʸ���������� - // ���ΰ�ʸ�������󥰥�Х��ȤǤʤ��ä������˴��� - if (pos && (!removeRemainder) && rmChars.size()) { - /* - while((pos - buf.size()) > 0) { - String s = utf8_wcstombs(text.substr(pos - (buf.length() + 1),1)); - if (s.length() == 1) { - buf = s + buf; - } else break; - }*/ - buf = rmChars + buf; - rmChars.clear(); - eval(); - return; - - } -} - - - -/*! - \fn Romkan::del() - */ -void Romkan::del() -{ - if (getPos() == getTextLength()) return; - text = text.substr(0,pos) + text.substr(pos + 1); -} - - - -/*! - \fn Romkan::hiraKata() - */ -void Romkan::hiraKata() -{ - convHiraKata(text); -} - - -/*! - \fn Romkan::kataHira() - */ -void Romkan::kataHira() -{ - convKataHira(text); -} - -/*! - \fn Romkan::toHalf() - */ -void Romkan::toHalf() -{ - setPos(convZenHan(text,getPos())); - buf.clear(); - rmChars.clear(); -} - -/*! - \fn Romkan::toWide() - */ -void Romkan::toWide() -{ - setPos(convHanZen(text,getPos())); - buf.clear(); - rmChars.clear(); -} - - - -/*! - \fn Romkan::keyEventHook(const KeyEvent &key) - */ -bool Romkan::keyEventHook(const KeyEvent &key) -{ - if (key_toggle_hw.comp(key)) { - switch (mode) { - case ASCII: { - mode = WASCII; - break; - } - case WASCII: { - mode = ASCII; - break; - } - case ROMA: { - mode = HROMA; - break; - } - case HROMA: { - mode = ROMA; - break; - } - } - return true; - } - if (key_toggle_hk.comp(key)) { - if (mode == ROMA) mode = KROMA; - else if (mode == KROMA) mode = ROMA; - return true; - } - - if ((isprint(key.code)) && ((mode == ASCII) || (mode == WASCII))) { - if ((!key.is_alt_down()) && (!key.is_control_down())) { - insert(key.get_ascii_code()); - return true; - } - } - - for(vector::iterator it = hookKey.begin();it != hookKey.end();it ++) { - if (it->comp(key)) { - text = text.substr(0,pos) + it->p + text.substr(pos); - pos += it->p.length(); - return true; - } - } - - if ((buf.length() < hookp.length()) || (!hookp.length())) return false; - else if (buf.substr(0,hookp.length()) == hookp) { - return inputEvent(key); - } - return false; -} - - -/*! - \fn Romkan::getModeName() - */ -String Romkan::getModeName() -{ - switch(mode) { - case ROMA: { - return String(_("Roma-Kana")); - break; - } - case KROMA: { - return String(_("Roma-Katakana")); - break; - } - case HROMA: { - return String(_("Half Roma-Kana")); - break; - } - case ASCII: { - return String(_("Ascii")); - break; - } - case WASCII: { - return String(_("Wide Ascii")); - break; - } - } -} - - -/*! - \fn Romkan::cancelEvent() - */ -bool Romkan::cancelEvent() -{ - if (((mode == ASCII) || (mode == WASCII)) && (asciiCancel)) { - mode = ROMA; - return true; - } - return false; -} - - -/*! - \fn Romkan::inputEvent(const KeyEvent &key) - */ -bool Romkan::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; - if (key_ascii_mode.comp(key)) { - mode = ASCII; - return true; - } - if (key_wascii_mode.comp(key)) { - mode = WASCII; - return true; - } - - if (key.get_ascii_code() && (!key.is_alt_down()) && (!key.is_control_down())) { - if ((key.get_ascii_code() == ' ') && (!getTextLength())) return false; - // ��ľ���֤��٤���� - if ((key.code == SCIM_KEY_Return) || - (key.code == SCIM_KEY_Linefeed) || - (key.code == SCIM_KEY_Tab)) return false; - insert(key.get_ascii_code()); - return true; - } - return false; -} - - -/*! - \fn Romkan::getName() - */ -String Romkan::getName() -{ - return String(_("Roma")); -} - - - - -/*! - \fn Romkan::getAttributeList() - */ -AttributeList Romkan::getAttributeList() -{ - AttributeList l; - if (buf.length()) { - Attribute a(pos - buf.length(),buf.length(),SCIM_ATTR_FOREGROUND,SCIM_RGB_COLOR(255,0,0)); - l.push_back(a); - } - return l; -} diff --git a/honoka/src/romkan.h b/honoka/src/romkan.h deleted file mode 100644 index f107c56..0000000 --- a/honoka/src/romkan.h +++ /dev/null @@ -1,99 +0,0 @@ -/*************************************************************************** - * 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 ROMKAN_H -#define ROMKAN_H - -#define Uses_SCIM_ICONV -#define Uses_SCIM_CONFIG_BASE -#include -#include -#include -#include -#include -#include -#include "preeditor.h" - -using namespace std; -using namespace scim; - -/** -@author TAM(Teppei Tamra) -*/ -struct RomkanTableEntry { - String key; - WideString kana; -}; - -class RomkanKeyEventList : public HonokaKeyEventList -{ -public: - WideString p; -}; - - -class Romkan : public PreEditor { -public: - Romkan(ConfigPointer cfg); - - ~Romkan(); - virtual void clear(); - virtual void setPos(int p); - virtual void reset(); - virtual WideString getText(bool hosei = false); - virtual void backspace(); - virtual void del(); - virtual void hiraKata(); - virtual void kataHira(); - virtual void toWide(); - virtual void toHalf(); - virtual bool keyEventHook(const KeyEvent &key); - virtual String getModeName(); - virtual bool cancelEvent(); - virtual bool inputEvent(const KeyEvent &key); - virtual String getName(); - virtual String getPropertyName() {return String("Romkan");}; - virtual void setText(const WideString &t); - virtual AttributeList getAttributeList(); - -protected: - WideString eval(); - WideString insert(char k); - void init(); - void loadTable(const String &filename, bool inc = false); - bool string2bool(const String &s); - -protected: - String buf; - String rmChars; - String modeName; - enum inputMode {ROMA,HROMA,KROMA,ASCII,WASCII}; - inputMode mode; - bool nnMode; - bool asciiCancel; - bool removeRemainder; - HonokaKeyEventList key_ascii_mode,key_wascii_mode,key_toggle_hw,key_toggle_hk; - map RomkanTable; - set keepTable; - map tableConfig; - String hookp; - vector hookKey; -}; - -#endif diff --git a/honoka/src/skkdic.cpp b/honoka/src/skkdic.cpp deleted file mode 100644 index 197023a..0000000 --- a/honoka/src/skkdic.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 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 "skkdic.h" - -SKKDic::SKKDic(String file) -{ - filename = file; - iconv.set_encoding("EUC-JP"); - init(); -} - - -SKKDic::~SKKDic() -{ -} - - - - -/*! - \fn SKKDic::init() - */ -void SKKDic::init() -{ - bool okuri = true; - FILE *f = fopen(filename.c_str(),"r"); - if (!f) return; - while(-1) { - char s[1024]; - if(fgets(s,1024,f) == NULL) break; - if (String(s) == String(";; okuri-ari entries.")) { - okuri = true; - continue; - } else if (String(s) == String(";; okuri-nasi entries.")) { - okuri = false; - continue; - } - if (String(s).length() >= 2) - if (String(s).substr(0,2) == ";;") continue; - - WideString wstr,ent; - iconv.convert(wstr,String(s)); - if (!wstr.length()) continue; - for(unsigned int i = 0;i < wstr.length();i ++) { - if (wstr.substr(i,1) == utf8_mbstowcs(String(" "))) { - ent = wstr.substr(0,i); - break; - } - } - - SKKDicEntry dic; - vector sList = parser(wstr); - for(unsigned int i = 1;i < sList.size();i ++) { - SKKDicEntryData e = annotationParser(sList[i]); - dic.data.push_back(e); - } - dic.cache = true; - dic.okuri = okuri; - dic_data.insert(pair(ent,dic)); - } - fclose(f); -} - - -/*! - \fn SKKDic::parser(const WideString data) - */ -vector SKKDic::parser(const WideString data) -{ - uint pos = 0,count = 0; - vector sList; - // "/"��split�� - while(-1) { - if ((pos + count) >= data.length()) break; - if (data.at(pos + count) == utf8_mbstowcs(String("/"))[0]) { - if (count) sList.push_back(data.substr(pos,count)); - pos += (count + 1); - count = 0; - continue; - } - count ++; - } - return sList; -} - - -/*! - \fn SKKDic::find(WideString text) - */ -const vector SKKDic::find(WideString text) -{ - vector d; - map::iterator it = dic_data.find(text); - if (it == dic_data.end()) return d; - if (it->second.cache) return it->second.data; - return d; -} - - -/*! - \fn SKKDic::annotationParser(WideString) - */ -SKKDicEntryData SKKDic::annotationParser(WideString l) -{ - SKKDicEntryData e; - if (l.length() <= 2) { - e.kouho = l; - return e; - } - for(unsigned int j = 1;j < (l.length() - 1);j ++) { - if (l.at(j) == utf8_mbstowcs(String(";"))[0]) { - e.annotation = l.substr(j + 1); - e.kouho = l.substr(0,j); - break; - } - } - if (!e.kouho.length()) e.kouho = l; - return e; - -} - diff --git a/honoka/src/skkdic.h b/honoka/src/skkdic.h deleted file mode 100644 index 65ccfa4..0000000 --- a/honoka/src/skkdic.h +++ /dev/null @@ -1,71 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 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 SKKDIC_H -#define SKKDIC_H - -#include -#include -#include -#include -#include -#include - -#define Uses_SCIM_UTILITY -#define Uses_SCIM_ICONV - -using namespace std; -using namespace scim; - - -/** -@author TAM (Teppei Tamra) -*/ -class SKKDicEntryData { -public: - WideString annotation; - WideString kouho; -}; - -class SKKDicEntry { -public: - vector data; - bool cache; - bool okuri; -}; - -class SKKDic{ -public: - SKKDic(String file); - - ~SKKDic(); - const vector find(WideString text); - SKKDicEntryData annotationParser(WideString l); - -protected: - String filename; - IConvert iconv; - map dic_data; -protected: - void init(); - vector parser(const WideString data); -}; - -#endif diff --git a/honoka/src/skkdicconversion.cpp b/honoka/src/skkdicconversion.cpp deleted file mode 100644 index 8d5409c..0000000 --- a/honoka/src/skkdicconversion.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 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 "skkdicconversion.h" - -#include - -#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(SKKDicConversion); - -SKKDicConversion::SKKDicConversion(ConfigPointer cfg) : Convertor(cfg) -{ - String file = cfg->read(String(HONOKA_SKKDIC_CONFIG_DICFILE), - String("")); - dic = new SKKDic(file); - pos = 0; -} - - -SKKDicConversion::~SKKDicConversion() -{ - delete(dic); -} - -bool SKKDicConversion::isConnected() { - return true; -} - -void SKKDicConversion::reset(){ - buns.clear(); - texts.clear(); - pos = 0; - return; -} - -void SKKDicConversion::setYomiText(WideString yomi) { - buns.clear(); - texts.clear(); - pos = 0; - buns.push_back(yomi); - return; -} - -int SKKDicConversion::ren_conversion() { - texts.push_back(buns[0]); - pos = 0; - return 1; -} - -WideString SKKDicConversion::getText() { - WideString t; - for(unsigned int i = 0;i < texts.size();i ++) { - t = t + texts[i]; - } - return t; -} - -int SKKDicConversion::setPos(int p){ - if ((p >= 0) && (p < buns.size())) pos = p; - return pos; -} - -int SKKDicConversion::getPos() { - return pos; -} - -ResultList SKKDicConversion::getResultList(int p,int kt){ - list.Yomi.clear(); - list.kouho.clear(); - list.Title = utf8_mbstowcs(String(_("lookup result"))); - //list.count = 0; - ResultEntry e; - if (kt != 0) return list; - if (p == -1) p = pos; - else if (setPos(p) != p) return list; - e.kanji = buns[pos]; - list.Yomi = buns[pos]; - list.kouho.push_back(e); - //list.count = 1; - vector es = dic->find(buns[p]); - for(unsigned int i = 0;i < es.size();i ++) { - e.kanji = es[i].kouho; - if (es[i].annotation.length()) { - e.label = es[i].kouho + utf8_mbstowcs(" (") + es[i].annotation + utf8_mbstowcs(")"); - } - list.kouho.push_back(e); - } - //list.count = list.kouho.size(); - return list; -} - - -bool SKKDicConversion::select(int p) { - if ((p < list.kouho.size()) && (p >= 0)) { - texts[pos] = list.kouho[p].kanji; - return true; - } - return false; -} - -AttributeList SKKDicConversion::getAttributeList() { - AttributeList attr; - int l = 0; - for(unsigned int i = 0;i < texts.size();i ++) { - if (pos == i) { - Attribute a(l,texts[i].length(),SCIM_ATTR_DECORATE,SCIM_ATTR_DECORATE_REVERSE); - attr.push_back(a); - } - l += texts[i].length(); - } - return attr; -} - -bool SKKDicConversion::resizeRegion(int w) { - if ((buns[pos].length() + w) < 1) return false; - if ((pos >= (buns.size() - 1)) && (w > 0)) return false; - - int s = buns[pos].length(); - WideString t; - vector ws; - for(unsigned int i = pos;i < buns.size();i ++) t = t + buns[i]; - for(unsigned int i = 0;i < pos;i ++) { - ws.push_back(buns[i]); - } - ws.push_back(t.substr(0,s + w)); - if ((s + w) < t.length()) ws.push_back(t.substr(s + w)); - buns.clear(); - texts.clear(); - buns = ws; - texts = ws; - return true; -} - -void SKKDicConversion::updateFrequency() { - return; -} - -bool SKKDicConversion::connect() { - return true; -} -void SKKDicConversion::disconnect() { - return; -} - -int SKKDicConversion::getCaretPos() { - int l = 0; - for(unsigned int i = 0;i < texts.size();i ++) { - if (pos == i) return l; - l += texts[i].length(); - } - return 0; -} - - -String SKKDicConversion::getName() -{ - return String("SKKDic"); -} - -String SKKDicConversion::getPropertyName() -{ - return getName(); -} diff --git a/honoka/src/skkdicconversion.h b/honoka/src/skkdicconversion.h deleted file mode 100644 index d4c26ef..0000000 --- a/honoka/src/skkdicconversion.h +++ /dev/null @@ -1,75 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 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 SKKDICCONVERSION_H -#define SKKDICCONVERSION_H - -#define Uses_SCIM_CONFIG_BASE - -#include -#include -#include -#include -#include -#include -#include -#include - -#define HONOKA_SKKDIC_CONFIG_DICFILE "/IMEngine/Honoka/SKKDic/File" - -using namespace std; -using namespace scim; - -/** -@author TAM (Teppei Tamra) -*/ -class SKKDicConversion : public Convertor { -public: - SKKDicConversion(ConfigPointer cfg); - - ~SKKDicConversion(); - virtual bool isConnected(); - virtual void reset(); - virtual void setYomiText(WideString yomi); - virtual int ren_conversion(); - virtual WideString getText(); - virtual int setPos(int p); - virtual int getPos(); - virtual ResultList getResultList(int p = -1 ,int kt = 0); - virtual bool select(int p); - virtual AttributeList getAttributeList(); - virtual bool resizeRegion(int w); - virtual void updateFrequency(); - virtual bool connect(); - virtual void disconnect(); - virtual int getCaretPos(); - virtual String getName(); - virtual String getPropertyName(); - -protected: - SKKDic *dic; - vector buns; - vector texts; - ResultList list; - int pos; - -}; - -#endif diff --git a/honoka/src/wnnconversion.cpp b/honoka/src/wnnconversion.cpp deleted file mode 100644 index 0b39667..0000000 --- a/honoka/src/wnnconversion.cpp +++ /dev/null @@ -1,539 +0,0 @@ -/*************************************************************************** - * 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 "wnnconversion.h" - - -#include - -#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(WnnConversion); - -WnnConversion::WnnConversion(ConfigPointer cfg) : Convertor(cfg) -{ - // �Ȥꤢ������ᤦ���Ǥ����ޤ��� - m_iconv.set_encoding ("EUC-JP"); - pos = 0; - bunsetu = 0; - wnn = 0; - sType = Wnn4; -} - - -WnnConversion::~WnnConversion() -{ -} - - - /* w_char����EUC���Ѵ����륢�� */ -void WnnConversion::wstostr(unsigned char *e,w_char *u) { - w_char x; - for(;*u;) { - x = *u ++; - if (x & 0x8000) { - *e ++ = x >> 8; - *e ++ = x; - } else - if (x & 0x80) { - *e ++ = 0x8e; - *e ++ = x & 0xff; - } else - *e++ = x; - } - *e ++ = 0; -} - - /* EUC����w_char���Ѵ�����ʥ� */ -void WnnConversion::strtows(w_char *u,unsigned char *e) { - w_char x; - for(;*e;) { - x = *e ++; - // ���줤��ʤ��� - //if (x == 0x8e) x = 0x80 | *e ++; - if (x & 0x80) - x = ((x << 8) & 0xff00) | *e ++; - *u ++ = x; - } - *u = 0; -} - -/*! - \fn WnnConversion::connect() - */ -bool WnnConversion::connect() -{ - String host = config->read(String(HONOKA_CONFIG_JSERVER),String(HONOKA_DEFAULT_JSERVER)); - String rc = config->read(String(HONOKA_CONFIG_WNNENVRC),String(HONOKA_DEFAULT_WNNENVRC)); - String t = config->read(String(HONOKA_CONFIG_JSERVERTYPE),String(HONOKA_DEFAULT_JSERVERTYPE)); - - if (t == "Wnn6") { - sType = Wnn6; - } else if (t == "Wnn7") { - sType = Wnn7; - } else if (t == "Wnn8") { - sType = Wnn8; - } else { - sType = Wnn4; - } - - wnnConnect(String("scim-wnn"),host,rc,sType,0); -} - -/*! - \fn WnnConversion::disconnect() - */ -void WnnConversion::disconnect() -{ - wnnDisconnect(); -} - - -/*! - \fn WnnConversion::wnnConnect(String name,String host,String rc,JServerType type,int timeout) - */ -bool WnnConversion::wnnConnect(String name,String host,String rc,JServerType type,int timeout) -{ - wnn = jl_open((char *)name.c_str(),(char *)host.c_str(),(char *)rc.c_str(),wnn_error,wnn_message,timeout); - //wnn = jl_open_lang("test","localhost","jp_JP","/usr/lib/wnn7/ja_JP/wnnenvrc",wnn_error,wnn_message,10); - if (wnn == NULL) return false; - #ifdef HAVE_LIBWNN7 - // ͽ¬���Ϥ��������Ƥ����� - jl_yosoku_init(wnn); - #endif - sType = type; - return true; -} - -/*! - \fn WnnConversion::wnnDisconnect() - */ -void WnnConversion::wnnDisconnect() -{ - if (wnn != NULL) { - #ifdef HAVE_LIBWNN7 - jl_yosoku_free(wnn); - #endif - jl_close(wnn); - wnn = NULL; - } -} - - - - -/*! - \fn WnnConversion::isConnected() - */ -bool WnnConversion::isConnected() -{ - if (wnn) return true; - else (false); -} - - - - -/*! - \fn WnnConversion::wnn_message (char *s) - */ -int WnnConversion::wnn_message (char *s) -{ - - SCIM_DEBUG_IMENGINE(1) << s << "\n"; -} - -/*! - \fn WnnConversion::wnn_error (char *s) - */ -int WnnConversion::wnn_error (char *s) -{ - - SCIM_DEBUG_IMENGINE(1) << s << "\n"; -} - - - - -/*! - \fn WnnConversion::reset() - */ -void WnnConversion::reset() -{ - yomiText.clear(); - bunList.clear(); - yomiList.clear(); - text.clear(); - attr.clear(); - pos = 0; - jl_kill(wnn,0,-1); -} - - -/*! - \fn WnnConversion::setYomiText(WideString yomi) - */ -void WnnConversion::setYomiText(WideString yomi) -{ - yomiText = yomi; -} - - - -/*! - \fn WnnConversion::ren_conversion() - */ -int WnnConversion::ren_conversion() -{ - convList.Yomi.clear(); - convList.kouho.clear(); - bunList.clear(); - yomiList.clear(); - pos = 0; - w_char ws[1024]; - char c[2048]; - String y; - m_iconv.convert(y,yomiText); - strtows(ws,(unsigned char*)y.c_str()); - bunsetu = jl_fi_ren_conv(wnn,ws,0,-1,WNN_USE_ZENGO); - if (bunsetu == -1) return -1; - for(unsigned int i = 0;i < bunsetu;i ++) { - WideString w; - jl_get_kanji(wnn,i,i + 1,ws); - wstostr((unsigned char*)c,ws); - m_iconv.convert(w,c,strlen(c)); - bunList.push_back(w); - jl_get_yomi(wnn,i,i + 1,ws); - wstostr((unsigned char*)c,ws); - m_iconv.convert(w,c,strlen(c)); - yomiList.push_back(w); - } - createText(); - return bunsetu; -} - - -/*! - \fn WnnConversion::resizeRegion(int w) - */ -bool WnnConversion::resizeRegion(int w) -{ - if (w == 0) return false; - if ((yomiList[pos].length() + w) <= 0) return false; - if (((pos + 1) >= yomiList.size()) && (w > 0)) return false; - - w_char ws[1024]; - char c[2048]; - int s; - int h = WNN_NO_USE; - if (pos > 0) h = WNN_USE_MAE; - else if (pos < bunsetu - 1) h = WNN_USE_ATO; - bunsetu = jl_fi_nobi_conv(wnn,pos,yomiList[pos].length() + w,-1,h,WNN_SHO); - convList.kouho.clear(); - bunList.clear(); - yomiList.clear(); - for(unsigned int i = 0;i < bunsetu;i ++) { - WideString w; - jl_get_kanji(wnn,i,i + 1,ws); - wstostr((unsigned char*)c,ws); - m_iconv.convert(w,c,strlen(c)); - bunList.push_back(w); - jl_get_yomi(wnn,i,i + 1,ws); - wstostr((unsigned char*)c,ws); - m_iconv.convert(w,c,strlen(c)); - yomiList.push_back(w); - } - createText(); - return true; -} - - -/*! - \fn WnnConversion::createText() - */ -void WnnConversion::createText() -{ - WideString w; - caretPos = 0; - for(unsigned int i = 0;i < bunsetu;i ++) { - if (pos == i) { - caretPos = w.length(); - attr.clear(); - Attribute a(w.length(),bunList[i].length(),SCIM_ATTR_DECORATE,SCIM_ATTR_DECORATE_REVERSE); - attr.push_back(a); - } - w = w + bunList[i]; - } - text = w; -} - -/*! - \fn WnnConversion::getText() - */ -WideString WnnConversion::getText() -{ - return text; -} - - -/*! - \fn WnnConversion::getAttributeList() - */ -AttributeList WnnConversion::getAttributeList() -{ - return attr; -} - - -/*! - \fn WnnConversion::setPos(int p) - */ -int WnnConversion::setPos(int p) -{ - /*if (p >= bunsetu) p = (p % bunsetu); - else if (p < 0) p = bunsetu - (abs(p) % bunsetu);*/ - if ((p < bunsetu) && (p >= 0)) pos = p; - - //pos = p; - createText(); - return pos; -} - - -/*! - \fn WnnConversion::getPos() - */ -int WnnConversion::getPos() -{ - return pos; -} - - -/*! - \fn WnnConversion::getYosokuList(const WideString &str) - */ -ResultList WnnConversion::getYosokuList(const WideString &str) -{ - convList.Yomi = str; - convList.kouho.clear(); - //convList.count = 0; - convList.pos = 0; - convList.kType = YOSOKU; - convList.Title = utf8_mbstowcs(String(_("yosoku lookup result"))); - #ifdef HAVE_LIBWNN7 - String s; - m_iconv.convert(s,convList.Yomi); - // @todo ������mbstowcs�����ۤ����ɤ��󤫡� - char c[1024]; - strcpy(c,s.c_str()); - if (jl_yosoku_yosoku(wnn,c) != 0) return convList; - //convList.count = ykYosokuKouhoNum; - for(unsigned int i = 0;i < ykYosokuKouhoNum;i ++) { - WideString w; - m_iconv.convert(w,ykYosokuKouho[i],strlen(ykYosokuKouho[i])); - convList.kouho.push_back(ResultEntry(w)); - } - //jl_yosoku_free(wnn); - #endif - return convList; -} - - -/*! - \fn WnnConversion::getResultList(int p,int kt) - */ -ResultList WnnConversion::getResultList(int p,int kt) -{ - w_char k[1024]; - char buf[2048]; - WideString u; - convList.kouho.clear(); - convList.Yomi.clear(); - convList.pos = 0; - //convList.count = 0; - if ((sType != Wnn8) && (sType != Wnn7) && (kt != DEFAULT)) return convList; - - if (p == -1) p = pos; - //if ((p >= bunsetu) || (p < 0)) p = p % bunsetu; - if (p >= bunsetu) return convList; - pos = p; - jl_get_yomi(wnn,pos,pos + 1,k); - wstostr((unsigned char*)buf,k); - m_iconv.convert(u,buf,strlen(buf)); - convList.Yomi = u; - - // bunsetu connection control - int conn = WNN_USE_ZENGO; - if (bunsetu == 1) conn = WNN_NO_USE; - else if (pos == 0) conn = WNN_USE_ATO; - else if (pos == (bunsetu - 1)) conn = WNN_USE_MAE; - switch (kt) { - #ifdef HAVE_LIBWNN7 - case IKEIJI: { - convList.pos = jl_zenikeiji_dai(wnn,pos,pos + 1,conn,WNN_UNIQ); - convList.kType = IKEIJI; - convList.Title = utf8_mbstowcs(String(_("Ikeiji lookup result"))); - break; - } - case RENSOU: { - convList.pos = jl_zenassoc_dai(wnn,pos,pos + 1,conn,WNN_UNIQ); - convList.kType = RENSOU; - convList.Title = utf8_mbstowcs(String(_("association lookup result"))); - break; - } - #endif - default: { - convList.pos = jl_zenkouho_dai(wnn,pos,pos + 1,conn,WNN_UNIQ); - convList.kType = DEFAULT; - convList.Title = utf8_mbstowcs(String(_("lookup result"))); - break; - } - } - - // @todo be implement to ikeiji conversion using "jl_zenikeiji_dai()". - // @todo be implement to rensou conversion using "jl_zenassoc_dai()". - // @todo jl_zenkouho should change to jl_zenkouho_dai. - //convList.pos = jl_zenassoc_dai(wnn,pos,pos + 1,WNN_USE_ZENGO,WNN_UNIQ); - //convList.pos = jl_zenkouho(wnn,pos,conn,WNN_UNIQ); - if (convList.pos == -1) return convList; - int count = jl_zenkouho_suu(wnn); - - for (unsigned int i = 0;i < count; i ++) { - jl_get_zenkouho_kanji(wnn,i,k); - wstostr((unsigned char*)buf,k); - m_iconv.convert(u,buf,strlen(buf)); - convList.kouho.push_back(u); - } - select(convList.pos); - createText(); - return convList; - -} - - -/*! - \fn WnnConversion::select(int p) - */ -bool WnnConversion::select(int p) -{ - if (p > convList.count()) p = 0; - convList.pos = p; - switch(convList.kType) { - case DEFAULT: { - jl_set_jikouho_dai(wnn,p); - break; - } - case YOSOKU: { - #ifdef HAVE_LIBWNN7 - jl_yosoku_selected_cand(wnn,p); - #endif - return true; - } - default: { - break; - } - } - - bunList.at(pos) = convList.kouho.at(p).kanji; - createText(); - - return true; - -} - - - - - - -/*! - \fn WnnConversion::updateFrequency() - */ -void WnnConversion::updateFrequency() -{ - if (bunsetu) { - #ifdef HAVE_LIBWNN7 - w_char ws[1024]; - int c = jl_get_kanji(wnn,0,bunsetu,ws); - jl_yosoku_toroku(wnn,ws,c); - #endif - jl_optimize_fi(wnn,0,-1); - pretext = getText(); - } -} - - - -/*! - \fn WnnConversion::getCaretPos() - */ -int WnnConversion::getCaretPos() -{ - return caretPos; -} - - -String WnnConversion::getName() -{ - return String("Wnn"); -} - -String WnnConversion::getPropertyName() -{ - return String("Wnn"); -} - - - -/*! - \fn WnnConversion::updateYosoku(WideString text,const WideString yomi) - */ -void WnnConversion::updateYosoku(WideString text,const WideString yomi) -{ - #ifdef HAVE_LIBWNN7 - if (text == pretext) return; - reset(); - setYomiText(yomi); - ren_conversion(); - w_char ws[1024]; - char c[2048]; - String y; - m_iconv.convert(y,text); - strtows(ws,(unsigned char*)y.c_str()); - jl_yosoku_toroku(wnn,ws,text.length()); - reset(); - #endif - return; - -} diff --git a/honoka/src/wnnconversion.h b/honoka/src/wnnconversion.h deleted file mode 100644 index c80ecc6..0000000 --- a/honoka/src/wnnconversion.h +++ /dev/null @@ -1,110 +0,0 @@ -/*************************************************************************** - * 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 WNNCONVERSION_H -#define WNNCONVERSION_H - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#define Uses_SCIM_ICONV -#include -#include -#include -#include - - - - -using namespace scim; -using namespace std; - - -/** -@author TAM(Teppei Tamra) -*/ -enum JServerType { Wnn4, Wnn6, Wnn7, Wnn8 }; - -#define DEFAULT 0 -#define IKEIJI 1 -#define RENSOU 2 -#define YOSOKU 3 - - -class WnnConversion : public Convertor { -public: - WnnConversion(ConfigPointer cfg); - - ~WnnConversion(); - virtual bool isConnected(); - virtual void reset(); - virtual void setYomiText(WideString yomi); - virtual int ren_conversion(); - virtual WideString getText(); - virtual int setPos(int p); - virtual int getPos(); - virtual ResultList getResultList(int p = -1 ,int kt = DEFAULT); - ResultList getYosokuList(const WideString &str); - virtual bool select(int p); - virtual AttributeList getAttributeList(); - virtual bool resizeRegion(int w); - virtual void updateFrequency(); - virtual bool connect(); - virtual void disconnect(); - virtual int getCaretPos(); - virtual String getName(); - virtual String getPropertyName(); - void updateYosoku(WideString text,const WideString yomi); - - -protected: - bool wnnConnect(String name,String host,String rc,JServerType type,int timeout); - void wnnDisconnect(); - void wstostr(unsigned char *e,w_char *u); - void strtows(w_char *u,unsigned char *e); - static int wnn_message (char *s); - static int wnn_error (char *s); - void createText(); - -protected: - struct wnn_buf *wnn; - String wnn_server; - String wnn_rc; - JServerType sType; - int wnn_timeout; - IConvert m_iconv; - WideString yomiText; - int pos; - int bunsetu; - int caretPos; - WideString text; - vector bunList; - vector yomiList; - AttributeList attr; - ResultList convList; - WideString pretext; - -}; - -#endif diff --git a/honoka/src/wnnplugin.cpp b/honoka/src/wnnplugin.cpp deleted file mode 100644 index 4accd15..0000000 --- a/honoka/src/wnnplugin.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 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 "wnnplugin.h" - -HonokaPluginRegister(WnnPlugin); - -WnnPlugin::WnnPlugin(ConfigPointer cfg) : HonokaMultiplePluginBase(cfg) -{ - predictor = 0; - convertor = new WnnConversion(cfg); - - bool yosoku = cfg->read(String(HONOKA_CONFIG_WNNYOSOKU),HONOKA_DEFAULT_WNNYOSOKU); - String sType = cfg->read(String(HONOKA_CONFIG_JSERVERTYPE),String(HONOKA_DEFAULT_JSERVERTYPE)); - if (yosoku && (sType == String("Wnn7"))) { - predictor = new WnnPrediction(cfg,convertor); - } -} - - -WnnPlugin::~WnnPlugin() -{ - if (predictor) delete predictor; - delete convertor; -} - -/*! - \fn WnnPlugin::getPluginInstanceAt(int p) - */ -HonokaPluginBase * WnnPlugin::getPluginInstanceAt(int p) -{ - if (p == 0) return convertor; - if ((p == 1) && predictor) return predictor; - return 0; -} - - -/*! - \fn WnnPlugin::getPluginCount() - */ -int WnnPlugin::getPluginCount() -{ - if (predictor) return 2; - return 1; -} - -/*! - \fn WnnPlugin::getName() - */ -String WnnPlugin::getName() -{ - return String("WnnPlugin"); -} - diff --git a/honoka/src/wnnplugin.h b/honoka/src/wnnplugin.h deleted file mode 100644 index c793f2f..0000000 --- a/honoka/src/wnnplugin.h +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 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 WNNPLUGIN_H -#define WNNPLUGIN_H - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -using namespace std; -using namespace scim; - - -/** -@author TAM (Teppei Tamra) -*/ -class WnnPlugin; - -class WnnPlugin : public HonokaMultiplePluginBase { -public: - WnnPlugin(ConfigPointer cfg); - - ~WnnPlugin(); - virtual HonokaPluginBase * getPluginInstanceAt(int p); - virtual int getPluginCount(); - virtual String getName(); - -protected: - WnnConversion * convertor; - WnnPrediction * predictor; -}; - -#endif diff --git a/honoka/src/wnnprediction.cpp b/honoka/src/wnnprediction.cpp deleted file mode 100644 index f0632ea..0000000 --- a/honoka/src/wnnprediction.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 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 "wnnprediction.h" - -#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 - - -WnnPrediction::WnnPrediction(ConfigPointer cfg,WnnConversion *wnn) : Predictor(cfg) -{ - convertor = wnn; -} - - -WnnPrediction::~WnnPrediction() -{ -} - - - -/*! - \fn WnnPrediction::getPredictionList(const WideString &str) - */ -ResultList WnnPrediction::getPredictionList(const WideString &str) -{ - return convertor->getYosokuList(str); -} - - -/*! - \fn WnnPrediction::disconnect() - */ -void WnnPrediction::disconnect() -{ - // disconnect��WnnConversion¦�˰�Ǥ�� - return; -} - - -/*! - \fn WnnPrediction::connect() - */ -bool WnnPrediction::connect() -{ - return convertor->connect(); -} - - -/*! - \fn WnnPrediction::isConnected() - */ -bool WnnPrediction::isConnected() -{ - return convertor->isConnected(); -} - - -/*! - \fn WnnPrediction::getPropertyName() - */ -String WnnPrediction::getPropertyName() -{ - return getName(); -} - -/*! - \fn WnnPrediction::getName() - */ -String WnnPrediction::getName() -{ - return String(_("WnnPrediction")); -} - -/*! - \fn WnnPrediction::update(const WideString str,const WideString yomi) - */ -void WnnPrediction::update(const WideString str,const WideString yomi) -{ - convertor->updateYosoku(str,yomi); - return; -} - diff --git a/honoka/src/wnnprediction.h b/honoka/src/wnnprediction.h deleted file mode 100644 index 9b17f93..0000000 --- a/honoka/src/wnnprediction.h +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 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 WNNPREDICTION_H -#define WNNPREDICTION_H - -#define Uses_SCIM_CONFIG_BASE - -#include -#include - -#include -#include -#include -#include -#include -#include - - -/** -@author TAM (Teppei Tamra) -*/ -class WnnPrediction : public Predictor { -public: - WnnPrediction(ConfigPointer cfg,WnnConversion *wnn); - - ~WnnPrediction(); - virtual ResultList getPredictionList(const WideString &str); - virtual void disconnect(); - virtual bool connect(); - virtual bool isConnected(); - virtual String getPropertyName(); - virtual String getName(); - virtual void update(const WideString str,const WideString yomi); - -protected: - WnnConversion *convertor; - -}; - -#endif diff --git a/honoka/src/wnnproto.h b/honoka/src/wnnproto.h deleted file mode 100644 index c6efaa7..0000000 --- a/honoka/src/wnnproto.h +++ /dev/null @@ -1,106 +0,0 @@ -/*************************************************************************** - * 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 WNNPROTO_H -#define WNNPROTO_H - -#ifdef HAVE_CONFIG_H -#include -#endif - -extern "C" { - - /* ����Ū�ʤ� */ - #define w_char unsigned short - struct wnn_buf *jl_open_lang(char *,char *,char *,char *,int (*)(char *),int(*)(char *),int); - #define jl_open(a,b,c,d,e,f) jl_open_lang(a,b,NULL,c,d,e,f) - void jl_close(struct wnn_buf*); - - - - - /* conversion */ - int jl_fi_ren_conv(struct wnn_buf*,w_char*,int,int,int); - int jl_optimize_fi(struct wnn_buf*,int,int); - int jl_fi_nobi_conv(struct wnn_buf*,int,int,int,int,int); - int jl_zenkouho_suu(struct wnn_buf*); - int jl_kill(struct wnn_buf*,int,int); - int jl_zenkouho(struct wnn_buf*,int,int,int); - int jl_zenkouho_dai(struct wnn_buf*,int,int,int,int); - - int jl_set_jikouho(struct wnn_buf*,int); - int jl_set_jikouho_dai(struct wnn_buf*,int); - - #ifdef HAVE_LIBWNN7 - /* wnn6sdk is not having it.*/ - int jl_zenikeiji_dai(struct wnn_buf*,int,int,int,int); - int jl_zenassoc_dai(struct wnn_buf*,int,int,int,int); - int wnn_get_area(struct wnn_buf*,int,int,w_char*,int,int); - void jl_get_zenkouho_kanji(struct wnn_buf*,int ,w_char *,int); - #define jl_get_zenkouho_kanji(a,b,c) jl_get_zenkouho_kanji(a,b,c,512) - #define jl_get_kanji(buf,bun1,bun2,area) wnn_get_area(buf,bun1,bun2,area,1,512) - #define jl_get_yomi(buf,bun1,bun2,area) wnn_get_area(buf,bun1,bun2,area,0,512) - - // input completion for Wnn7 - extern int ykYosokuKouhoNum; - extern char **ykYosokuKouho; - extern int jl_yosoku_init(struct wnn_buf*); - extern int jl_yosoku_set_param(struct wnn_buf*,int,int,int); - extern int jl_yosoku_free(struct wnn_buf*); - extern int jl_yosoku_yosoku(struct wnn_buf*,char *); - extern int jl_yosoku_toroku(struct wnn_buf*,w_char*,short); - extern int jl_yosoku_selected_cand(struct wnn_buf*,int); - extern int jl_yosoku_delete_cand(struct wnn_buf*,int); - extern int jl_yosoku_save_datalist(struct wnn_buf*); - extern int jl_yosoku_cancel_toroku(struct wnn_buf *); - extern int jl_yosoku_ikkatsu_toroku(struct wnn_buf *,char *,int); - extern int jl_yosoku_ikkatsu_toroku_init(struct wnn_buf *); - extern int jl_yosoku_ikkatsu_toroku_end(struct wnn_buf *); - extern int jl_yosoku_toroku(struct wnn_buf *,w_char *,short); - - #else - int wnn_get_area(struct wnn_buf*,int,int,w_char*,int); - void jl_get_zenkouho_kanji(struct wnn_buf*,int ,w_char *); - #define jl_get_kanji(buf,bun1,bun2,area) wnn_get_area(buf,bun1,bun2,area,1) - #define jl_get_yomi(buf,bun1,bun2,area) wnn_get_area(buf,bun1,bun2,area,0) - #endif - - - #define WNN_NO_USE 0 - #define WNN_USE_MAE 1 - #define WNN_USE_ATO 2 - #define WNN_USE_ZENGO (WNN_USE_MAE | WNN_USE_ATO) - - #define WNN_UNIQ_KNJ 2 - #define WNN_UNIQ 1 - #define WNN_NO_UNIQ 0 - - #define WNN_NO_CREATE 0 - #define WNN_CREATE (-1) - - #define WNN_SHO 0 - #define WNN_DAI 1 - - -} - -#endif -