diff --git a/scim-wnn/src/scim_wnn_imengine.cpp b/scim-wnn/src/scim_wnn_imengine.cpp index a4b66a0..e4119e0 100644 --- a/scim-wnn/src/scim_wnn_imengine.cpp +++ b/scim-wnn/src/scim_wnn_imengine.cpp @@ -265,7 +265,13 @@ return(true); } if ((key.code == SCIM_KEY_Left) || (key.code == SCIM_KEY_Right)) { - key.code == SCIM_KEY_Left ? wnn.setPos(wnn.getPos() - 1) : wnn.setPos(wnn.getPos() + 1); + if (key.mask == SCIM_KEY_ShiftMask) { + bool r; + key.code == SCIM_KEY_Left ? r = wnn.resizeRegion(-1) : r = wnn.resizeRegion(1); + if (!r) return(true); + } else { + key.code == SCIM_KEY_Left ? wnn.setPos(wnn.getPos() - 1) : wnn.setPos(wnn.getPos() + 1); + } m_convList = wnn.getConversionList(); update_preedit_string(wnn.getText(),wnn.getAttributeList()); return(true); diff --git a/scim-wnn/src/wnnconversion.cpp b/scim-wnn/src/wnnconversion.cpp index 93226e9..58c8040 100644 --- a/scim-wnn/src/wnnconversion.cpp +++ b/scim-wnn/src/wnnconversion.cpp @@ -118,6 +118,7 @@ { yomiText.clear(); bunList.clear(); + yomiList.clear(); text.clear(); attr.clear(); pos = 0; @@ -141,6 +142,7 @@ convList.Yomi.clear(); convList.kouho.clear(); bunList.clear(); + yomiList.clear(); pos = 0; w_char ws[1024]; char c[2048]; @@ -149,17 +151,55 @@ strtows(ws,(unsigned char*)y.data()); bunsetu = jl_ren_conv(wnn,ws,0,-1,WNN_USE_ATO); bunList.resize(bunsetu); + yomiList.resize(bunsetu); for(unsigned int i = 0;i < bunsetu;i ++) { WideString w; wnn_get_area(wnn,i,i + 1,ws,1); wstostr((unsigned char*)c,ws); m_iconv.convert(w,c,strlen(c)); bunList[i] = w; + wnn_get_area(wnn,i,i + 1,ws,0); + wstostr((unsigned char*)c,ws); + m_iconv.convert(w,c,strlen(c)); + yomiList[i] = 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; + bunsetu = jl_nobi_conv(wnn,pos,yomiList[pos].length() + w,-1,WNN_USE_ATO,WNN_SHO); + convList.kouho.clear(); + bunList.clear(); + bunList.resize(bunsetu); + yomiList.resize(bunsetu); + for(unsigned int i = 0;i < bunsetu;i ++) { + WideString w; + wnn_get_area(wnn,i,i + 1,ws,1); + wstostr((unsigned char*)c,ws); + m_iconv.convert(w,c,strlen(c)); + bunList[i] = w; + wnn_get_area(wnn,i,i + 1,ws,0); + wstostr((unsigned char*)c,ws); + m_iconv.convert(w,c,strlen(c)); + yomiList[i] = w; + } + createText(); + return(true); +} + /*! \fn WnnConversion::createText() @@ -234,6 +274,7 @@ convList.pos = jl_zenkouho(wnn,pos,WNN_USE_ATO,WNN_UNIQ); convList.count = jl_zenkouho_suu(wnn); convList.kouho.resize(convList.count); + for (unsigned int i = 0;i < convList.count; i ++) { w_char k[1024]; char buf[2048]; @@ -265,3 +306,5 @@ } + + diff --git a/scim-wnn/src/wnnconversion.h b/scim-wnn/src/wnnconversion.h index 5b8e9e3..82f6cc9 100644 --- a/scim-wnn/src/wnnconversion.h +++ b/scim-wnn/src/wnnconversion.h @@ -60,6 +60,7 @@ WnnConversionList getConversionList(int p = -1); bool select(int p); AttributeList getAttributeList(); + bool resizeRegion(int w); protected: void wstostr(unsigned char *e,w_char *u); @@ -77,6 +78,7 @@ int bunsetu; WideString text; vector bunList; + vector yomiList; AttributeList attr; WnnConversionList convList; diff --git a/scim-wnn/src/wnnproto.h b/scim-wnn/src/wnnproto.h index b89c5c6..a26e56b 100644 --- a/scim-wnn/src/wnnproto.h +++ b/scim-wnn/src/wnnproto.h @@ -36,6 +36,7 @@ int jl_zenkouho_suu(struct wnn_buf*); void jl_get_zenkouho_kanji(struct wnn_buf*,int ,w_char *); int jl_set_jikouho(struct wnn_buf*,int); + int jl_nobi_conv(struct wnn_buf*,int,int,int,int,int); #define WNN_NO_USE 0 #define WNN_USE_MAE 1 @@ -49,6 +50,9 @@ #define WNN_NO_CREATE 0 #define WNN_CREATE (-1) + #define WNN_SHO 0 + #define WNN_DAI 1 + #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)