?? pinyinwb.c
字號:
/*************************************************************************/
/* */
/* Copyright (C) 2004 SHENZHEN MEIJIN CO.LTD */
/* */
/* FILE NAME: PinYinWB.c */
/* MODULE NAME: 拼音和五筆輸入法 */
/* DESCRIPTION: 輸入法 */
/* */
/*************************************************************************/
/* DTAE AUTHOR VERSION REMARKS */
/* =========== ========== ========= ===================================*/
/* 2004-12-18 Bingle Ver 1.00 筆點機 */
/* 2007-04-05 mann Ver 1.1 針對6X8系列無數字鍵進行修改 */
/*************************************************************************/
#include "Kernel.h"
#include "ImeIn.h"
UINT8 g_byPYShengPressed;
UINT8 g_pIMEPyIndexBuffer[IM_INBUFF_LEN];
UINT8 g_pIMEWordBuffer[IM_WORD_MAX*2]; //IM_WORD_MAX*2
UINT16 g_pIMECurIndex;
UINT16 g_pIMEWbOrderNum;
UINT16 g_pIMEWordIndexNum; //用于五筆取數據
VOID _PinYinDrawGraph(UINT uType);
char Char2Num(UINT uChar);
/****************************************************************************/
/* FUNCTION: _IMEHandleEvent */
/* DESCRIPTION:輸入法消息處理公共函數 */
/* INPUTS: uType,當前輸入法類型 */
/* pEvent,消息結構 */
/* OUTPUTS: pEvent */
/* RETURN: 消息處理結果 */
/****************************************************************************/
/* NAME DATE REMARKS */
/* ========== ============ ==============================================*/
/* Qorse 2003-04-04 創建初始版本 */
/****************************************************************************/
FOR_IME_ALL
INT _IMEHandleEvent(IMEGUI_STRUCT *pApGui, UINT *pEvent, UINT *pParam,UINT uType)
{
BOOL bClearMsg;
UINT16 wMsgX;
UINT inputlen;
char cC2N;
bClearMsg = FALSE;
wMsgX = (UINT16)*pParam;
if (*pEvent == EVENT_DRAW)
{
g_mInputBox.refresh = IME_NEED_REFRESH;
}
else if(*pEvent == EVENT_KEY|| *pEvent==EVENT_KEYREPEAT)
{
BOOL bDirectOut;
bDirectOut = FALSE;
if(g_mInputBox.state == IM_INPUT_ERROR)
{
__ResetIME();
}
if(wMsgX == MVK_ESCAPE)
{
if(g_mInputBox.state == IM_INPUT_NULL)
{
return 0;
}
else
{
__ResetIME();
bClearMsg = TRUE;
}
}
else if (wMsgX == ' ')
{
bDirectOut = FALSE;
}
else if(wMsgX == MVK_DELETE || wMsgX == MVK_BACKSPACE)
{
if(g_mInputBox.state == IM_INPUT_NULL || g_mInputBox.state == IM_INPUT_LX)
{
return 0;
}
else if(g_mInputBox.state == IM_INPUT_ZC || g_mInputBox.state == IM_INPUT_DOING)
{
g_pIMEInBuffer[--g_pIMEInputednum] = 0;
if (g_pIMEInputednum == 0)
{
__ResetIME();
}
else
{
_PyWbGetData(uType);
g_mInputBox.state = IM_INPUT_DOING;
}
g_mInputBox.refresh = IME_NEED_REFRESH;
bClearMsg = TRUE;
}
else
{
__ResetIME();
}
}
__IMEGetChar(pEvent,pParam);
if(pApGui->uCurrentIme != IME_JAPANESE){ //added by Liang Ruhui at 2007-07-09
__ImeConvertCase(pEvent,pParam);
}
wMsgX = (UINT16)*pParam;
if(!bDirectOut)
{
switch (g_mInputBox.state)
{
case IM_INPUT_NULL:
if (MyIsAlpha(wMsgX))//(wMsgX >= 'a' && wMsgX <= 'z')
{
g_pIMEInBuffer[g_pIMEInputednum++] = (UINT8)wMsgX;
g_mInputBox.state = IM_INPUT_DOING;
_PyWbGetData(uType);
g_mInputBox.refresh = IME_NEED_REFRESH;
bClearMsg = TRUE;
}
break;
case IM_INPUT_DOING: /*正在輸入*/
if (wMsgX == ' ')
{
if (uType == IME_WUBI)
{
*pParam = '1';
wMsgX = '1';
bClearMsg = !_IMEGetSelectWord(pEvent,pParam);
break;
}
else if(uType == IME_JAPANESE){
if(g_pIMEWordNum == 1){
*pParam = '1';
wMsgX = '1';
bClearMsg = !_IMEGetSelectWord(pEvent,pParam);
}
else if(g_pIMEWordNum > 1){
/*輸入狀態,左右鍵用來輸入選字模式*/
g_mInputBox.state = IM_INPUT_ZC; /*轉入選字模式,并更新顯示*/
g_mInputBox.refresh = TRUE;
bClearMsg = TRUE;
}
else{
bClearMsg = TRUE;
}
break;
}
else if (uType == IME_PINYIN)
{
g_mInputBox.state = IM_INPUT_ZC;
}
else
{
break;
}
}
else if (MyIsAlpha(wMsgX))//(wMsgX >= 'a' && wMsgX <= 'z')
{
if (uType == IME_WUBI)
{
inputlen = IMWB_INPUT_LEN;
}
else
{
inputlen = IMPY_INPUT_LEN;
}
if (g_pIMEInputednum < inputlen)
{
if (uType == IME_PINYIN)
{
UINT8 *pTail;
pTail = &g_pIMEInBuffer[g_pIMEInputednum - 1];
if (!MyIsAlpha(*pTail))
{
bClearMsg = TRUE;
break;
}
}
g_pIMEInBuffer[g_pIMEInputednum++] = (UINT8)wMsgX;
_PyWbGetData(uType);
if( uType == IME_WUBI && g_pIMEInputednum == IMWB_INPUT_LEN)
{
if (g_pIMEWordNum == 1 )
{
*pParam = '1';
_IMEGetSelectWord(pEvent,pParam);
return 0;
}
else
{
g_mInputBox.state = IM_INPUT_ZC;
g_mInputBox.refresh = TRUE;
}
}
}
bClearMsg = TRUE;
break;
}
else if(wMsgX == MVK_LEFT || wMsgX == MVK_RIGHT || wMsgX == MVK_ENTER )
{
/*輸入狀態,左右鍵用來輸入選字模式*/
g_mInputBox.state = IM_INPUT_ZC; /*轉入選字模式,并更新顯示*/
g_mInputBox.refresh = TRUE;
bClearMsg = TRUE;
break;
}
case IM_INPUT_LX: //聯想狀態
case IM_INPUT_LXZC:
case IM_INPUT_ZC: /*選擇字詞*/
if(wMsgX == MVK_LEFT || wMsgX == MVK_RIGHT)
{
/*選字模式,左右鍵用來進行翻頁*/
g_mInputBox.refresh = _imLeftRight(pEvent,pParam);
bClearMsg = TRUE;
}
else if (wMsgX == ' ')
{
if ((uType == IME_WUBI))
{
*pParam = '1';
wMsgX = '1';
bClearMsg = !_IMEGetSelectWord(pEvent,pParam);
break;
}
else if ((uType == IME_PINYIN) || (uType == IME_JAPANESE))
{
UINT8 *pTail;
UINT8 tone;
UINT loopCount;
if (g_pIMEInputednum <= IMPY_INPUT_LEN)
{
loopCount = 0;
check_tone:
pTail = &g_pIMEInBuffer[g_pIMEInputednum - 1];
if (MyIsAlpha(*pTail))
{
if((g_pIMEInputednum == 0)
|| (g_pIMEInputednum == IMPY_INPUT_LEN))
{
bClearMsg = TRUE;
break;
}
g_pIMEInBuffer[g_pIMEInputednum++] = '1';
}
else
{
tone = *pTail - '0';
if (tone == 5)
{
tone = 1;
}
else
{
tone ++;
}
tone += '0';
g_pIMEInBuffer[g_pIMEInputednum - 1] = tone;
}
if(!_PyWbGetData(uType))
{
loopCount ++;
if (loopCount <= 4)
{
goto check_tone;
}
else
{
g_pIMEInBuffer[--g_pIMEInputednum] = 0;
_PyWbGetData(uType);
}
}
bClearMsg = TRUE;
}
}
}
else if (MyIsAlpha(wMsgX))//(wMsgX >= 'a' && wMsgX <= 'z')
{
cC2N = Char2Num(wMsgX); // 將字符鍵映射到數字
if(cC2N > '0' && cC2N <= '0' + g_pIMEWordTypeNum)
{
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -