HZspecial.c
资源名称:大熊猫输入法原码.zip [点击查看]
上传用户:szljw888
上传日期:2010-04-11
资源大小:124k
文件大小:4k
源码类别:
输入法编程
开发平台:
C/C++
- /* 大熊猫输入法(Free Chinese Input) 由YJMSIR(yjmsir@163.com)编写
- * 协议: GPL
- * freeinput( A Chinese Input Method) by YJMSIR(yjmsir@163.com)
- * Licence: GPL
- */
- #include "freepy.h"
- BOOL ReturnWuBicode(HIMC hIMC)
- {
- LPINPUTCONTEXT lpIMC;
- LPCOMPOSITIONSTRING lpCompStr;
- LPTSTR lpPreResultStr,lpStr;
- lpIMC = ImmLockIMC(hIMC);
- lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
- lpPreResultStr = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPreResultStr;
- if( _tcslen(lpPreResultStr)){
- lpStr = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPaintCompStr;
- _tcscpy(lpStr,lpPreResultStr);
- //_tcscat(lpStr,_T(" 五笔:"));
- _tcscat(lpStr,_T(" "));
- _tcscat(lpStr,StatusDisplay[CONVERSION_MODE_WUBI]);
- if(FindWuBiCodeWhole(lpPreResultStr))
- _tcscat(lpStr,YJMMessage);
- if(FindPYSWhole(lpPreResultStr)){
- //_tcscat(lpStr,_T("拼音:"));
- _tcscat(lpStr,_T(" "));
- _tcscat(lpStr,StatusDisplay[CONVERSION_MODE_PINYIN]);
- _tcscat(lpStr,YJMMessage);
- }
- _tcscpy(lpPreResultStr,"");
- MessageBox(NULL,lpStr,_T("编码查询结果"),MB_OK);
- ImmUnlockIMCC(lpIMC->hCompStr);
- ImmUnlockIMC(hIMC);
- return TRUE;
- }
- ImmUnlockIMCC(lpIMC->hCompStr);
- ImmUnlockIMC(hIMC);
- return FALSE;
- }
- BOOL RepeatPreResult(HIMC hIMC)
- {
- LPINPUTCONTEXT lpIMC;
- LPCOMPOSITIONSTRING lpCompStr;
- LPTSTR lpPreResultStr,lpConvStr;
- lpIMC = ImmLockIMC(hIMC);
- lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
- lpPreResultStr = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPreResultStr;
- if( _tcslen(lpPreResultStr) ){
- lpConvStr = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szConvCompStr;
- _tcscpy(lpConvStr,lpPreResultStr);
- MakeResultString(hIMC,TRUE);
- ImmUnlockIMCC(lpIMC->hCompStr);
- ImmUnlockIMC(hIMC);
- return TRUE;
- }
- ImmUnlockIMCC(lpIMC->hCompStr);
- ImmUnlockIMC(hIMC);
- return FALSE;
- }
- //产生符号
- BOOL GeneratePunct(HIMC hIMC, WORD wCode)
- {
- LPINPUTCONTEXT lpIMC;
- LPCOMPOSITIONSTRING lpCompStr;
- LPTSTR lpStr,lpConvStr,lpPreResultStr;
- WORD wHead,wLength;
- TCHAR cLastPreResultChar,MiddleResult[10];
- static BOOL i;
- lpIMC = ImmLockIMC(hIMC);
- lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
- lpCompStr->dwCompStrLen = 0;
- lpConvStr = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szConvCompStr;
- wLength=_tcslen(lpConvStr);
- //如果设置中文标点
- if(wConversionSet & CONVERSION_SET_PUNCT) {
- wHead = wCode - _T('!');
- //lpStr = aPunct[wHead][0];
- lpStr = aPunct+32*40*wHead;
- _tcscpy(MiddleResult,lpStr);
- if( _tcslen(lpStr) ){
- //对./的处理,对大键盘数字可以正确处理,对小键盘还不能正确处理。
- if( wCode == _T('.') || wCode == _T('/') ) {
- lpPreResultStr = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPreResultStr;
- cLastPreResultChar = *CharPrev(lpPreResultStr,lpPreResultStr + _tcslen(lpPreResultStr));
- //if(cLastPreResultChar >= _T('!') && cLastPreResultChar <= _T('~') ) {
- if(cLastPreResultChar >= _T('0') && cLastPreResultChar <= _T('9') ||( VK_OEM_1 <= cLastPreResultChar && VK_OEM_9 >= cLastPreResultChar )) {
- *MiddleResult = (TCHAR)wCode;
- *(MiddleResult+1) = _T(' ');
- }
- else _tcscpy(MiddleResult,lpStr);
- }
- //单引号的处理
- else if( wCode == _T(''')){
- i=!i;
- _tcscpy(MiddleResult,i?_T("‘"):_T("’"));
- }
- //双引号的处理
- else if( wCode == _T('"')){
- i=!i;
- _tcscpy(MiddleResult,i?_T("“"):_T("”"));
- }
- if(wLength==0)_tcscpy(lpConvStr,MiddleResult);
- else _tcscat(lpConvStr,MiddleResult);
- //DebugLog(2,(DebugLogFile,"lpConvStr: %s MiddleResult:%sn",lpConvStr,MiddleResult));
- MakeResultString(hIMC,TRUE);
- ImmUnlockIMCC(lpIMC->hCompStr);
- ImmUnlockIMC(hIMC);
- return TRUE;
- }
- }
- else {
- *lpConvStr = (TCHAR)wCode;
- *(lpConvStr+1) = _T(' ');
- MakeResultString(hIMC,TRUE);
- ImmUnlockIMCC(lpIMC->hCompStr);
- ImmUnlockIMC(hIMC);
- return TRUE;
- }
- ImmUnlockIMCC(lpIMC->hCompStr);
- ImmUnlockIMC(hIMC);
- return FALSE;
- }