📄 dic.c
字号:
( VK_MULTIPLY <= wParam && VK_DIVIDE >= wParam ))
{
// RETURN篮 烹苞登瘤 臼绊, 官肺 拉何盒俊辑 贸府啊 场抄促.
// 葛龙扼父 肋 给 悼累窍瘤 臼绰促搁 RETURN虐档 贸府且 荐 乐促.
return( FALSE );
}
else {
TCHAR szDev[80];
wsprintf(szDev, TEXT("code: %x\r\n"), wParam);
OutputDebugString(szDev);
return( TRUE );
}
}
/**********************************************************************/
/* */
/* Entry : MakeResultString( HIMC) */
/* */
/**********************************************************************/
BOOL WINAPI MakeResultString( HIMC hIMC, BOOL fFlag)
{
TRANSMSG GnMsg;
LPCOMPOSITIONSTRING lpCompStr;
LPCANDIDATEINFO lpCandInfo;
LPINPUTCONTEXT lpIMC;
if (!IsCompStr(hIMC))
return FALSE;
lpIMC = ImmLockIMC(hIMC);
lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
if (IsCandidate(lpIMC))
{
lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
ClearCandidate(lpCandInfo);
ImmUnlockIMCC(lpIMC->hCandInfo);
GnMsg.message = WM_IME_NOTIFY;
GnMsg.wParam = IMN_CLOSECANDIDATE;
GnMsg.lParam = 1L;
GenerateMessage(hIMC, lpIMC, lpCurTransKey,(LPTRANSMSG)&GnMsg);
}
Mylstrcpy(GETLPRESULTSTR(lpCompStr),GETLPCOMPSTR(lpCompStr));
Mylstrcpy(GETLPRESULTREADSTR(lpCompStr),GETLPCOMPREADSTR(lpCompStr));
lpCompStr->dwResultStrLen = lpCompStr->dwCompStrLen;
lpCompStr->dwResultReadStrLen = lpCompStr->dwCompReadStrLen;
lpCompStr->dwCompStrLen = 0;
lpCompStr->dwCompReadStrLen = 0;
//
// make clause info
//
SetClause(GETLPRESULTCLAUSE(lpCompStr),Mylstrlen(GETLPRESULTSTR(lpCompStr)));
SetClause(GETLPRESULTREADCLAUSE(lpCompStr),Mylstrlen(GETLPRESULTREADSTR(lpCompStr)));
lpCompStr->dwResultClauseLen = 8;
lpCompStr->dwResultReadClauseLen = 8;
ImmUnlockIMCC(lpIMC->hCompStr);
if (fFlag)
{
#if 1
// 茄臂 IME 2002绰 捞惑窍霸档, 刚历 WM_IME_ENDCOMPOSITION阑 柜绊
// 弊 促澜俊 WM_IME_COMPOSITION阑 柜绰促.
// 捞犯霸 秦具父 绊绊鸥磊俊辑 沥惑 累悼阑 茄促.
GnMsg.message = WM_IME_ENDCOMPOSITION;
GnMsg.wParam = 0;
GnMsg.lParam = 0;
GenerateMessage(hIMC, lpIMC, lpCurTransKey,(LPTRANSMSG)&GnMsg);
#endif
GnMsg.message = WM_IME_COMPOSITION;
GnMsg.wParam = 0;
GnMsg.lParam = GCS_RESULTALL;
if (dwImeFlag & SAENARU_ONTHESPOT)
{
LPMYSTR lpptr;
LPMYSTR lpstr;
DWORD dwCurPos;
dwCurPos = lpCompStr->dwCursorPos;
lpstr = GETLPCOMPSTR(lpCompStr);
lpptr = MyCharPrev( lpstr, lpstr+dwCurPos );
GnMsg.wParam = *lpptr;
}
GenerateMessage(hIMC, lpIMC, lpCurTransKey,(LPTRANSMSG)&GnMsg);
#if 0
GnMsg.message = WM_IME_ENDCOMPOSITION;
GnMsg.wParam = 0;
GnMsg.lParam = 0;
GenerateMessage(hIMC, lpIMC, lpCurTransKey,(LPTRANSMSG)&GnMsg);
#endif
}
ImmUnlockIMC(hIMC);
return TRUE;
}
/**********************************************************************/
/* */
/* MakeGuideLine() */
/* */
/* Update the transrate key buffer. */
/* */
/**********************************************************************/
BOOL PASCAL MakeGuideLine(HIMC hIMC, DWORD dwID)
{
LPINPUTCONTEXT lpIMC;
LPGUIDELINE lpGuideLine;
TRANSMSG GnMsg;
DWORD dwSize = sizeof(GUIDELINE) + (MAXGLCHAR + sizeof(MYCHAR)) * 2 * sizeof(MYCHAR);
LPMYSTR lpStr;
lpIMC = ImmLockIMC(hIMC);
lpIMC->hGuideLine = ImmReSizeIMCC(lpIMC->hGuideLine,dwSize);
lpGuideLine = (LPGUIDELINE)ImmLockIMCC(lpIMC->hGuideLine);
lpGuideLine->dwSize = dwSize;
lpGuideLine->dwLevel = glTable[dwID].dwLevel;
lpGuideLine->dwIndex = glTable[dwID].dwIndex;
lpGuideLine->dwStrOffset = sizeof(GUIDELINE);
lpStr = (LPMYSTR)(((LPSTR)lpGuideLine) + lpGuideLine->dwStrOffset);
LoadString(hInst,glTable[dwID].dwStrID,lpStr, MAXGLCHAR);
lpGuideLine->dwStrLen = Mylstrlen(lpStr);
if (glTable[dwID].dwPrivateID)
{
lpGuideLine->dwPrivateOffset = sizeof(GUIDELINE) + (MAXGLCHAR + 1) * sizeof(MYCHAR);
lpStr = (LPMYSTR)(((LPSTR)lpGuideLine) + lpGuideLine->dwPrivateOffset);
LoadString(hInst,glTable[dwID].dwStrID,lpStr, MAXGLCHAR);
lpGuideLine->dwPrivateSize = Mylstrlen(lpStr) * sizeof(MYCHAR);
}
else
{
lpGuideLine->dwPrivateOffset = 0L;
lpGuideLine->dwPrivateSize = 0L;
}
GnMsg.message = WM_IME_NOTIFY;
GnMsg.wParam = IMN_GUIDELINE;
GnMsg.lParam = 0;
GenerateMessage(hIMC, lpIMC, lpCurTransKey,(LPTRANSMSG)&GnMsg);
ImmUnlockIMCC(lpIMC->hGuideLine);
ImmUnlockIMC(hIMC);
return TRUE;
}
/**********************************************************************/
/* */
/* GenerateMessage() */
/* */
/* Update the transrate key buffer. */
/* */
/**********************************************************************/
BOOL PASCAL GenerateMessage(HIMC hIMC, LPINPUTCONTEXT lpIMC, LPTRANSMSGLIST lpTransBuf,LPTRANSMSG lpGeneMsg)
{
MyDebugPrint((TEXT("GenerateMessage:TransKey %d\n"),lpGeneMsg->message));
if (lpTransBuf)
return GenerateMessageToTransKey(lpTransBuf,lpGeneMsg);
MyDebugPrint((TEXT("GenerateMessage:ImmGenerateMessage %d\n"),lpGeneMsg->message));
if (IsWindow(lpIMC->hWnd))
{
LPTRANSMSG lpTransMsg;
if (!(lpIMC->hMsgBuf = ImmReSizeIMCC(lpIMC->hMsgBuf,
sizeof(TRANSMSG) * (lpIMC->dwNumMsgBuf +1))))
return FALSE;
if (!(lpTransMsg = (LPTRANSMSG)ImmLockIMCC(lpIMC->hMsgBuf)))
return FALSE;
lpTransMsg[lpIMC->dwNumMsgBuf] = *lpGeneMsg;
ImmUnlockIMCC(lpIMC->hMsgBuf);
lpIMC->dwNumMsgBuf++;
ImmGenerateMessage(hIMC);
}
return TRUE;
}
/**********************************************************************/
/* */
/* Entry : CheckAttr( LPCOMPOSITIONSTRING) */
/* */
/**********************************************************************/
BOOL PASCAL CheckAttr( LPCOMPOSITIONSTRING lpCompStr)
{
int i,len;
LPBYTE lpb = GETLPCOMPATTR(lpCompStr);
len = lpCompStr->dwCompAttrLen;
for (i = 0; i < len; i++)
if (*lpb++ & 0x01)
return TRUE;
return FALSE;
}
/**********************************************************************/
/* */
/* Entry : MakeAttrClause( LPCOMPOSITIONSTRING) */
/* */
/**********************************************************************/
void PASCAL MakeAttrClause( LPCOMPOSITIONSTRING lpCompStr)
{
int len = lpCompStr->dwCompAttrLen;
int readlen = lpCompStr->dwCompReadAttrLen;
LPDWORD lpdw;
LPBYTE lpb;
DWORD dwCursorPos = lpCompStr->dwCursorPos;
int i;
if (len != readlen)
return;
lpb = GETLPCOMPATTR(lpCompStr);
for (i = 0;i < len; i++)
{
if ((DWORD)i < dwCursorPos)
*lpb++ = 0x10;
else
*lpb++ = 0x00;
}
lpb = GETLPCOMPREADATTR(lpCompStr);
for (i = 0;i < readlen; i++)
{
if ((DWORD)i < dwCursorPos)
*lpb++ = 0x10;
else
*lpb++ = 0x00;
}
lpdw = GETLPCOMPCLAUSE(lpCompStr);
*lpdw++ = 0;
*lpdw++ = (BYTE)dwCursorPos;
*lpdw++ = len;
lpdw = GETLPCOMPREADCLAUSE(lpCompStr);
*lpdw++ = 0;
*lpdw++ = (BYTE)dwCursorPos;
*lpdw++ = len;
}
/**********************************************************************/
/* */
/* Entry : HandleShiftArrow( HIMC, fArrow) */
/* */
/**********************************************************************/
void PASCAL HandleShiftArrow( HIMC hIMC, BOOL fArrow)
{
LPINPUTCONTEXT lpIMC;
LPCOMPOSITIONSTRING lpCompStr;
DWORD dwStartClause = 0;
DWORD dwEndClause = 0;
LPMYSTR lpstart,lpstr,lpend;
if (!(lpIMC = ImmLockIMC(hIMC)))
return;
if (lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr))
{
// Temp! Error, if the string is already converted.
if (CheckAttr(lpCompStr))
goto hsa_exit;
lpstart = GETLPCOMPSTR(lpCompStr);
lpstr = lpstart + lpCompStr->dwCursorPos;
lpend = lpstart + Mylstrlen(lpstart);
if (fArrow == ARR_RIGHT)
{
if (lpstr < lpend)
lpstr = MyCharNext(lpstr);
}
else
{
if (lpstr > lpstart)
lpstr = MyCharPrev(lpstart,lpstr);
}
lpCompStr->dwCursorPos = (DWORD)(lpstr - lpstart);
MakeAttrClause(lpCompStr);
}
hsa_exit:
ImmUnlockIMCC(lpIMC->hCompStr);
ImmUnlockIMC(hIMC);
}
int CopyCandidateStringsFromDictionary(LPMYSTR lpDic, LPMYSTR lpRead, LPMYSTR lpBuf, DWORD dwBufLen)
{
DWORD dwWritten = 0;
LPMYSTR lpSection, lpTemp;
const LPMYSTR szSep = MYTEXT(" \r\n\t");
LPMYSTR lpToken = Mystrtok(lpDic, szSep);
while (NULL != lpToken)
{
if (MYTEXT('[') == *lpToken)
{
lpSection = lpToken + 1;
if (NULL != (lpTemp = Mystrchr(lpSection, MYTEXT(']'))))
*lpTemp = MYTEXT('\0');
if (0 == Mylstrcmp(lpSection, lpRead))
{
lpToken = Mystrtok(NULL, szSep);
break; // found it.
}
}
lpToken = Mystrtok(NULL, szSep);
}
if (NULL != lpToken)
{
LPMYSTR lpWrite = lpBuf;
DWORD dwW;
while ((NULL != lpToken) &&
((dwBufLen - dwWritten) > 1) &&
(MYTEXT('[') != *lpToken))
{
if (NULL != (lpTemp = Mystrchr(lpToken, MYTEXT('='))))
*lpTemp = MYTEXT('\0');
Mylstrcpyn(lpWrite, lpToken, dwBufLen - dwWritten - 1);
dwW = Mylstrlen(lpToken) + 1;
lpWrite += dwW;
dwWritten += dwW;
lpToken = Mystrtok(NULL, szSep);
}
*lpWrite = MYTEXT('\0');
dwWritten++;
return dwWritten;
}
return 0;
}
int GetCandidateStringsFromDictionary(LPMYSTR lpRead, LPMYSTR lpBuf, DWORD dwBufLen, LPTSTR lpFilename)
{
HANDLE hTblFile;
PSECURITY_ATTRIBUTES psa;
int nSize = 0;
DWORD dwFileSize, dwRead;
LPMYSTR lpDic;
psa = CreateSecurityAttributes();
hTblFile = CreateFile(lpFilename,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
(HANDLE)NULL);
if (hTblFile == INVALID_HANDLE_VALUE) {
goto Err0;
}
if (dwBufLen > 2)
{
if ((dwFileSize = GetFileSize(hTblFile, (LPDWORD)NULL)) != 0xffffffff)
{
if ((lpDic = (LPMYSTR)GlobalAlloc(GPTR, dwFileSize + 2)))
{
if (ReadFile(hTblFile, lpDic, dwFileSize, &dwRead, NULL))
{
if (*lpDic == 0xfeff)
{
*(LPWSTR)(((LPBYTE)lpDic) + dwFileSize) = MYTEXT('\0');
nSize = CopyCandidateStringsFromDictionary(lpDic+1, lpRead, lpBuf, dwBufLen);
}
}
GlobalFree(lpDic);
}
}
}
CloseHandle(hTblFile);
Err0:
FreeSecurityAttributes(psa);
return nSize;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -