Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4328 lines
192 KiB

  1. /*++
  2. Copyright (c) 1995-1999 Microsoft Corporation, All Rights Reserved
  3. Module Name:
  4. UI.c
  5. ++*/
  6. #include <stdio.h>
  7. #include <windows.h>
  8. #include <string.h>
  9. #include <memory.h>
  10. #include <immdev.h>
  11. #include "imedefs.h"
  12. typedef struct tagINTERCODEAREA {
  13. DWORD PreCount;
  14. DWORD StartInterCode;
  15. DWORD EndInterCode;
  16. } INTERCODEAREA,*LPINTERCODEAREA;
  17. PPRIVCONTEXT lpEngPrivate;
  18. EMB_Head *EMB_Table;
  19. TCHAR *ZM_Area;
  20. HANDLE HmemEMB_Table;
  21. DWORD MaxXLen;
  22. WORD MaxCodes, NumCodes;
  23. TCHAR UsedCode[MAXUSEDCODES];
  24. TCHAR WildChar;
  25. BYTE CodeAIndex[128];
  26. int MAX_LEN;
  27. MB_Head MB_Head_Table[48];
  28. LPBYTE EMBM = NULL;
  29. LPBYTE g_lptep = NULL;
  30. extern UINT UI_CANDSTR;
  31. extern MBINDEX MBIndex;
  32. #pragma data_seg (".sgroup")
  33. HMapStruc HMapTab[MaxTabNum] = {0};
  34. #pragma data_seg ()
  35. UINT WINAPI MB_SUB(HIMCC,TCHAR,BYTE,UINT);
  36. int WINAPI StartEngine(HIMCC) ;
  37. int WINAPI EndEngine(HIMCC);
  38. void CapKeyProc(TCHAR);
  39. int GetMBHead(void);
  40. BYTE GetEMBHead(void);
  41. UINT DelDoubleBuf(void);
  42. void ClrDoubleBuf(void);
  43. void ClrSelBuf(void);
  44. void DelSelBuf(void);
  45. void DelWCEdit(void);
  46. void ClrWCBuf(void);
  47. UINT CoreMBComp(TCHAR,BYTE);
  48. UINT WildProcess(TCHAR) ;
  49. int EMBWCWildComp(TCHAR,BYTE,int);
  50. int MBWCWildComp(TCHAR,BYTE,int);
  51. void SearchEMBPos(TCHAR,BYTE);
  52. UINT SearchEMBCompMatch(void);
  53. UINT SearchMBCompMatch(TCHAR);
  54. void SearchBEMBCompMatch(void);
  55. void SearchBMBCompMatch(void);
  56. void SearchEMBWildMatch(void);
  57. void SearchMBWildMatch(BYTE);
  58. void SearchBEMBWildMatch(void);
  59. void SearchBMBWildMatch(BYTE);
  60. void SearchBMBWWMatch(TCHAR,BYTE);
  61. void SearchMBWWMatch(TCHAR,BYTE);
  62. void SearchBEMBWWMatch(TCHAR,BYTE);
  63. void SearchEMBWWMatch(TCHAR,BYTE);
  64. void SearchEMBLXMatch(void);
  65. void SearchMBLXMatch(void);
  66. void SearchBEMBLXMatch(void);
  67. void SearchBMBLXMatch(void);
  68. void PageDnUp(BYTE);
  69. void CoreMBCompDnUp(BYTE);
  70. void CoreLXCompDnUp(BYTE);
  71. int CoreMCCompDnUp(BYTE);
  72. void CoreWWCompDnUp(BYTE);
  73. UINT CoreUnitProcess(TCHAR);
  74. void TurnToFirstPage(void);
  75. void TurnToEndPage(void);
  76. UINT CoreProcess(BYTE);
  77. UINT SelectCandi(TCHAR);
  78. UINT LXSelectCandi(TCHAR);
  79. UINT DefSelect(void);
  80. void TSMulCProc(void);
  81. void CoreLXComp(void);
  82. DWORD Skip_CaWord(DWORD);
  83. int Scan_Word(DWORD,LPTSTR);
  84. int VerScan_Word(DWORD,LPTSTR);
  85. BYTE WildInBuffer(void);
  86. BYTE CodeInSet(char);
  87. UINT InCodeSet(TCHAR);
  88. void Sort_EMB(int,int) ;
  89. void IMDReset(int) ;
  90. BOOL WriteEMBToFile(LPTSTR) ;
  91. BOOL GetUDCItem(HIMCC,UINT,LPTSTR,LPTSTR);
  92. int GetUDCIndex(HIMCC,LPTSTR,LPTSTR);
  93. int AddZCItem(HIMCC,LPTSTR,LPTSTR);
  94. void DelSelCU(HIMCC,int) ;
  95. void DelExmb(HIMCC);
  96. void Swap_Item(int,int);
  97. void ConvertCandi(void);
  98. BYTE MBPositionSearch(LPCTSTR ) ;
  99. BYTE EMBPositionSearch(LPCTSTR ) ;
  100. int GetFirstCode(LPTSTR ) ;
  101. DWORD GetNumber(HANDLE ,DWORD ,LPTSTR );
  102. UINT Conversion(HIMCC,LPCTSTR,UINT );
  103. UINT ReadArea(TCHAR );
  104. void ResetCont(HIMCC);
  105. int NumInSet(void);
  106. BOOL UnRegisterWord(HIMCC,LPCTSTR,LPCTSTR);
  107. UINT EnumRegisterWord(HIMCC,LPCTSTR,LPCTSTR,LPVOID);
  108. long GetLengthofBuf(void);
  109. long GetLengthTepBuf(LPTSTR);
  110. long GetLengthCCharBuf(LPTSTR);
  111. int Inputcodelen(LPCTSTR);
  112. int DBCSCharlen(LPCTSTR);
  113. LPTSTR _tcschr(LPTSTR, TCHAR);
  114. LPTSTR _rtcschr(LPTSTR string, TCHAR c);
  115. int IsGBK(LPTSTR);
  116. UINT WINAPI MB_SUB(HIMCC HmemPri,TCHAR code ,BYTE c_state, UINT UI_Mode) {
  117. UINT ret_state = 0;
  118. lpEngPrivate = (PPRIVCONTEXT) ImmLockIMCC(HmemPri);
  119. if(!lpEngPrivate){
  120. return ((UINT)-1);
  121. }
  122. if(UI_Mode==BOX_UI)
  123. MAX_LEN = 3000;
  124. else if(UI_Mode==LIN_UI)
  125. MAX_LEN = UI_CANDSTR;
  126. if(code>=TEXT('A') && code<=TEXT('Z')) {
  127. if(lpEngPrivate->PrivateArea.Comp_Status.dwPPTFH==0) //QuanJiao Switch if Off
  128. return (1); //English char don't do any process ,only return a status
  129. else {
  130. CapKeyProc(code); //Process quanjiao char
  131. return (2);
  132. }
  133. } else {
  134. //Capslock is up*/
  135. switch (code) {
  136. case 0x08: //Bac kspace key
  137. ret_state = DelDoubleBuf();
  138. break;
  139. case 0x1b:
  140. ClrDoubleBuf();
  141. lpEngPrivate->PrivateArea.Comp_Status.dwSTLX = 0;
  142. ret_state = 0;
  143. break;
  144. case TEXT('='):
  145. if (CodeAIndex[code] != 0 )
  146. goto here;
  147. else {
  148. if ((lpEngPrivate->PrivateArea.Comp_Context.PromptCnt==0) || (lpEngPrivate->PrivateArea.Comp_Status.dwInvalid==1))
  149. ret_state = 1;
  150. else {
  151. PageDnUp(1);
  152. ret_state = 0;
  153. }
  154. }
  155. break;
  156. case TEXT('-'):
  157. if (CodeAIndex[code] != 0 )
  158. goto here;
  159. else {
  160. if ((lpEngPrivate->PrivateArea.Comp_Context.PromptCnt==0) || (lpEngPrivate->PrivateArea.Comp_Status.dwInvalid==1))
  161. ret_state = 1;
  162. else {
  163. PageDnUp(0);
  164. ret_state = 0;
  165. }
  166. }
  167. break;
  168. case 0x21: //PGUP
  169. if ((lpEngPrivate->PrivateArea.Comp_Context.PromptCnt==0) || (lpEngPrivate->PrivateArea.Comp_Status.dwInvalid==1))
  170. ret_state = 1;
  171. else {
  172. PageDnUp(0);
  173. ret_state = 0;
  174. }
  175. break;
  176. case 0x22: //VK_PGDN
  177. if ((lpEngPrivate->PrivateArea.Comp_Context.PromptCnt==0) || (lpEngPrivate->PrivateArea.Comp_Status.dwInvalid==1))
  178. ret_state = 1;
  179. else {
  180. PageDnUp(1);
  181. ret_state = 0;
  182. }
  183. break;
  184. /////////////////
  185. case 0x23: //VK_END
  186. if ((lpEngPrivate->PrivateArea.Comp_Context.PromptCnt==0) || (lpEngPrivate->PrivateArea.Comp_Status.dwInvalid==1))
  187. ret_state = 1;
  188. else {
  189. TurnToEndPage();
  190. ret_state = 0;
  191. }
  192. break;
  193. case 0x24: //VK_HOME
  194. if ((lpEngPrivate->PrivateArea.Comp_Context.PromptCnt==0) || (lpEngPrivate->PrivateArea.Comp_Status.dwInvalid==1))
  195. ret_state = 1;
  196. else {
  197. TurnToFirstPage();
  198. ret_state = 0;
  199. }
  200. break;
  201. default:
  202. here:
  203. if (lpEngPrivate->PrivateArea.Comp_Status.dwSTLX==1) {
  204. if(code>=TEXT('0') && code<=TEXT('9') && c_state==1) {
  205. ret_state = LXSelectCandi(code); // select candidate
  206. } else if(CodeAIndex[code] != 0) {
  207. ClrDoubleBuf();
  208. lpEngPrivate->PrivateArea.Comp_Status.dwSTLX = 0;
  209. ret_state = CoreUnitProcess(code); //Retriver MB
  210. } else if(code>=TEXT('0') && code <=TEXT('9')) {
  211. ret_state = LXSelectCandi(code); // select candidate
  212. } else if(code==0x20) {
  213. ret_state = DefSelect();
  214. }
  215. } else {
  216. if(code>=TEXT('0') && code<=TEXT('9') && c_state==1) {
  217. ret_state = SelectCandi(code); // select candidate
  218. } else if(CodeAIndex[code] != 0 ) {
  219. //After input invalid code ,if input code_unit ,clear double buffer and begin again.
  220. if (lpEngPrivate->PrivateArea.Comp_Status.dwInvalid) {
  221. ClrDoubleBuf();
  222. lpEngPrivate->PrivateArea.Comp_Status.dwSTLX = 0;
  223. } else {
  224. ClrSelBuf();
  225. }
  226. if (lpEngPrivate->PrivateArea.Comp_Context.PromptCnt<MaxCodes) {
  227. if(lpEngPrivate->PrivateArea.Comp_Context.PromptCnt!=0 && _tcschr(lpEngPrivate->PrivateArea.Comp_Context.szInBuffer,WildChar)!=NULL)
  228. ret_state = WildProcess(code);
  229. else
  230. ret_state = CoreUnitProcess(code); //Retriver MB
  231. if ((lpEngPrivate->PrivateArea.Comp_Status.dwInvalid==1) && (lpEngPrivate->PrivateArea.Comp_Context.PromptCnt<MaxCodes)) {
  232. lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[lpEngPrivate->PrivateArea.Comp_Context.PromptCnt] = code;
  233. lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[lpEngPrivate->PrivateArea.Comp_Context.PromptCnt+1] = 0x0;
  234. lpEngPrivate->PrivateArea.Comp_Context.PromptCnt ++;
  235. MessageBeep((UINT)-1);
  236. }
  237. }
  238. } else if(code>=TEXT('0') && code<=TEXT('9')) {
  239. if(NumInSet())
  240. ret_state = 1;
  241. else
  242. ret_state = SelectCandi(code); // select candidate
  243. } else if(code==0x20) {
  244. ret_state = DefSelect();
  245. } else if (lpEngPrivate->PrivateArea.Comp_Context.PromptCnt==0) {
  246. ret_state = 1;
  247. } else if(code == WildChar) {
  248. ClrSelBuf();
  249. if ((lpEngPrivate->PrivateArea.Comp_Status.dwInvalid==0) || (lpEngPrivate->PrivateArea.Comp_Context.PromptCnt<MaxCodes)) {
  250. ret_state = WildProcess(code);
  251. if ((lpEngPrivate->PrivateArea.Comp_Status.dwInvalid==1) && (lpEngPrivate->PrivateArea.Comp_Context.PromptCnt<MaxCodes)) {
  252. lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[lpEngPrivate->PrivateArea.Comp_Context.PromptCnt] = code;
  253. lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[lpEngPrivate->PrivateArea.Comp_Context.PromptCnt+1] = 0x0;
  254. lpEngPrivate->PrivateArea.Comp_Context.PromptCnt ++;
  255. }
  256. }
  257. }
  258. }
  259. }
  260. ImmUnlockIMCC(HmemPri);
  261. return (ret_state);
  262. }
  263. }
  264. int WINAPI StartEngine(HIMCC HmemPri) {
  265. HANDLE hFile,hCProcess,hMProcess=NULL;
  266. TCHAR path_name[MAX_PATH];
  267. int i,j;
  268. TCHAR *tepstr;
  269. int byte_t_read;
  270. PSECURITY_ATTRIBUTES psa = NULL;
  271. lpEngPrivate = (PPRIVCONTEXT) ImmLockIMCC(HmemPri);
  272. if(!lpEngPrivate){
  273. return (0);
  274. }
  275. //bugfix to get current mb_name
  276. lstrcpy(lpEngPrivate->MB_Name,HMapTab[0].MB_Name);
  277. for (i=0;i<MaxTabNum;i++ ) {
  278. if(lstrcmp(HMapTab[i].MB_Name,lpEngPrivate->MB_Name)==0) {
  279. break;
  280. }
  281. }
  282. if(HMapTab[i].RefCnt) {
  283. lstrcpy(lpEngPrivate->EMB_Name,lpEngPrivate->MB_Name);
  284. tepstr = _rtcschr(lpEngPrivate->EMB_Name,TEXT('.'));
  285. *tepstr = TEXT('\0');
  286. lstrcat(lpEngPrivate->EMB_Name,TEXT(".EMB"));
  287. lpEngPrivate->PrivateArea.hMapMB = OpenFileMapping(FILE_MAP_READ|FILE_MAP_WRITE,
  288. FALSE,
  289. HMapTab[i].MB_Obj);
  290. hCProcess = GetCurrentProcess();
  291. hMProcess = OpenProcess(STANDARD_RIGHTS_REQUIRED|PROCESS_DUP_HANDLE,
  292. FALSE,HMapTab[i].EMB_ID);
  293. byte_t_read = DuplicateHandle(hMProcess,
  294. HMapTab[i].hMbFile,
  295. hCProcess,
  296. &lpEngPrivate->PrivateArea.hMbFile,
  297. 0,
  298. FALSE,
  299. DUPLICATE_SAME_ACCESS);
  300. if (HMapTab[i].hEmbFile!=NULL) {
  301. DuplicateHandle(hMProcess,
  302. HMapTab[i].hEmbFile,
  303. hCProcess,
  304. &lpEngPrivate->PrivateArea.hEmbFile,
  305. 0,
  306. FALSE,
  307. DUPLICATE_SAME_ACCESS);
  308. HmemEMB_Table = OpenFileMapping(FILE_MAP_READ|FILE_MAP_WRITE,
  309. FALSE,
  310. HMapTab[i].EMB_Obj);
  311. if(HmemEMB_Table!=NULL) {
  312. lpEngPrivate->PrivateArea.GlobVac.EMB_Exist = 1;
  313. if (EMBM) UnmapViewOfFile(EMBM);
  314. EMBM =MapViewOfFile(HmemEMB_Table,
  315. FILE_MAP_READ|FILE_MAP_WRITE,
  316. 0,
  317. 0,
  318. 0);
  319. lpEngPrivate->PrivateArea.GlobVac.EMB_Count = *(WORD *)EMBM;
  320. EMB_Table = (EMB_Head *)(EMBM+2);
  321. lpEngPrivate->PrivateArea.hMapEMB = HmemEMB_Table ;
  322. } else
  323. lpEngPrivate->PrivateArea.GlobVac.EMB_Exist = 0;
  324. } else {
  325. lpEngPrivate->PrivateArea.hMapEMB = NULL ;
  326. lpEngPrivate->PrivateArea.GlobVac.EMB_Exist = 0;
  327. }
  328. GetMBHead();
  329. } else {
  330. if (!GetMBHead()) {
  331. ImmUnlockIMCC(HmemPri);
  332. return(0);
  333. }
  334. StringCchCopy(path_name, ARRAYSIZE(path_name), sImeG.szIMESystemPath);
  335. StringCchCat(path_name, ARRAYSIZE(path_name), TEXT("\\"));
  336. StringCchCat(path_name, ARRAYSIZE(path_name), lpEngPrivate->MB_Name);
  337. psa = CreateSecurityAttributes();
  338. hFile = CreateFile(path_name,
  339. GENERIC_READ,
  340. FILE_SHARE_READ,
  341. psa,
  342. OPEN_EXISTING,
  343. 0,
  344. NULL);
  345. if(hFile==INVALID_HANDLE_VALUE) {
  346. FreeSecurityAttributes(psa);
  347. MessageBeep((UINT)-1);
  348. ImmUnlockIMCC(HmemPri);
  349. return(0);
  350. }
  351. HMapTab[i].hMbFile = hFile;
  352. lpEngPrivate->PrivateArea.hMbFile = hFile;
  353. lstrcpy(HMapTab[i].MB_Obj, lpEngPrivate->MB_Name);
  354. tepstr = _rtcschr(HMapTab[i].MB_Obj,TEXT('.'));
  355. *tepstr = TEXT('\0');
  356. HMapTab[i].EMB_Obj[0] = TEXT('e');
  357. HMapTab[i].EMB_Obj[1] = 0;
  358. lstrcat(HMapTab[i].EMB_Obj,HMapTab[i].MB_Obj);
  359. HMapTab[i].EMB_ID = GetCurrentProcessId();
  360. lpEngPrivate->PrivateArea.hMapMB = CreateFileMapping(hFile,
  361. psa,
  362. PAGE_READONLY,
  363. 0,
  364. 0,
  365. HMapTab[i].MB_Obj);
  366. if(lpEngPrivate->PrivateArea.GlobVac.EMB_Exist = GetEMBHead()) {
  367. HMapTab[i].hEmbFile = lpEngPrivate->PrivateArea.hEmbFile;
  368. HmemEMB_Table = CreateFileMapping(lpEngPrivate->PrivateArea.hEmbFile,
  369. psa,
  370. PAGE_READWRITE,
  371. 0,
  372. sizeof(EMB_Head)*MAXNUMBER_EMB+2,
  373. HMapTab[i].EMB_Obj);
  374. if (EMBM) UnmapViewOfFile(EMBM);
  375. EMBM = (LPBYTE)MapViewOfFile(HmemEMB_Table,
  376. FILE_MAP_READ|FILE_MAP_WRITE,
  377. 0,
  378. 0,
  379. sizeof(EMB_Head)*MAXNUMBER_EMB+2);
  380. EMB_Table =(EMB_Head *)(EMBM + 2);
  381. lpEngPrivate->PrivateArea.hMapEMB = HmemEMB_Table ;
  382. } else {
  383. HMapTab[i].hEmbFile = NULL;
  384. lpEngPrivate->PrivateArea.hEmbFile = NULL;
  385. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos = 0;
  386. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos = 0;
  387. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos = 0;
  388. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos = 0;
  389. EMB_Table = NULL;
  390. lpEngPrivate->PrivateArea.GlobVac.EMB_Count = 0;
  391. }
  392. }
  393. HMapTab[i].RefCnt ++;
  394. lpEngPrivate->PrivateArea.Comp_Context.PromptCnt = 0;
  395. if (psa != NULL)
  396. FreeSecurityAttributes(psa);
  397. ImmUnlockIMCC(HmemPri);
  398. if (hMProcess)
  399. CloseHandle(hMProcess);
  400. return(1);
  401. }
  402. int WINAPI EndEngine(HIMCC HmemPri) {
  403. int i;
  404. int state;
  405. lpEngPrivate = (PPRIVCONTEXT) ImmLockIMCC(HmemPri);
  406. if(!lpEngPrivate){
  407. return (0);
  408. }
  409. for(i=0; i<MaxTabNum; i++ ) {
  410. if(lstrcmp(lpEngPrivate->MB_Name, HMapTab[i].MB_Name)==0)
  411. break;
  412. }
  413. if(i==MaxTabNum) {
  414. ImmUnlockIMCC(HmemPri);
  415. return(0);
  416. }
  417. if(EMBM)
  418. state = FlushViewOfFile(EMBM,0);
  419. HMapTab[i].RefCnt--;
  420. if(HMapTab[i].RefCnt>0) {
  421. if(HMapTab[i].EMB_ID!=GetCurrentProcessId()) {
  422. if(lpEngPrivate->PrivateArea.hMbFile)
  423. state = CloseHandle(lpEngPrivate->PrivateArea.hMbFile);
  424. if(lpEngPrivate->PrivateArea.hEmbFile)
  425. state = CloseHandle(lpEngPrivate->PrivateArea.hEmbFile);
  426. }
  427. } else {
  428. if(EMBM) {
  429. UnmapViewOfFile(EMBM);
  430. EMBM = NULL;
  431. }
  432. if(lpEngPrivate->PrivateArea.hMbFile)
  433. state = CloseHandle(lpEngPrivate->PrivateArea.hMbFile);
  434. if(lpEngPrivate->PrivateArea.hEmbFile){
  435. SetFilePointer(lpEngPrivate->PrivateArea.hEmbFile,
  436. lpEngPrivate->PrivateArea.GlobVac.EMB_Count*sizeof(EMB_Head)+2,
  437. NULL,
  438. FILE_BEGIN);
  439. state = SetEndOfFile(lpEngPrivate->PrivateArea.hEmbFile);
  440. state = CloseHandle(lpEngPrivate->PrivateArea.hEmbFile);
  441. }
  442. HMapTab[i].hMbFile = NULL;
  443. HMapTab[i].hEmbFile = NULL;
  444. HMapTab[i].RefCnt = 0;
  445. }
  446. ImmUnlockIMCC(HmemPri);
  447. return (1);
  448. }
  449. int GetMBHead() {
  450. HANDLE hFile;
  451. TCHAR path_name[MAX_PATH];
  452. int i;
  453. MB_Head *lpMB_Head;
  454. DWORD byte_w_read,byte_t_read;
  455. DWORD tag,offset;
  456. PSECURITY_ATTRIBUTES psa;
  457. BOOL retVal;
  458. psa = CreateSecurityAttributes();
  459. StringCchCopy(path_name, ARRAYSIZE(path_name), sImeG.szIMESystemPath);
  460. StringCchCat(path_name, ARRAYSIZE(path_name), TEXT("\\"));
  461. StringCchCat(path_name, ARRAYSIZE(path_name), lpEngPrivate->MB_Name);
  462. hFile = CreateFile(path_name,
  463. GENERIC_READ,
  464. FILE_SHARE_READ,
  465. psa,
  466. OPEN_EXISTING,
  467. 0,
  468. NULL);
  469. FreeSecurityAttributes(psa);
  470. if(hFile==INVALID_HANDLE_VALUE) {
  471. MessageBeep((UINT)-1);
  472. return(0);
  473. }
  474. SetFilePointer(hFile,28,NULL,FILE_BEGIN);
  475. for(;;) {
  476. byte_t_read = 0;
  477. retVal = ReadFile(hFile,&tag,4,&byte_t_read,NULL);
  478. if ( retVal == FALSE )
  479. {
  480. CloseHandle(hFile);
  481. return 0;
  482. }
  483. if(tag==TAG_DESCRIPTION)
  484. break;
  485. SetFilePointer(hFile,12,NULL,FILE_CURRENT);
  486. }
  487. retVal = ReadFile(hFile,&offset,4,&byte_t_read,NULL);
  488. if ( retVal == FALSE )
  489. {
  490. CloseHandle(hFile);
  491. return 0;
  492. }
  493. SetFilePointer(hFile,offset,NULL,FILE_BEGIN);
  494. SetFilePointer(hFile,NAMESIZE*sizeof(TCHAR),NULL,FILE_CURRENT);
  495. retVal = ReadFile(hFile,&MaxCodes,2,&byte_t_read,NULL);
  496. if ( retVal == FALSE )
  497. {
  498. CloseHandle(hFile);
  499. return 0;
  500. }
  501. retVal = ReadFile(hFile,&NumCodes,2,&byte_t_read,NULL);
  502. if ( retVal == FALSE )
  503. {
  504. CloseHandle(hFile);
  505. return 0;
  506. }
  507. retVal = ReadFile(hFile,UsedCode,MAXUSEDCODES*sizeof(TCHAR),&byte_t_read,NULL);
  508. if ( retVal == FALSE )
  509. {
  510. CloseHandle(hFile);
  511. return 0;
  512. }
  513. #ifdef UNICODE
  514. // even though byMaxElement is a BYTE, but there is an alignment issue.
  515. // the next member cWildChar is a TCHAR, in NT it is a WCHAR, it will skip
  516. // one byte to make an aligment.
  517. // so we need to skip 2 bytes here
  518. SetFilePointer(hFile,2,NULL,FILE_CURRENT);
  519. #else
  520. SetFilePointer(hFile,1,NULL,FILE_CURRENT);
  521. #endif
  522. retVal = ReadFile(hFile,&WildChar,sizeof(TCHAR),&byte_t_read,NULL);
  523. if ( retVal == FALSE )
  524. {
  525. CloseHandle(hFile);
  526. return 0;
  527. }
  528. //Get the dic_associate info.
  529. SetFilePointer(hFile,28,NULL,FILE_BEGIN);
  530. for(;;) {
  531. retVal = ReadFile(hFile,&tag,4,&byte_t_read,NULL);
  532. if ( retVal == FALSE )
  533. {
  534. CloseHandle(hFile);
  535. return 0;
  536. }
  537. if(tag==TAG_BASEDICINDEX)
  538. break;
  539. SetFilePointer(hFile,12,NULL,FILE_CURRENT);
  540. }
  541. retVal = ReadFile(hFile,&offset,4,&byte_t_read,NULL);
  542. if ( retVal == FALSE )
  543. {
  544. CloseHandle(hFile);
  545. return 0;
  546. }
  547. SetFilePointer(hFile,offset,NULL,FILE_BEGIN);
  548. retVal = ReadFile(hFile,&MaxXLen,4,&byte_t_read,NULL);
  549. if ( retVal == FALSE )
  550. {
  551. CloseHandle(hFile);
  552. return 0;
  553. }
  554. retVal = ReadFile(hFile,CodeAIndex,128,&byte_t_read,NULL);
  555. if ( retVal == FALSE )
  556. {
  557. CloseHandle(hFile);
  558. return 0;
  559. }
  560. lpMB_Head = MB_Head_Table;
  561. byte_w_read = (NumCodes+1) * sizeof(DWORD);
  562. for(i=0; i<NumCodes; i++) {
  563. retVal = ReadFile(hFile,lpMB_Head,byte_w_read,&byte_t_read,NULL);
  564. if ( retVal == FALSE )
  565. {
  566. CloseHandle(hFile);
  567. return 0;
  568. }
  569. lpMB_Head++;
  570. }
  571. CloseHandle(hFile);
  572. return(1);
  573. }
  574. BYTE GetEMBHead() {
  575. HANDLE hFile;
  576. TCHAR path_name[MAX_PATH];
  577. TCHAR *tepstr;
  578. DWORD byte_w_read,byte_t_read;
  579. BOOL retVal;
  580. lstrcpy(lpEngPrivate->EMB_Name,lpEngPrivate->MB_Name);
  581. tepstr = _rtcschr(lpEngPrivate->EMB_Name,TEXT('.'));
  582. if ( tepstr != NULL )
  583. lstrcpy(tepstr,TEXT(".EMB"));
  584. StringCchCopy(path_name, ARRAYSIZE(path_name), sImeG.szIMEUserPath);
  585. StringCchCat(path_name, ARRAYSIZE(path_name), TEXT("\\") );
  586. StringCchCat(path_name, ARRAYSIZE(path_name), lpEngPrivate->EMB_Name);
  587. hFile = CreateFile(path_name,
  588. GENERIC_READ|GENERIC_WRITE,
  589. FILE_SHARE_READ|FILE_SHARE_WRITE,
  590. NULL,
  591. OPEN_EXISTING,
  592. 0,
  593. NULL);
  594. if(hFile==INVALID_HANDLE_VALUE)
  595. return(0);
  596. else if(GetFileSize(hFile,NULL)==0){
  597. CloseHandle(hFile);
  598. return (0);
  599. }
  600. byte_t_read = 0;
  601. byte_w_read = 2;
  602. retVal = ReadFile(hFile,&lpEngPrivate->PrivateArea.GlobVac.EMB_Count,byte_w_read,&byte_t_read,NULL);
  603. if ( retVal == FALSE )
  604. {
  605. CloseHandle(hFile);
  606. return 0;
  607. }
  608. byte_t_read = 0;
  609. byte_w_read = lpEngPrivate->PrivateArea.GlobVac.EMB_Count * sizeof(EMB_Head);
  610. lpEngPrivate->PrivateArea.hEmbFile = hFile;
  611. return (1);
  612. }
  613. UINT DelDoubleBuf() {
  614. if (lpEngPrivate->PrivateArea.Comp_Context.PromptCnt<=0)
  615. return (1);
  616. else {
  617. DelWCEdit();
  618. DelSelBuf();
  619. return(0);
  620. }
  621. }
  622. void ClrDoubleBuf() {
  623. ClrSelBuf();
  624. ClrWCBuf();
  625. }
  626. void ClrSelBuf() {
  627. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = 0;
  628. lpEngPrivate->PrivateArea.Comp_Status.dwSTMULCODE = 0;
  629. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[0]= TEXT('\0');
  630. lpEngPrivate->PrivateArea.GlobVac.SBufPos = 0;
  631. }
  632. void DelSelBuf() {
  633. BYTE i;
  634. TCHAR incode_buf[MAXCODE];
  635. BYTE code_num;
  636. int w_state = 0;
  637. if (lpEngPrivate->PrivateArea.Comp_Context.PromptCnt==0)
  638. ClrDoubleBuf();
  639. else {
  640. code_num = lpEngPrivate->PrivateArea.Comp_Context.PromptCnt;
  641. lstrcpyn(incode_buf,lpEngPrivate->PrivateArea.Comp_Context.szInBuffer,code_num+1);
  642. ClrDoubleBuf();
  643. for (i=0;i<code_num;i++) {
  644. ClrSelBuf();
  645. if ((incode_buf[i]!=WildChar) && (w_state!=1))
  646. CoreMBComp((char)incode_buf[i],i);
  647. else {
  648. w_state = 1;
  649. WildProcess(incode_buf[i]);
  650. }
  651. }
  652. }
  653. }
  654. void DelWCEdit() {
  655. lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1] = '\0';;
  656. lpEngPrivate->PrivateArea.Comp_Context.PromptCnt--;
  657. }
  658. void ClrWCBuf() {
  659. int i;
  660. for(i=0; i<lpEngPrivate->PrivateArea.Comp_Context.PromptCnt;i++)
  661. lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[i] = TEXT('\0');
  662. lpEngPrivate->PrivateArea.Comp_Context.PromptCnt = 0;
  663. lpEngPrivate->PrivateArea.Comp_Status.dwInvalid = 0;
  664. }
  665. UINT CoreMBComp(TCHAR code,BYTE code_num) {
  666. UINT byte_t_read;
  667. int sp;
  668. int edcm,bdcm;
  669. BYTE search_fail = 0;
  670. BYTE code_no,code_no1;
  671. WORD codelen,wordlen;
  672. if(code_num == 0 ) {
  673. byte_t_read = ReadArea(code);
  674. if(byte_t_read!=0) {
  675. lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos = 0;
  676. lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos = byte_t_read;
  677. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = 0;
  678. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos;
  679. lpEngPrivate->PrivateArea.GlobVac.Area_V_Lenth = byte_t_read;
  680. if(lpEngPrivate->PrivateArea.GlobVac.EMB_Exist)
  681. SearchEMBPos(code,(BYTE)(code_num+1));
  682. } else {
  683. if(lpEngPrivate->PrivateArea.GlobVac.EMB_Exist)
  684. SearchEMBPos(code,(BYTE)(code_num+1));
  685. if (lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos == lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos)
  686. search_fail = 1;
  687. else {
  688. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos;
  689. lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos;
  690. }
  691. }
  692. } else if(code_num == 1) {
  693. code_no1 = CodeAIndex[lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[0]];
  694. code_no = CodeAIndex[code];
  695. sp = MB_Head_Table[code_no1-1].W_offset[code_no-1]/sizeof(TCHAR);
  696. lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos = sp;
  697. if (code_no < NumCodes)
  698. lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos = MB_Head_Table[code_no1-1].W_offset[code_no]/sizeof(TCHAR);
  699. else
  700. lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos = lpEngPrivate->PrivateArea.GlobVac.Area_V_Lenth;
  701. if (lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos!=lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos) {
  702. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos;
  703. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos;
  704. if(lpEngPrivate->PrivateArea.GlobVac.EMB_Exist)
  705. SearchEMBPos(code,(BYTE)(code_num+1));
  706. } else {
  707. if(lpEngPrivate->PrivateArea.GlobVac.EMB_Exist)
  708. SearchEMBPos(code,(BYTE)(code_num+1));
  709. if (lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos == lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos)
  710. search_fail = 1;
  711. else {
  712. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos;
  713. lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos;
  714. }
  715. }
  716. } else if (code_num<MaxCodes) {
  717. sp = lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos;
  718. if(sp < lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos) {
  719. for(;;) {
  720. codelen = ZM_Area[sp];
  721. if ((codelen > code_num) && (ZM_Area[sp+code_num+1]==code))
  722. break;
  723. else {
  724. sp += (codelen+1);
  725. wordlen = ZM_Area[sp];
  726. sp += (2*wordlen/sizeof(TCHAR)+1);
  727. }
  728. if(sp >= lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos)
  729. break;
  730. }
  731. if (sp != lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos) {// no this code_word
  732. lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos = sp;
  733. for(;;) {
  734. codelen = ZM_Area[sp];
  735. if (ZM_Area[sp+code_num+1]>code)
  736. break;
  737. else {
  738. sp += (codelen+1);
  739. wordlen = ZM_Area[sp];
  740. sp += (2*wordlen/sizeof(TCHAR)+1);
  741. }
  742. if(sp >= lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos)
  743. break;
  744. }
  745. lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos = sp;
  746. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos;
  747. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos;
  748. if(lpEngPrivate->PrivateArea.GlobVac.EMB_Exist)
  749. SearchEMBPos(code,(BYTE)(code_num+1));
  750. } else {
  751. if(lpEngPrivate->PrivateArea.GlobVac.EMB_Exist)
  752. SearchEMBPos(code,(BYTE)(code_num+1));
  753. if (lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos == lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos)
  754. search_fail = 1;
  755. else {
  756. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos;
  757. lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos;
  758. }
  759. }
  760. } else {
  761. if(lpEngPrivate->PrivateArea.GlobVac.EMB_Exist)
  762. SearchEMBPos(code,(BYTE)(code_num+1));
  763. if (lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos == lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos)
  764. search_fail = 1;
  765. else {
  766. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos;
  767. lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos;
  768. }
  769. }
  770. } else { // too many key
  771. search_fail =1;
  772. }
  773. if(!search_fail) {
  774. lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[lpEngPrivate->PrivateArea.Comp_Context.PromptCnt] = code;
  775. lpEngPrivate->PrivateArea.Comp_Context.PromptCnt ++;
  776. lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[lpEngPrivate->PrivateArea.Comp_Context.PromptCnt] = TEXT('\0');
  777. lpEngPrivate->PrivateArea.GlobVac.ST_MUL_Cnt = 0;
  778. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 1;
  779. bdcm = SearchMBCompMatch(code_num);
  780. if(lpEngPrivate->PrivateArea.GlobVac.SBufPos==0) { //Selectbuf is empty
  781. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 0;
  782. edcm = SearchEMBCompMatch();
  783. } else if(GetLengthofBuf() < MAX_LEN)
  784. edcm = SearchEMBCompMatch();
  785. if(GetLengthofBuf()>=MAX_LEN) {
  786. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  787. }
  788. else {
  789. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos;
  790. SearchEMBWildMatch();
  791. if (((lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos==lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos)||(lpEngPrivate->PrivateArea.GlobVac.EMB_Exist==0))&&(GetLengthofBuf() < MAX_LEN)) {
  792. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos;
  793. SearchMBWildMatch(lpEngPrivate->PrivateArea.Comp_Context.PromptCnt);
  794. } else {
  795. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  796. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  797. }
  798. }
  799. if (lpEngPrivate->PrivateArea.GlobVac.SBufPos==0) {
  800. lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1] = 0x0;
  801. lpEngPrivate->PrivateArea.Comp_Context.PromptCnt --;
  802. lpEngPrivate->PrivateArea.Comp_Status.dwInvalid = 1;
  803. return(0);
  804. } else {
  805. lpEngPrivate->PrivateArea.GlobVac.Page_Num = 1;
  806. lpEngPrivate->PrivateArea.Comp_Status.dwInvalid = 0;
  807. return (1);
  808. }
  809. } else { // Invalid code
  810. lpEngPrivate->PrivateArea.Comp_Status.dwInvalid = 1;
  811. return(0);
  812. }
  813. }
  814. UINT WildProcess(TCHAR code) {
  815. if (lpEngPrivate->PrivateArea.Comp_Context.PromptCnt==MaxCodes) {
  816. MessageBeep((UINT)-1);
  817. return(0);
  818. }
  819. // wild search clear multi code number
  820. lpEngPrivate->PrivateArea.GlobVac.ST_MUL_Cnt = 0;
  821. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos;
  822. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos;
  823. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos;
  824. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos;
  825. SearchEMBWWMatch(code,lpEngPrivate->PrivateArea.Comp_Context.PromptCnt);
  826. if ((lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos==lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos)&&(GetLengthofBuf() <MAX_LEN)) {
  827. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos;
  828. SearchMBWWMatch(code,lpEngPrivate->PrivateArea.Comp_Context.PromptCnt);
  829. }
  830. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  831. if (lpEngPrivate->PrivateArea.GlobVac.SBufPos!=0) {
  832. lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[lpEngPrivate->PrivateArea.Comp_Context.PromptCnt] = code;
  833. lpEngPrivate->PrivateArea.Comp_Context.PromptCnt++;
  834. } else {
  835. lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[lpEngPrivate->PrivateArea.Comp_Context.PromptCnt] = code;
  836. lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[lpEngPrivate->PrivateArea.Comp_Context.PromptCnt+1] = 0x0;
  837. lpEngPrivate->PrivateArea.Comp_Context.PromptCnt ++;
  838. }
  839. return (0);
  840. }
  841. int MBWCWildComp(TCHAR code,BYTE code_num,int sp) {
  842. TCHAR codebuf[13];
  843. int i;
  844. if ((code_num+1) > sizeof(codebuf)/sizeof(TCHAR))
  845. return 0;
  846. lstrcpyn(codebuf,lpEngPrivate->PrivateArea.Comp_Context.szInBuffer,code_num+1);
  847. codebuf[code_num] = code;
  848. codebuf[code_num+1] = 0x0;
  849. for(i=0; i<=code_num;i++) {
  850. if((codebuf[i] != ZM_Area[sp+i+1]) && codebuf[i]!=WildChar)
  851. return(0);
  852. }
  853. return (1);
  854. }
  855. void SearchBMBWWMatch(TCHAR code,BYTE code_num){
  856. int j;
  857. int i,end_pos;
  858. int wordlen,len;
  859. LPTSTR lpStr;
  860. TCHAR tepbuf[130];
  861. TCHAR codebuf[13], codelen;
  862. end_pos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos-1 ;
  863. for(;;) {
  864. j = 0;
  865. i = end_pos;
  866. if(i<=lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos)
  867. break;
  868. wordlen = VerScan_Word(i,tepbuf);
  869. i -= (wordlen+1);
  870. j = wordlen;
  871. for (;;) {
  872. if (InCodeSet(ZM_Area[i])==0)
  873. break;
  874. i--;
  875. }
  876. codelen = ZM_Area[i];
  877. if ((codelen == code_num+1) && (MBWCWildComp(code,code_num,i)==1)){
  878. len = WildInBuffer();
  879. lstrcpyn(codebuf,ZM_Area+i+len+1,codelen-len+1);
  880. codebuf[codelen-len] = 0;
  881. if(MBIndex.IMEChara[0].IC_CTC==1) {
  882. if(GetLengthofBuf()+GetLengthTepBuf(tepbuf)+GetLengthTepBuf(TEXT("9:"))+GetLengthTepBuf(codebuf) > MAX_LEN) {
  883. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  884. break;
  885. }
  886. } else {
  887. if (GetLengthofBuf()+GetLengthTepBuf(tepbuf)+GetLengthTepBuf(TEXT("9:")) > MAX_LEN) { // SelectBuf is Overflow
  888. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  889. break;
  890. }
  891. }
  892. if (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt==IME_MAXCAND) { // words count is enough
  893. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  894. break;
  895. } else if ((MBIndex.IMEChara[0].IC_CZ==1) || (j==2/sizeof(TCHAR))) {
  896. #if defined(COMBO_IME)
  897. {
  898. int k;
  899. BOOL ISGBK = FALSE;
  900. if(MBIndex.IMEChara[0].IC_GB){ //should test GB/GBK
  901. for(k=0;k<j;k+=2/sizeof(TCHAR)){
  902. if(ISGBK = IsGBK(&tepbuf[k])){//out of GB range
  903. break;
  904. }
  905. }
  906. if(ISGBK){
  907. i --;
  908. end_pos = i;
  909. }else{
  910. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  911. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,tepbuf,j+1);
  912. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  913. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  914. if (MBIndex.IMEChara[0].IC_CTC) {
  915. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,ZM_Area+i+len+1,codelen-len+1);
  916. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (codelen-len);
  917. }
  918. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  919. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  920. i --;
  921. end_pos = i;
  922. }
  923. }else{
  924. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  925. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,tepbuf,j+1);
  926. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  927. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  928. if (MBIndex.IMEChara[0].IC_CTC) {
  929. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,ZM_Area+i+len+1,codelen-len+1);
  930. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (codelen-len);
  931. }
  932. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  933. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  934. i --;
  935. end_pos = i;
  936. }
  937. }
  938. #else
  939. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  940. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,tepbuf,j+1);
  941. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  942. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  943. if (MBIndex.IMEChara[0].IC_CTC) {
  944. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,ZM_Area+i+len+1,codelen-len+1);
  945. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (codelen-len);
  946. }
  947. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  948. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  949. i --;
  950. end_pos = i;
  951. #endif //COMBO_IME
  952. }
  953. } else {
  954. i--;
  955. end_pos = i;
  956. }
  957. }
  958. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  959. if (end_pos<=lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos )
  960. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos;
  961. else
  962. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = end_pos+1;
  963. return ;
  964. }
  965. void SearchMBWWMatch(TCHAR code,BYTE code_num) {
  966. int j;
  967. int i,start_pos,sp;
  968. LPTSTR lpStr;
  969. TCHAR tepbuf[130];
  970. int wordlen,len;
  971. TCHAR codebuf[13], codelen;
  972. start_pos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos;
  973. i = start_pos;
  974. for(;;) {
  975. codelen = ZM_Area[i];
  976. if ((codelen == code_num+1) && (MBWCWildComp(code,code_num,i)==1)) {
  977. sp = i;
  978. j = 0;
  979. i += (codelen+1);
  980. wordlen = Scan_Word(i,tepbuf);
  981. i += (wordlen+1);
  982. j = wordlen;
  983. len = WildInBuffer();
  984. if ((MBIndex.IMEChara[0].IC_CZ==1) || (j==2/sizeof(TCHAR))) {
  985. lstrcpyn(codebuf,ZM_Area+i+len+1,codelen-len+1);
  986. codebuf[codelen-len] = 0;
  987. if(MBIndex.IMEChara[0].IC_CTC==1) {
  988. if(GetLengthofBuf()+GetLengthTepBuf(tepbuf)+GetLengthTepBuf(TEXT("9:"))+GetLengthTepBuf(codebuf) > MAX_LEN) {
  989. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  990. break;
  991. }
  992. } else {
  993. if (GetLengthofBuf()+GetLengthTepBuf(tepbuf)+GetLengthTepBuf(TEXT("9:")) > MAX_LEN) { // SelectBuf is Overflow
  994. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  995. break;
  996. }
  997. }
  998. if (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt==IME_MAXCAND) {
  999. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1000. break;
  1001. }
  1002. #if defined(COMBO_IME)
  1003. {
  1004. int k;
  1005. BOOL ISGBK = FALSE;
  1006. if(MBIndex.IMEChara[0].IC_GB){ //should test GB/GBK
  1007. for(k=0;k<j;k+=2/sizeof(TCHAR)){
  1008. if(ISGBK = IsGBK(&tepbuf[k])){//out of GB range
  1009. break;
  1010. }
  1011. }
  1012. if(ISGBK){
  1013. i = Skip_CaWord(i);
  1014. }else{
  1015. lpStr = lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  1016. lstrcpyn(lpStr,tepbuf,j+1);
  1017. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[(lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1)%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  1018. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  1019. if (MBIndex.IMEChara[0].IC_CTC) {
  1020. lpStr = lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  1021. lstrcpyn(lpStr,ZM_Area+sp+len+1,codelen-len+1);
  1022. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (codelen-len);
  1023. }
  1024. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  1025. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  1026. start_pos = i;
  1027. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  1028. }
  1029. }else{
  1030. lpStr = lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  1031. lstrcpyn(lpStr,tepbuf,j+1);
  1032. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[(lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1)%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  1033. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  1034. if (MBIndex.IMEChara[0].IC_CTC) {
  1035. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,ZM_Area+sp+len+1,codelen-len+1);
  1036. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (codelen-len);
  1037. }
  1038. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  1039. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  1040. start_pos = i;
  1041. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  1042. }
  1043. }
  1044. #else
  1045. lpStr = lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  1046. lstrcpyn(lpStr,tepbuf,j+1);
  1047. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[(lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1)%IME_MAXCAND] = lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  1048. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  1049. if (MBIndex.IMEChara[0].IC_CTC) {
  1050. lpStr = lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  1051. lstrcpyn(lpStr,ZM_Area+sp+len+1,codelen-len+1);
  1052. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (codelen-len);
  1053. }
  1054. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  1055. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  1056. start_pos = i;
  1057. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  1058. #endif //COMBO_IME
  1059. }
  1060. } else {
  1061. i = Skip_CaWord(i);
  1062. }
  1063. if (i>=lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos)
  1064. break;
  1065. }
  1066. if (i>= lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos) {
  1067. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos;
  1068. } else {
  1069. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = start_pos;
  1070. }
  1071. }
  1072. UINT SearchMBCompMatch(TCHAR code_num) {
  1073. int j;
  1074. int i,start_pos;
  1075. int match_s = 0;
  1076. LPTSTR lpStr;
  1077. TCHAR tepbuf[130], codelen;
  1078. int wordlen;
  1079. lpEngPrivate->PrivateArea.GlobVac.SBufPos = 0;
  1080. start_pos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos;
  1081. i = start_pos;
  1082. for(;;) {
  1083. if (i>=lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos)
  1084. break;
  1085. codelen = ZM_Area[i];
  1086. if (codelen == code_num+1 ) {
  1087. j = 0;
  1088. i += (codelen+1);
  1089. wordlen = Scan_Word(i,tepbuf);
  1090. i += (wordlen+1);
  1091. j = wordlen;
  1092. if ((MBIndex.IMEChara[0].IC_CZ==1) || (j==2/sizeof(TCHAR))) {
  1093. if (GetLengthofBuf()+GetLengthTepBuf(tepbuf)+GetLengthTepBuf(TEXT("9:"))<=MAX_LEN) { //SelectBuffer enough
  1094. if (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt==IME_MAXCAND) {
  1095. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1096. break;
  1097. }
  1098. #if defined(COMBO_IME)
  1099. {
  1100. int k;
  1101. BOOL ISGBK = FALSE;
  1102. if(MBIndex.IMEChara[0].IC_GB){ //should test GB/GBK
  1103. for(k=0;k<j;k+=2/sizeof(TCHAR)){
  1104. if(ISGBK = IsGBK(&tepbuf[k])){//out of GB range
  1105. break;
  1106. }
  1107. }
  1108. if(ISGBK){
  1109. }else{
  1110. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,tepbuf,j+1);
  1111. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[(lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1)%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  1112. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  1113. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  1114. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  1115. match_s ++;
  1116. start_pos = i;
  1117. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  1118. }
  1119. }else{
  1120. lpStr = (LPTSTR)lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  1121. lstrcpyn(lpStr,tepbuf,j+1);
  1122. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[(lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1)%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  1123. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  1124. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  1125. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  1126. match_s ++;
  1127. start_pos = i;
  1128. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  1129. }
  1130. }
  1131. #else
  1132. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,tepbuf,j+1);
  1133. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[(lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1)%IME_MAXCAND] = lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  1134. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  1135. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  1136. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  1137. match_s ++;
  1138. start_pos = i;
  1139. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  1140. #endif ///COMBO_IME
  1141. } else {
  1142. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1143. break;
  1144. }
  1145. }
  1146. } else
  1147. break;
  1148. }
  1149. if (start_pos>= lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos) {
  1150. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos;
  1151. } else {
  1152. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = start_pos;
  1153. }
  1154. lpEngPrivate->PrivateArea.Comp_Proc.dBDicMCSPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos;
  1155. ;
  1156. lpEngPrivate->PrivateArea.GlobVac.ST_MUL_Cnt = (BYTE)match_s;
  1157. return (match_s);
  1158. }
  1159. void SearchBMBCompMatch() {
  1160. int j;
  1161. int i,end_pos;
  1162. int wordlen;
  1163. TCHAR codelen, tepbuf[130];
  1164. end_pos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos-1 ;
  1165. for(;;) {
  1166. j = 0;
  1167. i = end_pos;
  1168. if(i<=lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos)
  1169. break;
  1170. wordlen = VerScan_Word(i,tepbuf);
  1171. i -= (wordlen+1);
  1172. j = wordlen;
  1173. for (;;) {
  1174. if (InCodeSet(ZM_Area[i])==0)
  1175. break;
  1176. i--;
  1177. }
  1178. codelen = ZM_Area[i];
  1179. if (GetLengthofBuf()+GetLengthTepBuf(tepbuf)+GetLengthTepBuf(TEXT("9:")) > MAX_LEN) { //SelectBuffer enough
  1180. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1181. break;
  1182. }
  1183. else if (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt==IME_MAXCAND) { // words count is enough
  1184. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1185. break;
  1186. } else if ((MBIndex.IMEChara[0].IC_CZ==1) || (j==2/sizeof(TCHAR))) {
  1187. #if defined(COMBO_IME)
  1188. {
  1189. int k;
  1190. BOOL ISGBK = FALSE;
  1191. if(MBIndex.IMEChara[0].IC_GB){ //should test GB/GBK
  1192. for(k=0;k<j;k+=2/sizeof(TCHAR)){
  1193. if(ISGBK = IsGBK(&tepbuf[k])){//out of GB range
  1194. break;
  1195. }
  1196. }
  1197. if(ISGBK){
  1198. }else{
  1199. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  1200. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,tepbuf,j+1);
  1201. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  1202. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  1203. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  1204. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  1205. i --;
  1206. end_pos = i;
  1207. }
  1208. }else{
  1209. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  1210. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,tepbuf,j+1);
  1211. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  1212. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  1213. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  1214. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  1215. i --;
  1216. end_pos = i;
  1217. }
  1218. }
  1219. #else
  1220. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  1221. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,tepbuf,j+1);
  1222. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  1223. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  1224. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  1225. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  1226. i --;
  1227. end_pos = i;
  1228. #endif //COMBO_IME
  1229. }
  1230. }
  1231. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1232. if (end_pos<=lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos )
  1233. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos;
  1234. else
  1235. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = end_pos+1;
  1236. return ;
  1237. }
  1238. void SearchMBWildMatch(BYTE codecnt) {
  1239. TCHAR tepbuf[130];
  1240. int candi_start;
  1241. int i,j,start_pos;
  1242. int wordlen;
  1243. TCHAR codelen, codebuf[13];
  1244. if (GetLengthofBuf()>MAX_LEN) {
  1245. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1246. return ;
  1247. }
  1248. start_pos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos ;
  1249. i = start_pos;
  1250. for(;;) {
  1251. j = 0;
  1252. if(i>=lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos)
  1253. break;
  1254. candi_start = i;
  1255. codelen = ZM_Area[i];
  1256. i += (codelen+1);
  1257. wordlen = Scan_Word(i,tepbuf);
  1258. i += (wordlen+1);
  1259. j = wordlen;
  1260. if (codelen>codecnt) {
  1261. lstrcpyn(codebuf,ZM_Area+candi_start+codecnt+1,codelen-codecnt+1);
  1262. codebuf[codelen-codecnt] = 0;
  1263. }
  1264. if(MBIndex.IMEChara[0].IC_CTC==1) {
  1265. if(GetLengthofBuf()+GetLengthTepBuf(tepbuf)+GetLengthTepBuf(TEXT("9:"))+GetLengthTepBuf(codebuf) > MAX_LEN) {
  1266. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1267. break;
  1268. }
  1269. } else {
  1270. if (GetLengthofBuf()+GetLengthTepBuf(tepbuf)+GetLengthTepBuf(TEXT("9:")) > MAX_LEN) { // SelectBuf is Overflow
  1271. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1272. break;
  1273. }
  1274. }
  1275. if (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt==IME_MAXCAND) {// words count is enough
  1276. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1277. break;
  1278. }
  1279. else if ((MBIndex.IMEChara[0].IC_CZ==1) || (j==2/sizeof(TCHAR))) {
  1280. #if defined(COMBO_IME)
  1281. {
  1282. int k;
  1283. BOOL ISGBK = FALSE;
  1284. if(MBIndex.IMEChara[0].IC_GB){ //should test GB/GBK
  1285. for(k=0;k<j;k+=2/sizeof(TCHAR)){
  1286. if(ISGBK = IsGBK(&tepbuf[k])){//out of GB range
  1287. break;
  1288. }
  1289. }
  1290. if(ISGBK){
  1291. }else{
  1292. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,tepbuf,j+1);
  1293. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[(lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1)%IME_MAXCAND ] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  1294. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  1295. if(MBIndex.IMEChara[0].IC_CTC) {
  1296. if (codelen>codecnt) {
  1297. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,ZM_Area+candi_start+codecnt+1,codelen-codecnt+1);
  1298. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (codelen-codecnt);
  1299. }
  1300. }
  1301. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  1302. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  1303. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  1304. }
  1305. }else{
  1306. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,tepbuf,j+1);
  1307. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[(lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1)%IME_MAXCAND ] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  1308. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  1309. if(MBIndex.IMEChara[0].IC_CTC) {
  1310. if (codelen>codecnt) {
  1311. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,ZM_Area+candi_start+codecnt+1,codelen-codecnt+1);
  1312. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (codelen-codecnt);
  1313. }
  1314. }
  1315. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  1316. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  1317. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  1318. }
  1319. }
  1320. #else
  1321. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,tepbuf,j+1);
  1322. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[(lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1)%IME_MAXCAND ] = lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  1323. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  1324. if(MBIndex.IMEChara[0].IC_CTC) {
  1325. if (codelen>codecnt) {
  1326. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,ZM_Area+candi_start+codecnt+1,codelen-codecnt+1);
  1327. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (codelen-codecnt);
  1328. }
  1329. }
  1330. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  1331. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  1332. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  1333. #endif //COMBO_IME
  1334. }
  1335. start_pos = i;
  1336. }
  1337. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1338. if (start_pos>= lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos )
  1339. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos;
  1340. else
  1341. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = start_pos;
  1342. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1343. return;
  1344. }
  1345. void SearchBMBWildMatch(BYTE codecnt) {
  1346. TCHAR tepbuf[130];
  1347. int j;
  1348. int i,end_pos;
  1349. int wordlen;
  1350. TCHAR codelen, codebuf[13];
  1351. end_pos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos-1 ;
  1352. i = end_pos;
  1353. for(;;) {
  1354. j = 0;
  1355. if(i<=lpEngPrivate->PrivateArea.Comp_Proc.dBDicMCSPos)
  1356. break;
  1357. wordlen = VerScan_Word(i,tepbuf);
  1358. i -= (wordlen+1);
  1359. j = wordlen;
  1360. for (;;) {
  1361. if (InCodeSet(ZM_Area[i])==0)
  1362. break;
  1363. i--;
  1364. }
  1365. codelen = ZM_Area[i];
  1366. if(codelen>codecnt) {
  1367. lstrcpyn(codebuf,ZM_Area+i+codecnt+1,codelen-codecnt+1);
  1368. codebuf[codelen-codecnt] = 0;
  1369. }
  1370. if(MBIndex.IMEChara[0].IC_CTC==1) {
  1371. if(GetLengthofBuf()+GetLengthTepBuf(tepbuf)+GetLengthTepBuf(TEXT("9:"))+GetLengthTepBuf(codebuf) > MAX_LEN) {
  1372. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1373. break;
  1374. }
  1375. } else {
  1376. if (GetLengthofBuf()+GetLengthTepBuf(tepbuf)+GetLengthTepBuf(TEXT("9:")) > MAX_LEN) { // SelectBuf is Overflow
  1377. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1378. break;
  1379. }
  1380. }
  1381. if (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt==IME_MAXCAND) { // words count is enough
  1382. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1383. break;
  1384. } else if ((MBIndex.IMEChara[0].IC_CZ==1) || (j==2/sizeof(TCHAR))) {
  1385. #if defined(COMBO_IME)
  1386. {
  1387. int k;
  1388. BOOL ISGBK = FALSE;
  1389. if(MBIndex.IMEChara[0].IC_GB){ //should test GB/GBK
  1390. for(k=0;k<j;k+=2/sizeof(TCHAR)){
  1391. if(ISGBK = IsGBK(&tepbuf[k])){//out of GB range
  1392. break;
  1393. }
  1394. }
  1395. if(ISGBK){
  1396. }else{
  1397. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  1398. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,tepbuf,j+1);
  1399. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  1400. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  1401. if(MBIndex.IMEChara[0].IC_CTC) {
  1402. if (codelen>codecnt) {
  1403. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,ZM_Area+i+codecnt+1,codelen-codecnt+1);
  1404. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (codelen-codecnt);
  1405. }
  1406. }
  1407. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  1408. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  1409. end_pos = i;
  1410. }
  1411. }else{
  1412. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  1413. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,tepbuf,j+1);
  1414. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  1415. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  1416. if(MBIndex.IMEChara[0].IC_CTC) {
  1417. if (codelen>codecnt) {
  1418. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,ZM_Area+i+codecnt+1,codelen-codecnt+1);
  1419. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (codelen-codecnt);
  1420. }
  1421. }
  1422. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  1423. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  1424. end_pos = i;
  1425. }
  1426. }
  1427. #else
  1428. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  1429. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,tepbuf,j+1);
  1430. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  1431. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  1432. if(MBIndex.IMEChara[0].IC_CTC) {
  1433. if (codelen>codecnt) {
  1434. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,ZM_Area+i+codecnt+1,codelen-codecnt+1);
  1435. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (codelen-codecnt);
  1436. }
  1437. }
  1438. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  1439. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  1440. end_pos = i;
  1441. #endif //COMBO_IME
  1442. }
  1443. i --;
  1444. }
  1445. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1446. if (end_pos<=lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos )
  1447. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos;
  1448. else
  1449. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = end_pos;//5.15 +1;
  1450. return ;
  1451. }
  1452. void SearchBMBLXMatch() {
  1453. TCHAR tepbuf[130];
  1454. int i,j,end_pos;
  1455. int wordlen ;
  1456. end_pos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos;
  1457. i = end_pos - 1;
  1458. for (;;) {
  1459. j = 0;
  1460. wordlen = VerScan_Word(i,tepbuf);
  1461. i -= (wordlen+1) ;
  1462. j = wordlen;
  1463. if(wcsncmp(ZM_Area+i+2,lpEngPrivate->PrivateArea.Comp_Context.szLxBuffer,lpEngPrivate->PrivateArea.Comp_Context.LxStrCnt)==0 && j>lpEngPrivate->PrivateArea.Comp_Context.LxStrCnt) {
  1464. if (GetLengthofBuf()+GetLengthTepBuf(tepbuf)+GetLengthTepBuf(TEXT("9:")) > MAX_LEN) {// SelectBuf is Overflow
  1465. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1466. break;
  1467. }
  1468. if (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt==IME_MAXCAND) { // words count is enough
  1469. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1470. break;
  1471. }
  1472. #if defined(COMBO_IME)
  1473. {
  1474. int k;
  1475. BOOL ISGBK = FALSE;
  1476. if(MBIndex.IMEChara[0].IC_GB){ //should test GB/GBK
  1477. for(k=0;k<j;k+=2/sizeof(TCHAR)){
  1478. if(ISGBK = IsGBK(&tepbuf[k])){//out of GB range
  1479. break;
  1480. }
  1481. }
  1482. if(ISGBK){
  1483. }else{
  1484. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  1485. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,tepbuf,j+1);
  1486. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  1487. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  1488. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  1489. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  1490. }
  1491. }else{
  1492. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  1493. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,tepbuf,j+1);
  1494. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  1495. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  1496. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  1497. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  1498. }
  1499. }
  1500. #else
  1501. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  1502. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,tepbuf,j+1);
  1503. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  1504. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  1505. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  1506. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  1507. #endif //COMBO_IME
  1508. }
  1509. for (;;) {
  1510. if (InCodeSet(ZM_Area[i])==0)
  1511. break;
  1512. i--;
  1513. }
  1514. end_pos = i;
  1515. i --;
  1516. if (i<= lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos )
  1517. break;
  1518. }
  1519. if (i<=lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos )
  1520. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos;
  1521. else
  1522. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = end_pos;
  1523. }
  1524. void SearchMBLXMatch() {
  1525. TCHAR codelen,tepbuf[130];
  1526. int i,j,s_pos;
  1527. int wordlen;
  1528. i = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos;
  1529. for (;;) {
  1530. j = 0;
  1531. codelen = ZM_Area[i];
  1532. i += (codelen+1);
  1533. s_pos = i;
  1534. wordlen = Scan_Word(i,tepbuf);
  1535. i += (wordlen+1);
  1536. j = wordlen;
  1537. if(wcsncmp(ZM_Area+s_pos+1,lpEngPrivate->PrivateArea.Comp_Context.szLxBuffer,lpEngPrivate->PrivateArea.Comp_Context.LxStrCnt)==0 && j>lpEngPrivate->PrivateArea.Comp_Context.LxStrCnt) {
  1538. if(GetLengthofBuf()+GetLengthTepBuf(tepbuf)+GetLengthTepBuf(TEXT("9:")) > MAX_LEN) { // SelectBuf is Overflow
  1539. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1540. break;
  1541. }
  1542. if (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt==IME_MAXCAND) { // words count is enough
  1543. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1544. break;
  1545. }
  1546. #if defined(COMBO_IME)
  1547. {
  1548. int k;
  1549. BOOL ISGBK = FALSE;
  1550. if(MBIndex.IMEChara[0].IC_GB){ //should test GB/GBK
  1551. for(k=0;k<j;k+=2/sizeof(TCHAR)){
  1552. if(ISGBK = IsGBK(&tepbuf[k])){//out of GB range
  1553. break;
  1554. }
  1555. }
  1556. if(ISGBK){
  1557. }else{
  1558. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,tepbuf,j+1);
  1559. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  1560. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  1561. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  1562. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  1563. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  1564. }
  1565. }else{
  1566. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,tepbuf,j+1);
  1567. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  1568. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  1569. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  1570. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  1571. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  1572. }
  1573. }
  1574. #else
  1575. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,tepbuf,j+1);
  1576. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  1577. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  1578. lpEngPrivate->PrivateArea.GlobVac.SBufPos += j;
  1579. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  1580. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  1581. #endif //COMBO_IME
  1582. }
  1583. if (i>= lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos )
  1584. break;
  1585. }
  1586. if (i>=lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos)
  1587. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos;
  1588. else
  1589. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = s_pos-codelen-1;
  1590. }
  1591. void CoreLXComp() {
  1592. if (MBIndex.IMEChara[0].IC_LX==1) { // lx Search
  1593. lpEngPrivate->PrivateArea.Comp_Status.dwSTLX = 1;
  1594. lstrcpy(lpEngPrivate->PrivateArea.Comp_Context.szInBuffer,TEXT("LLXX"));
  1595. lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[4] = TEXT('\0');
  1596. lpEngPrivate->PrivateArea.Comp_Context.PromptCnt = 4;
  1597. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos = 0;
  1598. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos = lpEngPrivate->PrivateArea.GlobVac.EMB_Count;
  1599. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos = 0;
  1600. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos = 0;
  1601. lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos = 0;
  1602. lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos = lpEngPrivate->PrivateArea.GlobVac.Area_V_Lenth;;
  1603. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = 0;
  1604. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = 0;
  1605. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 0; //EMB
  1606. ClrSelBuf();
  1607. SearchEMBLXMatch();
  1608. if (lpEngPrivate->PrivateArea.GlobVac.SBufPos ==0) {
  1609. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 1;
  1610. SearchMBLXMatch();
  1611. } else if((GetLengthofBuf() <= MAX_LEN) && (lpEngPrivate->PrivateArea.GlobVac.EMB_Exist!=0))
  1612. SearchMBLXMatch();
  1613. if (lpEngPrivate->PrivateArea.GlobVac.SBufPos==0) {
  1614. lpEngPrivate->PrivateArea.Comp_Status.dwSTLX = 0;
  1615. ClrDoubleBuf();
  1616. } else
  1617. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1618. lpEngPrivate->PrivateArea.GlobVac.Page_Num = 1;
  1619. }
  1620. }
  1621. void PageDnUp(BYTE direct) {
  1622. if (lpEngPrivate->PrivateArea.Comp_Status.dwSTMULCODE) {
  1623. CoreMCCompDnUp(direct);
  1624. } else if (_tcschr(lpEngPrivate->PrivateArea.Comp_Context.szInBuffer,WildChar)!=NULL) {
  1625. CoreWWCompDnUp(direct);
  1626. } else if (lpEngPrivate->PrivateArea.Comp_Status.dwSTLX==0) {
  1627. lpEngPrivate->PrivateArea.Comp_Status.dwSTMULCODE = 0;
  1628. CoreMBCompDnUp(direct);
  1629. lpEngPrivate->PrivateArea.GlobVac.ST_MUL_Cnt = 0;
  1630. } else {
  1631. CoreLXCompDnUp(direct);
  1632. }
  1633. }
  1634. void CoreWWCompDnUp(BYTE direct) {
  1635. switch (direct) {
  1636. case 0:
  1637. if (lpEngPrivate->PrivateArea.GlobVac.Page_Num ==1) {
  1638. MessageBeep((UINT)-1);
  1639. return;
  1640. }
  1641. ClrSelBuf();
  1642. if (lpEngPrivate->PrivateArea.GlobVac.Cur_MB==1) { // Current at Basic EMB
  1643. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos;
  1644. SearchBMBWWMatch(lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1],(BYTE)(lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1));
  1645. if ((lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos==lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos)&&(GetLengthofBuf()<MAX_LEN)) {// Select buffer isn't overflow
  1646. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos;
  1647. SearchBEMBWWMatch(lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1],(BYTE)(lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1));
  1648. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 0;
  1649. }
  1650. } else { // turn at EMB
  1651. //8.23 emb mb connect position must be process specially
  1652. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos;
  1653. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos;
  1654. SearchBEMBWWMatch(lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1],(BYTE)(lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1));
  1655. }
  1656. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1657. lpEngPrivate->PrivateArea.GlobVac.Page_Num --;
  1658. ConvertCandi();
  1659. break;
  1660. case 1:
  1661. if ((lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos >= lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos) &&
  1662. (lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos >= lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos)) { // EMB reach bottom
  1663. MessageBeep((UINT)-1);
  1664. return;
  1665. }
  1666. ClrSelBuf();
  1667. if((lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos < lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos) && (lpEngPrivate->PrivateArea.GlobVac.EMB_Exist!=0)){ // Search at MB
  1668. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos;
  1669. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 0;
  1670. SearchEMBWWMatch(lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1],(BYTE)(lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1));
  1671. if (lpEngPrivate->PrivateArea.GlobVac.SBufPos == 0) {
  1672. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 1;
  1673. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos;
  1674. SearchMBWWMatch(lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1],(BYTE)(lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1));
  1675. } else if ((lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos==lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos) && (GetLengthofBuf()<MAX_LEN)) { // Select buffer isn't overflow
  1676. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos;
  1677. SearchMBWWMatch(lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1],(BYTE)(lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1));
  1678. }
  1679. } else { // Search at EMB
  1680. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos;
  1681. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 1;
  1682. SearchMBWWMatch(lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1],(BYTE)(lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1));
  1683. }
  1684. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1685. lpEngPrivate->PrivateArea.GlobVac.Page_Num ++;
  1686. break;
  1687. }
  1688. lpEngPrivate->PrivateArea.GlobVac.ST_MUL_Cnt = 0;
  1689. }
  1690. int CoreMCCompDnUp(BYTE direct) {
  1691. int i,len;
  1692. switch (direct) {
  1693. case 0:
  1694. if (lpEngPrivate->PrivateArea.GlobVac.Page_Num ==1) {
  1695. MessageBeep((UINT)-1);
  1696. return(0);
  1697. }
  1698. ClrSelBuf();
  1699. lpEngPrivate->PrivateArea.Comp_Status.dwSTMULCODE = 1;
  1700. if (lpEngPrivate->PrivateArea.GlobVac.Cur_MB==0) { // Current at Basic EMB
  1701. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos;
  1702. SearchBEMBCompMatch();
  1703. if ((lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos==lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos)&&(GetLengthofBuf() <MAX_LEN)) {// Select buffer isn't overflow
  1704. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos;
  1705. SearchBMBCompMatch();
  1706. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 1;
  1707. }
  1708. } else { // turn at MB
  1709. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos;
  1710. SearchBMBCompMatch();
  1711. }
  1712. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1713. lpEngPrivate->PrivateArea.GlobVac.Page_Num --;
  1714. ConvertCandi();
  1715. break;
  1716. case 1:
  1717. i = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos;
  1718. len = ZM_Area[i];
  1719. if((len>lpEngPrivate->PrivateArea.Comp_Context.PromptCnt) || (i>lpEngPrivate->PrivateArea.Comp_Proc.dBDicMCSPos) || (i>=lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos)) {
  1720. if (lpEngPrivate->PrivateArea.GlobVac.EMB_Exist==1) {
  1721. i = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos;
  1722. len = Inputcodelen(EMB_Table[i].W_Code);
  1723. if((len>lpEngPrivate->PrivateArea.Comp_Context.PromptCnt) || (i==lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos)) {
  1724. MessageBeep((UINT)-1);
  1725. return(0);
  1726. }
  1727. } else {
  1728. MessageBeep((UINT)-1);
  1729. return(0);
  1730. }
  1731. }
  1732. ClrSelBuf();
  1733. lpEngPrivate->PrivateArea.Comp_Status.dwSTMULCODE = 1;
  1734. if(lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos < lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos){
  1735. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos;
  1736. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 1;
  1737. SearchMBCompMatch((TCHAR)(lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1));
  1738. if (lpEngPrivate->PrivateArea.GlobVac.SBufPos == 0) {
  1739. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 0;
  1740. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos;
  1741. SearchEMBCompMatch();
  1742. } else if ((lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos==lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos)&&(GetLengthofBuf()<MAX_LEN)) { // Select buffer isn't overflow
  1743. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos;
  1744. SearchEMBCompMatch();
  1745. }
  1746. } else { // Search at EMB
  1747. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos;
  1748. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 0;
  1749. SearchEMBCompMatch();
  1750. }
  1751. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1752. lpEngPrivate->PrivateArea.GlobVac.Page_Num ++;
  1753. break;
  1754. }
  1755. lpEngPrivate->PrivateArea.GlobVac.ST_MUL_Cnt = 0;
  1756. return(1);
  1757. }
  1758. void CoreLXCompDnUp(BYTE direct) {
  1759. switch (direct) {
  1760. case 0: //PgUp Turn
  1761. if (lpEngPrivate->PrivateArea.GlobVac.Page_Num ==1) {
  1762. MessageBeep((UINT)-1);
  1763. return;
  1764. }
  1765. ClrSelBuf();
  1766. if (lpEngPrivate->PrivateArea.GlobVac.Cur_MB) { // Current at Basic MB
  1767. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos;
  1768. SearchBMBLXMatch();
  1769. if ((lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos==lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos)
  1770. && (GetLengthofBuf() <MAX_LEN)
  1771. && (lpEngPrivate->PrivateArea.GlobVac.EMB_Exist!=0)) { // Select buffer isn't overflow
  1772. SearchBEMBLXMatch(); // pass w_code
  1773. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 0;
  1774. }
  1775. } else { // turn at EMB
  1776. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos;
  1777. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos;
  1778. SearchBEMBLXMatch();
  1779. }
  1780. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1781. lpEngPrivate->PrivateArea.GlobVac.Page_Num --;
  1782. ConvertCandi();
  1783. break;
  1784. case 1: // PgDn Turn
  1785. if ((lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos >= lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos) &&
  1786. (lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos >= lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos)) { // EMB reach bottom
  1787. MessageBeep((UINT)-1);
  1788. return;
  1789. }
  1790. ClrSelBuf();
  1791. if((lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos < lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos) && (lpEngPrivate->PrivateArea.GlobVac.EMB_Exist!=0)){ // Search at EMB
  1792. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos;
  1793. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 0;
  1794. SearchEMBLXMatch();
  1795. if (lpEngPrivate->PrivateArea.GlobVac.SBufPos == 0) {
  1796. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 1;
  1797. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos;
  1798. SearchMBLXMatch(); // pass q_code
  1799. } else if ((lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos==lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos)&&(GetLengthofBuf()<MAX_LEN)) { // Select buffer isn't overflow
  1800. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos;
  1801. SearchMBLXMatch(); // pass w_code
  1802. }
  1803. } else { // Search at MB
  1804. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos;
  1805. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 1;
  1806. SearchMBLXMatch(); // pass w_code
  1807. }
  1808. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1809. lpEngPrivate->PrivateArea.GlobVac.Page_Num ++;
  1810. break;
  1811. }
  1812. }
  1813. void CoreMBCompDnUp(BYTE direct) {
  1814. int i;
  1815. TCHAR incode_buf[MAXCODE];
  1816. BYTE code_num;
  1817. switch (direct) {
  1818. case 0: //PgUp Turn
  1819. if (lpEngPrivate->PrivateArea.GlobVac.Page_Num ==1) {
  1820. MessageBeep((UINT)-1);
  1821. return ;
  1822. }
  1823. ClrSelBuf();
  1824. if (lpEngPrivate->PrivateArea.GlobVac.Page_Num ==2) {
  1825. code_num = lpEngPrivate->PrivateArea.Comp_Context.PromptCnt;
  1826. lstrcpyn(incode_buf,lpEngPrivate->PrivateArea.Comp_Context.szInBuffer,code_num+1);
  1827. ClrDoubleBuf();
  1828. for (i=0; i<code_num; i++) {
  1829. ClrSelBuf();
  1830. CoreMBComp(incode_buf[i],(BYTE)i);
  1831. }
  1832. lpEngPrivate->PrivateArea.GlobVac.Page_Num = 1;
  1833. } else {
  1834. if (lpEngPrivate->PrivateArea.GlobVac.Cur_MB) { // Current at Basic MB
  1835. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos;
  1836. SearchBMBWildMatch(lpEngPrivate->PrivateArea.Comp_Context.PromptCnt);
  1837. if ((lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos<=lpEngPrivate->PrivateArea.Comp_Proc.dBDicMCSPos)
  1838. && (GetLengthofBuf() <MAX_LEN )
  1839. && (lpEngPrivate->PrivateArea.GlobVac.EMB_Exist!=0)) {
  1840. SearchBEMBWildMatch(); // pass w_code
  1841. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 0;
  1842. }
  1843. } else { // turn at EMB
  1844. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos;
  1845. SearchBEMBWildMatch();
  1846. }
  1847. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1848. lpEngPrivate->PrivateArea.GlobVac.Page_Num --;
  1849. ConvertCandi();
  1850. }
  1851. break;
  1852. case 1: // PgDn Turn
  1853. if ((lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos >= lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos) &&
  1854. (lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos >= lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos)) { // EMB reach bottom
  1855. MessageBeep((UINT)-1);
  1856. return ;
  1857. }
  1858. ClrSelBuf();
  1859. if((lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos < lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos) && (lpEngPrivate->PrivateArea.GlobVac.EMB_Exist!=0)){ // Search at EMB
  1860. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos;
  1861. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 0;
  1862. SearchEMBWildMatch();
  1863. if (lpEngPrivate->PrivateArea.GlobVac.SBufPos == 0) {
  1864. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 1;
  1865. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos;
  1866. SearchMBWildMatch(lpEngPrivate->PrivateArea.Comp_Context.PromptCnt); // pass q_code
  1867. } else if ((lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos==lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos) && (GetLengthofBuf() <MAX_LEN)) { // Select buffer isn't overflow
  1868. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos;
  1869. SearchMBWildMatch(lpEngPrivate->PrivateArea.Comp_Context.PromptCnt); // pass w_code
  1870. }
  1871. } else {// Search at MB
  1872. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos;
  1873. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 1;
  1874. SearchMBWildMatch(lpEngPrivate->PrivateArea.Comp_Context.PromptCnt); // pass w_code
  1875. }
  1876. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1877. lpEngPrivate->PrivateArea.GlobVac.Page_Num ++;
  1878. break;
  1879. }
  1880. }
  1881. void TurnToFirstPage() {
  1882. int i;
  1883. TCHAR incode_buf[MAXCODE];
  1884. BYTE code_num;
  1885. if(lpEngPrivate->PrivateArea.GlobVac.Page_Num == 1) {
  1886. MessageBeep((UINT)-1);
  1887. return;
  1888. }
  1889. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos;
  1890. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos;
  1891. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos;
  1892. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos;
  1893. if (lpEngPrivate->PrivateArea.Comp_Status.dwSTMULCODE) {
  1894. ClrSelBuf();
  1895. lpEngPrivate->PrivateArea.Comp_Status.dwSTMULCODE = 1;
  1896. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 1;
  1897. SearchMBCompMatch((TCHAR)(lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1));
  1898. if (lpEngPrivate->PrivateArea.GlobVac.SBufPos == 0) {
  1899. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 0;
  1900. SearchEMBCompMatch();
  1901. } else if ((lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos==lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos)&&(GetLengthofBuf()<MAX_LEN)) { // Select buffer isn't overflow
  1902. SearchEMBCompMatch();
  1903. }
  1904. } else if (_tcschr(lpEngPrivate->PrivateArea.Comp_Context.szInBuffer,WildChar)!=NULL) {
  1905. ClrSelBuf();
  1906. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 0;
  1907. SearchEMBWWMatch(lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1],(BYTE)(lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1));
  1908. if (lpEngPrivate->PrivateArea.GlobVac.SBufPos == 0) {
  1909. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 0;
  1910. SearchMBWWMatch(lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1],(BYTE)(lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1));
  1911. } else if ((lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos==lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos) && (GetLengthofBuf()<MAX_LEN)) { // Select buffer isn't overflow
  1912. SearchMBWWMatch(lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1],(BYTE)(lpEngPrivate->PrivateArea.Comp_Context.PromptCnt-1));
  1913. }
  1914. } else if (lpEngPrivate->PrivateArea.Comp_Status.dwSTLX==0) {
  1915. ClrSelBuf();
  1916. lpEngPrivate->PrivateArea.GlobVac.ST_MUL_Cnt = 0;
  1917. lpEngPrivate->PrivateArea.Comp_Status.dwSTMULCODE = 0;
  1918. code_num = lpEngPrivate->PrivateArea.Comp_Context.PromptCnt;
  1919. lstrcpyn(incode_buf,lpEngPrivate->PrivateArea.Comp_Context.szInBuffer,code_num+1);
  1920. ClrDoubleBuf();
  1921. for (i=0; i<code_num; i++) {
  1922. ClrSelBuf();
  1923. CoreMBComp(incode_buf[i],(BYTE)i);
  1924. }
  1925. } else {
  1926. ClrSelBuf();
  1927. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 0;
  1928. SearchEMBLXMatch();
  1929. if (lpEngPrivate->PrivateArea.GlobVac.SBufPos == 0) {
  1930. lpEngPrivate->PrivateArea.GlobVac.Cur_MB = 1;
  1931. SearchMBLXMatch(); // pass q_code
  1932. } else if ((lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos==lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos)&&(GetLengthofBuf()<MAX_LEN)) { // Select buffer isn't overflow
  1933. SearchMBLXMatch(); // pass w_code
  1934. }
  1935. }
  1936. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  1937. lpEngPrivate->PrivateArea.GlobVac.Page_Num = 1;
  1938. lpEngPrivate->PrivateArea.GlobVac.ST_MUL_Cnt = 0;
  1939. }
  1940. void TurnToEndPage() {
  1941. if (lpEngPrivate->PrivateArea.Comp_Status.dwSTMULCODE) {
  1942. for(;;) {
  1943. if(!CoreMCCompDnUp(1))
  1944. break;
  1945. }
  1946. } else {
  1947. for(;;) {
  1948. PageDnUp(1);
  1949. if((lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos==lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos) && (lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos==lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos))
  1950. break;
  1951. }
  1952. }
  1953. }
  1954. UINT CoreUnitProcess(TCHAR code) {
  1955. int search_state;
  1956. search_state = CoreMBComp(code,lpEngPrivate->PrivateArea.Comp_Context.PromptCnt);
  1957. if(search_state) {
  1958. if (lpEngPrivate->PrivateArea.Comp_Context.PromptCnt==MaxCodes ) { // Four_key code
  1959. if (lpEngPrivate->PrivateArea.GlobVac.ST_MUL_Cnt>1 ) { // Mutilple code
  1960. TSMulCProc();
  1961. return (0);
  1962. }
  1963. else { // Result string
  1964. SelectCandi('1');
  1965. return (2);
  1966. }
  1967. }
  1968. return(0);
  1969. } else
  1970. return(0);
  1971. }
  1972. UINT SelectCandi(TCHAR code) {
  1973. BYTE resstart;
  1974. BYTE sel_succ,i;
  1975. TCHAR ch;
  1976. if (lpEngPrivate->PrivateArea.Comp_Context.PromptCnt>0) { // there are some w_code
  1977. if(lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt==0) // now we have 10 Candi_words
  1978. sel_succ = 0;
  1979. else if((code-0x30 <= lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt) && (code-0x30 > 0)) //select is valid
  1980. sel_succ = 1;
  1981. else if(lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt==10 && code=='0')
  1982. sel_succ = 1;
  1983. else
  1984. sel_succ = 0;
  1985. if (sel_succ) { //select successful
  1986. resstart = lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[code-0x30];
  1987. i = 0;
  1988. for(;;) {
  1989. lpEngPrivate->PrivateArea.Comp_Context.CKBBuf[i] = lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[resstart];
  1990. #ifdef UNICODE
  1991. i += 1;
  1992. resstart += 1;
  1993. #else
  1994. lpEngPrivate->PrivateArea.Comp_Context.CKBBuf[i+1] = lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[resstart+1];
  1995. i += 2;
  1996. resstart += 2;
  1997. #endif
  1998. ch = lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[resstart];
  1999. if(ch==TEXT(' ') || ch==TEXT('\0') || InCodeSet(ch)==1)
  2000. break;
  2001. }
  2002. lpEngPrivate->PrivateArea.Comp_Context.CKBBuf[i] = TEXT('\0');
  2003. lpEngPrivate->PrivateArea.Comp_Context.ResultStrCnt = i;
  2004. lstrcpy(lpEngPrivate->PrivateArea.Comp_Context.szLxBuffer,lpEngPrivate->PrivateArea.Comp_Context.CKBBuf);
  2005. lpEngPrivate->PrivateArea.Comp_Context.LxStrCnt = i;
  2006. //CHP
  2007. #ifdef FUSSYMODE
  2008. MBIndex.IsFussyCharFlag = 0;
  2009. if (lstrlen(lpEngPrivate->PrivateArea.Comp_Context.CKBBuf) == 1)
  2010. if (IsFussyChar(lpEngPrivate->PrivateArea.Comp_Context.szInBuffer,
  2011. lpEngPrivate->PrivateArea.Comp_Context.CKBBuf))
  2012. {
  2013. MBIndex.IsFussyCharFlag = 1;
  2014. }
  2015. #endif //FUSSYMODE
  2016. if (MBIndex.IMEChara[0].IC_LX==1) //&& (lpEngPrivate->PrivateArea.Comp_Context.ResultStrCnt==2))
  2017. CoreLXComp();
  2018. else
  2019. ClrDoubleBuf();
  2020. lpEngPrivate->PrivateArea.Comp_Status.dwSTMULCODE = 0;
  2021. lpEngPrivate->PrivateArea.GlobVac.ST_MUL_Cnt = 0;
  2022. return(2);
  2023. } else {
  2024. MessageBeep((UINT)-1);
  2025. return(0);
  2026. }
  2027. } else {
  2028. if (!lpEngPrivate->PrivateArea.Comp_Status.dwPPTFH)
  2029. return (1);
  2030. else {
  2031. CapKeyProc(code);
  2032. return (2);
  2033. }
  2034. }
  2035. }
  2036. UINT LXSelectCandi(TCHAR code) {
  2037. BYTE sel_succ,resstart;
  2038. BYTE i;
  2039. if(lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt==0) // no candidate
  2040. sel_succ = 0;
  2041. else if((code-0x30 <= lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt) && (code-0x30 > 0)) //select is valid
  2042. sel_succ = 1;
  2043. else if(lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt==10 && code=='0')
  2044. sel_succ = 1;
  2045. else
  2046. sel_succ = 0;
  2047. if (sel_succ) { //select successful
  2048. //lpEngPrivate->PrivateArea.Comp_Status.dwSTLX = 0;
  2049. resstart = lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[code-0x30];
  2050. resstart += lpEngPrivate->PrivateArea.Comp_Context.LxStrCnt;
  2051. i = 0;
  2052. for(;;) {
  2053. lpEngPrivate->PrivateArea.Comp_Context.CKBBuf[i] = lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[resstart];
  2054. #ifdef UNICODE
  2055. i += 1;
  2056. resstart += 1;
  2057. #else
  2058. lpEngPrivate->PrivateArea.Comp_Context.CKBBuf[i+1] = lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[resstart+1];
  2059. i += 2;
  2060. resstart += 2;
  2061. #endif
  2062. if(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[resstart]==TEXT(' ') || lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[resstart]==TEXT('\0'))
  2063. break;
  2064. }
  2065. lpEngPrivate->PrivateArea.Comp_Context.CKBBuf[i] = TEXT('\0');
  2066. lpEngPrivate->PrivateArea.Comp_Context.ResultStrCnt = i;
  2067. resstart = lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[code-0x30];
  2068. //resstart += lpEngPrivate->PrivateArea.Comp_Context.ResultStrCnt;
  2069. i = 0;
  2070. for(;;) {
  2071. lpEngPrivate->PrivateArea.Comp_Context.szLxBuffer[i] = lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[resstart];
  2072. lpEngPrivate->PrivateArea.Comp_Context.szLxBuffer[i+1] = lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[resstart+1];
  2073. i += 2;
  2074. resstart += 2;
  2075. if(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[resstart]==TEXT(' ') || lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[resstart]==TEXT('\0'))
  2076. break;
  2077. }
  2078. lpEngPrivate->PrivateArea.Comp_Context.szLxBuffer[i] = TEXT('\0');
  2079. lpEngPrivate->PrivateArea.Comp_Context.LxStrCnt = i;
  2080. if (MBIndex.IMEChara[0].IC_LX==1) //&& (lpEngPrivate->PrivateArea.Comp_Context.ResultStrCnt==2))
  2081. CoreLXComp();
  2082. else
  2083. ClrDoubleBuf();
  2084. lpEngPrivate->PrivateArea.Comp_Status.dwSTMULCODE = 0;
  2085. return(2);
  2086. } else {
  2087. MessageBeep((UINT)-1);
  2088. return(0);
  2089. }
  2090. }
  2091. UINT DefSelect() {
  2092. if (lpEngPrivate->PrivateArea.GlobVac.ST_MUL_Cnt > 1) { // Mutilple code
  2093. TSMulCProc();
  2094. return (0);
  2095. } else { // Result string
  2096. if (lpEngPrivate->PrivateArea.Comp_Status.dwSTLX)
  2097. return(LXSelectCandi(TEXT('1')));
  2098. else
  2099. return (SelectCandi(TEXT('1')));
  2100. //return(2);
  2101. }
  2102. }
  2103. void TSMulCProc(void) {
  2104. BYTE mul_code_end;
  2105. if(lpEngPrivate->PrivateArea.GlobVac.ST_MUL_Cnt < lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt) {
  2106. mul_code_end = lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[(lpEngPrivate->PrivateArea.GlobVac.ST_MUL_Cnt+1)%10]-1;
  2107. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[mul_code_end] = TEXT('\0');
  2108. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = lpEngPrivate->PrivateArea.GlobVac.ST_MUL_Cnt;
  2109. }
  2110. lpEngPrivate->PrivateArea.GlobVac.ST_MUL_Cnt = 0;
  2111. lpEngPrivate->PrivateArea.Comp_Status.dwSTMULCODE = 1;
  2112. MessageBeep((UINT)-1);
  2113. }
  2114. void SearchEMBPos(TCHAR code,BYTE m_lenth) {
  2115. int i;
  2116. TCHAR codebuf[MAXCODE];
  2117. if(!lpEngPrivate->PrivateArea.GlobVac.EMB_Exist)
  2118. return;
  2119. lstrcpyn(codebuf,lpEngPrivate->PrivateArea.Comp_Context.szInBuffer,m_lenth-1+1);
  2120. codebuf[m_lenth-1] = code;
  2121. for (i=0; i<lpEngPrivate->PrivateArea.GlobVac.EMB_Count; i++) {
  2122. if (wcsncmp(EMB_Table[i].W_Code,codebuf,m_lenth)==0)
  2123. {
  2124. //CHP
  2125. #ifdef FUSSYMODE
  2126. if ((lstrlen(EMB_Table[i].C_Char) == 1) && !MBIndex.IMEChara[0].IC_FCSR)
  2127. {
  2128. //If EUDC, let it go.
  2129. if (EMB_Table[i].C_Char[0] >= 0xe000 && EMB_Table[i].C_Char[0] <= 0xf8ff)
  2130. break;
  2131. }
  2132. else
  2133. #endif //FUSSYMODE
  2134. break;
  2135. }
  2136. }
  2137. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos = i;
  2138. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos = i;
  2139. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos = i;
  2140. for (i;i<lpEngPrivate->PrivateArea.GlobVac.EMB_Count; i++) {
  2141. if (wcsncmp(EMB_Table[i].W_Code, codebuf, m_lenth)!=0)
  2142. break;
  2143. }
  2144. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos = i;
  2145. }
  2146. //CHP
  2147. #ifdef FUSSYMODE
  2148. BOOL IsFussyChar(LPCTSTR lpReading, LPCTSTR lpString)
  2149. {
  2150. int i;
  2151. if(!lpEngPrivate->PrivateArea.GlobVac.EMB_Exist)
  2152. return FALSE;
  2153. for (i=0; i<lpEngPrivate->PrivateArea.GlobVac.EMB_Count; i++) {
  2154. if (!lstrcmp(EMB_Table[i].W_Code,lpReading) &&
  2155. !lstrcmp(EMB_Table[i].C_Char,lpString))
  2156. return TRUE;
  2157. }
  2158. return FALSE;
  2159. }
  2160. #endif //FUSSYMODE
  2161. int EMBWCWildComp(TCHAR code,BYTE code_num, int no) {
  2162. TCHAR codebuf[13];
  2163. int i;
  2164. if ( (code_num+1) > sizeof(codebuf)/sizeof(TCHAR) )
  2165. return 0;
  2166. lstrcpyn(codebuf,lpEngPrivate->PrivateArea.Comp_Context.szInBuffer,code_num+1);
  2167. codebuf[code_num] = code;
  2168. codebuf[code_num+1] = 0x0;
  2169. for(i=0; i<=code_num; i++) {
  2170. if((codebuf[i]!=EMB_Table[no].W_Code[i]) && (codebuf[i]!=WildChar))
  2171. return(0);
  2172. }
  2173. return(1);
  2174. }
  2175. void SearchBEMBWWMatch(TCHAR code,BYTE code_num) {
  2176. int i,lenw,lenc,len;
  2177. TCHAR codebuf[13];
  2178. if(!lpEngPrivate->PrivateArea.GlobVac.EMB_Exist)
  2179. return;
  2180. if (GetLengthofBuf() > MAX_LEN) {
  2181. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2182. return;
  2183. }
  2184. for (i=lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos-1 ; i>=lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos; i--) {
  2185. lenw = Inputcodelen(EMB_Table[i].W_Code);
  2186. if ((lenw == code_num+1) && (EMBWCWildComp(code,code_num,i)==1)) {
  2187. lenc = DBCSCharlen(EMB_Table[i].C_Char);
  2188. len = WildInBuffer();
  2189. if ((MBIndex.IMEChara[0].IC_CZ==1) || (lenc==2/sizeof(TCHAR))) {
  2190. lstrcpyn(codebuf,EMB_Table[i].W_Code+len,lenw-len+1);
  2191. codebuf[lenw-len] = 0;
  2192. if(MBIndex.IMEChara[0].IC_CTC) {
  2193. if (GetLengthCCharBuf(EMB_Table[i].C_Char)+GetLengthTepBuf(TEXT("9:"))+GetLengthofBuf()+GetLengthTepBuf(codebuf) > MAX_LEN) {
  2194. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2195. i++;
  2196. break;
  2197. }
  2198. } else {
  2199. if (GetLengthCCharBuf(EMB_Table[i].C_Char)+GetLengthTepBuf(TEXT("9:"))+GetLengthofBuf() > MAX_LEN) {
  2200. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2201. i++;
  2202. break;
  2203. }
  2204. }
  2205. if (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt==IME_MAXCAND) {
  2206. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2207. i++;
  2208. break;
  2209. }
  2210. #if defined(COMBO_IME)
  2211. {
  2212. int k;
  2213. BOOL ISGBK = FALSE;
  2214. if(MBIndex.IMEChara[0].IC_GB){ //should test GB/GBK
  2215. for(k=0;k<lenc;k+=2/sizeof(TCHAR)){
  2216. if(ISGBK = IsGBK(&EMB_Table[i].C_Char[k])){//out of GB range
  2217. break;
  2218. }
  2219. }
  2220. if(ISGBK){
  2221. }else{
  2222. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1) ;
  2223. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  2224. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,lenc+1);
  2225. lpEngPrivate->PrivateArea.GlobVac.SBufPos += DBCSCharlen(EMB_Table[i].C_Char);
  2226. if (MBIndex.IMEChara[0].IC_CTC) {
  2227. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].W_Code+len,lenw-len+1);
  2228. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (lenw-len);
  2229. }
  2230. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2231. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  2232. }
  2233. }else{
  2234. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1) ;
  2235. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  2236. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,lenc+1);
  2237. lpEngPrivate->PrivateArea.GlobVac.SBufPos += DBCSCharlen(EMB_Table[i].C_Char);
  2238. if (MBIndex.IMEChara[0].IC_CTC) {
  2239. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].W_Code+len,lenw-len+1);
  2240. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (lenw-len);
  2241. }
  2242. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2243. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  2244. }
  2245. }
  2246. #else
  2247. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1) ;
  2248. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  2249. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,lenc+1);
  2250. // modify 11.9
  2251. //lpEngPrivate->PrivateArea.GlobVac.SBufPos += lstrlen(EMB_Table[i].C_Char);
  2252. lpEngPrivate->PrivateArea.GlobVac.SBufPos += DBCSCharlen(EMB_Table[i].C_Char);
  2253. if (MBIndex.IMEChara[0].IC_CTC) {
  2254. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].W_Code+len,lenw-len+1);
  2255. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (lenw-len);
  2256. }
  2257. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2258. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  2259. #endif //COMBO_IME
  2260. }
  2261. }
  2262. }
  2263. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos = i;
  2264. }
  2265. void SearchEMBWWMatch(TCHAR code,BYTE code_num) {
  2266. int i,lenw,lenc,len;
  2267. TCHAR codebuf[13];
  2268. if(!lpEngPrivate->PrivateArea.GlobVac.EMB_Exist)
  2269. return;
  2270. for (i=lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos; i<lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos; i++) {
  2271. lenw = Inputcodelen(EMB_Table[i].W_Code);
  2272. if ((lenw == code_num+1) && (EMBWCWildComp(code,code_num,i)==1)) {
  2273. lenc = DBCSCharlen(EMB_Table[i].C_Char);
  2274. len = WildInBuffer();
  2275. if ((MBIndex.IMEChara[0].IC_CZ == 1) || (lenc == 2)) {
  2276. lstrcpyn(codebuf,EMB_Table[i].W_Code+len,lenw-len+1);
  2277. codebuf[lenw-len] = 0;
  2278. if(MBIndex.IMEChara[0].IC_CTC) {
  2279. if (GetLengthCCharBuf(EMB_Table[i].C_Char)+GetLengthTepBuf(TEXT("9:"))+GetLengthofBuf()+GetLengthTepBuf(codebuf) > MAX_LEN) {
  2280. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2281. break;
  2282. }
  2283. } else {
  2284. if (GetLengthCCharBuf(EMB_Table[i].C_Char)+GetLengthTepBuf(TEXT("9:"))+GetLengthofBuf() > MAX_LEN) {
  2285. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2286. break;
  2287. }
  2288. }
  2289. if (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt == IME_MAXCAND) {
  2290. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2291. break;
  2292. }
  2293. #if defined(COMBO_IME)
  2294. {
  2295. int k;
  2296. BOOL ISGBK = FALSE;
  2297. if(MBIndex.IMEChara[0].IC_GB){ //should test GB/GBK
  2298. for(k=0;k<lenc;k+=2/sizeof(TCHAR)){
  2299. if(ISGBK = IsGBK(&EMB_Table[i].C_Char[k])){//out of GB range
  2300. break;
  2301. }
  2302. }
  2303. if(ISGBK){
  2304. }else{
  2305. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  2306. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  2307. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,lenc+1);
  2308. lpEngPrivate->PrivateArea.GlobVac.SBufPos += lenc;
  2309. if (MBIndex.IMEChara[0].IC_CTC) {
  2310. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].W_Code+len,lenw-len+1);
  2311. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (lenw-len);
  2312. }
  2313. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2314. lpEngPrivate->PrivateArea.GlobVac.SBufPos++;
  2315. }
  2316. }else{
  2317. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  2318. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  2319. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,lenc+1);
  2320. lpEngPrivate->PrivateArea.GlobVac.SBufPos += lenc;
  2321. if (MBIndex.IMEChara[0].IC_CTC) {
  2322. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].W_Code+len,lenw-len+1);
  2323. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (lenw-len);
  2324. }
  2325. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2326. lpEngPrivate->PrivateArea.GlobVac.SBufPos++;
  2327. }
  2328. }
  2329. #else
  2330. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  2331. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  2332. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,lenc+1);
  2333. lpEngPrivate->PrivateArea.GlobVac.SBufPos += lenc;
  2334. if (MBIndex.IMEChara[0].IC_CTC) {
  2335. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].W_Code+len,lenw-len+1);
  2336. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (lenw-len);
  2337. }
  2338. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2339. lpEngPrivate->PrivateArea.GlobVac.SBufPos++;
  2340. #endif //COMBO_IME
  2341. }
  2342. }
  2343. }
  2344. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2345. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos = i;
  2346. }
  2347. UINT SearchEMBCompMatch() {
  2348. int i,len;
  2349. int match_s = 0;
  2350. if(!lpEngPrivate->PrivateArea.GlobVac.EMB_Exist)
  2351. return(match_s);
  2352. for (i=lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos; i<lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos; i++) {
  2353. if (wcsncmp(EMB_Table[i].W_Code ,lpEngPrivate->PrivateArea.Comp_Context.szInBuffer,MaxCodes)==0) { //Complete code match
  2354. len = DBCSCharlen(EMB_Table[i].C_Char);
  2355. if ((MBIndex.IMEChara[0].IC_CZ == 1) || (len == 2)) {
  2356. if (GetLengthCCharBuf(EMB_Table[i].C_Char)+GetLengthTepBuf(TEXT("9:"))+GetLengthofBuf() > MAX_LEN) {
  2357. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2358. break;
  2359. }
  2360. if (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt == IME_MAXCAND) {
  2361. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2362. break;
  2363. }
  2364. #if defined(COMBO_IME)
  2365. {
  2366. int k;
  2367. BOOL ISGBK = FALSE;
  2368. if(MBIndex.IMEChara[0].IC_GB){ //should test GB/GBK
  2369. for(k=0;k<len;k+=2/sizeof(TCHAR)){
  2370. if(ISGBK = IsGBK(&EMB_Table[i].C_Char[k])){//out of GB range
  2371. break;
  2372. }
  2373. }
  2374. if(ISGBK){
  2375. }else{
  2376. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  2377. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  2378. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,len+1);
  2379. lpEngPrivate->PrivateArea.GlobVac.SBufPos += len;
  2380. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2381. lpEngPrivate->PrivateArea.GlobVac.SBufPos++;
  2382. match_s ++;
  2383. }
  2384. }else{
  2385. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  2386. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  2387. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,len+1);
  2388. lpEngPrivate->PrivateArea.GlobVac.SBufPos += len;
  2389. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2390. lpEngPrivate->PrivateArea.GlobVac.SBufPos++;
  2391. match_s ++;
  2392. }
  2393. }
  2394. #else
  2395. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  2396. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  2397. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,len+1);
  2398. lpEngPrivate->PrivateArea.GlobVac.SBufPos += len;
  2399. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2400. lpEngPrivate->PrivateArea.GlobVac.SBufPos++;
  2401. match_s ++;
  2402. #endif //COMBO_IME
  2403. }
  2404. } else
  2405. break;
  2406. }
  2407. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2408. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos = i;
  2409. lpEngPrivate->PrivateArea.GlobVac.ST_MUL_Cnt += (BYTE)match_s;
  2410. return (match_s);
  2411. }
  2412. void SearchBEMBCompMatch() {
  2413. int i,lenw,lenc;
  2414. if(!lpEngPrivate->PrivateArea.GlobVac.EMB_Exist)
  2415. return;
  2416. if(GetLengthofBuf() > MAX_LEN) {
  2417. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2418. return;
  2419. }
  2420. for (i=lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos-1 ; i>=lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos; i--) {
  2421. if (wcsncmp(EMB_Table[i].W_Code ,lpEngPrivate->PrivateArea.Comp_Context.szInBuffer,lpEngPrivate->PrivateArea.Comp_Context.PromptCnt)==0) { //Wild code match
  2422. lenc = DBCSCharlen(EMB_Table[i].C_Char);
  2423. lenw = Inputcodelen(EMB_Table[i].W_Code);
  2424. if ((MBIndex.IMEChara[0].IC_CZ==1) || (lenc==2/sizeof(TCHAR))) {
  2425. if (GetLengthCCharBuf(EMB_Table[i].C_Char)+GetLengthTepBuf(TEXT("9:"))+GetLengthofBuf() > MAX_LEN) {
  2426. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2427. i++;
  2428. break;
  2429. }
  2430. if (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt==IME_MAXCAND) {
  2431. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2432. i++;
  2433. break;
  2434. }
  2435. #if defined(COMBO_IME)
  2436. {
  2437. int k;
  2438. BOOL ISGBK = FALSE;
  2439. if(MBIndex.IMEChara[0].IC_GB){ //should test GB/GBK
  2440. for(k=0;k<lenc;k+=2/sizeof(TCHAR)){
  2441. if(ISGBK = IsGBK(&EMB_Table[i].C_Char[k])){//out of GB range
  2442. break;
  2443. }
  2444. }
  2445. if(ISGBK){
  2446. }else{
  2447. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1) ;
  2448. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  2449. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,lenc+1);
  2450. lpEngPrivate->PrivateArea.GlobVac.SBufPos += DBCSCharlen(EMB_Table[i].C_Char);
  2451. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2452. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  2453. }
  2454. }else{
  2455. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1) ;
  2456. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  2457. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,lenc+1);
  2458. lpEngPrivate->PrivateArea.GlobVac.SBufPos += DBCSCharlen(EMB_Table[i].C_Char);
  2459. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2460. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  2461. }
  2462. }
  2463. #else
  2464. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1) ;
  2465. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  2466. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,lenc+1);
  2467. lpEngPrivate->PrivateArea.GlobVac.SBufPos += DBCSCharlen(EMB_Table[i].C_Char);
  2468. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2469. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  2470. #endif //COMBO_IME
  2471. }
  2472. }
  2473. }
  2474. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos = i+1;
  2475. }
  2476. void SearchEMBWildMatch() {
  2477. int i,lenw,lenc;
  2478. TCHAR codebuf[13];
  2479. if(!lpEngPrivate->PrivateArea.GlobVac.EMB_Exist)
  2480. return;
  2481. if(GetLengthofBuf() >= MAX_LEN) {
  2482. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2483. return;
  2484. }
  2485. for (i=lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos ; i<lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos; i++) {
  2486. if (wcsncmp(EMB_Table[i].W_Code ,lpEngPrivate->PrivateArea.Comp_Context.szInBuffer,lpEngPrivate->PrivateArea.Comp_Context.PromptCnt)==0) { //Wild code match
  2487. lenc = DBCSCharlen(EMB_Table[i].C_Char);
  2488. lenw = Inputcodelen(EMB_Table[i].W_Code);
  2489. if ((MBIndex.IMEChara[0].IC_CZ==1) || (lenc==2/sizeof(TCHAR))) {
  2490. lstrcpyn(codebuf,EMB_Table[i].W_Code+lpEngPrivate->PrivateArea.Comp_Context.PromptCnt,lenw-lpEngPrivate->PrivateArea.Comp_Context.PromptCnt+1);
  2491. codebuf[lenw-lpEngPrivate->PrivateArea.Comp_Context.PromptCnt] = 0;
  2492. if(MBIndex.IMEChara[0].IC_CTC) {
  2493. if (GetLengthCCharBuf(EMB_Table[i].C_Char)+GetLengthTepBuf(TEXT("9:"))+GetLengthofBuf()+GetLengthTepBuf(codebuf) > MAX_LEN) {
  2494. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2495. break;
  2496. }
  2497. } else {
  2498. if (GetLengthCCharBuf(EMB_Table[i].C_Char)+GetLengthTepBuf(TEXT("9:"))+GetLengthofBuf() > MAX_LEN) {
  2499. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2500. break;
  2501. }
  2502. }
  2503. if(lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt ==IME_MAXCAND) {
  2504. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2505. break;
  2506. }
  2507. #if defined(COMBO_IME)
  2508. {
  2509. int k;
  2510. BOOL ISGBK = FALSE;
  2511. if(MBIndex.IMEChara[0].IC_GB){ //should test GB/GBK
  2512. for(k=0;k<lenc;k+=2/sizeof(TCHAR)){
  2513. if(ISGBK = IsGBK(&EMB_Table[i].C_Char[k])){//out of GB range
  2514. break;
  2515. }
  2516. }
  2517. if(ISGBK){
  2518. }else{
  2519. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1) ;
  2520. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  2521. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,lenc+1);
  2522. lpEngPrivate->PrivateArea.GlobVac.SBufPos += lenc;
  2523. if(MBIndex.IMEChara[0].IC_CTC) {
  2524. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,
  2525. EMB_Table[i].W_Code+lpEngPrivate->PrivateArea.Comp_Context.PromptCnt,lenw-lpEngPrivate->PrivateArea.Comp_Context.PromptCnt+1);
  2526. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (lenw-lpEngPrivate->PrivateArea.Comp_Context.PromptCnt);
  2527. }
  2528. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2529. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  2530. }
  2531. }else{
  2532. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1) ;
  2533. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  2534. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,lenc+1);
  2535. lpEngPrivate->PrivateArea.GlobVac.SBufPos += lenc;
  2536. if(MBIndex.IMEChara[0].IC_CTC) {
  2537. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,
  2538. EMB_Table[i].W_Code+lpEngPrivate->PrivateArea.Comp_Context.PromptCnt,lenw-lpEngPrivate->PrivateArea.Comp_Context.PromptCnt+1);
  2539. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (lenw-lpEngPrivate->PrivateArea.Comp_Context.PromptCnt);
  2540. }
  2541. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2542. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  2543. }
  2544. }
  2545. #else
  2546. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1) ;
  2547. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  2548. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,lenc+1);
  2549. lpEngPrivate->PrivateArea.GlobVac.SBufPos += lenc;
  2550. if(MBIndex.IMEChara[0].IC_CTC) {
  2551. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,
  2552. EMB_Table[i].W_Code+lpEngPrivate->PrivateArea.Comp_Context.PromptCnt,lenw-lpEngPrivate->PrivateArea.Comp_Context.PromptCnt+1);
  2553. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (lenw-lpEngPrivate->PrivateArea.Comp_Context.PromptCnt);
  2554. }
  2555. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2556. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  2557. #endif //COMBO_IME
  2558. }
  2559. }
  2560. }
  2561. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos = i;
  2562. }
  2563. void SearchBEMBWildMatch() {
  2564. int i,lenw,lenc;
  2565. TCHAR codebuf[13];
  2566. if(!lpEngPrivate->PrivateArea.GlobVac.EMB_Exist)
  2567. return;
  2568. if(GetLengthofBuf() > MAX_LEN) {
  2569. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2570. return;
  2571. }
  2572. for (i=lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos-1 ; i>=lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos; i--) {
  2573. if (wcsncmp(EMB_Table[i].W_Code ,lpEngPrivate->PrivateArea.Comp_Context.szInBuffer,lpEngPrivate->PrivateArea.Comp_Context.PromptCnt)==0) { //Wild code match
  2574. lenc = DBCSCharlen(EMB_Table[i].C_Char);
  2575. lenw = Inputcodelen(EMB_Table[i].W_Code);
  2576. if ((MBIndex.IMEChara[0].IC_CZ==1) || (lenc==2/sizeof(TCHAR))) {
  2577. lstrcpyn(codebuf,EMB_Table[i].W_Code+lpEngPrivate->PrivateArea.Comp_Context.PromptCnt,lenw-lpEngPrivate->PrivateArea.Comp_Context.PromptCnt+1);
  2578. codebuf[lenw-lpEngPrivate->PrivateArea.Comp_Context.PromptCnt] = 0;
  2579. if(MBIndex.IMEChara[0].IC_CTC) {
  2580. if (GetLengthCCharBuf(EMB_Table[i].C_Char)+GetLengthTepBuf(TEXT("9:"))+GetLengthofBuf()+GetLengthTepBuf(codebuf) > MAX_LEN) {
  2581. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2582. i++;
  2583. break;
  2584. }
  2585. }else {
  2586. if (GetLengthCCharBuf(EMB_Table[i].C_Char)+GetLengthTepBuf(TEXT("9:"))+GetLengthofBuf() > MAX_LEN) {
  2587. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2588. i++;
  2589. break;
  2590. }
  2591. }
  2592. if (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt==IME_MAXCAND) {
  2593. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2594. i++;
  2595. break;
  2596. }
  2597. #if defined(COMBO_IME)
  2598. {
  2599. int k;
  2600. BOOL ISGBK = FALSE;
  2601. if(MBIndex.IMEChara[0].IC_GB){ //should test GB/GBK
  2602. for(k=0;k<lenc;k+=2/sizeof(TCHAR)){
  2603. if(ISGBK = IsGBK(&EMB_Table[i].C_Char[k])){//out of GB range
  2604. break;
  2605. }
  2606. }
  2607. if(ISGBK){
  2608. }else{
  2609. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1) ;
  2610. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  2611. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,lenc+1);
  2612. lpEngPrivate->PrivateArea.GlobVac.SBufPos += DBCSCharlen(EMB_Table[i].C_Char);
  2613. if(MBIndex.IMEChara[0].IC_CTC) {
  2614. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,
  2615. EMB_Table[i].W_Code+lpEngPrivate->PrivateArea.Comp_Context.PromptCnt,lenw-lpEngPrivate->PrivateArea.Comp_Context.PromptCnt+1);
  2616. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (lenw-lpEngPrivate->PrivateArea.Comp_Context.PromptCnt);
  2617. }
  2618. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2619. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  2620. }
  2621. }else{
  2622. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1) ;
  2623. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  2624. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,lenc+1);
  2625. lpEngPrivate->PrivateArea.GlobVac.SBufPos += DBCSCharlen(EMB_Table[i].C_Char);
  2626. if(MBIndex.IMEChara[0].IC_CTC) {
  2627. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,
  2628. EMB_Table[i].W_Code+lpEngPrivate->PrivateArea.Comp_Context.PromptCnt,lenw-lpEngPrivate->PrivateArea.Comp_Context.PromptCnt+1);
  2629. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (lenw-lpEngPrivate->PrivateArea.Comp_Context.PromptCnt);
  2630. }
  2631. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2632. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  2633. }
  2634. }
  2635. #else
  2636. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1) ;
  2637. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  2638. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,lenc+1);
  2639. lpEngPrivate->PrivateArea.GlobVac.SBufPos += DBCSCharlen(EMB_Table[i].C_Char);
  2640. if(MBIndex.IMEChara[0].IC_CTC) {
  2641. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,
  2642. EMB_Table[i].W_Code+lpEngPrivate->PrivateArea.Comp_Context.PromptCnt,lenw-lpEngPrivate->PrivateArea.Comp_Context.PromptCnt+1);
  2643. lpEngPrivate->PrivateArea.GlobVac.SBufPos += (lenw-lpEngPrivate->PrivateArea.Comp_Context.PromptCnt);
  2644. }
  2645. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2646. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  2647. #endif //COMBO_IME
  2648. }
  2649. }
  2650. }
  2651. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos = i;
  2652. }
  2653. void SearchBEMBLXMatch() {
  2654. int i,lenc;
  2655. if(!lpEngPrivate->PrivateArea.GlobVac.EMB_Exist)
  2656. return;
  2657. if(GetLengthofBuf() > MAX_LEN) {
  2658. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2659. return;
  2660. }
  2661. for (i=lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos-1 ; i>=0; i--) {
  2662. if (wcsncmp(EMB_Table[i].C_Char ,lpEngPrivate->PrivateArea.Comp_Context.szLxBuffer,lpEngPrivate->PrivateArea.Comp_Context.LxStrCnt)==0) { //Wild code match
  2663. lenc = DBCSCharlen(EMB_Table[i].C_Char);
  2664. if (lenc > lpEngPrivate->PrivateArea.Comp_Context.LxStrCnt) {
  2665. if (GetLengthCCharBuf(EMB_Table[i].C_Char)+GetLengthTepBuf(TEXT("9:"))+GetLengthofBuf() > MAX_LEN) {
  2666. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2667. i++;
  2668. break;
  2669. }
  2670. if (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt==IME_MAXCAND) { // words count is enough
  2671. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2672. i++;
  2673. break;
  2674. }
  2675. #if defined(COMBO_IME)
  2676. {
  2677. int k;
  2678. BOOL ISGBK = FALSE;
  2679. if(MBIndex.IMEChara[0].IC_GB){ //should test GB/GBK
  2680. for(k=0;k<lenc;k+=2/sizeof(TCHAR)){
  2681. if(ISGBK = IsGBK(&EMB_Table[i].C_Char[k])){//out of GB range
  2682. break;
  2683. }
  2684. }
  2685. if(ISGBK){
  2686. }else{
  2687. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  2688. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  2689. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,lenc+1);
  2690. lpEngPrivate->PrivateArea.GlobVac.SBufPos += lenc;
  2691. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2692. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  2693. }
  2694. }else{
  2695. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  2696. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  2697. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,lenc+1);
  2698. lpEngPrivate->PrivateArea.GlobVac.SBufPos += lenc;
  2699. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2700. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  2701. }
  2702. }
  2703. #else
  2704. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  2705. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  2706. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,lenc+1);
  2707. lpEngPrivate->PrivateArea.GlobVac.SBufPos += lenc;
  2708. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2709. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  2710. #endif //COMBO_IME
  2711. }
  2712. }
  2713. }
  2714. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos = i;
  2715. }
  2716. void SearchEMBLXMatch() {
  2717. int i,lenw,lenc;
  2718. if(!lpEngPrivate->PrivateArea.GlobVac.EMB_Exist)
  2719. return;
  2720. if(GetLengthofBuf() >= MAX_LEN) {
  2721. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2722. return;
  2723. }
  2724. for (i=lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos ; i<lpEngPrivate->PrivateArea.GlobVac.EMB_Count; i++) {
  2725. if (wcsncmp(EMB_Table[i].C_Char ,lpEngPrivate->PrivateArea.Comp_Context.szLxBuffer,lpEngPrivate->PrivateArea.Comp_Context.LxStrCnt)==0) {
  2726. lenc = DBCSCharlen(EMB_Table[i].C_Char);
  2727. lenw = Inputcodelen(EMB_Table[i].W_Code);
  2728. if (lenc > lpEngPrivate->PrivateArea.Comp_Context.LxStrCnt) {
  2729. if (GetLengthCCharBuf(EMB_Table[i].C_Char)+GetLengthTepBuf(TEXT("9:"))+GetLengthofBuf() > MAX_LEN) {
  2730. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2731. break;
  2732. }
  2733. if (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt ==IME_MAXCAND) {
  2734. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  2735. break;
  2736. }
  2737. #if defined(COMBO_IME)
  2738. {
  2739. int k;
  2740. BOOL ISGBK = FALSE;
  2741. if(MBIndex.IMEChara[0].IC_GB){ //should test GB/GBK
  2742. for(k=0;k<lenc;k+=2/sizeof(TCHAR)){
  2743. if(ISGBK = IsGBK(&EMB_Table[i].C_Char[k])){//out of GB range
  2744. break;
  2745. }
  2746. }
  2747. if(ISGBK){
  2748. }else{
  2749. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  2750. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  2751. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,lenc+1);
  2752. lpEngPrivate->PrivateArea.GlobVac.SBufPos += lenc;
  2753. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2754. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  2755. }
  2756. }else{
  2757. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  2758. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  2759. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,lenc+1);
  2760. lpEngPrivate->PrivateArea.GlobVac.SBufPos += lenc;
  2761. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2762. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  2763. }
  2764. }
  2765. #else
  2766. lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt = (lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt+1);
  2767. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt%IME_MAXCAND] = lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  2768. lstrcpyn(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,EMB_Table[i].C_Char,lenc+1);
  2769. lpEngPrivate->PrivateArea.GlobVac.SBufPos += lenc;
  2770. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  2771. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  2772. #endif //COMBO_IME
  2773. }
  2774. }
  2775. }
  2776. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos = i;
  2777. }
  2778. void CapKeyProc(TCHAR code){}
  2779. DWORD Skip_CaWord(DWORD sp) { // sp's start position must be chinese's first byte
  2780. TCHAR len;
  2781. len = ZM_Area[sp];
  2782. sp += (len+1);
  2783. len = ZM_Area[sp];
  2784. #ifdef UNICODE
  2785. // all the code in MB are Unicode now, len should not be mult by 2.
  2786. sp += len + 1;
  2787. #else
  2788. sp += (2*len+1);
  2789. #endif
  2790. return (sp);
  2791. }
  2792. int Scan_Word(DWORD sp, LPTSTR tbuf) {
  2793. TCHAR numwords;
  2794. numwords = ZM_Area[sp];
  2795. numwords = numwords*2/sizeof(TCHAR);
  2796. //Engine mess up to unreasonable number, force it return. NTBUG #86303
  2797. if (numwords > 130)
  2798. return 0;
  2799. lstrcpyn(tbuf,&ZM_Area[sp+1],numwords+1);
  2800. tbuf[numwords] = TEXT('\0');
  2801. return (numwords);
  2802. }
  2803. int VerScan_Word(DWORD sp, LPTSTR tbuf) { //start position must be the last byte
  2804. TCHAR numwords;
  2805. for (;;) {
  2806. #ifdef UNICODE
  2807. if(ZM_Area[sp] > 0x100)
  2808. sp -= 1;
  2809. #else
  2810. if(ZM_Area[sp-1]&0x80)
  2811. sp -= 2;
  2812. #endif
  2813. else
  2814. break;
  2815. }
  2816. numwords = ZM_Area[sp];
  2817. numwords = numwords*2/sizeof(TCHAR);
  2818. sp++;
  2819. lstrcpyn(tbuf,ZM_Area+sp,numwords+1);
  2820. *(tbuf+numwords) = TEXT('\0');
  2821. return (numwords);
  2822. }
  2823. void IMDReset(int i) {
  2824. if(i<=lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos) {
  2825. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos++;
  2826. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos++;
  2827. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos++;
  2828. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos++;
  2829. } else if(i<=lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos) {
  2830. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos++;
  2831. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos++;
  2832. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos++;
  2833. } else if(i<=lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos) {
  2834. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos++;
  2835. }
  2836. }
  2837. // Write to EMB_File
  2838. BOOL WriteEMBToFile(LPTSTR embaddress) {
  2839. HANDLE hFile;
  2840. DWORD byte_t_write;
  2841. TCHAR path_name[MAX_PATH];
  2842. StringCchCopy(path_name, ARRAYSIZE(path_name), sImeG.szIMEUserPath);
  2843. StringCchCat(path_name, ARRAYSIZE(path_name), TEXT("\\"));
  2844. StringCchCat(path_name, ARRAYSIZE(path_name), lpEngPrivate->EMB_Name);
  2845. hFile = CreateFile(path_name,
  2846. GENERIC_WRITE|GENERIC_READ,
  2847. FILE_SHARE_WRITE|FILE_SHARE_READ,
  2848. NULL,
  2849. CREATE_ALWAYS,
  2850. 0,
  2851. NULL);
  2852. if(hFile==INVALID_HANDLE_VALUE) {
  2853. byte_t_write = GetLastError();
  2854. return(0);
  2855. }
  2856. WriteFile(hFile,
  2857. &lpEngPrivate->PrivateArea.GlobVac.EMB_Count,
  2858. 2,
  2859. &byte_t_write,
  2860. NULL);
  2861. WriteFile(hFile,
  2862. embaddress,
  2863. lpEngPrivate->PrivateArea.GlobVac.EMB_Count*sizeof(EMB_Head),
  2864. &byte_t_write,
  2865. NULL);
  2866. SetEndOfFile(hFile);
  2867. CloseHandle(hFile);
  2868. return (1);
  2869. }
  2870. BOOL GetUDCItem(HIMCC HmemPri,UINT Index,LPTSTR Read_String,LPTSTR Result_String) {
  2871. lpEngPrivate = (PPRIVCONTEXT) ImmLockIMCC(HmemPri);
  2872. if(!lpEngPrivate){
  2873. return (0);
  2874. }
  2875. if(!lpEngPrivate->PrivateArea.GlobVac.EMB_Exist) {
  2876. ImmUnlockIMCC(HmemPri);
  2877. return (0);
  2878. }
  2879. else if (lpEngPrivate->PrivateArea.GlobVac.EMB_Count <= Index) {
  2880. ImmUnlockIMCC(HmemPri);
  2881. return (0);
  2882. }
  2883. else {
  2884. lstrcpyn(Read_String, EMB_Table[Index].W_Code, MAXCODE+1);
  2885. Read_String[MAXCODE] = 0;
  2886. lstrcpyn(Result_String, EMB_Table[Index].C_Char, MAXINPUTWORD+1);
  2887. Result_String[MAXINPUTWORD] = 0;
  2888. return(1);
  2889. }
  2890. }
  2891. int AddZCItem(HIMCC HmemPri,LPTSTR wai_code,LPTSTR cCharStr) {
  2892. HANDLE hFile,hMProcess,hCProcess;
  2893. TCHAR path_name[MAX_PATH];
  2894. int byte_t_write, i,j;
  2895. TCHAR emp;
  2896. EMB_Head *emb;
  2897. HANDLE hemb;
  2898. TCHAR szW_Code[MAXCODE];
  2899. TCHAR szC_CharStr[MAXINPUTWORD];
  2900. lpEngPrivate = (PPRIVCONTEXT) ImmLockIMCC(HmemPri);
  2901. if(!lpEngPrivate){
  2902. return (0);
  2903. }
  2904. hemb = GlobalAlloc(GMEM_DISCARDABLE,
  2905. (lpEngPrivate->PrivateArea.GlobVac.EMB_Count+1)*sizeof(EMB_Head));
  2906. if(!hemb){
  2907. ImmUnlockIMCC(HmemPri);
  2908. return (0);
  2909. }
  2910. emb = GlobalLock(hemb);
  2911. if(!emb){
  2912. GlobalFree(hemb);
  2913. ImmUnlockIMCC(HmemPri);
  2914. return(0);
  2915. }
  2916. for (i=0; i<MAXCODE; i++)
  2917. szW_Code[i] = TEXT('\0');
  2918. for (i=0; i<MAXINPUTWORD; i++)
  2919. szC_CharStr[i] = TEXT('\0');
  2920. for (i=0; i<lstrlen(wai_code); i++)
  2921. szW_Code[i] = wai_code[i];
  2922. for (i=0; i<lstrlen(cCharStr); i++)
  2923. szC_CharStr[i] = cCharStr[i];
  2924. if (!lpEngPrivate->PrivateArea.GlobVac.EMB_Exist) {
  2925. StringCchCopy(path_name, ARRAYSIZE(path_name), sImeG.szIMEUserPath);
  2926. StringCchCat(path_name, ARRAYSIZE(path_name), TEXT("\\"));
  2927. StringCchCat(path_name, ARRAYSIZE(path_name), lpEngPrivate->EMB_Name);
  2928. hFile = CreateFile(path_name,
  2929. GENERIC_WRITE,
  2930. FILE_SHARE_WRITE,
  2931. NULL,
  2932. CREATE_NEW,
  2933. 0,
  2934. NULL);
  2935. if(hFile==INVALID_HANDLE_VALUE) {
  2936. GlobalUnlock(emb);
  2937. GlobalFree(hemb);
  2938. ImmUnlockIMCC(HmemPri);
  2939. return(0);
  2940. }
  2941. lpEngPrivate->PrivateArea.GlobVac.EMB_Count = 1;
  2942. WriteFile(hFile,
  2943. &lpEngPrivate->PrivateArea.GlobVac.EMB_Count,
  2944. 2,
  2945. &byte_t_write,
  2946. NULL);
  2947. WriteFile(hFile,
  2948. szW_Code,
  2949. MAXCODE*sizeof(TCHAR),
  2950. &byte_t_write,
  2951. NULL);
  2952. WriteFile(hFile,
  2953. szC_CharStr,
  2954. MAXINPUTWORD * sizeof(TCHAR),
  2955. &byte_t_write,
  2956. NULL);
  2957. SetEndOfFile(hFile);
  2958. CloseHandle(hFile);
  2959. lpEngPrivate->PrivateArea.GlobVac.EMB_Exist = 1;
  2960. hFile = CreateFile(path_name,
  2961. GENERIC_READ|GENERIC_WRITE,
  2962. FILE_SHARE_READ|FILE_SHARE_WRITE,
  2963. NULL,
  2964. OPEN_EXISTING,
  2965. 0,
  2966. NULL);
  2967. for (i=0;i<MaxTabNum;i++) {
  2968. if(lstrcmp(HMapTab[i].MB_Name,lpEngPrivate->MB_Name)==0)
  2969. break;
  2970. }
  2971. HmemEMB_Table = CreateFileMapping(hFile,
  2972. NULL,
  2973. PAGE_READWRITE,
  2974. 0,
  2975. sizeof(EMB_Head)*MAXNUMBER_EMB+2,
  2976. HMapTab[i].EMB_Obj);
  2977. if (EMBM)
  2978. UnmapViewOfFile(EMBM);
  2979. EMBM = MapViewOfFile(HmemEMB_Table,
  2980. FILE_MAP_READ|FILE_MAP_WRITE,
  2981. 0,
  2982. 0,
  2983. sizeof(EMB_Head)*MAXNUMBER_EMB+2);
  2984. EMB_Table =(EMB_Head *)(EMBM+2);
  2985. lpEngPrivate->PrivateArea.hEmbFile = hFile;
  2986. lpEngPrivate->PrivateArea.hMapEMB = HmemEMB_Table;
  2987. if(GetCurrentProcessId()==HMapTab[i].EMB_ID) {
  2988. HMapTab[i].hEmbFile = hFile;
  2989. } else {
  2990. hCProcess = GetCurrentProcess();
  2991. hMProcess = OpenProcess(STANDARD_RIGHTS_REQUIRED|PROCESS_DUP_HANDLE,
  2992. FALSE,
  2993. HMapTab[i].EMB_ID);
  2994. DuplicateHandle(hCProcess,
  2995. lpEngPrivate->PrivateArea.hEmbFile,
  2996. hMProcess,
  2997. &HMapTab[i].hEmbFile,
  2998. 0,
  2999. FALSE,
  3000. DUPLICATE_SAME_ACCESS);
  3001. }
  3002. } else {
  3003. if(lpEngPrivate->PrivateArea.GlobVac.EMB_Count==MAXNUMBER_EMB){
  3004. GlobalUnlock(emb);
  3005. GlobalFree(hemb);
  3006. ImmUnlockIMCC(HmemPri);
  3007. return (3);
  3008. }
  3009. for(i=0; i<lpEngPrivate->PrivateArea.GlobVac.EMB_Count;i++) {
  3010. if(wcsncmp(szW_Code, EMB_Table[i].W_Code, MAXCODE) <=0)
  3011. break;
  3012. }
  3013. if ((wcsncmp(szW_Code,EMB_Table[i].W_Code,MAXCODE)==0) &&
  3014. (wcsncmp(EMB_Table[i].C_Char,szC_CharStr,MAXINPUTWORD)==0))
  3015. {
  3016. // this record has already been in the dictionary.
  3017. GlobalUnlock(emb);
  3018. GlobalFree(hemb);
  3019. ImmUnlockIMCC(HmemPri);
  3020. return(2);
  3021. }
  3022. else {
  3023. memmove(EMB_Table+i+1,
  3024. EMB_Table+i,
  3025. (lpEngPrivate->PrivateArea.GlobVac.EMB_Count-i)*sizeof(EMB_Head));
  3026. for (j=0; j<MAXCODE; j++)
  3027. EMB_Table[i].W_Code[j] = szW_Code[j];
  3028. for (j=0; j<MAXINPUTWORD; j++)
  3029. EMB_Table[i].C_Char[j] = szC_CharStr[j];
  3030. lpEngPrivate->PrivateArea.GlobVac.EMB_Count ++;
  3031. (LPWORD)(EMBM)[0]++;//=lpEngPrivate->PrivateArea.GlobVac.EMB_Count;
  3032. //the file is flushed from base address to the end of the mapping
  3033. FlushViewOfFile(EMBM, 0);
  3034. }
  3035. }
  3036. IMDReset(i);
  3037. GlobalUnlock(emb);
  3038. GlobalFree(hemb);
  3039. ImmUnlockIMCC(HmemPri);
  3040. return(1);
  3041. }
  3042. void DelSelCU(HIMCC HmemPri,int item) {
  3043. lpEngPrivate = (PPRIVCONTEXT) ImmLockIMCC(HmemPri);
  3044. if(!lpEngPrivate){
  3045. ImmUnlockIMCC(HmemPri);
  3046. return ;
  3047. }
  3048. if(!lpEngPrivate->PrivateArea.GlobVac.EMB_Exist){
  3049. ImmUnlockIMCC(HmemPri);
  3050. return;
  3051. }
  3052. memcpy(EMB_Table+item,EMB_Table+item+1,(lpEngPrivate->PrivateArea.GlobVac.EMB_Count-item-1)*sizeof(EMB_Head));
  3053. lpEngPrivate->PrivateArea.GlobVac.EMB_Count --;
  3054. *((LPWORD)EMB_Table-1) = lpEngPrivate->PrivateArea.GlobVac.EMB_Count ;
  3055. IMDReset(item);
  3056. ImmUnlockIMCC(HmemPri);
  3057. }
  3058. int GetUDCIndex(HIMCC HmemPri,LPTSTR lpreadstring,LPTSTR lpresultstring) {
  3059. int i ;
  3060. lpEngPrivate = (PPRIVCONTEXT) ImmLockIMCC(HmemPri);
  3061. if(!lpEngPrivate){
  3062. ImmUnlockIMCC(HmemPri);
  3063. return (-1);
  3064. }
  3065. if(!lpEngPrivate->PrivateArea.GlobVac.EMB_Exist) {
  3066. ImmUnlockIMCC(HmemPri);
  3067. return (-1);
  3068. }
  3069. for(i=0;i<lpEngPrivate->PrivateArea.GlobVac.EMB_Count;i++) {
  3070. if((wcsncmp(EMB_Table[i].W_Code, lpreadstring, MAXCODE)==0) && (wcsncmp(EMB_Table[i].C_Char,lpresultstring,MAXINPUTWORD)==0)){
  3071. ImmUnlockIMCC(HmemPri);
  3072. return(i);
  3073. }
  3074. }
  3075. ImmUnlockIMCC(HmemPri);
  3076. return(-1);
  3077. }
  3078. void DelExmb(HIMCC HmemPri) {
  3079. TCHAR path_name[MAX_PATH];
  3080. lpEngPrivate = (PPRIVCONTEXT) ImmLockIMCC(HmemPri);
  3081. if(!lpEngPrivate){
  3082. return ;
  3083. }
  3084. if (!lpEngPrivate->PrivateArea.GlobVac.EMB_Exist) {
  3085. ImmUnlockIMCC(HmemPri);
  3086. return;
  3087. }
  3088. lpEngPrivate->PrivateArea.GlobVac.EMB_Count = 0;
  3089. StringCchCopy(path_name, ARRAYSIZE(path_name), sImeG.szIMEUserPath);
  3090. StringCchCat(path_name, ARRAYSIZE(path_name), TEXT("\\"));
  3091. StringCchCat(path_name, ARRAYSIZE(path_name), lpEngPrivate->EMB_Name);
  3092. DeleteFile(path_name);
  3093. lpEngPrivate->PrivateArea.GlobVac.EMB_Exist = 0;
  3094. ImmUnlockIMCC(HmemPri);
  3095. }
  3096. BYTE CodeInSet(char ch) {
  3097. BYTE i;
  3098. for (i=0;i<NumCodes;i++) {
  3099. if(UsedCode[i]==ch)
  3100. break;
  3101. }
  3102. return(i);
  3103. }
  3104. UINT InCodeSet(TCHAR ch) {
  3105. BYTE i;
  3106. for (i=0;i<NumCodes;i++) {
  3107. if(UsedCode[i]==ch)
  3108. break;
  3109. }
  3110. if (i==NumCodes)
  3111. return (0);
  3112. else
  3113. return (1);
  3114. }
  3115. int NumInSet() {
  3116. int i;
  3117. for (i=0;i<9;i++) {
  3118. if(CodeAIndex[30+i]!=0)
  3119. return(1);
  3120. }
  3121. return(0);
  3122. }
  3123. void ConvertCandi() {
  3124. int i,j;
  3125. BYTE tempos[IME_MAXCAND];
  3126. BYTE s_pos,n_pos;
  3127. TCHAR tembuf[3000];
  3128. TCHAR ch;
  3129. n_pos = 0;
  3130. j = 1;
  3131. for(i=lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt; i>0; i--) {
  3132. tempos[j%IME_MAXCAND] = n_pos;
  3133. s_pos = lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[i%IME_MAXCAND];
  3134. for(;;) {
  3135. ch = lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[s_pos];
  3136. if(ch==0x20 || ch==0x00)
  3137. break;
  3138. tembuf[n_pos] = ch;
  3139. n_pos ++;
  3140. s_pos ++;
  3141. }
  3142. tembuf[n_pos] = 0x20;
  3143. n_pos ++;
  3144. j ++;
  3145. }
  3146. tembuf[n_pos] = 0x00;
  3147. for(i=0; i<=lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt; i++)
  3148. lpEngPrivate->PrivateArea.Comp_Context.Candi_Pos[i] = tempos[i];
  3149. lstrcpy(lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer,tembuf);
  3150. }
  3151. BYTE WildInBuffer() {
  3152. BYTE i;
  3153. for (i=0;i<lpEngPrivate->PrivateArea.Comp_Context.PromptCnt;i++) {
  3154. if(WildChar==lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[i])
  3155. break;
  3156. }
  3157. return(i);
  3158. }
  3159. void ResetCont(HIMCC HmemPri) {
  3160. int i;
  3161. int scs,csce;
  3162. HANDLE hMProcess,hCProcess;
  3163. lpEngPrivate = (PPRIVCONTEXT) ImmLockIMCC(HmemPri);
  3164. if(!lpEngPrivate){
  3165. return ;
  3166. }
  3167. GetMBHead();
  3168. if(lpEngPrivate->PrivateArea.hMapEMB!=NULL) {
  3169. if (EMBM) UnmapViewOfFile(EMBM);
  3170. EMBM =MapViewOfFile(HmemEMB_Table,FILE_MAP_READ|FILE_MAP_WRITE,0,0,0);
  3171. lpEngPrivate->PrivateArea.GlobVac.EMB_Count = *(WORD *)EMBM;
  3172. EMB_Table = (EMB_Head *) (EMBM+2);
  3173. scs = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos - lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos;
  3174. csce = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos - lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos;
  3175. for (i=0;i<lpEngPrivate->PrivateArea.Comp_Context.PromptCnt;i++)
  3176. SearchEMBPos(lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[i],(BYTE)(i+1));
  3177. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos + scs;
  3178. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos + csce;
  3179. } else {
  3180. for (i=0;i<MaxTabNum;i++ ) {
  3181. if(wcscmp(HMapTab[i].MB_Name,lpEngPrivate->MB_Name)==0) {
  3182. break;
  3183. }
  3184. }
  3185. if (HMapTab[i].hEmbFile!=NULL) {
  3186. hCProcess = GetCurrentProcess();
  3187. hMProcess = OpenProcess(STANDARD_RIGHTS_REQUIRED|PROCESS_DUP_HANDLE,FALSE,HMapTab[i].EMB_ID);
  3188. DuplicateHandle(hMProcess,HMapTab[i].hEmbFile,hCProcess,&lpEngPrivate->PrivateArea.hEmbFile,0,FALSE,DUPLICATE_SAME_ACCESS);
  3189. HmemEMB_Table = OpenFileMapping(FILE_MAP_READ|FILE_MAP_WRITE,FALSE,HMapTab[i].EMB_Obj);
  3190. lpEngPrivate->PrivateArea.GlobVac.EMB_Exist = 1;
  3191. if (EMBM) UnmapViewOfFile(EMBM);
  3192. EMBM =MapViewOfFile(HmemEMB_Table,FILE_MAP_READ|FILE_MAP_WRITE,0,0,0);
  3193. lpEngPrivate->PrivateArea.GlobVac.EMB_Count = *(WORD *)EMBM;
  3194. EMB_Table = (EMB_Head *) (EMBM+2);
  3195. lpEngPrivate->PrivateArea.hMapEMB = HmemEMB_Table ;
  3196. scs = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos - lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos;
  3197. csce = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos - lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos;
  3198. for (i=0;i<lpEngPrivate->PrivateArea.Comp_Context.PromptCnt;i++)
  3199. SearchEMBPos(lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[i],(BYTE)(i+1));
  3200. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos + scs;
  3201. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos + csce;
  3202. }
  3203. }
  3204. ReadArea(lpEngPrivate->PrivateArea.Comp_Context.szInBuffer[0]);
  3205. ImmUnlockIMCC(HmemPri);
  3206. }
  3207. UINT ReadArea(TCHAR code) {
  3208. HANDLE hFile;
  3209. TCHAR path_name[MAX_PATH];
  3210. int path_lenth;
  3211. long boffset,offset,area_size;
  3212. DWORD tag,byte_t_read;
  3213. DWORD b_dic_len;
  3214. BYTE code_no;
  3215. PSECURITY_ATTRIBUTES psa;
  3216. BOOL retVal;
  3217. StringCchCopy(path_name, ARRAYSIZE(path_name), sImeG.szIMESystemPath);
  3218. StringCchCat(path_name, ARRAYSIZE(path_name), TEXT("\\"));
  3219. StringCchCat(path_name, ARRAYSIZE(path_name), lpEngPrivate->MB_Name);
  3220. psa = CreateSecurityAttributes();
  3221. hFile = CreateFile(path_name,
  3222. GENERIC_READ,
  3223. FILE_SHARE_READ,
  3224. psa,
  3225. OPEN_EXISTING,
  3226. 0,
  3227. NULL);
  3228. FreeSecurityAttributes(psa);
  3229. if(hFile == INVALID_HANDLE_VALUE)
  3230. return(0);
  3231. SetFilePointer(hFile,28,NULL,FILE_BEGIN);
  3232. for(;;) {
  3233. retVal = ReadFile(hFile,&tag,4,&byte_t_read,NULL);
  3234. if ( retVal == FALSE )
  3235. {
  3236. CloseHandle(hFile);
  3237. return 0;
  3238. }
  3239. if(tag==TAG_BASEDIC)
  3240. break;
  3241. SetFilePointer(hFile,12,NULL,FILE_CURRENT);
  3242. }
  3243. retVal = ReadFile(hFile,&boffset,4,&byte_t_read,NULL);
  3244. if ( retVal == FALSE )
  3245. {
  3246. CloseHandle(hFile);
  3247. return 0;
  3248. }
  3249. retVal = ReadFile(hFile,&b_dic_len,4,&byte_t_read,NULL);
  3250. if ( retVal == FALSE )
  3251. {
  3252. CloseHandle(hFile);
  3253. return 0;
  3254. }
  3255. SetFilePointer(hFile,boffset,NULL,FILE_BEGIN);
  3256. code_no = CodeAIndex[code];
  3257. offset = MB_Head_Table[code_no-1].Q_offset;
  3258. SetFilePointer(hFile,offset,NULL,FILE_CURRENT);
  3259. byte_t_read = 0;
  3260. CloseHandle(hFile);
  3261. if (CodeAIndex[code]<NumCodes) {
  3262. area_size = (MB_Head_Table[code_no].Q_offset - offset)/sizeof(TCHAR);
  3263. if(lpEngPrivate->PrivateArea.hMapMB==NULL) {
  3264. MessageBeep((UINT)-1);
  3265. } else {
  3266. if (g_lptep == NULL)
  3267. g_lptep = MapViewOfFile(lpEngPrivate->PrivateArea.hMapMB,FILE_MAP_READ,0,0,0);
  3268. ZM_Area = (LPTSTR)((LPBYTE)g_lptep+boffset+offset);
  3269. }//return(0);
  3270. } else {
  3271. area_size = (b_dic_len - offset)/sizeof(TCHAR);
  3272. if (g_lptep == NULL)
  3273. g_lptep = MapViewOfFile(lpEngPrivate->PrivateArea.hMapMB,FILE_MAP_READ,0,0,0);
  3274. ZM_Area = (LPTSTR)((LPBYTE)g_lptep+boffset+offset);
  3275. }
  3276. byte_t_read = area_size;
  3277. return(byte_t_read);
  3278. }
  3279. UINT Conversion(HIMCC HmemPri,LPCTSTR lpSrc,UINT uFlag) {
  3280. UINT srclen;
  3281. UINT dstlen;
  3282. UINT byte_t_read;
  3283. BYTE search_suc ;
  3284. UINT wordlen,codelen,len;
  3285. int i,start_pos;
  3286. TCHAR tepbuf[130];
  3287. int areacode;
  3288. TCHAR charbuf[256];
  3289. lpEngPrivate = (PPRIVCONTEXT) ImmLockIMCC(HmemPri);
  3290. if(!lpEngPrivate){
  3291. return (0);
  3292. }
  3293. switch (uFlag) {
  3294. case 0:
  3295. srclen = lstrlen(lpSrc);
  3296. byte_t_read = ReadArea(lpSrc[0]);
  3297. if(byte_t_read==0){
  3298. ImmUnlockIMCC(HmemPri);
  3299. return(0);
  3300. }
  3301. lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos = 0;
  3302. lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos = byte_t_read;
  3303. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = 0;
  3304. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos;
  3305. lpEngPrivate->PrivateArea.GlobVac.Area_V_Lenth = byte_t_read;
  3306. search_suc = MBPositionSearch(lpSrc);
  3307. if(search_suc) {
  3308. lpEngPrivate->PrivateArea.GlobVac.SBufPos = 0;
  3309. i = lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos;
  3310. for(;;) {
  3311. codelen = ZM_Area[i];
  3312. if(wcsncmp(ZM_Area+i+1,lpSrc,codelen)==0) {
  3313. i += (codelen+1);
  3314. wordlen = Scan_Word(i,tepbuf);
  3315. i += (wordlen+1);
  3316. lstrcpyn(ConverList.szSelectBuffer+lpEngPrivate->PrivateArea.GlobVac.SBufPos,tepbuf,wordlen+1);
  3317. ConverList.Candi_Pos[ConverList.Candi_Cnt+1] = (BYTE)(lpEngPrivate->PrivateArea.GlobVac.SBufPos);
  3318. lpEngPrivate->PrivateArea.GlobVac.SBufPos += wordlen;
  3319. ConverList.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT(' ');
  3320. lpEngPrivate->PrivateArea.GlobVac.SBufPos ++;
  3321. ConverList.Candi_Cnt ++;
  3322. } else
  3323. break;
  3324. }
  3325. lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer[lpEngPrivate->PrivateArea.GlobVac.SBufPos] = TEXT('\0');
  3326. dstlen = lstrlen(ConverList.szSelectBuffer);
  3327. len = dstlen;
  3328. } else { // Invaild code
  3329. ClrDoubleBuf();
  3330. len = 0;
  3331. }
  3332. break;
  3333. case 1:
  3334. lstrcpyn(charbuf,lpSrc,2/sizeof(TCHAR)+1);
  3335. charbuf[2/sizeof(TCHAR)] = TEXT('\0');
  3336. areacode = GetFirstCode(charbuf);
  3337. if(areacode==0){
  3338. if(g_lptep)
  3339. {
  3340. UnmapViewOfFile(g_lptep);
  3341. g_lptep = NULL;
  3342. }
  3343. ImmUnlockIMCC(HmemPri);
  3344. return(0);
  3345. }
  3346. byte_t_read = ReadArea((TCHAR)areacode);
  3347. if (byte_t_read == 0 ) {
  3348. if(g_lptep)
  3349. {
  3350. UnmapViewOfFile(g_lptep);
  3351. g_lptep = NULL;
  3352. }
  3353. ImmUnlockIMCC(HmemPri);
  3354. return(0);
  3355. }
  3356. lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos = 0;
  3357. lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos = byte_t_read;;
  3358. srclen = lstrlen(lpSrc);
  3359. i = 0;
  3360. for (;;) {
  3361. codelen = ZM_Area[i];
  3362. start_pos = i+1;
  3363. i += (codelen+1);
  3364. wordlen = Scan_Word(i,charbuf);
  3365. if (!wordlen) // Engine mess up, force exit. hack for #86303
  3366. {
  3367. if(g_lptep)
  3368. {
  3369. UnmapViewOfFile(g_lptep);
  3370. g_lptep = NULL;
  3371. }
  3372. ImmUnlockIMCC(HmemPri);
  3373. return(0);
  3374. }
  3375. i += (wordlen+1);
  3376. if ((wordlen==srclen) && wcsncmp(charbuf,lpSrc,wordlen)==0) {
  3377. lstrcpyn(tepbuf,ZM_Area+start_pos,codelen+1);
  3378. break;
  3379. }
  3380. if (i>=lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos)
  3381. break;
  3382. }
  3383. if (i>lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos) {
  3384. len = 0;
  3385. }else if (i==lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos && wcsncmp(charbuf,lpSrc,wordlen)!=0){
  3386. ConverList.szInBuffer[0] = 0x0;
  3387. len = 0;
  3388. } else {
  3389. lstrcpyn(ConverList.szInBuffer,tepbuf,codelen+1);
  3390. ConverList.szInBuffer[codelen] = 0x0;
  3391. len = codelen;
  3392. }
  3393. break;
  3394. }
  3395. ImmUnlockIMCC(HmemPri);
  3396. return(len);
  3397. }
  3398. BYTE MBPositionSearch(LPCTSTR lpSrc) {
  3399. int srclen;
  3400. int sp;
  3401. BYTE search_fail = 0;
  3402. BYTE code_no,code_no1;
  3403. int wordlen,codelen;
  3404. srclen = lstrlen(lpSrc);
  3405. if (srclen <=2)
  3406. {
  3407. search_fail = 1;
  3408. return 0;
  3409. }
  3410. else if ((BYTE)lpSrc[0]>=0x80 || (BYTE)lpSrc[1]>=0x80)
  3411. {
  3412. search_fail = 1;
  3413. return 0;
  3414. }
  3415. code_no1 = CodeAIndex[lpSrc[0]];
  3416. code_no = CodeAIndex[lpSrc[1]];
  3417. sp = MB_Head_Table[code_no1-1].W_offset[code_no-1]/sizeof(TCHAR);
  3418. for(;;) {
  3419. codelen = ZM_Area[sp];
  3420. if ((codelen == srclen) && (wcsncmp(ZM_Area+sp+1,lpSrc,codelen)==0)) {
  3421. break;
  3422. } else {
  3423. sp += (codelen+1);
  3424. wordlen = ZM_Area[sp];
  3425. sp += (2*wordlen/sizeof(TCHAR)+1);
  3426. }
  3427. if (sp>=lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos)
  3428. break;
  3429. }
  3430. lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos = sp;
  3431. if (lpSrc[1] < TEXT('z'))
  3432. lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos = MB_Head_Table[code_no1-1].W_offset[code_no]/sizeof(TCHAR);
  3433. else
  3434. lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos = lpEngPrivate->PrivateArea.GlobVac.Area_V_Lenth;
  3435. if (lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos==lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos) {
  3436. search_fail = 1;
  3437. } else {
  3438. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCStartPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos;
  3439. lpEngPrivate->PrivateArea.Comp_Proc.dBDicCEndPos = lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos;
  3440. sp = lpEngPrivate->PrivateArea.Comp_Proc.dBDicStartPos;
  3441. for(;;) {
  3442. codelen = ZM_Area[sp];
  3443. if ((codelen==srclen) && (wcsncmp(ZM_Area+sp+1,lpSrc,srclen)==0))
  3444. break;
  3445. else {
  3446. sp += (codelen+1);
  3447. wordlen = ZM_Area[sp];
  3448. sp += (2*wordlen/sizeof(TCHAR)+1);
  3449. }
  3450. if(sp >= lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos)
  3451. break;
  3452. }
  3453. if (sp == lpEngPrivate->PrivateArea.Comp_Proc.dBDicEndPos) {// no this code_word
  3454. search_fail = 1;
  3455. return 0;
  3456. }
  3457. }
  3458. return (1);
  3459. }
  3460. int GetFirstCode(LPTSTR lpSrc) {
  3461. HANDLE hFile;
  3462. TCHAR path_name[MAX_PATH];
  3463. long offset;
  3464. DWORD tag,byte_t_read;
  3465. DWORD char_no;
  3466. TCHAR areacode;
  3467. PSECURITY_ATTRIBUTES psa;
  3468. BOOL retVal;
  3469. StringCchCopy(path_name, ARRAYSIZE(path_name), sImeG.szIMESystemPath);
  3470. StringCchCat(path_name, ARRAYSIZE(path_name), TEXT("\\"));
  3471. StringCchCat(path_name, ARRAYSIZE(path_name), lpEngPrivate->MB_Name);
  3472. psa = CreateSecurityAttributes();
  3473. hFile = CreateFile(path_name,
  3474. GENERIC_READ,
  3475. FILE_SHARE_READ,
  3476. psa,
  3477. OPEN_EXISTING,
  3478. 0,
  3479. NULL);
  3480. FreeSecurityAttributes(psa);
  3481. if(hFile == INVALID_HANDLE_VALUE)
  3482. return(0);
  3483. SetFilePointer(hFile,28,NULL,FILE_BEGIN);
  3484. for(;;) {
  3485. byte_t_read = 0;
  3486. retVal = ReadFile(hFile,&tag,4,&byte_t_read,NULL);
  3487. if ( retVal == FALSE )
  3488. {
  3489. CloseHandle(hFile);
  3490. return 0;
  3491. }
  3492. if(tag==TAG_INTERCODE)
  3493. break;
  3494. SetFilePointer(hFile,12,NULL,FILE_CURRENT);
  3495. }
  3496. retVal = ReadFile(hFile,&offset,4,&byte_t_read,NULL);
  3497. if ( retVal == FALSE )
  3498. {
  3499. CloseHandle(hFile);
  3500. return 0;
  3501. }
  3502. char_no = GetNumber(hFile,offset,lpSrc) ;
  3503. SetFilePointer(hFile,28,NULL,FILE_BEGIN);
  3504. if ((tag & 0x00000003) != FFLG_RULE) {
  3505. for(;;) {
  3506. byte_t_read = 0;
  3507. retVal = ReadFile(hFile,&tag,4,&byte_t_read,NULL);
  3508. if ( retVal == FALSE )
  3509. {
  3510. CloseHandle(hFile);
  3511. return 0;
  3512. }
  3513. if(tag==TAG_CRTWORDCODE)
  3514. break;
  3515. SetFilePointer(hFile,12,NULL,FILE_CURRENT);
  3516. }
  3517. } else {
  3518. for(;;) {
  3519. byte_t_read = 0;
  3520. retVal = ReadFile(hFile,&tag,4,&byte_t_read,NULL);
  3521. if ( retVal == FALSE )
  3522. {
  3523. CloseHandle(hFile);
  3524. return 0;
  3525. }
  3526. if(tag==TAG_RECONVINDEX)
  3527. break;
  3528. SetFilePointer(hFile,12,NULL,FILE_CURRENT);
  3529. }
  3530. }
  3531. retVal = ReadFile(hFile,&offset,4,&byte_t_read,NULL);
  3532. if ( retVal == FALSE )
  3533. {
  3534. CloseHandle(hFile);
  3535. return 0;
  3536. }
  3537. SetFilePointer(hFile,offset,NULL,FILE_BEGIN);
  3538. SetFilePointer(hFile,char_no*MaxCodes*sizeof(TCHAR),NULL,FILE_CURRENT);
  3539. retVal = ReadFile(hFile,&areacode,1*sizeof(TCHAR),&byte_t_read,NULL);
  3540. if ( retVal == FALSE )
  3541. {
  3542. CloseHandle(hFile);
  3543. return 0;
  3544. }
  3545. CloseHandle(hFile);
  3546. return(areacode);
  3547. }
  3548. DWORD GetNumber(HANDLE hFile,DWORD dwOffset,LPTSTR szDBCS) {
  3549. DWORD dwNumArea,dwNumWord,dwBytes;
  3550. DWORD i;
  3551. DWORD RetNo = 0;
  3552. HANDLE hInterCode;
  3553. LPINTERCODEAREA lpInterCode;
  3554. BOOL retVal;
  3555. SetFilePointer(hFile,dwOffset,0,FILE_BEGIN);
  3556. retVal = ReadFile(hFile,&dwNumWord,4,&dwBytes,NULL);
  3557. if ( retVal == FALSE )
  3558. return 0;
  3559. retVal = ReadFile(hFile,&dwNumArea,4,&dwBytes,NULL);
  3560. if ( retVal == FALSE )
  3561. return 0;
  3562. hInterCode = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,
  3563. dwNumArea*sizeof(INTERCODEAREA));
  3564. if(!hInterCode)
  3565. return (0);
  3566. lpInterCode = GlobalLock(hInterCode);
  3567. if(!lpInterCode){
  3568. GlobalFree(hInterCode);
  3569. return(0);
  3570. }
  3571. retVal = ReadFile(hFile,lpInterCode,dwNumArea*sizeof(INTERCODEAREA),&dwBytes,NULL);
  3572. if ( retVal )
  3573. {
  3574. for(i=dwNumArea-1; (long)i>=0; i--) {
  3575. #ifdef UNICODE
  3576. dwBytes = szDBCS[0];
  3577. #else
  3578. dwBytes = 256*(BYTE)szDBCS[0]+(BYTE)szDBCS[1];
  3579. #endif
  3580. if(dwBytes >= lpInterCode[i].StartInterCode && dwBytes <= lpInterCode[i].EndInterCode) {
  3581. RetNo = lpInterCode[i].PreCount+dwBytes-lpInterCode[i].StartInterCode;
  3582. break;
  3583. }
  3584. }
  3585. }
  3586. GlobalUnlock(hInterCode);
  3587. GlobalFree(hInterCode);
  3588. return (RetNo);
  3589. }
  3590. BOOL UnRegisterWord(HIMCC HmemPri,LPCTSTR lpReading,LPCTSTR lpString) {
  3591. int i;
  3592. int succ = 0;
  3593. lpEngPrivate = (PPRIVCONTEXT) ImmLockIMCC(HmemPri);
  3594. if(!lpEngPrivate){
  3595. return FALSE;
  3596. }
  3597. for (i=0;i<lpEngPrivate->PrivateArea.GlobVac.EMB_Count;i++ ) {
  3598. if((wcsncmp(EMB_Table[i].W_Code,lpReading,MAXCODE)==0) && (wcsncmp(EMB_Table[i].C_Char,lpString,MAXINPUTWORD)==0)) {
  3599. DelSelCU(HmemPri,i);
  3600. succ = 1;
  3601. }
  3602. if(succ==1 && wcsncmp(EMB_Table[i].W_Code,lpReading,MAXCODE)!=0)
  3603. break;
  3604. }
  3605. ImmUnlockIMCC(HmemPri);
  3606. return(succ);
  3607. }
  3608. UINT EnumRegisterWord(HIMCC HmemPri,LPCTSTR lpReading,LPCTSTR lpString,LPVOID lpData) {
  3609. UINT count;
  3610. int i,pos,wordlen;
  3611. TCHAR *lptep;
  3612. lpEngPrivate = (PPRIVCONTEXT) ImmLockIMCC(HmemPri);
  3613. if(!lpEngPrivate){
  3614. return (0);
  3615. }
  3616. lptep = (TCHAR *) lpData;
  3617. if((lpReading==NULL) && (lpString==NULL)) {
  3618. lpData = EMB_Table;
  3619. count = lpEngPrivate->PrivateArea.GlobVac.EMB_Count;
  3620. } else if(lpReading==NULL) {
  3621. pos = 0;
  3622. count = 0;
  3623. for(i=0; i<lpEngPrivate->PrivateArea.GlobVac.EMB_Count; i++) {
  3624. if (wcsncmp(EMB_Table[i].C_Char,lpString,MAXINPUTWORD)==0) {
  3625. wordlen = Inputcodelen(EMB_Table[i].W_Code);
  3626. lstrcpyn(lptep+pos,EMB_Table[i].W_Code,wordlen+1);
  3627. pos += wordlen;
  3628. lptep[pos] = 0x20;
  3629. pos ++;
  3630. count ++;
  3631. }
  3632. }
  3633. } else if(lpString==NULL) {
  3634. if(EMBPositionSearch(lpReading)) {
  3635. pos = 0;
  3636. for(i=lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos; i<lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos; i++) {
  3637. wordlen = DBCSCharlen(EMB_Table[i].C_Char);
  3638. lstrcpyn(lptep+pos,EMB_Table[i].C_Char,wordlen+1);
  3639. pos += wordlen;
  3640. lptep[pos] = 0x20;
  3641. pos ++;
  3642. }
  3643. count = lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos - lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos;
  3644. } else {
  3645. count = 0;
  3646. }
  3647. } else {
  3648. if(EMBPositionSearch(lpReading)) {
  3649. pos = 0;
  3650. count = 0;
  3651. for(i=lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos; i<lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos; i++) {
  3652. if (wcsncmp(EMB_Table[i].C_Char,lpString,MAXINPUTWORD)==0) {
  3653. wordlen = DBCSCharlen(EMB_Table[i].C_Char);
  3654. lstrcpyn(lptep+pos,EMB_Table[i].C_Char,wordlen+1);
  3655. pos += wordlen;
  3656. lptep[pos] = 0x20;
  3657. pos ++;
  3658. count ++;
  3659. }
  3660. }
  3661. } else {
  3662. count = 0;
  3663. }
  3664. }
  3665. ImmUnlockIMCC(HmemPri);
  3666. return(count);
  3667. }
  3668. BYTE EMBPositionSearch(LPCTSTR lpSrc) {
  3669. int i;
  3670. int srclen;
  3671. srclen = lstrlen(lpSrc);
  3672. for (i=0; i<lpEngPrivate->PrivateArea.GlobVac.EMB_Count; i++) {
  3673. if ((Inputcodelen(EMB_Table[i].W_Code)==srclen) && (wcsncmp(EMB_Table[i].W_Code,lpSrc,srclen)==0))
  3674. break;
  3675. }
  3676. if(i==lpEngPrivate->PrivateArea.GlobVac.EMB_Count)
  3677. return (0);
  3678. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQStartPos = i;
  3679. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCStartPos = i;
  3680. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQCEndPos = i;
  3681. for (i; i<lpEngPrivate->PrivateArea.GlobVac.EMB_Count; i++) {
  3682. if ((Inputcodelen(EMB_Table[i].W_Code)!=srclen) || (wcsncmp(EMB_Table[i].W_Code,lpSrc,srclen)!=0))
  3683. break;
  3684. }
  3685. lpEngPrivate->PrivateArea.Comp_Proc.dwUDicQEndPos = i;
  3686. return (1);
  3687. }
  3688. long GetLengthofBuf() {
  3689. SIZE size;
  3690. int ncount;
  3691. BOOL succ;
  3692. TCHAR tepbuf[3000];
  3693. long ret_len ;
  3694. HDC hDC;
  3695. HGDIOBJ hOldFont;
  3696. LOGFONT lfFont;
  3697. hDC = GetDC(NULL);
  3698. hOldFont = GetCurrentObject(hDC, OBJ_FONT);
  3699. GetObject(hOldFont, sizeof(LOGFONT), &lfFont);
  3700. ZeroMemory(&lfFont, sizeof(lfFont));
  3701. lfFont.lfHeight = -MulDiv(12, GetDeviceCaps(hDC, LOGPIXELSY), 72);
  3702. lfFont.lfCharSet = NATIVE_CHARSET;
  3703. lstrcpy(lfFont.lfFaceName, TEXT("Simsun"));
  3704. SelectObject(hDC, CreateFontIndirect(&lfFont));
  3705. ncount = lpEngPrivate->PrivateArea.GlobVac.SBufPos;
  3706. lstrcpyn(tepbuf,lpEngPrivate->PrivateArea.Comp_Context.szSelectBuffer,ncount+1);
  3707. tepbuf[ncount] = TEXT('\0');
  3708. succ = GetTextExtentPoint(hDC,tepbuf,ncount,(LPSIZE)&size);
  3709. if(!succ){
  3710. memset(&size, 0, sizeof(SIZE));
  3711. }
  3712. ret_len = size.cx;
  3713. succ = GetTextExtentPoint(hDC,TEXT("9:"),2,(LPSIZE)&size);
  3714. if(!succ){
  3715. memset(&size, 0, sizeof(SIZE));
  3716. }
  3717. ret_len += (size.cx*lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt );
  3718. DeleteObject(SelectObject(hDC, hOldFont));
  3719. ReleaseDC(NULL, hDC);
  3720. return(ret_len);
  3721. }
  3722. long GetLengthTepBuf(LPTSTR lpstring) {
  3723. SIZE size;
  3724. int ncount;
  3725. BOOL succ;
  3726. HDC hDC;
  3727. HGDIOBJ hOldFont;
  3728. LOGFONT lfFont;
  3729. hDC = GetDC(NULL);
  3730. hOldFont = GetCurrentObject(hDC, OBJ_FONT);
  3731. GetObject(hOldFont, sizeof(LOGFONT), &lfFont);
  3732. ZeroMemory(&lfFont, sizeof(lfFont));
  3733. lfFont.lfHeight = -MulDiv(12, GetDeviceCaps(hDC, LOGPIXELSY), 72);
  3734. lfFont.lfCharSet = NATIVE_CHARSET;
  3735. lstrcpy(lfFont.lfFaceName, TEXT("Simsun"));
  3736. SelectObject(hDC, CreateFontIndirect(&lfFont));
  3737. ncount = lstrlen(lpstring);
  3738. succ = GetTextExtentPoint(hDC,lpstring,ncount,(LPSIZE)&size);
  3739. if(!succ){
  3740. memset(&size, 0, sizeof(SIZE));
  3741. }
  3742. DeleteObject(SelectObject(hDC, hOldFont));
  3743. ReleaseDC(NULL, hDC);
  3744. if(lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt<1 )
  3745. return (0);
  3746. else
  3747. return(size.cx);
  3748. }
  3749. long GetLengthCCharBuf(LPTSTR lpstring) {
  3750. TCHAR CCharStr[41];
  3751. SIZE size;
  3752. int ncount;
  3753. BOOL succ;
  3754. HDC hDC;
  3755. HGDIOBJ hOldFont;
  3756. LOGFONT lfFont;
  3757. hDC = GetDC(NULL);
  3758. hOldFont = GetCurrentObject(hDC, OBJ_FONT);
  3759. GetObject(hOldFont, sizeof(LOGFONT), &lfFont);
  3760. ZeroMemory(&lfFont, sizeof(lfFont));
  3761. lfFont.lfHeight = -MulDiv(12, GetDeviceCaps(hDC, LOGPIXELSY), 72);
  3762. lfFont.lfCharSet = NATIVE_CHARSET;
  3763. lstrcpy(lfFont.lfFaceName, TEXT("Simsun"));
  3764. SelectObject(hDC, CreateFontIndirect(&lfFont));
  3765. lstrcpyn(CCharStr, lpstring, MAXINPUTWORD+1);
  3766. CCharStr[MAXINPUTWORD] = TEXT('\0');
  3767. ncount = lstrlen(CCharStr);
  3768. succ = GetTextExtentPoint(hDC,CCharStr,ncount,(LPSIZE)&size);
  3769. if(!succ){
  3770. memset(&size, 0, sizeof(SIZE));
  3771. }
  3772. DeleteObject(SelectObject(hDC, hOldFont));
  3773. ReleaseDC(NULL, hDC);
  3774. if(lpEngPrivate->PrivateArea.Comp_Context.Candi_Cnt<1 )
  3775. return (0);
  3776. else
  3777. return(size.cx);
  3778. }
  3779. int Inputcodelen(LPCTSTR string) {
  3780. TCHAR str[13];
  3781. lstrcpyn(str, string, MAXCODE+1);
  3782. str[MAXCODE] = TEXT('\0');
  3783. return(lstrlen(str));
  3784. }
  3785. int DBCSCharlen(LPCTSTR string) {
  3786. TCHAR str[41];
  3787. lstrcpyn(str, string, MAXINPUTWORD+1);
  3788. str[MAXINPUTWORD] = TEXT('\0');
  3789. return(lstrlen(str));
  3790. }
  3791. LPTSTR _tcschr(LPTSTR string, TCHAR c)
  3792. {
  3793. #ifdef UNICODE
  3794. return (wcschr(string, c));
  3795. #else
  3796. return (strchr(string, c));
  3797. #endif
  3798. }
  3799. //Backward search specific charactor.
  3800. LPTSTR _rtcschr(LPTSTR string, TCHAR c)
  3801. {
  3802. int i,ilen = lstrlen(string);
  3803. if (ilen)
  3804. for (i=ilen;i>=0;i--)
  3805. {
  3806. if (string[i] == c)
  3807. return (string+i);
  3808. }
  3809. return NULL;
  3810. }
  3811. int IsGBK(LPTSTR lpStr)
  3812. {
  3813. int iRet = FALSE;
  3814. char szGBK[80];
  3815. #ifdef UNICODE
  3816. WideCharToMultiByte(NATIVE_ANSI_CP, WC_COMPOSITECHECK, lpStr, -1, szGBK,
  3817. sizeof(szGBK), NULL, NULL);
  3818. #else
  3819. StringCchCopy(szGBK, ARRAYSIZE(szGBK), lpStr);
  3820. #endif
  3821. if((unsigned char)szGBK[0]<0xa1 || (unsigned char)szGBK[1] < 0xa1) //out of GB range
  3822. iRet = TRUE;
  3823. return iRet;
  3824. }