diff --git a/scim-wnn/src/Makefile.am b/scim-wnn/src/Makefile.am index d096f89..150de1a 100644 --- a/scim-wnn/src/Makefile.am +++ b/scim-wnn/src/Makefile.am @@ -25,7 +25,7 @@ -DSCIM_WNN_ICON_FILE=\"@SCIM_ICONDIR@/scim-wnn.png\" noinst_HEADERS = scim_wnn_imengine.h wnnproto.h romkan.h romkan_table.h \ - wnnconversion.h + wnnconversion.h scim_wnn_def.h moduledir = @SCIM_MODULEDIR@/IMEngine module_LTLIBRARIES = wnn.la diff --git a/scim-wnn/src/scim_wnn_def.h b/scim-wnn/src/scim_wnn_def.h new file mode 100644 index 0000000..4a9e40e --- /dev/null +++ b/scim-wnn/src/scim_wnn_def.h @@ -0,0 +1,65 @@ +/*************************************************************************** + * 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 SCIM_WNN_DEF_H +#define SCIM_WNN_DEF_H + +#define SCIM_CONFIG_WNN_KEY_CONVERSION_START "/IMEngine/Wnn/Key/ConversionStart" +#define SCIM_DEFAULT_WNN_KEY_CONVERSION_START "space" +#define SCIM_CONFIG_WNN_KEY_CANCEL "/IMEngine/Wnn/Key/Cancel" +#define SCIM_DEFAULT_WNN_KEY_CANCEL "Escape,Control+g" +#define SCIM_CONFIG_WNN_KEY_DELETE "/IMEngine/Wnn/Key/Delete" +#define SCIM_DEFAULT_WNN_KEY_DELETE "Delete" +#define SCIM_CONFIG_WNN_KEY_BACKSPACE "/IMEngine/Wnn/Key/BackSpace" +#define SCIM_DEFAULT_WNN_KEY_BACKSPACE "BackSpace" +#define SCIM_CONFIG_WNN_KEY_COMMIT "/IMEngine/Wnn/Key/Commit" +#define SCIM_DEFAULT_WNN_KEY_COMMIT "Return" +#define SCIM_CONFIG_WNN_KEY_CONVERSION_NEXT "/IMEngine/Wnn/Key/ConversionNext" +#define SCIM_DEFAULT_WNN_KEY_CONVERSION_NEXT "space,Down" +#define SCIM_CONFIG_WNN_KEY_CONVERSION_PREV "/IMEngine/Wnn/Key/ConversionPrev" +#define SCIM_DEFAULT_WNN_KEY_CONVERSION_PREV "Up" +#define SCIM_CONFIG_WNN_KEY_CONVERSION_EXPAND "/IMEngine/Wnn/Key/ConversionExpand" +#define SCIM_DEFAULT_WNN_KEY_CONVERSION_EXPAND "Shift+Right,Control+o" +#define SCIM_CONFIG_WNN_KEY_CONVERSION_SHRINK "/IMEngine/Wnn/Key/ConversionShrink" +#define SCIM_DEFAULT_WNN_KEY_CONVERSION_SHRINK "Shift+Left,Control+i" +#define SCIM_CONFIG_WNN_KEY_CONVERSION_FORWARD "/IMEngine/Wnn/Key/ConversionForward" +#define SCIM_DEFAULT_WNN_KEY_CONVERSION_FORWARD "Right" +#define SCIM_CONFIG_WNN_KEY_CONVERSION_BACKWARD "/IMEngine/Wnn/Key/ConversionBackward" +#define SCIM_DEFAULT_WNN_KEY_CONVERSION_BACKWARD "Left" +#define SCIM_CONFIG_WNN_KEY_FORWARD "/IMEngine/Wnn/Key/Forward" +#define SCIM_DEFAULT_WNN_KEY_FORWARD "Right" +#define SCIM_CONFIG_WNN_KEY_BACKWARD "/IMEngine/Wnn/Key/Backword" +#define SCIM_DEFAULT_WNN_KEY_BACKWARD "Left" +#define SCIM_CONFIG_WNN_KEY_LOOKUPPOPUP "/IMEngine/Wnn/Key/LookupPopup" +#define SCIM_DEFAULT_WNN_KEY_LOOKUPPOPUP "Alt+s" +#define SCIM_CONFIG_WNN_KEY_LOOKUPPAGEUP "/IMEngine/Wnn/Key/LookupPageUp" +#define SCIM_DEFAULT_WNN_KEY_LOOKUPPAGEUP "Page_Up" +#define SCIM_CONFIG_WNN_KEY_LOOKUPPAGEDOWN "/IMEngine/Wnn/Key/LookupPageDown" +#define SCIM_DEFAULT_WNN_KEY_LOOKUPPAGEDOWN "Page_Down" + +#define SCIM_CONFIG_WNN_ALP "/IMEngine/Wnn/AutoLookupPopup" +#define SCIM_DEFAULT_WNN_ALP 3 +#define SCIM_CONFIG_WNN_SERVER "/IMEngine/Wnn/Server" +#define SCIM_DEFAULT_WNN_SERVER "localhost" +#define SCIM_CONFIG_WNN_RC "/IMEngine/Wnn/Rc" +#define SCIM_DEFAULT_WNN_RC "/usr/lib/wnn7/ja_JP/wnnenvrc" + +#endif + diff --git a/scim-wnn/src/scim_wnn_imengine.cpp b/scim-wnn/src/scim_wnn_imengine.cpp index 95739e3..cc916d5 100644 --- a/scim-wnn/src/scim_wnn_imengine.cpp +++ b/scim-wnn/src/scim_wnn_imengine.cpp @@ -50,6 +50,7 @@ // scim�Τ��ޤ��ʤ��� // ����Ǹ����С����ɤ�s #include "scim_wnn_imengine.h" +#include "scim_wnn_def.h" #define scim_module_init wnn_LTX_scim_module_init #define scim_module_exit wnn_LTX_scim_module_exit @@ -59,10 +60,6 @@ #define SCIM_WNN_ICON_FILE (SCIM_ICONDIR "/scim-wnn.png") #endif -#define SCIM_CONFIG_WNN_SERVER "/IMEngine/Wnn/Server" -#define SCIM_CONFIG_WNN_RC "/IMEngine/Wnn/Rc" -#define SCIM_CONFIG_WNN_KEY "/IMEngine/Wnn/Key/" -#define SCIM_CONFIG_WNN_ALP "/IMEngine/Wnn/AutoLookupPopup" #define SCIM_PROP_WNN_INPUTMODE "/IMEngine/Wnn/InputMode" static Pointer _scim_wnn_factory; @@ -197,63 +194,62 @@ { m_conversion = false; m_lookup = false; - String host,rc; + m_connected = false; host = _scim_config->read(String(SCIM_CONFIG_WNN_SERVER),String("localhost")); rc = _scim_config->read(String(SCIM_CONFIG_WNN_RC),String("/usr/lib/wnn7/ja_JP/wnnenvrc")); - alp = _scim_config->read(String(SCIM_CONFIG_WNN_ALP),1); + alp = _scim_config->read(String(SCIM_CONFIG_WNN_ALP),SCIM_DEFAULT_WNN_ALP); - wnn.wnnConnect(String("test"),host,rc,10); // �ǥե���ȥ������ꡣ // ����ե����뤫���ɤ�褦�ˤ��Ƥ��ˤ礴�ˤ硣 scim_string_to_key_list(k_conversion_start, - _scim_config->read(String(SCIM_CONFIG_WNN_KEY) + String("ConversionStart"), - String("space"))); + _scim_config->read(String(SCIM_CONFIG_WNN_KEY_CONVERSION_START), + String(SCIM_DEFAULT_WNN_KEY_CONVERSION_START))); scim_string_to_key_list(k_cancel, - _scim_config->read(String(SCIM_CONFIG_WNN_KEY) + String("Cancel"), - String("Escape,Control+g"))); + _scim_config->read(String(SCIM_CONFIG_WNN_KEY_CANCEL), + String(SCIM_DEFAULT_WNN_KEY_CANCEL))); scim_string_to_key_list(k_delete, - _scim_config->read(String(SCIM_CONFIG_WNN_KEY) + String("Delete"), - String("Delete"))); + _scim_config->read(String(SCIM_CONFIG_WNN_KEY_DELETE), + String(SCIM_DEFAULT_WNN_KEY_DELETE))); scim_string_to_key_list(k_backspace, - _scim_config->read(String(SCIM_CONFIG_WNN_KEY) + String("BackSpace"), - String("BackSpace"))); + _scim_config->read(String(SCIM_CONFIG_WNN_KEY_BACKSPACE), + String(SCIM_DEFAULT_WNN_KEY_BACKSPACE))); scim_string_to_key_list(k_commit, - _scim_config->read(String(SCIM_CONFIG_WNN_KEY) + String("Commit"), - String("Return"))); + _scim_config->read(String(SCIM_CONFIG_WNN_KEY_COMMIT), + String(SCIM_DEFAULT_WNN_KEY_COMMIT))); scim_string_to_key_list(k_conversion_next, - _scim_config->read(String(SCIM_CONFIG_WNN_KEY) + String("ConversionNext"), - String("space,Down"))); + _scim_config->read(String(SCIM_CONFIG_WNN_KEY_CONVERSION_NEXT), + String(SCIM_DEFAULT_WNN_KEY_CONVERSION_NEXT))); scim_string_to_key_list(k_conversion_prev, - _scim_config->read(String(SCIM_CONFIG_WNN_KEY) + String("ConversionPrev"), - String("Up"))); + _scim_config->read(String(SCIM_CONFIG_WNN_KEY_CONVERSION_PREV), + String(SCIM_DEFAULT_WNN_KEY_CONVERSION_PREV))); scim_string_to_key_list(k_conversion_expand, - _scim_config->read(String(SCIM_CONFIG_WNN_KEY) + String("ConversionExpand"), - String("Shift+Right,Control+o"))); + _scim_config->read(String(SCIM_CONFIG_WNN_KEY_CONVERSION_EXPAND), + String(SCIM_DEFAULT_WNN_KEY_CONVERSION_EXPAND))); scim_string_to_key_list(k_conversion_shrink, - _scim_config->read(String(SCIM_CONFIG_WNN_KEY) + String("ConversionShrink"), - String("Shift+Left,Control+i"))); + _scim_config->read(String(SCIM_CONFIG_WNN_KEY_CONVERSION_SHRINK), + String(SCIM_DEFAULT_WNN_KEY_CONVERSION_SHRINK))); scim_string_to_key_list(k_conversion_forward, - _scim_config->read(String(SCIM_CONFIG_WNN_KEY) + String("ConversionForward"), - String("Right"))); + _scim_config->read(String(SCIM_CONFIG_WNN_KEY_CONVERSION_FORWARD), + String(SCIM_DEFAULT_WNN_KEY_CONVERSION_FORWARD))); scim_string_to_key_list(k_conversion_backward, - _scim_config->read(String(SCIM_CONFIG_WNN_KEY) + String("ConversionBackward"), - String("Left"))); + _scim_config->read(String(SCIM_CONFIG_WNN_KEY_CONVERSION_BACKWARD), + String(SCIM_DEFAULT_WNN_KEY_CONVERSION_BACKWARD))); scim_string_to_key_list(k_forward, - _scim_config->read(String(SCIM_CONFIG_WNN_KEY) + String("Forward"), - String("Right"))); + _scim_config->read(String(SCIM_CONFIG_WNN_KEY_FORWARD), + String(SCIM_DEFAULT_WNN_KEY_FORWARD))); scim_string_to_key_list(k_backward, - _scim_config->read(String(SCIM_CONFIG_WNN_KEY) + String("Backward"), - String("Left"))); + _scim_config->read(String(SCIM_CONFIG_WNN_KEY_BACKWARD), + String(SCIM_DEFAULT_WNN_KEY_BACKWARD))); scim_string_to_key_list(k_lookup_popup, - _scim_config->read(String(SCIM_CONFIG_WNN_KEY) + String("LookupPopup"), - String("Alt+s"))); + _scim_config->read(String(SCIM_CONFIG_WNN_KEY_LOOKUPPOPUP), + String(SCIM_DEFAULT_WNN_KEY_LOOKUPPOPUP))); scim_string_to_key_list(k_lookup_pageup, - _scim_config->read(String(SCIM_CONFIG_WNN_KEY) + String("LookupPageUp"), - String("Page_Up"))); + _scim_config->read(String(SCIM_CONFIG_WNN_KEY_LOOKUPPAGEUP), + String(SCIM_DEFAULT_WNN_KEY_LOOKUPPAGEUP))); scim_string_to_key_list(k_lookup_pagedown, - _scim_config->read(String(SCIM_CONFIG_WNN_KEY) + String("LookupPageDown"), - String("Page_Down"))); + _scim_config->read(String(SCIM_CONFIG_WNN_KEY_LOOKUPPAGEDOWN), + String(SCIM_DEFAULT_WNN_KEY_LOOKUPPAGEDOWN))); } @@ -278,11 +274,12 @@ if (!m_rk.getTextLength()) { return(false); } - m_conversion = true; startConversion(m_rk.getText(true)); show_preedit_string(); - update_preedit_string(wnn.getText(),wnn.getAttributeList()); - update_preedit_caret(wnn.getCaretPos()); + if (m_conversion) { + update_preedit_string(wnn.getText(),wnn.getAttributeList()); + update_preedit_caret(wnn.getCaretPos()); + } return(true); } else if (k_commit.comp(key)) { @@ -370,6 +367,7 @@ m_conversion = false; hide_preedit_string(); hide_lookup_table(); + hide_aux_string(); m_lookup = false; alp_count = 0; return(true); @@ -380,6 +378,7 @@ update_preedit_string(m_rk.getText()); update_preedit_caret(m_rk.getPos()); hide_lookup_table(); + hide_aux_string(); m_lookup = false; alp_count = 0; return(true); @@ -388,6 +387,7 @@ k_conversion_prev.comp(key) ? m_convList.pos --: m_convList.pos ++; if (m_convList.pos >= m_convList.count) m_convList.pos = 0; else if (m_convList.pos < 0) m_convList.pos = m_convList.count - 1; + alp_count ++; wnn.select(m_convList.pos); update_preedit_string(wnn.getText(),wnn.getAttributeList()); @@ -396,7 +396,6 @@ m_lookup_table.set_cursor_pos(m_convList.pos); update_lookup_table(m_lookup_table); } - alp_count ++; return(true); } else if (k_conversion_expand.comp(key) || k_conversion_shrink.comp(key)) { @@ -407,6 +406,7 @@ update_preedit_string(wnn.getText(),wnn.getAttributeList()); update_preedit_caret(wnn.getCaretPos()); hide_lookup_table(); + hide_aux_string(); m_lookup = false; alp_count = 0; return(true); @@ -417,6 +417,7 @@ update_preedit_string(wnn.getText(),wnn.getAttributeList()); update_preedit_caret(wnn.getCaretPos()); hide_lookup_table(); + hide_aux_string(); m_lookup = false; alp_count = 0; return(true); @@ -429,6 +430,7 @@ m_conversion = false; hide_preedit_string(); hide_lookup_table(); + hide_aux_string(); m_lookup = false; alp_count = 0; return(process_preedit_key_event(key)); @@ -500,6 +502,7 @@ m_conversion = false; m_lookup = false; hide_lookup_table (); + hide_aux_string(); hide_preedit_string (); wnn.reset(); m_rk.reset(); @@ -519,6 +522,7 @@ m_conversion = false; hide_preedit_string(); hide_lookup_table(); + hide_aux_string(); m_lookup = false; alp_count = 0; } else if (m_rk.getTextLength()) { @@ -542,9 +546,20 @@ */ void WnnInstance::startConversion(WideString s) { + if (!m_connected) { + m_connected = wnn.wnnConnect(String("test"),host,rc,0); + } + if (!m_connected) { + update_aux_string(utf8_mbstowcs(String(_("could not connect to jserver.")))); + show_aux_string(); + return; + } + wnn.setYomiText(s); wnn.ren_conversion(); m_convList = wnn.getConversionList(); + m_conversion = true; + alp_count = 0; } @@ -571,5 +586,7 @@ { createLookupTable(m_convList); m_lookup = true; + update_aux_string(utf8_mbstowcs(String(_("lookup result")))); + show_aux_string(); show_lookup_table(); } diff --git a/scim-wnn/src/scim_wnn_imengine.h b/scim-wnn/src/scim_wnn_imengine.h index 7ce93de..9e1e05a 100644 --- a/scim-wnn/src/scim_wnn_imengine.h +++ b/scim-wnn/src/scim_wnn_imengine.h @@ -88,6 +88,9 @@ PropertyList m_proplist; int alp; int alp_count; + String host; + String rc; + bool m_connected; protected: bool process_preedit_key_event(const KeyEvent &key); bool process_conversion_key_event(const KeyEvent &key); diff --git a/scim-wnn/src/wnnconversion.cpp b/scim-wnn/src/wnnconversion.cpp index 92ff551..ab62e74 100644 --- a/scim-wnn/src/wnnconversion.cpp +++ b/scim-wnn/src/wnnconversion.cpp @@ -87,9 +87,9 @@ */ bool WnnConversion::wnnConnect(String name,String host,String rc,int timeout) { - wnn = jl_open_lang((char *)name.data(),(char *)host.data(),"jp_JP",(char *)rc.data(),wnn_error,wnn_message,timeout); + wnn = jl_open((char *)name.data(),(char *)host.data(),(char *)rc.data(),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) return(false); + if (wnn == NULL) return(false); return(true); }