Source code of Windows XP (NT5)
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.

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