📄 chcand.cpp
字号:
/*++
Copyright (c) 1990-1999 Microsoft Corporation, All Rights Reserved
Module Name:
chcand.c
++*/
#include <windows.h>
#include <imm.h>
#include "imedefs.h"
/**********************************************************************/
/* SelectOneCand() */
/**********************************************************************/
void PASCAL SelectOneCand(
LPINPUTCONTEXT lpIMC,
LPCOMPOSITIONSTRING lpCompStr,
LPPRIVCONTEXT lpImcP,
LPCANDIDATELIST lpCandList)
{
DWORD dwCompStrLen;
DWORD dwReadStrLen;
if (!lpCompStr) return;
if (!lpImcP) return;
// backup the dwCompStrLen, this value decide whether
// we go for phrase prediction
dwCompStrLen = lpCompStr->dwCompStrLen;
dwReadStrLen = lpCompStr->dwCompReadStrLen;
InitCompStr(lpCompStr);
// calculate result string length
lpCompStr->dwResultStrLen = lstrlen(
(LPTSTR)((LPBYTE)lpCandList + lpCandList->dwOffset[
lpCandList->dwSelection]));
// the result string = the selected candidate;
lstrcpy((LPTSTR)((LPBYTE)lpCompStr + lpCompStr->dwResultStrOffset),
(LPTSTR)((LPBYTE)lpCandList + lpCandList->dwOffset[
lpCandList->dwSelection]));
// tell application, there is a reslut string
lpImcP->fdwImeMsg |= MSG_COMPOSITION;
lpImcP->dwCompChar = (DWORD)0;
lpImcP->fdwGcsFlag |= GCS_COMPREAD|GCS_COMP|GCS_CURSORPOS|
GCS_DELTASTART|GCS_RESULTREAD|GCS_RESULT;
//lpImcP->fdwImeMsg |= MSG_ALREADY_OPEN|MSG_ALREADY_START;
if (lpImcP->fdwImeMsg & MSG_ALREADY_OPEN) {
lpImcP->fdwImeMsg = (lpImcP->fdwImeMsg | MSG_CLOSE_CANDIDATE) &
~(MSG_OPEN_CANDIDATE);
}
// no candidate now, the right candidate string already be finalized
lpCandList->dwCount = 0;
lpImcP->iImeState = CST_INIT;
// init Engine private data
*(LPDWORD)lpImcP->bSeq = 0;
return;
}
/**********************************************************************/
/* CandEscapeKey() */
/**********************************************************************/
void PASCAL CandEscapeKey(
LPINPUTCONTEXT lpIMC,
LPPRIVCONTEXT lpImcP)
{
LPCOMPOSITIONSTRING lpCompStr;
// clean all candidate information
if (lpImcP->fdwImeMsg & MSG_ALREADY_OPEN) {
ClearCand(lpIMC);
lpImcP->fdwImeMsg = (lpImcP->fdwImeMsg | MSG_CLOSE_CANDIDATE) &
~(MSG_OPEN_CANDIDATE);
}
// if it start composition, we need to clean composition
if (!(lpImcP->fdwImeMsg & MSG_ALREADY_START)) {
return;
}
lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
if (!lpCompStr) {
return;
}
CompEscapeKey(lpIMC, lpCompStr, lpImcP);
ImmUnlockIMCC(lpIMC->hCompStr);
return;
}
/**********************************************************************/
/* ChooseCand() */
/**********************************************************************/
void PASCAL ChooseCand( // choose one of candidate strings by
// input char
WORD wCharCode,
LPINPUTCONTEXT lpIMC,
LPCANDIDATEINFO lpCandInfo,
LPPRIVCONTEXT lpImcP)
{
LPCANDIDATELIST lpCandList;
if (!lpCandInfo) {
return;
}
lpCandList = (LPCANDIDATELIST)
((LPBYTE)lpCandInfo + lpCandInfo->dwOffset[0]);
if (wCharCode == TEXT(' ')) { // circle selection
if ((lpCandList->dwSelection += lpCandList->dwPageSize) >=
lpCandList->dwCount) {
// no more candidates, restart it!
lpCandList->dwSelection = 0;
// __asm int 3;
MessageBeep((UINT)-1);
}
// inform UI, dwSelectedCand is changed
lpImcP->fdwImeMsg |= MSG_CHANGE_CANDIDATE;
return;
}
if (wCharCode == TEXT('=')) { // next selection
if (( lpCandList->dwSelection + lpCandList->dwPageSize ) > lpCandList->dwCount ){
return;
}
lpCandList->dwSelection += lpCandList->dwPageSize;
// inform UI, dwSelectedCand is changed
lpImcP->fdwImeMsg |= MSG_CHANGE_CANDIDATE;
return;
}
if (wCharCode == TEXT('-')) { // previous selection
if (lpCandList->dwSelection < lpCandList->dwPageSize) {
MessageBeep((UINT)-1);
// __asm int 3;
return;
}
lpCandList->dwSelection -= lpCandList->dwPageSize;
// inform UI, dwSelectedCand is changed
lpImcP->fdwImeMsg |= MSG_CHANGE_CANDIDATE;
return;
}
if (wCharCode == 0x23) { // previous selection
if(sImeL.dwRegImeIndex == INDEX_GB){
if (lpCandList->dwSelection >= ((IME_MAXCAND-1)/CANDPERPAGE)*lpCandList->dwPageSize) {
MessageBeep((UINT)-1);
// __asm int 3;
return;
}else{
lpCandList->dwSelection = ((IME_MAXCAND-1)/CANDPERPAGE)*lpCandList->dwPageSize;
}
}else if(sImeL.dwRegImeIndex == INDEX_GBK){
if (lpCandList->dwSelection >= ((IME_XGB_MAXCAND-1)/CANDPERPAGE)*lpCandList->dwPageSize) {
MessageBeep((UINT)-1);
// __asm int 3;
return;
}else{
lpCandList->dwSelection = ((IME_XGB_MAXCAND-1)/CANDPERPAGE)*lpCandList->dwPageSize;
}
}else if(sImeL.dwRegImeIndex == INDEX_UNICODE){
if (lpCandList->dwSelection >= ((IME_UNICODE_MAXCAND-1)/CANDPERPAGE)*lpCandList->dwPageSize) {
MessageBeep((UINT)-1);
// __asm int 3;
return;
}else{
lpCandList->dwSelection = ((IME_UNICODE_MAXCAND-1)/CANDPERPAGE)*lpCandList->dwPageSize;
}
}
// inform UI, dwSelectedCand is changed
lpImcP->fdwImeMsg |= MSG_CHANGE_CANDIDATE;
return;
}
if (wCharCode == 0x24) {
if (lpCandList->dwSelection < lpCandList->dwPageSize) {
MessageBeep((UINT)-1);
// __asm int 3;
return;
}
lpCandList->dwSelection = 0;
// inform UI, dwSelectedCand is changed
lpImcP->fdwImeMsg |= MSG_CHANGE_CANDIDATE;
return;
}
if (wCharCode == TEXT('?')) { // home selection
if (lpCandList->dwSelection == 0) {
MessageBeep((UINT)-1); // already home!
// __asm int 3;
return;
}
lpCandList->dwSelection = 0;
// inform UI, dwSelectedCand is changed
lpImcP->fdwImeMsg |= MSG_CHANGE_CANDIDATE;
return;
}
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -