diff --git a/honoka/configure.ac b/honoka/configure.ac index a9e2ddc..6ae8ade 100644 --- a/honoka/configure.ac +++ b/honoka/configure.ac @@ -139,8 +139,31 @@ AM_CONDITIONAL(ANTHYCONVERSION, [test "x$anthy" = "xtrue"]) AC_SUBST(ANTHYCONVERSION) +AC_ARG_ENABLE(canna, + [ --enable-canna Turn on CannaConversion], + [case "${enableval}" in + yes) canna=true ;; + no) canna=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-canna) ;; + esac],[canna=true]) + +if test "x$canna" = "xtrue"; then + AC_CHECK_HEADER([canna/jrkanji.h], [ + CANNA_LIBS="-lcanna" + ],[]) + if echo $CANNA_LIBS | grep "canna" > /dev/null; then + AC_DEFINE([HAVE_LIBCANNA],[1],[Canna]) + else + canna=false + fi +fi +AM_CONDITIONAL(CANNACONVERSION, [test "x$canna" = "xtrue"]) +AC_SUBST(CANNACONVERSION) + + AC_SUBST(WNN_LIBS) AC_SUBST(ANTHY_LIBS) +AC_SUBST(CANNA_LIBS) #if echo $LIBS | grep -v "wnn" > /dev/null; then # if echo $LIBS | grep -v "anthy" > /dev/null; then diff --git a/honoka/m4/Makefile b/honoka/m4/Makefile index 4e43678..8594909 100644 --- a/honoka/m4/Makefile +++ b/honoka/m4/Makefile @@ -76,6 +76,10 @@ AUTOMAKE = ${SHELL} /home/tamra/ANef/honoka/missing --run automake-1.9 AWK = gawk BUILD_INCLUDED_LIBINTL = no +CANNACONVERSION = +CANNACONVERSION_FALSE = # +CANNACONVERSION_TRUE = +CANNA_LIBS = -lcanna CATOBJEXT = .gmo CC = gcc CCDEPMODE = depmode=gcc3 diff --git a/honoka/m4/Makefile.in b/honoka/m4/Makefile.in index 0bbd9d6..5be5390 100644 --- a/honoka/m4/Makefile.in +++ b/honoka/m4/Makefile.in @@ -76,6 +76,10 @@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@ +CANNACONVERSION = @CANNACONVERSION@ +CANNACONVERSION_FALSE = @CANNACONVERSION_FALSE@ +CANNACONVERSION_TRUE = @CANNACONVERSION_TRUE@ +CANNA_LIBS = @CANNA_LIBS@ CATOBJEXT = @CATOBJEXT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ diff --git a/honoka/plugins/Makefile.am b/honoka/plugins/Makefile.am index bb530f3..ef96f46 100644 --- a/honoka/plugins/Makefile.am +++ b/honoka/plugins/Makefile.am @@ -28,7 +28,7 @@ noinst_HEADERS = wnnproto.h romkan.h wnnconversion.h kanainput.h \ anthyconversion.h skkdic.h skkdicconversion.h wnnplugin.h wnnprediction.h \ - honoka_plugin_def.h simpleprediction.h + honoka_plugin_def.h simpleprediction.h cannaconversion.h moduledir = @SCIM_MODULEDIR@/IMEngine @@ -41,8 +41,12 @@ ANTHY_PLUGIN = plugin-anthy.la endif +if CANNACONVERSION +CANNA_PLUGIN = plugin-canna.la +endif + plugindir = @SCIM_MODULEDIR@/honoka -plugin_LTLIBRARIES = $(ANTHY_PLUGIN) $(WNN_PLUGIN) plugin-skkdic.la plugin-romkan.la plugin-kanainput.la plugin-simpleprediction.la +plugin_LTLIBRARIES = $(ANTHY_PLUGIN) $(WNN_PLUGIN) $(CANNA_PLUGIN) plugin-skkdic.la plugin-romkan.la plugin-kanainput.la plugin-simpleprediction.la plugin_anthy_la_SOURCES = anthyconversion.cpp plugin_anthy_la_CFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ @@ -80,4 +84,10 @@ plugin_simpleprediction_la_LDFLAGS = -avoid-version -module -rpath $(plugindir) @LIBTOOL_EXPORT_OPTIONS@ @INTLLIBS@ @SCIM_LIBS@ plugin_simpleprediction_la_LIBADD = $(top_builddir)/libhonoka/libhonoka_plugin.la +plugin_canna_la_SOURCES = cannaconversion.cpp +plugin_canna_la_CFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ +plugin_canna_la_CXXFLAGS = @SCIM_CFLAGS@ @SCIM_DEBUG_FLAGS@ +plugin_canna_la_LDFLAGS = -avoid-version -module -rpath $(plugindir) @LIBTOOL_EXPORT_OPTIONS@ @INTLLIBS@ @SCIM_LIBS@ @CANNA_LIBS@ +plugin_canna_la_LIBADD = $(top_builddir)/libhonoka/libhonoka_plugin.la + diff --git a/honoka/plugins/anthyconversion.cpp b/honoka/plugins/anthyconversion.cpp index fd647eb..71e1869 100644 --- a/honoka/plugins/anthyconversion.cpp +++ b/honoka/plugins/anthyconversion.cpp @@ -108,7 +108,9 @@ bool AnthyConversion::select(int p) { if (p < convResult[pos].count()) { convResult[pos].pos = p; + return true; } + return false; } AttributeList AnthyConversion::getAttributeList() { diff --git a/honoka/plugins/cannaconversion.cpp b/honoka/plugins/cannaconversion.cpp new file mode 100644 index 0000000..510445c --- /dev/null +++ b/honoka/plugins/cannaconversion.cpp @@ -0,0 +1,211 @@ +/*************************************************************************** + * 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 "cannaconversion.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(CannaConversion); + + +CannaConversion::CannaConversion(ConfigPointer cfg) : Convertor(cfg) +{ + m_iconv.set_encoding ("EUC-JP"); + pos = 0; + RkInitialize("/var/lib/canna/dic"); + context = RkCreateContext(); + ready = false; +} + + +CannaConversion::~CannaConversion() +{ +} + +bool CannaConversion::isConnected() { + return ready; +} + +void CannaConversion::reset(){ + RkEndBun(context,0); + return; +} + +void CannaConversion::setYomiText(WideString yomi) { + yomiText = yomi; +} + +int CannaConversion::ren_conversion() { + pos = 0; + String y; + m_iconv.convert(y,yomiText); + bun = RkBgnBun(context,(char *)y.c_str(),strlen(y.c_str()),RK_XFER); + if (bun > 0) { + buildResult(); + } + RkGoTo(context,0); + + return bun; +} + +WideString CannaConversion::getText() { + WideString text; + for(unsigned int i = 0;i < convResult.size();i ++) { + text += convResult[i].kouho[convResult[i].pos].kanji; + } + return text; +} + +int CannaConversion::setPos(int p){ + if ((p < convResult.size()) && (p >= 0)) pos = p; + RkGoTo(context,pos); + return pos; +} + +int CannaConversion::getPos() { + return pos; +} + +ResultList CannaConversion::getResultList(int p,ResultType kt){ + if (p == -1) p = pos; + if (p >= convResult.size()) return ResultList(); + if ((kt != DEFAULT) || (p >= convResult.size())) return ResultList(); + setPos(p); + return convResult[p]; +} + +bool CannaConversion::select(int p) { + if (p < convResult[pos].count()) { + convResult[pos].pos = p; + return true; + } + return false; +} + +AttributeList CannaConversion::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 CannaConversion::resizeRegion(int w) { + if ((convResult[pos].Yomi.length() + w) < 1) return false; + if ((pos >= (convResult.size() - 1)) && (w > 0)) return false; + WideString nt; + for(unsigned int i = pos;i < convResult.size();i ++) nt += convResult[i].Yomi; + nt = nt.substr(0,convResult[pos].Yomi.length() + w); + String s; + m_iconv.convert(s,nt); + bun = RkResize(context,strlen(s.c_str())); + buildResult(); + return true; +} + +void CannaConversion::updateFrequency() { + return; +} + +bool CannaConversion::connect() { + char dic[4096],*dicp; + int dc = RkGetDicList(context,dic,4095); + if (dc == -1) { + return false; + } + dicp = dic; + for(unsigned int i = 0;i < dc;i ++) { + RkMountDic(context,dicp,0); + dicp += strlen(dicp) + 1; + } + ready = true; + return true; +} + +void CannaConversion::disconnect() { + return; +} + +int CannaConversion::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 CannaConversion::buildResult() { + convResult.clear(); + for(unsigned int i = 0;i < bun;i ++) { + RkGoTo(context,i); + unsigned char k[4096],*resp; + resp = k; + WideString t; + ResultList m_res; + m_res.kType = DEFAULT; + m_res.Title = utf8_mbstowcs(String(_("lookup result"))); + RkGetYomi(context,k,511); + m_iconv.convert(t,String((const char *)k)); + m_res.Yomi = t; + int c = RkGetKanjiList(context,k,4095); + m_res.pos = 0; + for(unsigned int j = 0;j < c;j ++) { + m_iconv.convert(t,String((const char *)resp)); + m_res.kouho.push_back(t); + resp += strlen((const char*)resp) + 1; + } + convResult.push_back(m_res); + } + RkGoTo(context,pos); +} + + + +String CannaConversion::getName() +{ + return String("Canna"); +} + +String CannaConversion::getPropertyName() +{ + return String(_("CannaConversion")); +} + + diff --git a/honoka/plugins/cannaconversion.h b/honoka/plugins/cannaconversion.h new file mode 100644 index 0000000..6795c5b --- /dev/null +++ b/honoka/plugins/cannaconversion.h @@ -0,0 +1,78 @@ +/*************************************************************************** + * 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 CANNACONVERSION_H +#define CANNACONVERSION_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 CannaConversion : public Convertor { +public: + CannaConversion(ConfigPointer cfg); + + ~CannaConversion(); + 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 ,ResultType kt = DEFAULT); + 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: + bool ready; + int bun; + int context; + IConvert m_iconv; + WideString yomiText; + vector convResult; + int pos; + +}; + + +#endif diff --git a/honoka/po/POTFILES.in b/honoka/po/POTFILES.in index a39eae0..f31e8fa 100644 --- a/honoka/po/POTFILES.in +++ b/honoka/po/POTFILES.in @@ -17,6 +17,8 @@ plugins/simpleprediction.cpp plugins/skkdicconversion.h plugins/skkdicconversion.cpp +plugins/cannaconversion.h +plugins/cannaconversion.cpp libhonoka/preeditor.h libhonoka/preeditor.cpp libhonoka/convertor.h diff --git a/honoka/po/honoka.pot b/honoka/po/honoka.pot index 56bfc07..dcc962f 100644 --- a/honoka/po/honoka.pot +++ b/honoka/po/honoka.pot @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2005-06-29 09:32+0900\n" +"POT-Creation-Date: 2005-07-01 05:00+0900\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -520,8 +520,9 @@ msgid "association lookup result" msgstr "" -#: plugins/wnnconversion.cpp:420 plugins/anthyconversion.cpp:167 +#: plugins/wnnconversion.cpp:420 plugins/anthyconversion.cpp:169 #: plugins/simpleprediction.cpp:70 plugins/skkdicconversion.cpp:103 +#: plugins/cannaconversion.cpp:183 msgid "lookup result" msgstr "" @@ -533,7 +534,7 @@ msgid "WnnPrediction" msgstr "" -#: plugins/anthyconversion.cpp:194 +#: plugins/anthyconversion.cpp:196 msgid "AnthyConversion" msgstr "" @@ -545,6 +546,10 @@ msgid "SKKDic" msgstr "" +#: plugins/cannaconversion.cpp:208 +msgid "CannaConversion" +msgstr "" + #: libhonoka/predictor.cpp:92 msgid "Predicter" msgstr "" diff --git a/honoka/po/ja.po b/honoka/po/ja.po index aacd38d..1ba8261 100644 --- a/honoka/po/ja.po +++ b/honoka/po/ja.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: ja\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2005-06-29 09:32+0900\n" +"POT-Creation-Date: 2005-07-01 05:00+0900\n" "PO-Revision-Date: 2004-12-01 14:29+0900\n" "Last-Translator: TAM (Teppei Tamra) \n" "Language-Team: Japanese\n" @@ -522,8 +522,9 @@ msgid "association lookup result" msgstr "連想変換" -#: plugins/wnnconversion.cpp:420 plugins/anthyconversion.cpp:167 +#: plugins/wnnconversion.cpp:420 plugins/anthyconversion.cpp:169 #: plugins/simpleprediction.cpp:70 plugins/skkdicconversion.cpp:103 +#: plugins/cannaconversion.cpp:183 msgid "lookup result" msgstr "候補一覧" @@ -535,7 +536,7 @@ msgid "WnnPrediction" msgstr "Wnn予測" -#: plugins/anthyconversion.cpp:194 +#: plugins/anthyconversion.cpp:196 msgid "AnthyConversion" msgstr "Anthy変換" @@ -547,6 +548,10 @@ msgid "SKKDic" msgstr "SKK辞書" +#: plugins/cannaconversion.cpp:208 +msgid "CannaConversion" +msgstr "Canna変換" + #: libhonoka/predictor.cpp:92 msgid "Predicter" msgstr "予測なし"