diff --git a/scim-wnn/src/scim_wnn_imengine.cpp b/scim-wnn/src/scim_wnn_imengine.cpp index 72891e6..f67ee78 100644 --- a/scim-wnn/src/scim_wnn_imengine.cpp +++ b/scim-wnn/src/scim_wnn_imengine.cpp @@ -205,7 +205,8 @@ rc = _scim_config->read(String(SCIM_CONFIG_WNN_RC),String(SCIM_DEFAULT_WNN_RC)); alp = _scim_config->read(String(SCIM_CONFIG_WNN_ALP),SCIM_DEFAULT_WNN_ALP); mini_status = _scim_config->read(String(SCIM_CONFIG_WNN_MINISTATUS),SCIM_DEFAULT_WNN_MINISTATUS); - + // @todo ���꤫���ɽФ��� + yosoku = true; // �ǥե���ȥ������ꡣ scim_string_to_key_list(k_conversion_start, @@ -332,6 +333,7 @@ update_preedit_caret(m_preeditor->getPos()); } else { hide_preedit_string(); + hide_lookup_table(); } if (mini_status) { update_aux_string(utf8_mbstowcs(m_preeditor->getModeName())); @@ -339,7 +341,21 @@ } else { hide_aux_string(); } - hide_lookup_table(); + + if (yosoku && m_preeditor->getTextLength() && m_connected) { + m_convList = wnn.getYosokuList(m_preeditor->getText()); + if (m_convList.count) { + m_lookup_table.clear(); + for(unsigned int i = 0;i < m_convList.count;i ++) { + m_lookup_table.append_candidate(m_convList.kouho.at(i)); + } + startLookup(); + } else { + //m_lookup_table.clear(); + hide_lookup_table(); + } + } + updateProperty(); } /*! @@ -430,6 +446,7 @@ if (m_preeditor->inputEvent(key)) { updatePreEditor(); + return(true); } else { // preeditor�ǽ����Ǥ��ʤ��ä����Ϥ�Ϥ�commit���ƥ��ץꥱ���������֤��٤����� @@ -596,10 +613,12 @@ int p = m_lookup_table.get_current_page_start() + item; m_convList.pos = p; wnn.select(m_convList.pos); - update_preedit_string(wnn.getText(),wnn.getAttributeList()); - update_preedit_caret(wnn.getCaretPos()); - m_lookup_table.set_cursor_pos(m_convList.pos); - update_lookup_table(m_lookup_table); + if (m_convList.kType != YOSOKU) { + update_preedit_string(wnn.getText(),wnn.getAttributeList()); + update_preedit_caret(wnn.getCaretPos()); + m_lookup_table.set_cursor_pos(m_convList.pos); + update_lookup_table(m_lookup_table); + } } void WnnInstance::update_lookup_table_page_size (unsigned int page_size) @@ -751,6 +770,10 @@ update_aux_string(utf8_mbstowcs(String(_("association lookup result")))); break; } + case YOSOKU: { + update_aux_string(utf8_mbstowcs(String(_("yosoku lookup result")))); + break; + } default: { update_aux_string(utf8_mbstowcs(String(_("lookup result")))); break; diff --git a/scim-wnn/src/scim_wnn_imengine.h b/scim-wnn/src/scim_wnn_imengine.h index 4fe4874..0d5d65a 100644 --- a/scim-wnn/src/scim_wnn_imengine.h +++ b/scim-wnn/src/scim_wnn_imengine.h @@ -30,6 +30,11 @@ #include #include +#ifdef HAVE_CONFIG_H +#include +#endif + + using namespace scim; using namespace std; @@ -91,6 +96,7 @@ int alp; int alp_count; bool mini_status; + bool yosoku; String host; String rc; bool m_connected; diff --git a/scim-wnn/src/wnnconversion.cpp b/scim-wnn/src/wnnconversion.cpp index d135715..ea2a183 100644 --- a/scim-wnn/src/wnnconversion.cpp +++ b/scim-wnn/src/wnnconversion.cpp @@ -87,9 +87,13 @@ */ bool WnnConversion::wnnConnect(String name,String host,String rc,int timeout) { - wnn = jl_open((char *)name.data(),(char *)host.data(),(char *)rc.data(),wnn_error,wnn_message,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 return(true); } @@ -151,6 +155,7 @@ } + /*! \fn WnnConversion::ren_conversion() */ @@ -165,7 +170,7 @@ char c[2048]; String y; m_iconv.convert(y,yomiText); - strtows(ws,(unsigned char*)y.data()); + 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 ++) { @@ -280,6 +285,35 @@ /*! + \fn WnnConversion::getYosokuList(const WideString &str) + */ +WnnConversionList WnnConversion::getYosokuList(const WideString &str) +{ + convList.Yomi = str; + convList.kouho.clear(); + convList.count = 0; + convList.pos = 0; + convList.kType = YOSOKU; + #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 < convList.count;i ++) { + WideString w; + m_iconv.convert(w,ykYosokuKouho[i],strlen(ykYosokuKouho[i])); + convList.kouho.push_back(w); + } + //jl_yosoku_free(wnn); + #endif + return(convList); +} + + +/*! \fn WnnConversion::getConversionList(int p,KouhoType kt) */ WnnConversionList WnnConversion::getConversionList(int p,KouhoType kt) @@ -351,7 +385,19 @@ { if (p > convList.count) p = 0; convList.pos = p; - if (convList.kType == DEFAULT) jl_set_jikouho_dai(wnn,p); + switch(convList.kType) { + case DEFAULT: { + jl_set_jikouho_dai(wnn,p); + break; + } + case YOSOKU: { + // ͽ¬��Ͽ�򤹤٤��� + return(true); + } + default: { + break; + } + } bunList.at(pos) = convList.kouho.at(p); createText(); @@ -383,3 +429,5 @@ { return(caretPos); } + + diff --git a/scim-wnn/src/wnnconversion.h b/scim-wnn/src/wnnconversion.h index fd51997..dbb0515 100644 --- a/scim-wnn/src/wnnconversion.h +++ b/scim-wnn/src/wnnconversion.h @@ -30,6 +30,12 @@ #include #include +#ifdef HAVE_CONFIG_H +#include +#endif + + + using namespace scim; using namespace std; @@ -37,7 +43,7 @@ /** @author TAM(Teppei Tamra) */ -enum KouhoType { DEFAULT, IKEIJI, RENSOU }; +enum KouhoType { DEFAULT, IKEIJI, RENSOU, YOSOKU }; class WnnConversionList{ public: @@ -48,6 +54,7 @@ vector kouho; }; + class WnnConversion{ public: WnnConversion(); @@ -61,6 +68,7 @@ int setPos(int p); int getPos(); WnnConversionList getConversionList(int p = -1 ,KouhoType kt = DEFAULT); + WnnConversionList getYosokuList(const WideString &str); bool select(int p); AttributeList getAttributeList(); bool resizeRegion(int w); diff --git a/scim-wnn/src/wnnproto.h b/scim-wnn/src/wnnproto.h index 3a1d333..4495d56 100644 --- a/scim-wnn/src/wnnproto.h +++ b/scim-wnn/src/wnnproto.h @@ -59,6 +59,23 @@ #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 *);