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

5762 lines
146 KiB

  1. /*************************************************
  2. * abc95wp.c *
  3. * *
  4. * Copyright (C) 1995-1999 Microsoft Inc. *
  5. * *
  6. *************************************************/
  7. #include "windows.h"
  8. #include "winuser.h"
  9. #include "immdev.h"
  10. #include "abc95def.h"
  11. #include "abcbx.h"
  12. struct INPT_BF kbf={40,0,{0}};
  13. INT_PTR WINAPI OpenDlg(HWND,UINT,WPARAM,LPARAM);
  14. int word_select_bx(int input_char);
  15. int word_long;
  16. int unit_length=2; /* single word */
  17. int disp_tail=0;
  18. int disp_head=0;
  19. int group_no=24;
  20. int current_no;
  21. /******************************************************************
  22. /* CharProc(ImeChar,wParam,lParam,hIMC,lpIMC,lpImcP) *
  23. /*****************************************************************/
  24. extern HWND hCrtDlg;
  25. int WINAPI CharProc(ImeChar,wParam,lParam,hIMC,lpIMC,lpImcP)
  26. WORD ImeChar;
  27. WPARAM wParam;
  28. LPARAM lParam;
  29. HIMC hIMC;
  30. LPINPUTCONTEXT lpIMC;
  31. LPPRIVCONTEXT lpImcP;
  32. {
  33. int x;
  34. ghIMC=hIMC;
  35. glpIMCP=lpImcP;
  36. glpIMC=lpIMC;
  37. TypeOfOutMsg = 0;
  38. waitzl_flag = 0; //waitzl 3
  39. if (cap_mode){
  40. if(ImeChar<0x8000){ //for mouse message pass
  41. send_one_char(ImeChar/*wParam*/); // changed 94/8/6
  42. return(0);
  43. }
  44. }
  45. if(lpIMC->fdwConversion&IME_CMODE_NATIVE){
  46. switch(kb_mode){
  47. case CIN_STD: //stand change
  48. if (V_Flag)
  49. v_proc(ImeChar); // V fuction
  50. else {
  51. if (sImeG.cbx_flag==1) {
  52. if (bx_allow) {
  53. if (BX_MODE(ImeChar,wParam))
  54. return(0);
  55. }
  56. } //if (sImeG.cbx_flag)
  57. STD_MODE(ImeChar);
  58. }
  59. break;
  60. case CIN_SDA: //double hit inputing
  61. for (x=0; x<(sizeof sda_trans)/2; x++) //Note sizeof!! 1992 2
  62. sda_trans[x]=0; //clear the transport buffer
  63. if(((!step_mode)||(step_mode==RESELECT))&&((ImeChar == 0x60)||(ImeChar == 0x27)))
  64. return (STD_MODE(ImeChar));
  65. if (sImeG.cbx_flag==1) {
  66. if (bx_allow){
  67. if (BX_MODE(ImeChar,wParam))
  68. return(0);
  69. } //if (bx_allow)
  70. } //if (sImeG.cbx_flag)
  71. if ((step_mode==ONINPUT)&&(I_U_Flag==1)){
  72. STD_MODE(ImeChar);
  73. return(0);
  74. }
  75. if ( if_zimu_or_not((BYTE)ImeChar)/*||(wParam == 0x60)*/||(wParam == 0x27) )
  76. {
  77. if ((step_mode==START)||/*(Return==NULL)||*/(step_mode==RESELECT))
  78. {
  79. if (((wParam&0xdf)=='U')||((wParam&0xdf)=='I'))
  80. {
  81. I_U_Flag=1;
  82. STD_MODE(ImeChar);
  83. return(0);
  84. } else {
  85. I_U_Flag=0;
  86. }//else...
  87. }//if (step_mode....
  88. if (!Sd_Open_flag){
  89. if(KeyBoardState){
  90. SdaPromptOpen=1;
  91. tran_data(
  92. 0,
  93. ghIMC,
  94. Sd_Open_flag);
  95. }//if Key
  96. }//if (Sd_Open_flag)
  97. }//if (if_zimu_...
  98. if ((wParam==VK_BACK)&&(step_mode==ONINPUT)
  99. &&(Return==NULL)&&(!Sd_Open_flag)){
  100. if(KeyBoardState){
  101. SdaPromptOpen=1;
  102. tran_data(
  103. 0,
  104. ghIMC,
  105. Sd_Open_flag);
  106. }
  107. }//if (wParam)
  108. sda_proc(ImeChar, (LPWORD)sda_trans, step_mode, ghIMC); //change the key into standed
  109. if (sda_trans[0]==0xff) //change error or input more than 40 chars
  110. break;
  111. if (sda_trans[0]==0xf0){ //if free the dialog?
  112. if(KeyBoardState){
  113. tran_data(
  114. 2,
  115. ghIMC,
  116. Sd_Open_flag);
  117. }//if key
  118. SdaPromptOpen=0;
  119. sda_trans[0]=sda_trans[1];
  120. sda_trans[1]=0;
  121. }
  122. x=0; //chinese spelling
  123. while (sda_trans[x]){
  124. if (wait_flag && (sda_trans[x]=='h')) //waitzl 4
  125. waitzl_flag = 1;
  126. STD_MODE(sda_trans[x++]);
  127. }
  128. break;
  129. }
  130. }else
  131. send_one_char(ImeChar/*wParam*/);
  132. return (0);
  133. }
  134. /****************************************************************
  135. v_proc(): produce the V fuction
  136. *****************************************************************/
  137. int WINAPI v_proc(input_char)
  138. WORD input_char;
  139. {
  140. int i, n;
  141. n=0;
  142. if (V_Flag==1) {
  143. switch (input_char) {
  144. case '0':
  145. case VK_BACK:
  146. cls_inpt_bf(0);
  147. step_mode = START;
  148. V_Flag = 0;
  149. return(1);
  150. }
  151. }
  152. if ((if_number_or_not((BYTE)input_char)) && (V_Flag!=2)){
  153. input_char &= 0x000f; //get the QUMA
  154. for (i=1; i<=94; i++){ //get WEIMA
  155. if (input_char==2){
  156. if (i==1) i=17;
  157. if (i==67) i=69;
  158. if (i==79) i=81;
  159. }
  160. out_svw[n++]=input_char+0xa0;
  161. out_svw[n++]=i+0xa0;
  162. }
  163. group_no=94;
  164. if (input_char==2) group_no=72;
  165. unit_length=2;
  166. current_no=0;
  167. disp_tail=0;
  168. V_Flag=0;
  169. msg_type=2; //94/8/22
  170. fmt_transfer();
  171. SetToIMC(ghIMC,(LPSTR)&out_svw,(WORD)group_no,(WORD)(unit_length+0x1000));
  172. move_result();
  173. prompt_disp();
  174. word_back_flag=0x55; //93,9,4
  175. step_mode=SELECT;
  176. } //if (if_number_or_not)
  177. else {
  178. V_Flag=2;
  179. step_mode=ONINPUT;
  180. STD_MODE(input_char);
  181. }
  182. return (1);
  183. }
  184. int ReDrawSdaKB(hIMC, KbIndex, ShowOp)
  185. HIMC hIMC;
  186. DWORD KbIndex;
  187. DWORD ShowOp;
  188. {
  189. //return 0;
  190. if (KbIndex) // if not PC KB
  191. return 0;
  192. if (kb_mode != CIN_SDA)
  193. return 0; // if not SDA mode
  194. if (ShowOp==SW_HIDE)
  195. return 0; // if SW_SHOW....
  196. if (SdaInst){
  197. tran_data(
  198. 0x5678, //Return,
  199. ghIMC,//hWnd,
  200. Sd_Open_flag);
  201. return 1;}
  202. return 0;
  203. }
  204. void WINAPI DispModeEx()
  205. {
  206. cls_inpt_bf(0);
  207. step_mode=START;
  208. }
  209. /****************************************************************
  210. FUNCTION: disp_mode(hW)
  211. PORPUSE: display the mode item at the input window.
  212. *****************************************************************/
  213. void WINAPI DispMode(HIMC hIMC)
  214. {
  215. LPINPUTCONTEXT lpIMC;
  216. LPPRIVCONTEXT lpImcP;
  217. UINT fdwConversion;
  218. if (!hIMC)
  219. return;
  220. lpIMC =(LPINPUTCONTEXT)ImmLockIMC(hIMC);
  221. if (!lpIMC)
  222. return;
  223. lpImcP =(LPPRIVCONTEXT)ImmLockIMCC(lpIMC->hPrivate);
  224. if (!lpImcP)
  225. return;
  226. DispModeEx(); //zl#3(hW);
  227. if (SdaInst&&(kb_mode!=CIN_SDA)){
  228. Sd_Open_flag=0;
  229. SdaPromptOpen=0;
  230. SdaInst=0;
  231. }
  232. if ((kb_mode==CIN_SDA)&&(!SdaInst)) {
  233. SdaInst = 1; // The ABCSDA.DLL is Load In.
  234. }
  235. ImmUnlockIMCC(lpIMC->hPrivate);
  236. ImmUnlockIMC(hIMC);
  237. }
  238. void WINAPI DispSpecChar(c,n)
  239. int c,n;
  240. {
  241. int i;
  242. for (i=now_cs;i<n+now_cs;i++)
  243. InputBuffer[i]=(BYTE)c;
  244. ImeSetCompositionString(ghIMC,SCS_SETSTR,NULL,0,
  245. &InputBuffer,now_cs+i);
  246. }
  247. //////////////////////////////////////////////////////////////////////////
  248. void WINAPI show_char(string,count)
  249. unsigned char *string;
  250. int count;
  251. {
  252. int i;
  253. BOOL fdwImeMsgKeep;
  254. if(count==0) {
  255. ImeSetCompositionString(ghIMC,SCS_SETSTR,NULL,0,
  256. &InputBuffer,now_cs);
  257. return ; }
  258. for(i=0; i<count; i++)
  259. InputBuffer[now_cs+i]=string[i];
  260. now_cs+=count;
  261. if (!(wait_flag | waitzl_flag )){ //waitzl 5
  262. ImeSetCompositionString(ghIMC,SCS_SETSTR,NULL,0,
  263. &InputBuffer,now_cs);
  264. }
  265. }
  266. /******************************************************
  267. disp_jiyi(): display the word "jiyi" in the windows
  268. *******************************************************/
  269. void WINAPI disp_jiyi(xxx)
  270. HANDLE xxx;
  271. {
  272. }
  273. /*********************************************************************
  274. PROMPT_DISP(): display the result of changing.
  275. **********************************************************************/
  276. void WINAPI prompt_disp()
  277. {
  278. int i;
  279. pass_word=0;
  280. disp_head=disp_tail;
  281. n=0;
  282. for(i=0; i<now.fmt_group; i++){
  283. disp_tail++;
  284. if (disp_tail>=group_no){
  285. pass_word=1;
  286. if (disp_head==0)
  287. pass_word=2;
  288. break;}
  289. }//for (i=...
  290. if (pass_word<1){
  291. pass_word=3;
  292. if (disp_head==0)
  293. pass_word=4;
  294. }
  295. SetToIMC(ghIMC,NULL,(WORD)pass_word,(WORD)disp_head);
  296. }
  297. /****************************************************
  298. cls_prompt
  299. *****************************************************/
  300. int WINAPI cls_prompt()
  301. {
  302. int i;
  303. for (i=0;i<sizeof InputBuffer;i++) InputBuffer[i]=0x20; //Clear the display buffer.
  304. now_cs = 0;
  305. //DispSpecChar((BYTE)0x20,sizeof InputBuffer);
  306. cs_p(0);
  307. SetCloseCompWinMsg(0);
  308. cls_prompt_only();
  309. return 0;
  310. }
  311. int WINAPI cls_prompt_only(){
  312. int i;
  313. LPINPUTCONTEXT lpIMC;
  314. LPPRIVCONTEXT lpImcP;
  315. if (!ghIMC) return (0); // The IMC must be a valid one.
  316. lpIMC = (LPINPUTCONTEXT)ImmLockIMC(ghIMC);
  317. if(!lpIMC) return 0;
  318. lpImcP = (LPPRIVCONTEXT)ImmLockIMCC(lpIMC->hPrivate);
  319. if ( lpImcP != NULL )
  320. lpImcP->fdwImeMsg = (lpImcP->fdwImeMsg | MSG_CLOSE_CANDIDATE) &
  321. ~(MSG_OPEN_CANDIDATE);
  322. ImmUnlockIMCC(lpIMC->hPrivate);
  323. ImmUnlockIMC(ghIMC);
  324. return 0;
  325. }
  326. int WINAPI SetCloseCompWinMsg(int ClsFlag)
  327. {
  328. LPINPUTCONTEXT lpIMC;
  329. LPPRIVCONTEXT lpImcP;
  330. if (!ghIMC) return (0); // The IMC must be a valid one.
  331. lpIMC = (LPINPUTCONTEXT)ImmLockIMC(ghIMC);
  332. if(!lpIMC) return 0;
  333. lpImcP = (LPPRIVCONTEXT)ImmLockIMCC(lpIMC->hPrivate);
  334. if (!ClsFlag )
  335. {
  336. if ( lpImcP != NULL )
  337. lpImcP->fdwImeMsg = (lpImcP->fdwImeMsg | MSG_END_COMPOSITION ) &
  338. ~(MSG_COMPOSITION) ;
  339. }
  340. ImmUnlockIMCC(lpIMC->hPrivate);
  341. ImmUnlockIMC(ghIMC);
  342. return 0;
  343. }
  344. void WINAPI ABCstrnset(bufferd,value,n)
  345. LPSTR bufferd;
  346. BYTE value;
  347. {
  348. int i;
  349. for (i=0; i<n; i++) bufferd[i]=value;
  350. return;
  351. }
  352. LPSTR WINAPI ABCstrstr(str1,str2)
  353. LPSTR str1,str2;
  354. {
  355. int i,m,n,j,pos;
  356. m=lstrlen(str1);
  357. n=lstrlen(str2);
  358. if(!n) return str1;
  359. pos=0xffff0;
  360. for(i=0;i<m-n; i++){
  361. pos=i;
  362. for(j=0;j<n;j++) {
  363. if (str1[i+j]!=str2[j])
  364. { pos=0xffff0;break;}}
  365. if (pos!=0xffff0) break;
  366. }
  367. if (pos==0xffff0) return NULL;
  368. return str1+pos;
  369. }
  370. /*****************************************************
  371. back_a_space(x): do a BACKSPACE command
  372. ******************************************************/
  373. int WINAPI back_a_space(x)
  374. int x;
  375. {
  376. if (x<=0){
  377. x=0;
  378. MessageBeep(0);}
  379. else{
  380. x--;
  381. InputBuffer[x]=' ';
  382. cs_p(x);
  383. }
  384. return(x);
  385. }
  386. /******************************************************
  387. cs_p
  388. *******************************************************/
  389. int WINAPI cs_p(x)
  390. int x;
  391. {
  392. int xx,yy,zz,kk,i;
  393. now_cs=x;
  394. cur_hibit=1;
  395. hDC=GetDC(hInputWnd);
  396. kk=(WORD)(GetText32(hDC, InputBuffer, x))
  397. +CUR_START_X;
  398. cur_start_ps=(WORD)(GetText32(hDC, InputBuffer,cur_start_count ))
  399. +CUR_START_X;
  400. zz=kk-cur_start_ps;
  401. if (x<cur_start_count){
  402. cur_start_count=(WORD)x;
  403. now_cs_dot=CUR_START_X;
  404. ReleaseDC(hInputWnd,hDC);
  405. UpdateCompCur(hInputWnd);
  406. cur_hibit=0;
  407. return 0;}
  408. if (zz>=(CUR_START_X+(lpImeL->rcCompText.right-4))){
  409. xx=CUR_START_X;
  410. for (i =now_cs; i>0; i--)
  411. { yy=GetText32(hDC, &InputBuffer[i-1], 1);
  412. if ( (xx+yy) >= (CUR_START_X+(lpImeL->rcCompText.right-4)))
  413. break;
  414. else xx+=yy;
  415. }
  416. cur_start_count=(WORD)i;
  417. // Adgust for Chines Word Display
  418. kk=0;
  419. for (i=0; i<cur_start_count; i++){
  420. if (InputBuffer[i]>0xa0){
  421. kk++;
  422. kk&=1;
  423. } else
  424. kk=0;}
  425. if (kk){
  426. xx=xx- GetText32(hDC, &InputBuffer[cur_start_count], 1);
  427. cur_start_count++;
  428. }
  429. cur_start_ps=(WORD)GetText32(hDC, &InputBuffer[0], i);
  430. now_cs_dot=xx;
  431. ReleaseDC(hInputWnd,hDC);
  432. UpdateCompCur(hInputWnd);
  433. cur_hibit=0;
  434. return 0;
  435. }
  436. cur_hibit=0;
  437. ReleaseDC(hInputWnd,hDC);
  438. if (zz<(CUR_START_X+(lpImeL->rcCompText.right-4))){
  439. now_cs_dot=kk-cur_start_ps;
  440. DrawInputCur();
  441. }
  442. return 0;
  443. }
  444. /********************************************************************
  445. Function:DrawInputCur
  446. ********************************************************************/
  447. void WINAPI DrawInputCur()
  448. {
  449. HDC OldDC;
  450. if (!hInputWnd) return;
  451. if ((WORD)now_cs_dot!=old_curx)
  452. {
  453. if (cur_flag)
  454. {
  455. hDC=GetDC(hInputWnd);
  456. OldDC=SelectObject(hMemoryDC,cur_h);
  457. BitBlt(hDC,old_curx+lpImeL->rcCompText.left,
  458. lpImeL->rcCompText.top+3,
  459. CUR_W,CUR_H,hMemoryDC,0,0,SRCINVERT);
  460. SelectObject(hMemoryDC,OldDC);
  461. ReleaseDC(hInputWnd,hDC);
  462. cur_flag=!cur_flag;
  463. }
  464. old_curx=(WORD)now_cs_dot;
  465. }
  466. hDC=GetDC(hInputWnd);
  467. OldDC=SelectObject(hMemoryDC,cur_h);
  468. BitBlt(hDC,now_cs_dot+lpImeL->rcCompText.left,
  469. lpImeL->rcCompText.top+3,
  470. CUR_W,CUR_H,hMemoryDC,0,0,SRCINVERT);
  471. SelectObject(hMemoryDC,OldDC);
  472. ReleaseDC(hInputWnd,hDC);
  473. cur_flag=!cur_flag;
  474. return;
  475. }//#0
  476. /************************************************************
  477. UpdateUser(): if the user.rem has changed, clear the tmmr.rem_area
  478. and read the user.rem's index once again.
  479. *************************************************************/
  480. void WINAPI UpdateUser()
  481. {
  482. // 94/4/16 HANDLE hd;
  483. int hd;
  484. int i;
  485. WORD op_count;
  486. OFSTRUCT ofs;
  487. if (UpdateFlag) { //increase the user.rem
  488. for (i=0; i<0x200; i++) //1993.3
  489. tmmr.rem_area[i] = 0;
  490. last_item_name=0; //clear the date in memory flag
  491. UpdateFlag = 0;
  492. hd = OpenFile (user_lib, &ofs, OF_READ); //1993.4.15
  493. if (hd==-1)
  494. err_exit_proc(jiyi_wenjian_cuo);
  495. _llseek(hd,0xa000l,0);
  496. op_count=(WORD)_lread(hd,&kzk_ndx,NDX_REAL_LENGTH);
  497. if (op_count!=NDX_REAL_LENGTH)
  498. err_exit_proc(jiyi_wenjian_cuo);
  499. _lclose(hd);
  500. }
  501. }
  502. //##!!extern void AddExtLib();
  503. ///////////////////////////////////////////////////////////////////////////
  504. // STD_MODE
  505. // Deels with stdandard Chinese Pinyin input with some written_stroke
  506. // attributes when neccerry.
  507. //
  508. //////////////////////////////////////////////////////////////////////////
  509. int WINAPI STD_MODE(input_char)
  510. WORD input_char;
  511. {
  512. int leibie,input_char_type,i;
  513. sImeG.InbxProc = 0;
  514. wait_flag=0;
  515. if (input_char==BACKWORD_KEY)
  516. return(backword_proc());
  517. if (input_char==FORWORD_KEY){
  518. if ((step_mode!=ONINPUT)&&(group_no>1))
  519. step_mode=SELECT;
  520. return(0);}
  521. switch(step_mode){ //step_mode indicate the input step
  522. // step_mode take this value:
  523. // START=0 first input pinyin
  524. // SELECT=1 can select/cansel the result
  525. // RESELECT=2 use FORCE SELECT KEY
  526. // ONINPUT=3 just in inputing step
  527. case SELECT:
  528. if ((input_char==VK_HOME*0x100)||
  529. (input_char==VK_END*0x100)||
  530. (input_char==VK_PRIOR*0x100)||
  531. (input_char==VK_NEXT*0x100)){
  532. word_select(input_char);
  533. break;}
  534. if (input_char>=0x8000)
  535. input_char-=0x8000;
  536. if ((input_char==VK_SPACE)||(input_char==VK_RETURN)){
  537. if(!out_result(0))
  538. step_mode=RESELECT; //92/12/14 SZ
  539. break;
  540. }
  541. if (input_char==VK_ESCAPE){
  542. cls_inpt_bf(0);
  543. step_mode=START;
  544. break;
  545. }
  546. if (input_char==VK_BACK){
  547. if (word_back_flag!=0x55)
  548. del_and_reconvert();
  549. break;
  550. }
  551. if (if_zimu_or_not((BYTE)input_char)){
  552. wait_flag=1;
  553. while(out_result(0));
  554. step_mode=START;
  555. }
  556. else{
  557. word_select(input_char);
  558. break;
  559. }
  560. case RESELECT:
  561. case START:
  562. if (input_char >= 0x8000){
  563. input_char -= 0x8000;
  564. if ( word_select(input_char) == 1 )
  565. return(0);
  566. else
  567. return(send_one_char(input_char));
  568. }//if (input_char)
  569. else{
  570. if (if_first_key(input_char)){
  571. if (input_char=='v')
  572. V_Flag = 1;
  573. else {
  574. V_Flag = 0; } //93,9,3
  575. step_mode=ONINPUT;
  576. sent_back_msg();
  577. if (wait_flag) cls_inpt_bf(1);
  578. else cls_inpt_bf(1); //1993. cock
  579. }
  580. else{
  581. if ((kb_mode==CIN_SDA)&&(input_char==0x27)){ //1993. cock
  582. step_mode=ONINPUT; //1993. cock
  583. sent_back_msg(); //1993. cock
  584. if (wait_flag) cls_inpt_bf(1);
  585. else cls_inpt_bf(1); //1993. cock
  586. }//if(kb_mode) //1993. cock
  587. else
  588. return(send_one_char(input_char));
  589. }
  590. }
  591. case ONINPUT:
  592. input_char_type=sent_chr1(input_char);
  593. switch(input_char_type){
  594. case REINPUT:
  595. ImeSetCompositionString(ghIMC,SCS_SETSTR,NULL,0,&InputBuffer,now_cs);//#52224
  596. step_mode=START;
  597. return(0);
  598. break;
  599. case CLC:
  600. return(0); // Continue input.
  601. case STC: // input finished
  602. if (V_Flag){
  603. msg_type=2; //94/8/22
  604. send_msg(&in.buffer[1], in.true_length-1); //1993.3 skip the 'v'
  605. V_Flag = 0;
  606. step_mode = 0;
  607. return(0);}
  608. step_mode=4 ; // enter proccessing step
  609. leibie=analize();
  610. if (leibie==BIAODIAN_ONLY){
  611. out_result_area[0]=(BYTE)biaodian_value;
  612. out_pointer=2; // may not used
  613. msg_type=0;
  614. out_result(0);
  615. step_mode=0;
  616. return(0);
  617. } //only bioadian case
  618. return(call_czh(leibie));
  619. }// switch (sent_chr1)
  620. } //switch step_mode
  621. return 0;
  622. }
  623. /*******************************************************************
  624. &2:
  625. DealWithSH():
  626. ********************************************************************/
  627. void WINAPI DealWithSH()
  628. {
  629. int len,p;
  630. if (group_no <= 1)
  631. return;
  632. if (unit_length > 2)
  633. return;
  634. if (in.true_length != 2) return;
  635. if (in.buffer[0] != 's') return;
  636. if (in.buffer[1] != 'h') return ;
  637. current_no = 1;
  638. }
  639. /*******************************************************************
  640. &2:
  641. call_czh():
  642. ********************************************************************/
  643. int WINAPI call_czh(mtype)
  644. int mtype;
  645. {
  646. int x;
  647. unsigned char prompt_flag_wu[]="�ޣ�";
  648. jiyi_mode=0;
  649. in.buffer[in.true_length]=0;
  650. sImeG.cp_ajust_flag = 0;
  651. group_no=0;
  652. unit_length=0;
  653. if (cwp_proc(mtype)!=1){
  654. MessageBeep((UINT)-1);
  655. MessageBeep(0); //word exchange is wrong
  656. MessageBeep(0);
  657. MessageBeep(0); //word exchange is wrong
  658. if (result_area_pointer>=0){
  659. // jiyi_mode=0;
  660. // group_no =0;
  661. // cls_prompt_only();
  662. // unit_length=result_area_pointer;
  663. // out_result(1);
  664. // step_mode=0;
  665. // return(9);
  666. // }//result_area
  667. //else{
  668. // show_char(prompt_flag_wu,4);
  669. step_mode=ONINPUT;
  670. return(0);
  671. }
  672. } //cwp_proc=-1
  673. disp_jiyi(0);
  674. if (msg_type==2){
  675. current_no=0;
  676. move_result();
  677. out_result(1); /* special change*/
  678. return(0);
  679. }
  680. if_jlxw_mode();
  681. fmt_transfer();
  682. current_no=0;
  683. DealWithSH();
  684. if (group_no==1){
  685. if (sImeG.cp_ajust_flag!=0)
  686. result_area_pointer-=unit_length;
  687. move_result();
  688. step_mode=1;
  689. return(0);
  690. }//if (group_no=1)
  691. else{
  692. disp_tail=0;
  693. if (sImeG.cp_ajust_flag==1)
  694. AutoMoveResult();
  695. else
  696. move_result();
  697. SetToIMC(ghIMC,(BYTE *)&out_svw,(WORD)group_no,(WORD)unit_length);
  698. prompt_disp();
  699. step_mode=1;
  700. return(0);
  701. }//else
  702. }
  703. /**********************************************************************/
  704. /* MoveWordIntoCand() */
  705. /**********************************************************************/
  706. void WINAPI MoveWordIntoCand(
  707. LPCANDIDATELIST lpCandList,
  708. LPBYTE srcBuffer,
  709. BYTE srcAttr,
  710. WORD perLength )
  711. {
  712. int i;
  713. if (lpCandList->dwCount >= MAXCAND) {
  714. return;
  715. }
  716. // add this string into candidate list
  717. for (i=0; i<perLength; i++)
  718. *(LPBYTE)((LPBYTE)lpCandList + lpCandList->dwOffset[
  719. lpCandList->dwCount]+i) =srcBuffer[i] ;
  720. // null terminator
  721. *(LPTSTR)((LPBYTE)lpCandList + lpCandList->dwOffset[
  722. lpCandList->dwCount] + i ) = '\0';
  723. *(LPTSTR)((LPBYTE)lpCandList + lpCandList->dwOffset[
  724. lpCandList->dwCount] + i+1 ) = srcAttr;
  725. lpCandList->dwOffset[lpCandList->dwCount + 1] =
  726. lpCandList->dwOffset[lpCandList->dwCount] +
  727. i + sizeof(TCHAR)+1;
  728. lpCandList->dwCount++;
  729. return;
  730. }
  731. /**********************************************************************/
  732. /* SetToIMC() */
  733. /* Return vlaue */
  734. /* the number of candidates in the candidate list */
  735. /**********************************************************************/
  736. UINT WINAPI SetToIMC(ghIMC,srcBuffer,srcCount,perLength)
  737. HIMC ghIMC;
  738. BYTE *srcBuffer; //soarce buffer (normal for out_svw)
  739. WORD srcCount; //How many candidates are.
  740. WORD perLength; //How long of each of that?
  741. {
  742. LPINPUTCONTEXT lpIMC;
  743. LPCANDIDATEINFO lpCandInfo;
  744. LPCANDIDATELIST lpCandList;
  745. LPPRIVCONTEXT lpImcP;
  746. INT i,j,nRecord,where;
  747. WORD temp[20],xx,yy;
  748. LPSTR ppt;
  749. static int CandiCount;
  750. where = 0 ;
  751. if (perLength>0x1000){
  752. perLength -=0x1000; // if where = 1, msg_type = 2
  753. where = 1;}
  754. if (!ghIMC) return (0); // The IMC must be a valid one.
  755. lpIMC = (LPINPUTCONTEXT)ImmLockIMC(ghIMC);
  756. if(!lpIMC) return 0;
  757. if (srcBuffer) ClearCand(lpIMC);
  758. if (!lpIMC->hCandInfo){
  759. ImmUnlockIMC(ghIMC);
  760. return (0); }
  761. // The CandInfo must...
  762. lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
  763. if (!lpCandInfo) {
  764. ImmUnlockIMC(ghIMC);
  765. return (0);}
  766. lpCandList = (LPCANDIDATELIST)
  767. ((LPBYTE)lpCandInfo + lpCandInfo->dwOffset[0]);
  768. if(srcBuffer){
  769. CandiCount = srcCount;
  770. lpCandList->dwCount = 0;
  771. for (i=0; i<(int)srcCount; i++){
  772. if ( where ) {
  773. ppt = (LPSTR)temp;
  774. for (j=0; j<perLength; j++)
  775. ppt[j] = srcBuffer[i*perLength+j];
  776. }
  777. else {
  778. for(j=0; j<perLength; j=j+2){
  779. xx = srcBuffer[i*perLength+j];
  780. yy = srcBuffer[i*perLength+j+1]*0x100;
  781. yy = yy + xx;
  782. temp[j/2]=(WORD)find_hz(yy);
  783. } // for j loop
  784. } // else loop
  785. MoveWordIntoCand(lpCandList,
  786. (LPSTR)temp,
  787. 0,//NULL,
  788. perLength);
  789. } //for i loop
  790. // default start from 0
  791. lpCandList->dwSelection = 0;
  792. // for showing phrase prediction string(s)
  793. nRecord = lpCandInfo->dwCount;
  794. } else {
  795. lpCandList->dwSelection = perLength;
  796. //Hack for IME aware application 9/13/96
  797. lpCandInfo->dwCount = CandiCount;
  798. // for showing phrase prediction string(s)
  799. nRecord = lpCandInfo->dwCount;
  800. }
  801. lpImcP = (LPPRIVCONTEXT)ImmLockIMCC(lpIMC->hPrivate);
  802. if ( lpImcP != NULL )
  803. {
  804. if ((lpImcP->fdwImeMsg & (MSG_ALREADY_OPEN|MSG_CLOSE_CANDIDATE)) ==
  805. (MSG_ALREADY_OPEN|MSG_CLOSE_CANDIDATE)) {
  806. lpImcP->fdwImeMsg = (lpImcP->fdwImeMsg | MSG_CHANGE_CANDIDATE) &
  807. ~(MSG_CLOSE_CANDIDATE);
  808. } else if (lpImcP->fdwImeMsg & MSG_ALREADY_OPEN) {
  809. lpImcP->fdwImeMsg |= MSG_CHANGE_CANDIDATE;
  810. } else {
  811. lpImcP->fdwImeMsg = (lpImcP->fdwImeMsg | MSG_OPEN_CANDIDATE) &
  812. ~(MSG_CLOSE_CANDIDATE);
  813. }
  814. }
  815. ImmUnlockIMCC(lpIMC->hPrivate);
  816. ImmUnlockIMCC(lpIMC->hCandInfo);
  817. ImmUnlockIMC(ghIMC);
  818. return (nRecord); /* The real number of being moved */
  819. }
  820. /********************************************************************
  821. word_select(wParam): select the word or turn to the next or up page
  822. *********************************************************************/
  823. int WINAPI word_select(input_char)
  824. int input_char;
  825. {
  826. int x;
  827. switch (input_char){
  828. case VK_END*0x100:
  829. case VK_NEXT*0x100:
  830. case '=': //94/8/22
  831. case ']':
  832. if (disp_tail>=group_no)
  833. MessageBeep(0);
  834. else{
  835. if(input_char == VK_END*0x100 ){
  836. disp_head = (group_no - 1)/now.fmt_group*now.fmt_group;
  837. disp_tail = disp_head;}
  838. fmt_transfer();
  839. current_no=disp_tail;
  840. result_area_pointer-=unit_length; //if recall, unit_length=8
  841. if (in.info_flag==1) //result_area_pointer maybe small
  842. result_area_pointer=0; //than zero, so reset it =0
  843. move_result();
  844. prompt_disp();}
  845. return(1); //means break the STD MODE
  846. case VK_HOME*0x100:
  847. case '-': //94/8/22
  848. case '[':
  849. case VK_PRIOR*0x100:
  850. if (disp_head==0)
  851. MessageBeep(0);
  852. else{
  853. if(input_char == VK_HOME*0x100 )
  854. disp_head = 0;
  855. else
  856. disp_head=disp_head-now.fmt_group;
  857. disp_tail=disp_head;
  858. fmt_transfer();
  859. current_no=disp_tail;
  860. result_area_pointer-=unit_length; //if recall, unit_length=8
  861. if (in.info_flag==1) //result_area_pointer maybe small
  862. result_area_pointer=0; //than zero, so reset it =0
  863. move_result();
  864. prompt_disp();
  865. }
  866. return(1);
  867. default:
  868. if (if_biaodian((BYTE)input_char)){ //1993.1.15 cock
  869. if (!biaodian_value){
  870. sent_chr1(input_char); //this produce the situation
  871. bd_proc(); //when the result had display
  872. while(out_result(0)); //94-4-22
  873. step_mode=START;
  874. return(1); //1993.1.15 cock
  875. }
  876. }
  877. if ( !if_number_or_not((BYTE)input_char)) { //1993.4.22
  878. while(out_result(0)); //94-4-22 //if input is not number
  879. step_mode = START; //send the result and set start step
  880. return(1);
  881. } //1993.4.22
  882. if(input_char=='0') x=disp_head+9; //92/12/21 SZ
  883. else
  884. x=(input_char-0x30-1)+disp_head;
  885. if (x>=group_no) //1994.4
  886. current_no=group_no-1;
  887. else
  888. current_no=x;
  889. result_area_pointer-=unit_length; //if recall, unit_length=8
  890. if (in.info_flag==1) //result_area_pointer maybe small
  891. result_area_pointer=0; //than zero, so reset it =0
  892. else{
  893. if((step_mode==RESELECT)
  894. &&biaodian_value
  895. &&(result_area_pointer>=biaodian_len))
  896. result_area_pointer-=biaodian_len;
  897. }
  898. move_result();
  899. pindu_ajust();
  900. step_mode=RESELECT; //Note: pindu_ajust
  901. out_result(0); // must above out_result
  902. return(1); // step_mode must be set to 2(Re..)
  903. }
  904. }
  905. /*********************************************
  906. del_and_reconvert()
  907. **********************************************/
  908. int WINAPI del_and_reconvert()
  909. {
  910. int x;
  911. if (word_back_flag==0xaa)
  912. return(same_as_backwords());
  913. wp.dw_count--;
  914. x=wp.dw_stack[wp.dw_count+1]-wp.dw_stack[wp.dw_count];
  915. if (x==1){ //if the single word exchange
  916. if (!wp.dw_count)
  917. return(same_as_backwords());
  918. else{
  919. wp.dw_count--;
  920. x=wp.dw_stack[wp.dw_count+1]-wp.dw_stack[wp.dw_count]+1;
  921. }
  922. }
  923. result_area_pointer-=x*2;
  924. word_back_flag=x-1;
  925. wp.xsyjw=wp.dw_stack[wp.dw_count];
  926. return(call_czh(13));
  927. }
  928. /***********************************************
  929. backword_proc()
  930. ************************************************/
  931. int WINAPI backword_proc()
  932. {
  933. switch(step_mode){
  934. case SELECT:
  935. return(same_as_backwords());
  936. break;
  937. case RESELECT:
  938. case START:
  939. if ((!msg_type)&&((kb_mode==CIN_STD)||(kb_mode==CIN_SDA)))
  940. return(same_as_backwords());
  941. else
  942. send_msg(msg_bf,msg_count);
  943. break;
  944. case ONINPUT:
  945. return(call_czh(14));
  946. break;
  947. }
  948. return 0;
  949. }
  950. /***********************************************
  951. same_as_backwords()
  952. ************************************************/
  953. int WINAPI same_as_backwords()
  954. {
  955. int i;
  956. if (in.buffer[0]!='v'){
  957. cls_prompt_only();
  958. if (in.true_length>=1)
  959. if (in.buffer[0]!='U')
  960. if (!cap_mode){
  961. cs_p(input_msg_disp);
  962. show_char(in.buffer,in.true_length);
  963. cs_p(input_msg_disp+in.true_length);
  964. half_init();
  965. if (kb_mode==CIN_STD||kb_mode==CIN_SDA){ //STD_MODE
  966. step_mode=ONINPUT;
  967. return(0);
  968. }//if (kb_mode)
  969. return(read_kb()); //double hit input_mode
  970. }//if (cap_mode)
  971. }//if (in.buffer[0])
  972. out_length=last_out_length;
  973. return(REINPUT);
  974. }
  975. /*******************************************
  976. AutoMoveResult()
  977. ********************************************/
  978. void WINAPI AutoMoveResult()
  979. {
  980. int i,j,ct;
  981. WORD x;
  982. BYTE *ps,*pd;
  983. x=(WORD)unit_length;
  984. j=unit_length*current_no;
  985. for (i=0;i<group_no;i++){
  986. ct=0;
  987. for (j=0; j<x; j++)
  988. if (result_area[result_area_pointer+i]==out_svw[j*unit_length+i])
  989. ct++;
  990. if (ct == x){
  991. current_no=i;
  992. break;}
  993. }
  994. disp_auto_select();
  995. }
  996. /*******************************************
  997. move_result()
  998. ********************************************/
  999. void WINAPI move_result()
  1000. {
  1001. int i,j;
  1002. WORD x;
  1003. BYTE *p;
  1004. p=(BYTE *)msx_area;
  1005. if (in.info_flag==1){ // recall statue
  1006. x=*(p+current_no*22);
  1007. j=current_no*22+1;
  1008. for (i=0; i<x; i++)
  1009. result_area[result_area_pointer++]=*(p+j+i);
  1010. }
  1011. else{
  1012. x=(WORD)unit_length;
  1013. j=unit_length*current_no;
  1014. for (i=0; i<x; i++)
  1015. result_area[result_area_pointer++]=out_svw[j+i];
  1016. }
  1017. if (now.fmt_start!=12)
  1018. disp_auto_select();
  1019. }
  1020. /********************************************
  1021. pindu_ajust()
  1022. ********************************************/
  1023. int WINAPI pindu_ajust()
  1024. {
  1025. if (sImeG.auto_mode!=1)
  1026. return(0); //if the pindu_ajust mode is set
  1027. if (group_no<=1)
  1028. return(0);
  1029. if (unit_length>6)
  1030. return(0);
  1031. if (msg_type&2)
  1032. return(0);
  1033. switch (unit_length){
  1034. case 2:
  1035. rem_pd1((WORD *)&out_svw[current_no*unit_length]);
  1036. break;
  1037. case 4:
  1038. rem_pd2((WORD *)&out_svw[current_no*unit_length]);
  1039. break;
  1040. default:
  1041. rem_pd3((WORD *)&out_svw[current_no*unit_length]);
  1042. break;
  1043. }
  1044. return (0);
  1045. }
  1046. /***********************************************************
  1047. cls_inpt_bf(): inputing information init. clear the display
  1048. area, and give the init_value to processing
  1049. paraments.
  1050. ************************************************************/
  1051. void WINAPI cls_inpt_bf(int hFunc)
  1052. {
  1053. int i;
  1054. cls_prompt_only();
  1055. input_cur=0;//input_msg_disp;
  1056. for (i=0;i<in.max_length;i++)
  1057. in.buffer[i]=0;
  1058. for (i=0;i<sizeof InputBuffer; i++) InputBuffer[i]=' ';
  1059. SetCloseCompWinMsg(hFunc);
  1060. cs_p(0/*input_msg_disp*/);
  1061. pass_word=0;
  1062. group_no=0;
  1063. now.fmt_group=0;
  1064. disp_head=0;
  1065. disp_tail=0;
  1066. in.true_length=0;
  1067. in.info_flag=0;
  1068. result_area_pointer=0;
  1069. word_back_flag=0;
  1070. biaodian_value=0;
  1071. msg_type=0;
  1072. jiyi_mode=0;
  1073. new_no=0;
  1074. end_flg=0;
  1075. }
  1076. void InitCvtPara(void){
  1077. int i;
  1078. input_cur=0;//input_msg_disp;
  1079. for (i=0;i<in.max_length;i++)
  1080. in.buffer[i]=0;
  1081. for (i=0;i<sizeof InputBuffer; i++) InputBuffer[i]=' ';
  1082. now_cs = 0;
  1083. cs_p(now_cs);
  1084. step_mode = 0;
  1085. pass_word=0;
  1086. in.true_length=0;
  1087. in.info_flag=0;
  1088. result_area_pointer=0;
  1089. word_back_flag=0;
  1090. biaodian_value=0;
  1091. msg_type=0;
  1092. jiyi_mode=0;
  1093. new_no=0;
  1094. end_flg=0;
  1095. V_Flag = 0;
  1096. bx_inpt_on = 0;
  1097. }
  1098. /*****************************************
  1099. half_init()
  1100. ******************************************/
  1101. void WINAPI half_init()
  1102. {
  1103. step_mode=ONINPUT;
  1104. result_area_pointer=0;
  1105. biaodian_value=0;
  1106. new_no=0;
  1107. msg_type=0;
  1108. word_back_flag=0;
  1109. jiyi_mode=0;
  1110. input_cur=now_cs;
  1111. }
  1112. /*******************************************************
  1113. sent_chr1(): send the string received from the keyboard
  1114. to the received buffer.
  1115. "JMP K1": return(REINPUT)
  1116. "JMP RECALL": return(RECALL)
  1117. "STC": return(STC)
  1118. "CLC": return(CLC)
  1119. ********************************************************/
  1120. int WINAPI sent_chr1(input_char)
  1121. int input_char;
  1122. {
  1123. int bd_find=0,i;
  1124. if ((input_char < 0x21)||(input_char == 0x12e)){
  1125. switch(input_char){
  1126. case VK_ESCAPE: //VK_ESCAPE=0x1b:
  1127. cls_inpt_bf(0);
  1128. return(REINPUT); /* JMP K1 */
  1129. case VK_SPACE: //CK_SPACE=0x20
  1130. in.info_flag=BY_WORD;
  1131. return(STC); /* STC */
  1132. case VK_DELETE+0X100:
  1133. if (in.true_length>input_cur){
  1134. for (i=0;i<in.true_length-input_cur-1;i++)
  1135. in.buffer[input_cur+i]
  1136. =in.buffer[input_cur+i+1];
  1137. in.true_length--;
  1138. in.buffer[in.true_length]=0x20;
  1139. cs_p(0);
  1140. show_char(in.buffer,in.true_length+1);
  1141. cs_p(input_cur);
  1142. return(CLC);} /* CLC */
  1143. else{
  1144. MessageBeep(0);
  1145. return(CLC);}
  1146. case VK_BACK: //VK_BACK=0x08
  1147. if (!input_cur){
  1148. if (in.true_length){
  1149. MessageBeep(0);
  1150. return(CLC); } //1993.4 oringal return(CLC)
  1151. else {
  1152. MessageBeep(0);
  1153. return(REINPUT); } //1993.4 oringal return(CLC)
  1154. }
  1155. in.true_length--; //1993.4.16
  1156. if ( !in.true_length ) { //1993.4.16
  1157. end_flg=0; //????
  1158. input_cur=0;
  1159. cls_inpt_bf(0);
  1160. V_Flag=0; //93.9.4
  1161. return(REINPUT);} /* JMP K1 */
  1162. else{
  1163. input_cur--;
  1164. for (i=0;i<in.true_length-input_cur;i++)
  1165. in.buffer[input_cur+i]
  1166. =in.buffer[input_cur+i+1];
  1167. in.buffer[in.true_length]= 0; //0x20; //95/8/22 zst
  1168. cs_p(0);
  1169. show_char(in.buffer,in.true_length/*+1*/); //95/8/22 zst
  1170. cs_p(input_cur);
  1171. return(CLC);} /* CLC */
  1172. case VK_RETURN: //VK_RETURN=0x0d:
  1173. in.info_flag=BY_CHAR;
  1174. new_no=0;
  1175. return(STC); /* STC */
  1176. default:
  1177. MessageBeep(0);
  1178. return(CLC); /* CLC */
  1179. }
  1180. }
  1181. else{
  1182. switch(input_char){
  1183. case VK_LEFT+0x100:
  1184. if (input_cur>0) input_cur--;
  1185. cs_p(input_cur);
  1186. return (CLC);
  1187. case VK_RIGHT+0x100:
  1188. if (input_cur<in.true_length) input_cur++;
  1189. cs_p(input_cur);
  1190. return (CLC);
  1191. case VK_UP+0x100:
  1192. input_cur=0;
  1193. cs_p(input_cur);
  1194. return(CLC);
  1195. case VK_DOWN+0x100:
  1196. input_cur=in.true_length;
  1197. cs_p(input_cur);
  1198. return (CLC);
  1199. case ']':
  1200. case '[':
  1201. if (!V_Flag)
  1202. {
  1203. if (input_char==']')
  1204. jlxw_mode=1;
  1205. else
  1206. jlxw_mode=-1;
  1207. in.info_flag=BY_WORD;
  1208. return(STC); /* STC */
  1209. }
  1210. default:
  1211. if (if_biaodian((BYTE)input_char) && (!V_Flag)) //1993,3
  1212. bd_find=1;
  1213. if (in.max_length<=in.true_length){
  1214. // in.true_length=in.max_length;
  1215. MessageBeep(0);
  1216. return(CLC); //1994.4 old =STC // changed 12-12 SZ
  1217. }
  1218. else{
  1219. if(input_cur>=in.true_length){
  1220. in.buffer[in.true_length++]=(BYTE)input_char;
  1221. show_char(&in.buffer[input_cur],1); //1994.4.5
  1222. input_cur++;
  1223. cs_p(input_cur); // zst 95.54
  1224. if (bd_find==1)
  1225. return(STC); /* STC */
  1226. else
  1227. return(CLC);}
  1228. else{
  1229. if((!input_cur)&&((input_char&0xdf)=='V'))
  1230. return(CLC); //1994.7.24
  1231. for (i=0; i<in.true_length-input_cur;i++)
  1232. in.buffer[in.true_length-i]
  1233. =in.buffer[in.true_length-i-1]; /* CLC */
  1234. in.buffer[input_cur++]=(BYTE)input_char;
  1235. if (!bd_find){
  1236. in.true_length++;
  1237. cs_p(0);
  1238. show_char(in.buffer,in.true_length);
  1239. cs_p(input_cur);
  1240. return(CLC);
  1241. }
  1242. else{
  1243. for(i=input_cur;i<in.true_length;i++)
  1244. in.buffer[i]=0x20; //1993.4.20
  1245. cs_p(0);
  1246. show_char(in.buffer,in.true_length);
  1247. cs_p(input_cur);
  1248. in.true_length=(WORD)input_cur; //1993.4.20
  1249. return(STC);
  1250. }
  1251. }//#4 if now_cs...else
  1252. }//#3 if max...else
  1253. }//#2 case
  1254. }//#1 if..else
  1255. }//#0
  1256. /*******************************************************
  1257. &4:
  1258. if_biaodian(x): judge if the input is "biaodian"
  1259. return(FALSE): NO
  1260. return(TRUE): YES
  1261. ********************************************************/
  1262. BOOL if_biaodian(x)
  1263. BYTE x;
  1264. {
  1265. int i;
  1266. if ((step_mode==ONINPUT)&&(x==0x27)) return(FALSE); //94/8/22
  1267. if (x=='$') {
  1268. if((in.buffer[0]&0xdf)=='I')
  1269. if((step_mode!=START)&&(step_mode!=RESELECT))
  1270. return (FALSE);}
  1271. for (i=0; i<lstrlen(biaodian_table); i++){
  1272. if (x==biaodian_table[i]){
  1273. biaodian_pos=i; /* record the porsition in biaodian_table */
  1274. return(TRUE);
  1275. }
  1276. }
  1277. return(FALSE);
  1278. }
  1279. /******************************************************
  1280. &3:
  1281. analize(): analize the input information
  1282. process the biaodian , and analize the
  1283. first byte of the input information.
  1284. return(BIAODIAN_ONLY): chinese biaodian
  1285. return(0): standard change
  1286. return(1): ABBR
  1287. return(2): "I" change
  1288. return(3): "i" change
  1289. return(4): "u" change
  1290. return(0xff): trun to "remember forced"
  1291. *******************************************************/
  1292. int WINAPI analize()
  1293. {
  1294. if (bd_proc())
  1295. return(BIAODIAN_ONLY); /* only have the chinese biaodian */
  1296. switch (in.buffer[0]){
  1297. case 'I':
  1298. return(2); /* special change: "l" change */
  1299. case 'i':
  1300. return(3); /* special change: "i" change */
  1301. case 'u':
  1302. case 'U': //in.buffer[0]='U';
  1303. if (in.true_length==1)
  1304. return(0xff); /* CTRL_F4_ENTRY: trun to the "remember forced" */
  1305. else
  1306. return(4); /* special change: "u" change */
  1307. }
  1308. if ((in.buffer[0]&0x20)==0) /*1992 9 5 &&->& */
  1309. return(1); /* ABBR */
  1310. else
  1311. return(0); /* mark of the standard change */
  1312. }
  1313. /***************************************************
  1314. &4:
  1315. bd_proc(): process the chinese biaodian
  1316. return(FALES): have chinese biaodian and another char
  1317. return(TRUE): only have the chinese biaodian
  1318. ****************************************************/
  1319. BOOL bd_proc()
  1320. {
  1321. BYTE x;
  1322. x=in.buffer[in.true_length-1];
  1323. if(!GetBDValue(x)) return(FALSE);
  1324. in.true_length--;
  1325. if (in.true_length==0)
  1326. return(TRUE);
  1327. else
  1328. return(FALSE);
  1329. }
  1330. int WINAPI GetBDValue(bd_char)
  1331. int bd_char;
  1332. {
  1333. if (!if_biaodian((BYTE)bd_char))
  1334. return(FALSE);
  1335. biaodian_len =2;
  1336. if ((bd_char=='^')||(bd_char=='^'))
  1337. biaodian_len =4;
  1338. biaodian_value=cc_biaodian[biaodian_pos*2]+
  1339. cc_biaodian[biaodian_pos*2+1]*0x100;
  1340. if (bd_char==0x22){
  1341. if (yinhao_flag==1)
  1342. biaodian_value=cc_biaodian[(biaodian_pos+2)*2]
  1343. +cc_biaodian[(biaodian_pos+2)*2+1]*0x100;
  1344. yinhao_flag=!yinhao_flag; //92-12-21 SZ
  1345. }
  1346. if (bd_char==0x27){
  1347. if (d_yinhao_flag==1)
  1348. biaodian_value=cc_biaodian[(biaodian_pos+2)*2]
  1349. +cc_biaodian[(biaodian_pos+2)*2+1]*0x100;
  1350. d_yinhao_flag=!d_yinhao_flag; //92-12-21 SZ
  1351. }
  1352. if(bd_char=='<'){
  1353. if(book_name==1){
  1354. biaodian_value=cc_biaodian[(biaodian_pos+10)*2]
  1355. +cc_biaodian[(biaodian_pos+10)*2+1]*0x100;
  1356. book_name_sub++;
  1357. }
  1358. else{
  1359. book_name=1;
  1360. book_name_sub=0;
  1361. }
  1362. }
  1363. if(bd_char=='>'){
  1364. if(book_name_sub){
  1365. biaodian_value=cc_biaodian[(biaodian_pos+10)*2]
  1366. +cc_biaodian[(biaodian_pos+10)*2+1]*0x100;
  1367. book_name_sub--;
  1368. }
  1369. else
  1370. book_name=0;
  1371. }
  1372. return(TRUE);
  1373. }
  1374. /*******************************************************
  1375. &4:
  1376. if_zimu_or_not(): judge if the input is char or number
  1377. return(TRUE): is char
  1378. return(FALSE): is number
  1379. ********************************************************/
  1380. BOOL if_zimu_or_not(x)
  1381. BYTE x;
  1382. {
  1383. if (('A'<=x) && (x<='Z'))
  1384. return(TRUE);
  1385. if (('a'<=x) && (x<='z'))
  1386. return(TRUE);
  1387. return(FALSE);
  1388. }
  1389. /***************************************************
  1390. if_number_or_not(c)
  1391. ****************************************************/
  1392. int WINAPI if_number_or_not(c)
  1393. BYTE c;
  1394. {
  1395. if ((c<'0')||(c>'9'))
  1396. return(STC);
  1397. else
  1398. return(CLC);
  1399. }
  1400. /***************************************************
  1401. if_bx_number(c)
  1402. ****************************************************/
  1403. int WINAPI if_bx_number(c)
  1404. BYTE c;
  1405. {
  1406. if ((c<'1')||(c>'8'))
  1407. return(STC);
  1408. else
  1409. return(CLC);
  1410. }
  1411. /*********************************************************
  1412. &3:
  1413. out_result(result_type): output the change result.
  1414. **********************************************************/
  1415. int WINAPI out_result(result_type)
  1416. int result_type;
  1417. {
  1418. int i;
  1419. if ((jiyi_mode==1)){
  1420. if (word_back_flag==0x99){
  1421. word_back_flag=2;
  1422. return(call_czh(13));}
  1423. else{
  1424. if (call_czh(12)==9){
  1425. step_mode=START;
  1426. }
  1427. else
  1428. step_mode=SELECT;
  1429. return(1);
  1430. }
  1431. } // if (jiyi)
  1432. else{
  1433. if (result_area_pointer!=unit_length)
  1434. if (msg_type!=2)
  1435. if (in.info_flag!=1)
  1436. new_no=result_area_pointer;
  1437. if (biaodian_value!=0){
  1438. result_area[result_area_pointer++]=LOBYTE(biaodian_value);
  1439. result_area[result_area_pointer++]=HIBYTE(biaodian_value);
  1440. if (biaodian_len==4)
  1441. {
  1442. result_area[result_area_pointer++]=LOBYTE(biaodian_value);
  1443. result_area[result_area_pointer++]=HIBYTE(biaodian_value);
  1444. }
  1445. }
  1446. if (!(msg_type&2)){
  1447. if (result_area_pointer>0){
  1448. temp_rem_proc();
  1449. for (i=0; i<result_area_pointer; i=i+2)
  1450. out_bfb[i/2]=(WORD)find_hz((WORD)(result_area[i]+result_area[i+1]*0x100));
  1451. } // if (result_area_pointer)
  1452. last_out_length=out_length;
  1453. out_length=result_area_pointer/2;
  1454. AddExtLib();
  1455. send_msg((BYTE *)out_bfb,result_area_pointer);
  1456. } // if (msg_type)
  1457. else{
  1458. last_out_length=out_length;
  1459. out_length=result_area_pointer/2;
  1460. send_msg(result_area,result_area_pointer);
  1461. if (in.buffer[0]!='v'){
  1462. step_mode=0;
  1463. return(0);}
  1464. }
  1465. return(0);
  1466. }
  1467. }
  1468. //////////////////////////////////////////////////////////////////////////
  1469. void WINAPI fmt_transfer()
  1470. {
  1471. if (lpImeL->wImeStyle == IME_APRS_FIX){
  1472. if (in.info_flag==BY_RECALL)
  1473. { now.fmt_group=3; //5;
  1474. now.fmt_start=26;
  1475. now.fmt_ttl_len=54;
  1476. word_back_flag=0x55; //back convert is not allowed.
  1477. }
  1478. else
  1479. { now.fmt_group=(WORD)form[unit_length/2];
  1480. now.fmt_start=27;
  1481. now.fmt_ttl_len=53;
  1482. }
  1483. } else {
  1484. now.fmt_group = CANDPERPAGE ;
  1485. if (in.info_flag==BY_RECALL)
  1486. word_back_flag=0x55;
  1487. }
  1488. }
  1489. //////////////////////////////////////////////////////////////////////////
  1490. //////////////////////////////////////////////////////////////////////////
  1491. int WINAPI sent_back_msg()
  1492. {
  1493. if (new_no<=2)
  1494. return(0);
  1495. if (new_no>18)
  1496. return(0);
  1497. new_word();
  1498. return(0);
  1499. }
  1500. //////////////////////////////////////////////////////////////////////////
  1501. //////////////////////////////////////////////////////////////////////////
  1502. int WINAPI if_jlxw_mode()
  1503. {
  1504. int x,i,j;
  1505. WORD *out_svw_p;
  1506. out_svw_p=(WORD *)out_svw;
  1507. if (jlxw_mode==0)
  1508. return(0);
  1509. if (jlxw_mode<0){
  1510. if (sImeG.cp_ajust_flag==1)
  1511. result_area_pointer=result_area_pointer-unit_length+2;
  1512. x=0;
  1513. } // if (jlxw)
  1514. else{
  1515. if (sImeG.cp_ajust_flag==1){
  1516. x=result_area_pointer-unit_length;
  1517. result_area[x++]=result_area[result_area_pointer-2];
  1518. result_area[x++]=result_area[result_area_pointer-1];
  1519. result_area_pointer=x;
  1520. }// if (cp_ajust)
  1521. x=unit_length-2;
  1522. }// else
  1523. jlxw_mode=0;
  1524. word_back_flag=0xaa;
  1525. if (unit_length<=2)
  1526. return(0);
  1527. j=0;
  1528. x=x/2; //out_svw_p transmit by word;
  1529. for (i=0; i<group_no; i++){
  1530. out_svw_p[j++]=out_svw_p[x];
  1531. x+=unit_length/2;
  1532. }// for
  1533. unit_length=2;
  1534. for (i=0; i<group_no; i++)
  1535. out_svw_p[i+100]=out_svw_p[i];
  1536. x=0;
  1537. for (i=0; i<group_no; i++){
  1538. if (out_svw_p[i+100]){
  1539. out_svw_p[x]=out_svw_p[i+100];
  1540. for (j=i+1; j<group_no; j++){
  1541. if (out_svw_p[j+100]==out_svw_p[x])
  1542. out_svw_p[j+100]=0;
  1543. }//for(j)
  1544. x++;
  1545. }//if(out_svw_p)
  1546. }//for(i)
  1547. group_no=x;
  1548. return(0);
  1549. }
  1550. //////////////////////////////////////////////////////////////////////////
  1551. //////////////////////////////////////////////////////////////////////////
  1552. int WINAPI disp_auto_select()
  1553. {
  1554. WORD x,y,lng;
  1555. int i,j;
  1556. BYTE disp_bf[80];
  1557. if (result_area_pointer==0)
  1558. return(0);
  1559. cs_p(input_msg_disp);
  1560. if (msg_type==2){
  1561. show_char(result_area, result_area_pointer);
  1562. cs_p(input_msg_disp+result_area_pointer);
  1563. }
  1564. else{
  1565. for (i=0; i<result_area_pointer; i=i+2){
  1566. x=result_area[i]+result_area[i+1]*0x100;
  1567. y=(WORD)find_hz(x);
  1568. disp_bf[i]=LOBYTE(y);
  1569. disp_bf[i+1]=HIBYTE(y);
  1570. }// for
  1571. lng=in.true_length;
  1572. if (jiyi_mode!=0){
  1573. if (wp.xsyjw!=0){
  1574. if (wp.yj_ps[wp.xsyjw-1]<in.true_length){
  1575. j=wp.yj_ps[wp.xsyjw-1];
  1576. x=in.true_length-wp.yj_ps[wp.xsyjw-1];
  1577. for (n=0; n<x; n++){
  1578. disp_bf[i++]=in.buffer[j++];
  1579. }//for
  1580. }// if (yj_ps)
  1581. }//if(wp.xsyjw)
  1582. }// if (jiyi)
  1583. show_char(disp_bf, i);
  1584. cs_p(input_msg_disp+result_area_pointer);
  1585. }// else
  1586. return (0);
  1587. }
  1588. //////////////////////////////////////////////////////////////////////////
  1589. int WINAPI if_first_key(input_char)
  1590. WORD input_char;
  1591. {
  1592. if (input_char=='U') return(STC);
  1593. if(if_number_or_not((BYTE)input_char))
  1594. return(STC); //the first key is number,it's not allowed
  1595. if(if_zimu_or_not((BYTE)input_char))
  1596. return(CLC); //the first key is zimu
  1597. return(STC);
  1598. }
  1599. /*****************************************************************
  1600. temp_rem_proc(): save the output in logging_stack for recall process
  1601. ********************************************************************/
  1602. int WINAPI temp_rem_proc()
  1603. {
  1604. int c,i;
  1605. if (in.true_length<2)
  1606. if (in.info_flag!=1)
  1607. return(0);
  1608. if (biaodian_value){
  1609. c=result_area_pointer-2+1; //-2 biaodian isn't consider
  1610. if ((c>=2)&&(biaodian_len==4))
  1611. c = c-2;
  1612. }
  1613. else //+1 logging_stack struck is
  1614. c=result_area_pointer+1; // result_area_pointer plus
  1615. // one byte counter
  1616. CopyMemory/*memmove*/(&logging_stack[c],&logging_stack[0],(logging_stack_size-c));
  1617. logging_stack[0]=c-1; //length of storing string
  1618. for (i=0; i<logging_stack[0]; i++)
  1619. logging_stack[i+1]=result_area[i];
  1620. if_multi_rem(c);
  1621. return(0);
  1622. }
  1623. /*******************************************
  1624. if_multi_rem()
  1625. ********************************************/
  1626. int WINAPI if_multi_rem(c)
  1627. int c;
  1628. {
  1629. BYTE cmp_buffer[25]={0}; //max input is 10 chinese words
  1630. int i,cn;
  1631. char *p;
  1632. for (i=0; i<c; i++)
  1633. cmp_buffer[i]=logging_stack[i];
  1634. cmp_buffer[i]=0;
  1635. p=(LPSTR)ABCstrstr(&logging_stack[c],cmp_buffer);
  1636. if (p!=NULL){
  1637. c=(INT)(p-logging_stack);
  1638. cn=logging_stack[c]+1; //cn is the length a group in logging_stack
  1639. CopyMemory/*memmove*/(&logging_stack[c],&logging_stack[c+cn],logging_stack_size-c-cn);
  1640. }
  1641. return(0);
  1642. }
  1643. /////////////////////////////////////////////////////////////////////
  1644. void WINAPI send_msg(bf,count)
  1645. BYTE *bf;
  1646. int count;
  1647. {
  1648. int i,j;
  1649. unsigned int focus,xx;
  1650. TypeOfOutMsg = ABC_OUT_MULTY ;
  1651. msg_count=count; //Keep msg for repeat.
  1652. for (i=0;i<count;i++){
  1653. msg_bf[i]=bf[i]; //send msg for Edit class W.
  1654. if (bf[i]<0x80) TypeOfOutMsg = ABC_OUT_ASCII;
  1655. }
  1656. SetResultToIMC(ghIMC,msg_bf,(WORD)count);
  1657. }
  1658. /*******************************************
  1659. Popurse: To send a single char as message .
  1660. *******************************************/
  1661. int WINAPI send_one_char(chr)
  1662. int chr;
  1663. {
  1664. int scn;
  1665. if(glpIMC->fdwConversion&IME_CMODE_SYMBOL)
  1666. if(GetBDValue(chr)){
  1667. unsigned char buffer[4];
  1668. int num = 2;
  1669. buffer[0]=LOBYTE(biaodian_value);
  1670. buffer[1]=HIBYTE(biaodian_value);
  1671. if ((chr == '_')|| (chr == '^'))
  1672. {
  1673. buffer[2]=LOBYTE(biaodian_value);
  1674. buffer[3]=HIBYTE(biaodian_value);
  1675. num = 4 ;
  1676. }
  1677. send_msg(buffer,num);
  1678. return(0);
  1679. }
  1680. if(glpIMC->fdwConversion&IME_CMODE_FULLSHAPE)
  1681. cap_full((WORD)chr);
  1682. else
  1683. TypeOfOutMsg = ABC_OUT_ONE ;
  1684. return(0);
  1685. }
  1686. int WINAPI send_one_char0(chr)
  1687. int chr;
  1688. {
  1689. TypeOfOutMsg = ABC_OUT_ONE ;
  1690. return (0);
  1691. }
  1692. /**********************************************************************/
  1693. /* SetResultToIMC() */
  1694. /* Return vlaue */
  1695. /* the number of candidates in the candidate list */
  1696. /**********************************************************************/
  1697. UINT WINAPI SetResultToIMC(
  1698. HIMC ghIMC,
  1699. LPSTR outBuffer, //soarce buffer (normal for out_svw)
  1700. WORD outCount) //How many candidates are.
  1701. {
  1702. LPINPUTCONTEXT lpIMC;
  1703. LPCANDIDATEINFO lpCandInfo;
  1704. LPCANDIDATELIST lpCandList;
  1705. LPPRIVCONTEXT lpImcP;
  1706. LPCOMPOSITIONSTRING lpCompStr;
  1707. WORD dwCompStrLen;
  1708. WORD dwReadClauseLen;
  1709. WORD dwReadStrLen;
  1710. if (!ghIMC) return (0); // The IMC must be a valid one.
  1711. lpIMC = (LPINPUTCONTEXT)ImmLockIMC(ghIMC);
  1712. if(!lpIMC) return 0;
  1713. if (!lpIMC->hCandInfo){
  1714. ImmUnlockIMC(ghIMC);
  1715. return (0); }
  1716. // The CandInfo must...
  1717. lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
  1718. if (!lpCandInfo) {
  1719. ImmUnlockIMC(ghIMC);
  1720. return (0);}
  1721. lpCandList = (LPCANDIDATELIST)
  1722. ((LPBYTE)lpCandInfo + lpCandInfo->dwOffset[0]);
  1723. lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
  1724. if (!lpCompStr) {
  1725. MessageBeep((UINT)-1);
  1726. ImmUnlockIMCC(lpIMC->hCandInfo);
  1727. ImmUnlockIMC(ghIMC);
  1728. return (0);
  1729. }
  1730. dwCompStrLen = 0;
  1731. dwReadClauseLen = 0;
  1732. dwReadStrLen = 0;
  1733. InitCompStr(lpCompStr);
  1734. // the result reading clause = compsotion reading clause
  1735. CopyMemory((LPSTR)lpCompStr + lpCompStr->dwResultReadClauseOffset,
  1736. (LPSTR)lpCompStr + lpCompStr->dwCompReadClauseOffset,
  1737. dwReadClauseLen);
  1738. lpCompStr->dwResultReadClauseLen = dwReadClauseLen;
  1739. *(LPSTR)((LPSTR)lpCompStr+lpCompStr->dwResultReadClauseOffset+dwReadClauseLen) = '\0';
  1740. // the result reading string = compsotion reading string
  1741. CopyMemory((LPSTR)lpCompStr + lpCompStr->dwResultReadStrOffset,
  1742. (LPSTR)lpCompStr + lpCompStr->dwCompReadStrOffset,
  1743. dwReadStrLen);
  1744. lpCompStr->dwResultReadStrLen = dwReadStrLen;
  1745. *(LPSTR)((LPSTR)lpCompStr+lpCompStr->dwResultReadStrOffset+dwReadStrLen) = '\0';
  1746. // calculate result string length
  1747. lpCompStr->dwResultStrLen = outCount;
  1748. // the result string = outBuffer;
  1749. CopyMemory((LPSTR)lpCompStr + lpCompStr->dwResultStrOffset,
  1750. (LPSTR)outBuffer,outCount);
  1751. *(LPSTR)((LPSTR)lpCompStr+lpCompStr->dwResultStrOffset+outCount) = '\0';
  1752. lpCompStr->dwResultClauseLen = 0;
  1753. *(LPUNADWORD)((LPBYTE)lpCompStr + lpCompStr->dwResultClauseOffset +
  1754. sizeof(DWORD)) = 0;
  1755. lpImcP = (LPPRIVCONTEXT)ImmLockIMCC(lpIMC->hPrivate);
  1756. // tell application, there is a reslut string
  1757. lpImcP->fdwImeMsg |= MSG_COMPOSITION;
  1758. lpImcP->dwCompChar = (DWORD)0;
  1759. lpImcP->fdwGcsFlag |= GCS_COMPREAD|GCS_COMP|GCS_CURSORPOS|
  1760. GCS_DELTASTART|GCS_RESULTREAD|GCS_RESULT;
  1761. if(TypeOfOutMsg == ABC_OUT_ASCII)
  1762. lpImcP->fdwGcsFlag &=(~GCS_RESULT);
  1763. if (lpImcP->fdwImeMsg & MSG_ALREADY_OPEN) {
  1764. lpImcP->fdwImeMsg = (lpImcP->fdwImeMsg | MSG_CLOSE_CANDIDATE) &
  1765. ~(MSG_OPEN_CANDIDATE);
  1766. }
  1767. // no candidate now, the right candidate string already be finalized
  1768. lpCandList->dwCount = 0;
  1769. lpImcP->iImeState = CST_INIT;
  1770. ImmUnlockIMCC(lpIMC->hPrivate);
  1771. ImmUnlockIMCC(lpIMC->hCandInfo);
  1772. ImmUnlockIMC(ghIMC);
  1773. return (0) ; /* The real number of being moved */
  1774. }
  1775. /**********************************************************
  1776. FUNCTION: cap_full()
  1777. PURPOES: if the full_switch on, and in the Caps status,
  1778. change the English into Chinese mode
  1779. ************************************************************/
  1780. void WINAPI cap_full(wParam)
  1781. WORD wParam;
  1782. {
  1783. if (wParam==VK_BACK){
  1784. // send_one_char(VK_BACK);
  1785. send_one_char0(VK_BACK);
  1786. return;
  1787. }
  1788. if (wParam==VK_SPACE){
  1789. result_area[0]=0xa1; //94-8-6!
  1790. result_area[1]=0xa1; //04-8-6!
  1791. send_msg(result_area,2);
  1792. return;
  1793. }
  1794. if (wParam== '~'){
  1795. result_area[0]=0xa1; //94-8-6!
  1796. result_area[1]=0xab; //04-8-6!
  1797. send_msg(result_area,2);
  1798. return;
  1799. }
  1800. if (wParam=='$'){
  1801. result_area[0]=0xa1; //94-8-6!
  1802. result_area[1]=0xe7; //04-8-6!
  1803. send_msg(result_area,2);
  1804. return;
  1805. }
  1806. if ((wParam>0x20) && (wParam<=0x7e)){
  1807. result_area[0]=0xa3;
  1808. result_area[1]=((wParam-0x20)*0x100+0xa0a3)/0x100;
  1809. send_msg(result_area,2);
  1810. return;
  1811. }
  1812. send_one_char0(wParam);
  1813. }
  1814. /*********************************************
  1815. read_kb()
  1816. **********************************************/
  1817. int WINAPI read_kb()
  1818. {
  1819. return(0);
  1820. }
  1821. /////////////////////////////////////////////////////////////////////////
  1822. // BX_MODE //
  1823. // Deel with pure bx input //
  1824. /////////////////////////////////////////////////////////////////////////
  1825. extern WORD last_size;
  1826. BX_MODE(input_char,wParam)
  1827. WORD input_char;
  1828. WPARAM wParam;
  1829. {
  1830. if (if_number_or_not((BYTE)input_char)
  1831. &&(input_char!='9')
  1832. &&(input_char!='0')){
  1833. if (step_mode==START||step_mode==RESELECT){
  1834. if (input_char >= 0x8000) //1993.4.19
  1835. return(STC); //when RESELECT use the mouse reselect result
  1836. else {
  1837. if (!bx_inpt_on)
  1838. { cls_bx_disp(1);
  1839. sent_back_msg();
  1840. }
  1841. step_mode=ONINPUT;
  1842. bx_inpt_on=1; }//else
  1843. } //if (step_mode)
  1844. }//if (if_number...)
  1845. if (bx_inpt_on){
  1846. bx_proc(input_char,wParam);
  1847. return(CLC);
  1848. }
  1849. return(STC);
  1850. }
  1851. /**********************************************************************
  1852. FUNTION: bx_proc(WORD)
  1853. PURPOSE: when the pure bx were inputed, find one chinese word
  1854. corespond with it and eight related words with it.
  1855. ***********************************************************************/
  1856. void WINAPI bx_proc(input_char,wParam)
  1857. WORD input_char;
  1858. WPARAM wParam;
  1859. {
  1860. int i;
  1861. lib_p=(BYTE *)lib_w; //lib_p point to the lib_buffer
  1862. switch (bx_analize(input_char,wParam))
  1863. {
  1864. case BX_CHOICE:
  1865. if (input_char>=0x8000){
  1866. current_no=(input_char - 0x8000-0x31)+disp_head;
  1867. sImeG.InbxProc = 0;
  1868. }else
  1869. current_no=((INT)wParam - 0x31)+disp_head;
  1870. if(current_no>=group_no){
  1871. MessageBeep(0);
  1872. disp_help_and_result();
  1873. }else
  1874. send_bx_result();
  1875. break;
  1876. case BX_SELECT:
  1877. word_select_bx(input_char);
  1878. break;
  1879. case ESC:
  1880. cls_bx_disp(0);
  1881. break;
  1882. case OTHER:
  1883. MessageBeep(0);
  1884. disp_help_and_result();
  1885. break;
  1886. case SPACE:
  1887. send_bx_result();
  1888. break;
  1889. case BXMA:
  1890. if(!disp_help_and_result()){
  1891. if(in.true_length>1){
  1892. in.true_length--;
  1893. MessageBeep(0);
  1894. disp_help_and_result();
  1895. }
  1896. }
  1897. break;
  1898. default:
  1899. break;
  1900. }//swith
  1901. }
  1902. /********************************************************************
  1903. word_select(wParam): select the word or turn to the next or up page
  1904. *********************************************************************/
  1905. word_select_bx(input_char)
  1906. int input_char;
  1907. {
  1908. int x;
  1909. switch (input_char){
  1910. case VK_END*0x100:
  1911. case VK_DOWN*0x100:
  1912. case '=': //94/8/22
  1913. case ']':
  1914. if (disp_tail>=group_no)
  1915. MessageBeep(0);
  1916. else{
  1917. if(input_char == VK_END*0x100 ){
  1918. disp_head = (group_no - 1)/now.fmt_group*now.fmt_group;
  1919. disp_tail = disp_head;}
  1920. fmt_transfer();
  1921. current_no=disp_tail;
  1922. prompt_disp();}
  1923. return(1); //means break the STD MODE
  1924. case VK_HOME*0x100:
  1925. case '-': //94/8/22
  1926. case '[':
  1927. case VK_UP*0x100:
  1928. if (disp_head==0)
  1929. MessageBeep(0);
  1930. else{
  1931. if(input_char == VK_HOME*0x100 )
  1932. disp_head = 0;
  1933. else
  1934. disp_head=disp_head-now.fmt_group;
  1935. disp_tail=disp_head;
  1936. fmt_transfer();
  1937. current_no=disp_tail;
  1938. prompt_disp();
  1939. }
  1940. return(1);
  1941. default:
  1942. return(1); //1993.1.15 cock
  1943. }
  1944. }
  1945. /************************************************************************
  1946. FUNTION: bx_analize(WORD)
  1947. PURPOSE: analize the input char. find out if it is pure bx
  1948. *************************************************************************/
  1949. int WINAPI bx_analize(input_char,wParam)
  1950. WORD input_char;
  1951. WPARAM wParam;
  1952. {
  1953. if(input_char>=0x8000) return(BX_CHOICE);
  1954. if (input_char == VK_UP*0x100)
  1955. return(BX_SELECT);
  1956. if (input_char == VK_DOWN*0x100)
  1957. return(BX_SELECT);
  1958. if (input_char == VK_HOME*0x100)
  1959. return(BX_SELECT);
  1960. if (input_char == VK_END*0x100)
  1961. return(BX_SELECT);
  1962. if (input_char == ']')
  1963. return(BX_SELECT);
  1964. if (input_char == '[')
  1965. return(BX_SELECT);
  1966. if (input_char == '-')
  1967. return(SELECT);
  1968. if (input_char == '=')
  1969. return(SELECT);
  1970. if (input_char==VK_ESCAPE)
  1971. return(ESC);
  1972. if (input_char==VK_SPACE)
  1973. {
  1974. in.info_flag=0x80; //standard end flag
  1975. return(SPACE);
  1976. }
  1977. if (input_char==VK_RETURN)
  1978. {
  1979. in.info_flag=0x80; //standard end flag
  1980. return(SPACE);
  1981. }
  1982. if (input_char==VK_BACK)
  1983. {
  1984. if (in.true_length==1)
  1985. {
  1986. input_char=VK_ESCAPE; //if it has inputed only one word
  1987. return(ESC);
  1988. } //cls the display
  1989. in.true_length--;
  1990. key_bx_code_long=in.true_length;
  1991. return(BXMA);
  1992. }
  1993. if (!if_bx_number((BYTE)input_char))
  1994. {
  1995. if( ((BYTE)wParam>'0') && ((BYTE)wParam <= CANDPERPAGE+0x30))
  1996. return (BX_CHOICE);
  1997. in.info_flag=(BYTE)input_char; //rest key is put into the end_flag position
  1998. return(OTHER);
  1999. }
  2000. if ((input_char>0x30)||(input_char<0x39))
  2001. {
  2002. if (in.true_length>6)
  2003. {
  2004. in.info_flag=(BYTE)input_char;
  2005. return(OTHER);
  2006. }
  2007. else
  2008. {
  2009. in.buffer[in.true_length++]=(BYTE)input_char;
  2010. key_bx_code_long=in.true_length;
  2011. return(BXMA);
  2012. }
  2013. }
  2014. else{
  2015. in.info_flag=(BYTE)input_char;
  2016. return(OTHER);
  2017. }
  2018. }
  2019. /************************************************************************
  2020. FUCTION: disp_help_and_result()
  2021. PURPOSE: seach the bx_table and display the tishi result
  2022. ENTRY: bx string is in inpt_bx.bf
  2023. RESULT: display the result and tishi information
  2024. **************************************************************************/
  2025. int WINAPI disp_help_and_result()
  2026. {
  2027. int i, pass_flag;
  2028. if (in.true_length==1)
  2029. if (in.buffer[0]!=in_mem_part) //if this part of table is in memory
  2030. load_one_part_bxtab();
  2031. for (i=0; i<in.true_length; i++)
  2032. key_bx_code[i]=in.buffer[i]&0x0f; // 'and' high 4 bit
  2033. search_pointer=0;
  2034. current_bx_code_long=0;
  2035. pass_flag=0;
  2036. while (search_pointer<current_part_length)
  2037. {
  2038. if (cmp_bx_word_exactly())
  2039. { //search correct result
  2040. pass_flag=1;
  2041. break;
  2042. }
  2043. }
  2044. if (!pass_flag)
  2045. return 0;
  2046. for (i=0; i<8*2; i++)
  2047. out_svw[i]=0; //clear the prompt result buffer
  2048. search_pointer=0;
  2049. current_bx_code_long=0;
  2050. pass_flag=0;
  2051. while (search_pointer<current_part_length)
  2052. if (cmp_bx_code2()) //search the related prompt result
  2053. pass_flag=1; //if found it, set the flag and continue
  2054. if (pass_flag)
  2055. {
  2056. disp_bx_result();
  2057. disp_bx_prompt();
  2058. }
  2059. else
  2060. {
  2061. if (group_no>1){ //1993.3
  2062. disp_bx_result(); //1993.3
  2063. disp_bx_prompt();
  2064. }
  2065. else //1993.3
  2066. send_bx_result();
  2067. }
  2068. return 1;
  2069. }
  2070. /***********************************************************************
  2071. FUCTION: cmp_bx_word_exactly()
  2072. PURPOSE: find the correct result position, and send the result
  2073. into buffer.
  2074. ENTRY: the input bx is in the key_bx_code buffer
  2075. RESULT: CLC--- the input bx is matched with the current bx in the table
  2076. the correct result is in the out_svw buffer
  2077. STC--- not match
  2078. the search_pointer points the position the next bx in
  2079. the table.
  2080. ************************************************************************/
  2081. int WINAPI cmp_bx_word_exactly()
  2082. {
  2083. BYTE x;
  2084. int i;
  2085. for (i=0;i<20;i++)
  2086. result_area[i]= 0;
  2087. conbine(); //get the bx from the bx_table
  2088. result_area_pointer=0;
  2089. if (key_bx_code_long==current_bx_code_long){
  2090. if (cmp_subr()){
  2091. group_no=0;
  2092. search_pointer++;
  2093. while (lib_p[search_pointer]>0xa0){
  2094. // result_area[result_area_pointer++]=group_no|0x40;
  2095. // result_area[result_area_pointer++]=0x2e;
  2096. result_area[result_area_pointer++]=lib_p[search_pointer++]; //save the "quma"
  2097. result_area[result_area_pointer++]=lib_p[search_pointer++]; //save the "weima"
  2098. // result_area[result_area_pointer++]=0x20;
  2099. group_no++; //sum of chinese word
  2100. }//while
  2101. return(CLC);
  2102. }//if (cmp_subr())
  2103. }//if(key_bx_code_long)
  2104. search_pointer++;
  2105. while (lib_p[search_pointer]>=0xa0)
  2106. search_pointer+=2; //move the pointer to the beginning
  2107. return(STC); //of the next bx in the table
  2108. }
  2109. /**************************************************************************
  2110. FUCTION: cmp_bx_code2()
  2111. PURPOSE: search the prompt information and get the chinese word
  2112. which is related with the input.
  2113. **************************************************************************/
  2114. int WINAPI cmp_bx_code2()
  2115. {
  2116. WORD x;
  2117. conbine(); //get the bx from the bx_table
  2118. if (key_bx_code_long==(current_bx_code_long-1)){
  2119. if (cmp_subr()){
  2120. bx_help_flag|=0x80;
  2121. x=(lib_p[search_pointer++]&0x0f)-1;
  2122. if (x>7) //if the bx overflow
  2123. x=7;
  2124. out_svw[x*2]=lib_p[search_pointer++]; //get the prompt bx
  2125. out_svw[x*2+1]=lib_p[search_pointer++];
  2126. while (lib_p[search_pointer]>0xa0)
  2127. search_pointer+=2; //move the pointer to the next string
  2128. return(CLC);
  2129. }//if (cmp_subr())
  2130. }//if (key_bx_code_long)
  2131. search_pointer++;
  2132. while (lib_p[search_pointer]>0xa0)
  2133. search_pointer+=2; //move the pointer to the next string
  2134. return(STC);
  2135. }
  2136. /************************************************************************
  2137. FUCTION: conbine()
  2138. PURPOSE: get the bx from the table and change the high 4 bit into
  2139. the position where the last bit of bx should put in and
  2140. get this string of bx's length.
  2141. *************************************************************************/
  2142. void WINAPI conbine()
  2143. {
  2144. int x;
  2145. x=(lib_p[search_pointer]>>4)&0x0f;
  2146. current_bx_code[x]=lib_p[search_pointer]&0x0f;
  2147. current_bx_code_long=x+1;
  2148. }
  2149. /***********************************************************************
  2150. FUCTION: cmp_surb()
  2151. PURPOSE: compare the input bx with the bx in the table
  2152. ************************************************************************/
  2153. int WINAPI cmp_subr()
  2154. {
  2155. int i;
  2156. for (i=0; i<key_bx_code_long; i++)
  2157. if(key_bx_code[i]!=current_bx_code[i])
  2158. return(STC);
  2159. return(CLC);
  2160. }
  2161. void WINAPI cls_bx_disp(int flag)
  2162. {
  2163. if(!flag)
  2164. cls_prompt();
  2165. input_cur=input_msg_disp;
  2166. cs_p(input_msg_disp);
  2167. in.true_length=0;
  2168. in.info_flag=0;
  2169. bx_inpt_on=0;
  2170. group_no=0;
  2171. current_no = 0;
  2172. step_mode=START;
  2173. }
  2174. int WINAPI load_one_part_bxtab()
  2175. {
  2176. int hd, close_hd;
  2177. int op_count,i;
  2178. WORD distance;
  2179. in_mem_part=in.buffer[0]&0x0f; //save the current first bx ma
  2180. distance=bxtable_ndx[in_mem_part-1]; //get the beginning position
  2181. current_part_length=bxtable_ndx[in_mem_part]-distance; //get the read length
  2182. hd=OpenFile("winabc.ovl",&reopen,OF_READ);
  2183. if (hd==-1)
  2184. {
  2185. err_exit_proc("OPEN WINABC.OVL ERROR!");
  2186. return (FALSE);
  2187. }
  2188. _llseek(hd,distance,0);
  2189. last_size=0;
  2190. last_item_name=0;
  2191. op_count=_lread(hd,&lib_w,current_part_length);
  2192. lib_p[op_count]=0;
  2193. lib_p[op_count+1]=0; // cls the below limited
  2194. if (op_count!=current_part_length)
  2195. {
  2196. err_exit_proc("READ WINABC.OVL ERROR!");
  2197. close_hd = _lclose(hd);
  2198. return (FALSE);
  2199. }
  2200. close_hd = _lclose(hd);
  2201. return (TRUE);
  2202. }
  2203. int WINAPI disp_bx_result()
  2204. {
  2205. BYTE buffer[50];
  2206. int keep_cs, i;
  2207. for (i=0; i<50; i++) buffer[i] = ' ' ;
  2208. input_cur=input_msg_disp;
  2209. cs_p(input_msg_disp);
  2210. for (i=0; i<in.true_length; i++)
  2211. buffer[i]= in.buffer[i];
  2212. show_char(buffer, i);
  2213. now_cs= i; //restore
  2214. cs_p(now_cs); //disp cs
  2215. return (0);
  2216. }
  2217. void WINAPI disp_bx_prompt()
  2218. {
  2219. int i,j,n;
  2220. HWND hhh;
  2221. int GroupCounter;
  2222. BYTE buffer [100];
  2223. disp_head=0;
  2224. disp_tail=8;
  2225. j=0,n=0;
  2226. GroupCounter= 0;
  2227. if (group_no) { //if the results are more the 5
  2228. for (i=0; i<group_no*2; i=i+2) //display the rest in the prompt area
  2229. if(result_area[i]){
  2230. buffer[j++]=result_area[i];
  2231. buffer[j++]=result_area[i+1];
  2232. buffer[j++]=0xa1;
  2233. buffer[j++]=0xa1;}
  2234. }
  2235. n =group_no*2;
  2236. for(i=0; i<16; i = i+2){
  2237. if(out_svw[i]){
  2238. buffer[j++] = out_svw[i];
  2239. result_area[n++] = out_svw[i];
  2240. buffer[j++] = out_svw[i+1];
  2241. result_area[n++] = out_svw[i+1];
  2242. buffer[j++] = 0xa2;
  2243. buffer[j++] = 0xd9+GroupCounter;}
  2244. GroupCounter++;
  2245. }//for
  2246. group_no = j/4;
  2247. unit_length = 4;
  2248. current_no=0;
  2249. disp_tail=0;
  2250. V_Flag=0;
  2251. msg_type=2; //94/8/22
  2252. fmt_transfer();
  2253. SetToIMC(ghIMC,(LPSTR)&buffer,(WORD)group_no,(WORD)(unit_length+0x1000));
  2254. prompt_disp();
  2255. step_mode=SELECT;
  2256. }
  2257. void WINAPI send_bx_result()
  2258. {
  2259. out_length=1;
  2260. send_msg(&result_area[current_no*2],2);
  2261. cls_bx_disp(1);
  2262. }
  2263. ////////////////////////////////////////////////////////////////////////
  2264. // ��ʼ�������� data_init() //
  2265. // ����: ���������ļ� //
  2266. // ���� 1. ?MMR.REM //
  2267. // 2. ������������, ������Ƶ�ȱ�,�����ʻ��� //
  2268. // 3. ������׼�ʿ����û��ʿ��IJ���. //
  2269. // 4. ����TMMR.REM, �����û��ʿⲻ����,����֮. //
  2270. // 5. �����û��ʿ� //
  2271. // ���ڲ���: �� //
  2272. // ���ڲ���: TURE ��ʼ���ɹ� //
  2273. // FALSE ��ʼ��ʧ�� //
  2274. ////////////////////////////////////////////////////////////////////////
  2275. void WINAPI data_init()
  2276. {
  2277. BYTE new_flag=0; //һ�δ����û��ļ�?
  2278. BYTE the_para='U'; //�����IJ���
  2279. BYTE disp_mode=0;
  2280. BYTE current_dd=0;
  2281. BYTE current_disk='C';
  2282. BYTE current_path[64];
  2283. HFILE hd;
  2284. DWORD op_count;
  2285. BYTE tmp_buffer[16]={0};
  2286. int i;
  2287. char god[]="WINABC.CWD";
  2288. char cw_ovr[]="WINABC.OVL";
  2289. char no_file[]=ERR01; //ȱ�ٴʿ��ļ�WINABC.CWD
  2290. char read_ndx_wrong[]=ERR03; //"�ļ���������";
  2291. char m_short[]=ERR14; //"�ڴ治����";
  2292. char no_cw_ovr[]=ERR04; //"ȱ�ٻ������ļ�WINABC.OVL��";
  2293. char jiyi_wenjian_cuo[]=ERR13; //"�û������ļ�������!";
  2294. char TMMR_WRITE_WRONG[]=ERR09; // "�����ļ�д��";
  2295. OFSTRUCT ofs;
  2296. LPSTR cisu_1;
  2297. memset(tmmr_rem, 0, sizeof(tmmr_rem));
  2298. memset(user_lib, 0, sizeof(user_lib));
  2299. // support multi-user
  2300. lstrcpy(tmmr_rem, sImeG.szIMEUserPath);
  2301. lstrcat(tmmr_rem, TEXT("\\tmmr.rem") );
  2302. lstrcpy(user_lib, sImeG.szIMEUserPath);
  2303. lstrcat(user_lib, TEXT("\\user.rem") );
  2304. hd =OpenFile(god, &ofs, OF_READ|OF_SHARE_COMPAT|GENERIC_READ);
  2305. if ( hd==HFILE_ERROR)
  2306. err_exit(no_file);
  2307. op_count = _lread(hd,&ndx,NDX_REAL_LENGTH);
  2308. if(op_count!=NDX_REAL_LENGTH)
  2309. err_exit(read_ndx_wrong);
  2310. _lclose(hd);
  2311. hd = OpenFile(cw_ovr, &ofs, OF_READ|OF_SHARE_COMPAT|GENERIC_READ);
  2312. if (hd==HFILE_ERROR)
  2313. err_exit(no_cw_ovr);
  2314. _llseek(hd, PTZ_LIB_START_POINTER, FILE_BEGIN); // ����ָ��
  2315. cisu_hd=GlobalAlloc(GMEM_MOVEABLE,(DWORD)PTZ_LIB_LENGTH);
  2316. if (!cisu_hd)
  2317. {
  2318. err_exit(ERR22); //Memory Alloc Wrong!");
  2319. _lclose(hd);
  2320. return;
  2321. }
  2322. cisu_1=GlobalLock(cisu_hd); /*GlobalWire* for v32*/
  2323. if (!cisu_1)
  2324. err_exit(ERR22); //"Memory Alloc Wrong!");
  2325. cisu=(struct TBF FAR *)cisu_1;
  2326. op_count=_lread((HFILE)hd,(LPSTR)&cisu->t_bf_start,PTZ_LIB_LENGTH); // ������������
  2327. if (op_count!=PTZ_LIB_LENGTH)
  2328. err_exit(ERR06); //"Read WINABC.OVL Wrong!");
  2329. _llseek((HFILE)hd, PD_START_POINTER, 0); //����ָ��
  2330. op_count=_lread((HFILE)hd,(LPSTR)&pindu.pd_bf0,PD_LENGTH); //������ӡ����Ƶ�ȱ�
  2331. if (op_count!=PD_LENGTH)
  2332. err_exit(ERR06); //("Read WINABC.OVL Wrong!");
  2333. _llseek(hd, SPBX_START_POINTER, 0); //����ָ��
  2334. op_count=_lread(hd,(LPSTR)&spbx_tab,SPBX_LENGTH); // �����������α�
  2335. if (op_count!=SPBX_LENGTH)
  2336. err_exit(ERR06); //("Read WINABC.OVL Wrong!");
  2337. _lclose((HFILE)hd);
  2338. if (CheckAndCreate(tmmr_rem,user_lib)){
  2339. hd = OpenFile(tmmr_rem, &ofs, OF_READWRITE); //1993.4.15
  2340. if (hd==HFILE_ERROR)
  2341. err_exit(ERR13); //(jiyi_wenjian_cuo);
  2342. op_count=_lread(hd,(LPSTR)&tmmr,TMMR_REAL_LENGTH);
  2343. if (op_count!=TMMR_REAL_LENGTH)
  2344. err_exit(ERR06); //(jiyi_wenjian_cuo);
  2345. _llseek(hd,TMMR_REAL_LENGTH,0); //move the pointer to the paremeter area
  2346. op_count=_lread(hd,tmp_buffer, PAREMETER_LENGTH); //read the paremeters to the buffer
  2347. if (!op_count) { //1993.4.15 if old tmmr.rem hasn't this ten parameters
  2348. memset(tmp_buffer, 0 , PAREMETER_LENGTH);
  2349. tmp_buffer[0] = (BYTE)IfTopMost; //transfer the peremeters
  2350. tmp_buffer[1] = sImeG.auto_mode ;
  2351. tmp_buffer[2] = bdd_flag;
  2352. tmp_buffer[3] = sImeG.cbx_flag;
  2353. op_count = _lwrite((HFILE)hd, rem_area, PAREMETER_LENGTH); //writer the file
  2354. if (op_count!=PAREMETER_LENGTH)
  2355. err_exit (ERR09); //(TMMR_WRITE_WRONG);
  2356. }//if (!op_count)
  2357. else {
  2358. if (op_count!=PAREMETER_LENGTH)
  2359. err_exit(ERR08); //(jiyi_wenjian_cuo);
  2360. }//else
  2361. _lclose(hd);
  2362. IfTopMost = tmp_buffer[0]; //transfer the paremeter
  2363. sImeG.auto_mode = tmp_buffer[1]; //1993.4
  2364. bdd_flag = tmp_buffer[2];
  2365. sImeG.cbx_flag = tmp_buffer[3];
  2366. hd = OpenFile(user_lib, &ofs, OF_READ); //1993.4.15
  2367. if (hd==-1)
  2368. err_exit(ERR10); //(jiyi_wenjian_cuo);
  2369. _llseek(hd,0xa000l,0);
  2370. op_count=_lread(hd,(LPSTR)&kzk_ndx,NDX_REAL_LENGTH);
  2371. if (op_count!=NDX_REAL_LENGTH)
  2372. err_exit(ERR11); //(jiyi_wenjian_cuo);
  2373. _lclose(hd);
  2374. }
  2375. }
  2376. //
  2377. //Popose: check user_word dictionary files "TMMR.REM"
  2378. // "USER.REM"
  2379. // If they are not exist, created.
  2380. //
  2381. int WINAPI CheckAndCreate(tmmr_rem,user_rem)
  2382. BYTE *tmmr_rem,*user_rem;
  2383. {
  2384. struct INDEX user_file_head;
  2385. struct M_NDX mulu_head={
  2386. 0,
  2387. 0, //MULU_START_LOW Ŀ¼��д���ֽ�
  2388. 0x1800, //MULU_LENGTH_MAX SIZELIB+SIZELIB_KZK Ŀ¼���󳤶�=�����صij���
  2389. 0x10, //MULU_TRUE_LENGTH 10H Ŀ¼��ʵ�ʳ���,��ʼֻ�в���.
  2390. 0xA, //MULU_RECORD_LENGTH 10 Ŀ¼ÿ����¼�ij��ȡ�
  2391. 0, //DATA_START_HI 0 �����û��ļ�������64K֮��.
  2392. 0x1800, //DATA_START_LOW DW SIZE LIB_W Ŀ¼�����������������ν�.
  2393. 0x20}; //DATA_RECORD_LENGTH 32 ÿ����¼�ij���.
  2394. OFSTRUCT ofs;
  2395. int hd,i,count;
  2396. HANDLE hMem;
  2397. LPSTR rem_area,p;
  2398. WORD *pp;
  2399. char TMMR_OPEN_WRONG[]= ERR07; //"�����ļ��򿪴�";
  2400. char TMMR_READ_WRONG[]= ERR08; //"�����ļ�����";
  2401. char TMMR_WRITE_WRONG[]=ERR09; // "�����ļ�д��";
  2402. char USER_OPEN_WRONG[]= ERR10; //"�û��ʿ��򿪴�";
  2403. char USER_READ_WRONG[]= ERR11; //"�û��ʿ�����";
  2404. char USER_WRITE_WRONG[]=ERR12; // "�û��ʿ�д��";
  2405. hMem=GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT ,TMMR_LIB_LENGTH );
  2406. if ( hMem == NULL )
  2407. return 0;
  2408. rem_area=GlobalLock(hMem);
  2409. hd = OpenFile(tmmr_rem, &ofs, OF_READ);
  2410. if (hd!=-1){
  2411. count = _lread(hd, rem_area, TMMR_LIB_LENGTH);
  2412. if ((rem_area[CHECK_POINT]=='T')&& (rem_area[CHECK_POINT+1]=='X')
  2413. && (rem_area[CHECK_POINT+2]=='L')
  2414. && (rem_area[CHECK_POINT+3]=='N'))
  2415. _lclose(hd);
  2416. else
  2417. _lclose(hd),hd=-1;
  2418. } // if (hd!=-1)....
  2419. if (hd==-1){
  2420. hd = OpenFile(tmmr_rem, &ofs, OF_CREATE|OF_SHARE_DENY_NONE);
  2421. if (hd==-1)
  2422. err_exit(TMMR_OPEN_WRONG);
  2423. else{
  2424. for (i = 0; i<TMMR_LIB_LENGTH; i++)
  2425. rem_area[i]=0; // Init the temp rem
  2426. // area by zero.
  2427. rem_area[CHECK_POINT]='T';
  2428. rem_area[CHECK_POINT+1]='X';
  2429. rem_area[CHECK_POINT+2]='L';
  2430. rem_area[CHECK_POINT+3]='N';
  2431. //give Mark!
  2432. count = _lwrite(hd, rem_area, TMMR_LIB_LENGTH);
  2433. if (count!=TMMR_LIB_LENGTH)
  2434. err_exit(TMMR_WRITE_WRONG);
  2435. for (i=0; i<PAREMETER_LENGTH; i++)
  2436. rem_area[0]=0; //clear the buffer
  2437. rem_area[0] = (CHAR)IfTopMost; //transfer the peremeters
  2438. rem_area[1] = sImeG.auto_mode =0;
  2439. rem_area[2] = bdd_flag=0;
  2440. rem_area[3] = sImeG.cbx_flag=0;
  2441. count = _lwrite(hd, rem_area, PAREMETER_LENGTH); //writer the file
  2442. if (count!=PAREMETER_LENGTH)
  2443. err_exit (TMMR_WRITE_WRONG);
  2444. _lclose(hd); //close the file
  2445. } //else...
  2446. }//if (hd==-1)...
  2447. //
  2448. // Check or create TMMR.REM file is over. Now, deel with USER.REM.
  2449. //
  2450. hd = OpenFile(user_rem, &ofs, OF_READ);
  2451. if (hd!=-1){
  2452. _llseek(hd,(LONG)LENGTH_OF_USER, 0);
  2453. count = _lread(hd, rem_area, NDX_REAL_LENGTH);
  2454. if ((rem_area[CHECK_POINT2]=='T')&&(rem_area[CHECK_POINT2+1]=='X')
  2455. &&(rem_area[CHECK_POINT2+2]=='L')
  2456. && (rem_area[CHECK_POINT2+3]=='N'))
  2457. _lclose(hd);
  2458. else
  2459. _lclose(hd),hd=-1;
  2460. } // if (hd!=-1)....
  2461. if (hd==-1){
  2462. hd = OpenFile(user_rem, &ofs, OF_CREATE|OF_SHARE_DENY_NONE);
  2463. if (hd==-1)
  2464. err_exit(USER_OPEN_WRONG);
  2465. else{
  2466. for (i = 0; i<TMMR_LIB_LENGTH ; i++)
  2467. rem_area[i]=0; // Init the temp rem
  2468. // area by zero.
  2469. // First, write file para for force remenber.
  2470. p=(BYTE *)&mulu_head.mulu_start_hi;
  2471. for (i=0; i<16; i++) rem_area[i]=p[i];
  2472. // Init force rem file
  2473. for (i=0; i<LENGTH_OF_USER/0x1000; i++){
  2474. count = _lwrite(hd, rem_area, 0x1000);
  2475. if (count!=0x1000 )
  2476. err_exit(USER_WRITE_WRONG);}
  2477. //Init user dictionary file
  2478. p=(BYTE *)&user_file_head.body_start;
  2479. for (i=0; i<sizeof user_file_head;i++) p[i]=0;
  2480. user_file_head.body_start=NDX_REAL_LENGTH/16;
  2481. user_file_head.ttl_length=NDX_REAL_LENGTH/16;
  2482. user_file_head.body_length=0;
  2483. user_file_head.index_start=3;
  2484. user_file_head.index_length=NDX_REAL_LENGTH/16-3;
  2485. user_file_head.unused1=0x2000;
  2486. p[CHECK_POINT2]='T';
  2487. p[CHECK_POINT2+1]='X';
  2488. p[CHECK_POINT2+2]='L';
  2489. p[CHECK_POINT2+3]='N';
  2490. //give Mark!
  2491. count = _lwrite(hd,(LPSTR)&user_file_head, NDX_REAL_LENGTH );
  2492. if (count!=NDX_REAL_LENGTH )
  2493. err_exit(TMMR_WRITE_WRONG);
  2494. _lclose(hd);
  2495. } //else...
  2496. }//if (hd==-1)...
  2497. GlobalUnlock(hMem);
  2498. GlobalFree(hMem);
  2499. return(CLC);
  2500. }// create and check
  2501. //
  2502. // ������������,ĿǰΪģ��������, ��������Ϊһ���Ի���
  2503. // ���ص���Ϣ����: RETRY, IGNORE, CANCEL
  2504. //
  2505. void WINAPI err_exit(err_msg)
  2506. char *err_msg;
  2507. {
  2508. MessageBox(hWnd, err_msg, "ERR", MB_OKCANCEL);
  2509. PostMessage(hWnd,WM_DESTROY,0,0l);
  2510. }
  2511. void WINAPI err_exit_proc( err_msg)
  2512. char *err_msg;
  2513. {
  2514. MessageBox(NULL, err_msg, "ERR", MB_OKCANCEL);
  2515. return ;
  2516. }
  2517. int WINAPI GetText32( HDC hdc,LPCTSTR lpString,int cbString)
  2518. {
  2519. SIZE lSize;
  2520. GetTextExtentPoint32(hdc,lpString,cbString,(LPSIZE)&lSize);
  2521. return lSize.cx;
  2522. }
  2523. int WINAPI makep(LPARAM lParam, LPPOINT oldPoint)
  2524. {
  2525. POINTS newPoint;
  2526. newPoint=MAKEPOINTS(lParam);
  2527. oldPoint->x=(WORD)newPoint.x;
  2528. oldPoint->y=(WORD)newPoint.y;
  2529. return 0;
  2530. }
  2531. /*******************************************************
  2532. &3:
  2533. cwp_proc():
  2534. ********************************************************/
  2535. int WINAPI cwp_proc(mtype)
  2536. int mtype;
  2537. {
  2538. int i, j, m;
  2539. BYTE x;
  2540. switch (mtype){
  2541. case 0:
  2542. return(normal()); //normal pinyin convert
  2543. case 1:
  2544. abbr(); //ABBR
  2545. return(normal());
  2546. case 2: // "I" capital chinese number
  2547. case 3: // "i" small chinese number
  2548. if (in.true_length==1){
  2549. in.buffer[1]='1';
  2550. in.true_length++;}
  2551. if (in.true_length>20) in.true_length=20;
  2552. m=0;
  2553. for(i=1; i<in.true_length; i++){
  2554. x=in.buffer[i];
  2555. if (if_number_or_not(in.buffer[i])){
  2556. if (mtype==2)
  2557. x=in.buffer[i]-0x30;
  2558. }
  2559. if (if_zimu_or_not(in.buffer[i])){
  2560. x=in.buffer[i]&0xdf;
  2561. if (mtype==2)
  2562. if (x=='S' || x=='B' || x=='Q')
  2563. x=x|0x20;
  2564. }
  2565. for (j=0; j<160; j=j+3){
  2566. if (x==fk_tab[j]){
  2567. out_svw[m++]=fk_tab[j+1];
  2568. out_svw[m++]=fk_tab[j+2];
  2569. x=0xff; // found it
  2570. break;}
  2571. }// for(j)
  2572. if (x!=0xff)
  2573. goto err_back;
  2574. } // for(i)
  2575. group_no=1;
  2576. unit_length=m;
  2577. msg_type=2;
  2578. return(1); // success!
  2579. case 4: // "u" user define word
  2580. return(user_definition());
  2581. case 12: //continue to change
  2582. return(find_next());
  2583. case 13: // backword
  2584. return(normal_1(word_back_flag));
  2585. case 14:
  2586. return(recall());
  2587. default:
  2588. err_back:
  2589. return(-1);
  2590. }// switch
  2591. }
  2592. /************************************************
  2593. find_next()
  2594. *************************************************/
  2595. int WINAPI find_next()
  2596. {
  2597. if (wp.yjs<=wp.xsyjw)
  2598. return(STC);
  2599. return( normal_1(0) );
  2600. }
  2601. /*************************************************
  2602. normal()
  2603. **************************************************/
  2604. int WINAPI normal()
  2605. {
  2606. extb_ps=0xffff;
  2607. by_cchar_flag=0;
  2608. wp.yjs=0;
  2609. wp.xsyjw=0;
  2610. wp.dw_count=0;
  2611. wp.dw_stack[0]=0;
  2612. if (in.info_flag==0x81)
  2613. by_cchar_flag=1;
  2614. detail_analyse();
  2615. if (!convert(0)){
  2616. zdyb();
  2617. return(STC);
  2618. }
  2619. wp.xsyjs=wp.xsyjw;
  2620. wp.xsyjw+=word_long;
  2621. wp.dw_stack[++wp.dw_count]=(BYTE)wp.xsyjw;
  2622. if (by_cchar_flag!=1){
  2623. if (wp.yjs==wp.xsyjw){
  2624. if (wp.xsyjs!=0){
  2625. sfx_attr=2; //mark for finding sfx_table
  2626. rzw();}
  2627. }//if (wp.xsyjs)
  2628. else{
  2629. if (word_long<=1){
  2630. if (wp.xsyjs==0){
  2631. sfx_attr=1; //mark for finding sfx_table
  2632. rzw();}//if (wp.xsyjs)
  2633. }//if (word_long)
  2634. }//else
  2635. }//if (by_cchar...
  2636. if (wp.yjs<=wp.xsyjw)
  2637. jiyi_mode=0;
  2638. else
  2639. jiyi_mode=1;
  2640. return(CLC);
  2641. }
  2642. /*******************************************************
  2643. normal_1()
  2644. ********************************************************/
  2645. int WINAPI normal_1(flag)
  2646. int flag;
  2647. {
  2648. if (in.info_flag==0x81)
  2649. by_cchar_flag=1;
  2650. if (!convert(flag)){
  2651. zdyb();
  2652. return(STC);
  2653. }
  2654. wp.xsyjs=wp.xsyjw;
  2655. wp.xsyjw+=word_long;
  2656. wp.dw_stack[++wp.dw_count]=(BYTE)wp.xsyjw;
  2657. if (by_cchar_flag!=1){
  2658. if (wp.yjs==wp.xsyjw){
  2659. if (wp.xsyjs!=0){
  2660. sfx_attr=2; //mark for finding sfx_table
  2661. rzw();}
  2662. }//if (wp.xsyjs)
  2663. else{
  2664. if (word_long<=1){
  2665. if (wp.xsyjs==0){
  2666. sfx_attr=1; //mark for finding sfx_table
  2667. rzw();}//if (wp.xsyjs)
  2668. }//if (word_long)
  2669. }//else
  2670. }//if (by_cchar...
  2671. if (wp.yjs<=wp.xsyjw)
  2672. jiyi_mode=0;
  2673. else
  2674. jiyi_mode=1;
  2675. return(CLC);
  2676. }
  2677. //////////////////////////////////////////////////////////////////////////
  2678. //////////////////////////////////////////////////////////////////////////
  2679. int WINAPI recall()
  2680. {
  2681. cls_prompt_only();
  2682. in.info_flag=1;
  2683. wp.yjs=0;
  2684. wp.xsyjw=0;
  2685. by_cchar_flag=0;
  2686. detail_analyse();
  2687. if (!recall_rc())
  2688. return(-1);
  2689. return (0);
  2690. }
  2691. /*************************************************************
  2692. user_definition(): produce the user define word
  2693. **************************************************************/
  2694. int WINAPI user_definition()
  2695. {
  2696. int i,rec_cnt;
  2697. kbf.max_length=in.max_length;
  2698. kbf.true_length=in.true_length-1; //delete the word "u"
  2699. for (i=0; i<kbf.true_length; i++)
  2700. kbf.buffer[i]=in.buffer[i+1];
  2701. read_mulu();
  2702. if (!(rec_cnt=look_for_code()))
  2703. return(STC); //not found
  2704. if (!read_data(rec_cnt-1)) //-1 get the real record count
  2705. return(STC); //not found
  2706. unit_length=out_svw[0]-0x30; //plus 1 is plus the mark
  2707. word_long=(out_svw[0]-0x30)/2;
  2708. group_no=1;
  2709. CopyMemory/*memmove*/(out_svw,&out_svw[2],unit_length);
  2710. msg_type|=2;
  2711. return(CLC);
  2712. }
  2713. /***************************************************************
  2714. detail_analyse()
  2715. ***************************************************************/
  2716. int WINAPI detail_analyse()
  2717. {
  2718. int i=0,j=0;
  2719. BYTE *p;
  2720. copy_input();
  2721. p=(BYTE *)kbf.buffer;
  2722. do{
  2723. if (!slbl(p)){
  2724. if (i==0)
  2725. return(STC);
  2726. else
  2727. break;
  2728. }
  2729. if (sb.length==0)
  2730. break;
  2731. p+=sb.length;
  2732. if (LOBYTE(sb.value)=='V')
  2733. if (sb.head=='J'||sb.head=='Q'||sb.head=='X')
  2734. (BYTE)sb.value='U';
  2735. wp.syj[i]=sb.head;
  2736. wp.bx_stack[i]=sb.bx1;
  2737. wp.tone[i]=sb.tune;
  2738. wp.yj[j]=sb.value; //WORD transport
  2739. wp.yj_ps[j]=(int)(p-(BYTE *)kbf.buffer);
  2740. i++, j++;
  2741. if (i>=10) //10 1994.4
  2742. break;
  2743. if (sb.flag==TRUE)
  2744. break;
  2745. }while(1);
  2746. wp.yjs=i;
  2747. input_msg_type();
  2748. return (0);
  2749. }
  2750. int WINAPI slbl(s_buffer)
  2751. BYTE *s_buffer;
  2752. {
  2753. int i=0,j;
  2754. BYTE cmp_buffer[5]={0};
  2755. char *p;
  2756. BYTE x,attr,y;
  2757. /* analize the SHENGMU */
  2758. x=s_buffer[i++];
  2759. attr=(BYTE)getattr(x,&x); // get char's attribute
  2760. if (!attr){
  2761. sb.length=i-1;
  2762. sb.flag=TRUE;
  2763. return(1);}
  2764. if (attr==NUMBER)
  2765. return(0); // error
  2766. if (x=='I' || x=='U' || x=='V')
  2767. return(0); // error
  2768. switch (attr) { //1993.4.22
  2769. case FIRST_T:
  2770. case SECOND_T:
  2771. case THIRD_T:
  2772. case FORTH_T:
  2773. return (0); //error
  2774. } //1993.4.22
  2775. sb.value=0;
  2776. sb.head=0;
  2777. sb.length=0;
  2778. sb.tune=0;
  2779. sb.bx1=0;
  2780. sb.bx2=0;
  2781. sb.flag=FALSE;
  2782. sb.head=x;
  2783. if (attr==FUYIN){
  2784. if (x=='Z' || x=='C' || x=='S' ){
  2785. if ((s_buffer[i]&0xdf)==0x48){
  2786. for (j=0; j<15; j=j+5){
  2787. if (x==slbl_tab[j]){
  2788. sb.value=(WORD)slbl_tab[j+4]<<8;
  2789. sb.head=slbl_tab[j+4];
  2790. break;}
  2791. }// for()
  2792. i++;
  2793. }// if (s_buffer)
  2794. else
  2795. sb.value=(WORD)x<<8;
  2796. }// if (x=='z')
  2797. else
  2798. sb.value=(WORD)x<<8;
  2799. }//if (attr==FUYIN)
  2800. else{
  2801. i--;
  2802. sb.value=0;
  2803. } //else
  2804. /* analize the YUNMU */
  2805. x=s_buffer[i];
  2806. attr=(BYTE)getattr(x,&x);
  2807. if (!attr){
  2808. sb.length=(WORD)i;
  2809. sb.flag=TRUE;
  2810. return(1);}
  2811. if (attr==YUANYIN){ //if no YUANYIN, goto step3
  2812. (BYTE)sb.value=x;
  2813. cmp_buffer[0]=x;
  2814. i++;
  2815. for (j=1; j<4; j++){
  2816. x=s_buffer[i++];
  2817. attr=(BYTE)getattr(x,&x);
  2818. if (!attr){
  2819. for (j=j; j<4; j++)
  2820. cmp_buffer[j]='0';
  2821. i--;
  2822. sb.flag=TRUE;
  2823. break;}
  2824. if (attr==NUMBER){
  2825. for (j=j; j<4; j++)
  2826. cmp_buffer[j]='0';
  2827. i--;
  2828. break;
  2829. }// if
  2830. else
  2831. cmp_buffer[j]=x;
  2832. }//for
  2833. for (j=3; j>0; j--){
  2834. p=(LPSTR)ABCstrstr((LPSTR)slbl_tab,cmp_buffer); //search the YUNMU
  2835. if (p!=NULL){
  2836. (BYTE)sb.value=*(p+4); //get the YUNMU value
  2837. break;
  2838. }// if (p)
  2839. if (cmp_buffer[j]!=0x30){
  2840. cmp_buffer[j]='0';
  2841. i--;}//if (cmp)
  2842. }// for(j)
  2843. }//if (x!=YUANYIN)
  2844. else
  2845. (BYTE)sb.value=0;
  2846. /* see if the next is YUANYIN */
  2847. x=s_buffer[i];
  2848. attr=(BYTE)getattr(x,&x);
  2849. if (!attr){
  2850. sb.length=(WORD)i;
  2851. sb.flag=TRUE;
  2852. if (sb.value<=0xff)
  2853. sb.value=sb.value<<8;
  2854. return(1);}
  2855. if (attr==YUANYIN){
  2856. y=s_buffer[i-1]&0xdf;
  2857. if (y=='R'||y=='N'||y=='G'){
  2858. i--;
  2859. (BYTE)sb.value=0;
  2860. for (j=3; j>0; j--){
  2861. if (cmp_buffer[j]!=0x30){
  2862. cmp_buffer[j]='0';
  2863. break;}//if
  2864. }//for
  2865. for (j=3; j>0; j--){
  2866. p=(LPSTR)ABCstrstr((LPSTR)slbl_tab,cmp_buffer); //search the YUNMU
  2867. if (p!=NULL){
  2868. (BYTE)sb.value=*(p+4); //get the YUNMU value
  2869. break;
  2870. }// if (p)
  2871. if (cmp_buffer[j]!=0x30){
  2872. cmp_buffer[j]='0';
  2873. i--;}//if (cmp)
  2874. }// for(j)
  2875. if (!(BYTE)sb.value)
  2876. (BYTE)sb.value=cmp_buffer[0];
  2877. }//if (y=='R')
  2878. }//if (attr==YUANYIN)
  2879. if (sb.value<=0xff)
  2880. sb.value=sb.value<<8;
  2881. /* analize the tune */
  2882. x=s_buffer[i];
  2883. attr=(BYTE)getattr(x,&x);
  2884. if (!attr){
  2885. sb.length=(WORD)i;
  2886. sb.flag=TRUE;
  2887. return(1);}
  2888. if (attr==FIRST_T||attr==SECOND_T||attr==THIRD_T||attr==FORTH_T){
  2889. sb.tune=attr;
  2890. i++;}
  2891. /* analize the BIXING */
  2892. for (j=0; j<6; j++){
  2893. x=s_buffer[i++];
  2894. attr=(BYTE)getattr(x,&x);
  2895. if (!attr){
  2896. sb.flag=TRUE;
  2897. sb.length=i-1;
  2898. return(1);}
  2899. if (attr==SEPERATOR){
  2900. sb.flag=FALSE;
  2901. sb.length=(WORD)i;
  2902. return(1); // if the string has seperator, move the
  2903. } // pointer to the beginning of next YINJIE
  2904. if (attr!=NUMBER){
  2905. do{ //1993.4.22
  2906. if (attr==YUANYIN || attr==FUYIN){
  2907. sb.flag=FALSE;
  2908. sb.length=i-1;
  2909. return(1);}
  2910. x=s_buffer[i++];
  2911. attr=(BYTE)getattr(x,&x);
  2912. if (!attr){
  2913. sb.flag=TRUE;
  2914. sb.length=i-1;
  2915. return(1);}
  2916. }while(i<100);
  2917. return (1);
  2918. } //1993.4.22
  2919. if (x>'0' && x<'9'){
  2920. switch(j){
  2921. case 0:
  2922. sb.bx1=x<<4;
  2923. break;
  2924. case 1:
  2925. sb.bx1+=x&0x0f;
  2926. break;
  2927. case 2:
  2928. sb.bx2=(WORD)x;
  2929. sb.bx2<<=12;
  2930. break;
  2931. case 3:
  2932. sb.bx2=sb.bx2+(WORD)((x&0xf)<<8);
  2933. break;
  2934. case 4:
  2935. (BYTE)sb.bx2=x<<4;
  2936. break;
  2937. case 5:
  2938. (BYTE)sb.bx2+=x&0x0f;
  2939. break;
  2940. }//switch
  2941. }//if(x)
  2942. }// for
  2943. do{
  2944. x=s_buffer[i++];
  2945. attr=(BYTE)getattr(x,&x);
  2946. if (!attr){
  2947. sb.flag=TRUE;
  2948. sb.length=i-1;
  2949. return(1);}
  2950. if (attr==YUANYIN || attr==FUYIN){
  2951. sb.flag=FALSE;
  2952. sb.length=(WORD)i;
  2953. return(1);}
  2954. }while(i<100);
  2955. return (0);
  2956. }
  2957. /*******************************************************
  2958. getchr(x)
  2959. *******************************************************/
  2960. int WINAPI getattr(x,p)
  2961. BYTE x;
  2962. char *p;
  2963. {
  2964. if (x==0)
  2965. return(FALSE);
  2966. if (if_number_or_not(x))
  2967. return(NUMBER);
  2968. if (if_zimu_or_not(x)){
  2969. x=x&0xdf;
  2970. *p=x;
  2971. if (x=='A'||x=='E'||x=='I'||x=='O'||x=='U'||x=='V')
  2972. return(YUANYIN);
  2973. else
  2974. return(FUYIN);
  2975. }
  2976. if (x==SEPERATOR)
  2977. return(SEPERATOR);
  2978. switch(x){
  2979. case '-':
  2980. return(FIRST_T);
  2981. case '/':
  2982. return(SECOND_T);
  2983. case '~':
  2984. case '^':
  2985. return(THIRD_T);
  2986. case '\\':
  2987. return(FORTH_T);
  2988. }
  2989. return (FALSE);
  2990. }
  2991. /*******************************************************
  2992. neg_slbl()
  2993. ********************************************************/
  2994. int WINAPI neg_slbl(value)
  2995. WORD value;
  2996. {
  2997. int i=0;
  2998. BYTE x;
  2999. s_tune();
  3000. x=HIBYTE(value);
  3001. if (x>=0x41)
  3002. neg.buffer[i++]=x;
  3003. else{
  3004. if (x!=0)
  3005. i=neg_sc(i,x);
  3006. }
  3007. x=LOBYTE(value);
  3008. if (x>=0x41)
  3009. neg.buffer[i++]=x;
  3010. else{
  3011. if (x!=0)
  3012. i=neg_sc(i,x);
  3013. }
  3014. neg.buffer[i]=sb.tune;
  3015. neg.length=i;
  3016. for (x=0; x<i+1; x++)
  3017. neg.buffer[x]=neg.buffer[x]|0x20;
  3018. return(1);
  3019. }
  3020. /******************************************
  3021. neg_sc(i,x)
  3022. *******************************************/
  3023. int WINAPI neg_sc(i,x)
  3024. int i;
  3025. BYTE x;
  3026. {
  3027. int j,n;
  3028. n=(x-1)*5;
  3029. for (j=0; j<4; j++){
  3030. if (slbl_tab[n+j]!=0x30)
  3031. neg.buffer[i++]=slbl_tab[n+j];
  3032. else
  3033. break;
  3034. }
  3035. return(i);
  3036. }
  3037. // if (in.buffer[2]==1)
  3038. // return(recall_rc());
  3039. //========================================================================
  3040. // Covert
  3041. //========================================================================
  3042. //
  3043. int WINAPI convert(flag)
  3044. int flag;
  3045. {
  3046. int j;
  3047. // if (sb.bx2!=0)
  3048. // return(0);
  3049. if (!flag)
  3050. word_long=wp.yjs-wp.xsyjw;
  3051. else
  3052. word_long=flag;
  3053. if (word_long>9) //?
  3054. word_long=9; //?
  3055. if (by_cchar_flag==1)
  3056. word_long=1;
  3057. if (word_long==1)
  3058. return(pre_nt_w1(wp.xsyjw));
  3059. for (j=word_long; j>1; j--){
  3060. word_long=j;
  3061. prepare_search1();
  3062. abbr_s1();
  3063. if (group_no){
  3064. unit_length=j*2;
  3065. return(CLC);
  3066. }// if ()
  3067. }// for()
  3068. return(pre_nt_w1(wp.xsyjw));
  3069. }
  3070. /*********************************************
  3071. copy_input()
  3072. **********************************************/
  3073. int WINAPI copy_input()
  3074. {
  3075. int i=0, j=0;
  3076. if (in.info_flag==VK_MULTIPLY) //if "*"
  3077. return(0);
  3078. kbf.true_length=in.true_length;
  3079. if (in.buffer[0]==SEPERATOR){
  3080. kbf.true_length=in.true_length-1;
  3081. i=1;
  3082. }// if ((in.buffer)
  3083. for (i=i; i<in.true_length+2; i++)
  3084. kbf.buffer[j++]=in.buffer[i];
  3085. kbf.max_length=in.max_length;
  3086. kbf.info_flag=in.info_flag;
  3087. return (0);
  3088. }
  3089. /**************************************************
  3090. input_msg_type()
  3091. **************************************************/
  3092. void WINAPI input_msg_type()
  3093. {
  3094. int i;
  3095. for (i=0; i<wp.yjs; i++){
  3096. wp.cmp_stack[i]=QP_FLAG;
  3097. if (LOBYTE(wp.yj[i])==0)
  3098. if (wp.syj[i]==HIBYTE(wp.yj[i]))
  3099. wp.cmp_stack[i]=JP_FLAG;
  3100. if (wp.tone[i]!=0)
  3101. wp.cmp_stack[i]|=YD_FLAG;
  3102. if (wp.bx_stack[i]!=0)
  3103. wp.cmp_stack[i]|=BX_FLAG;
  3104. }// for
  3105. }
  3106. /*****************************************************
  3107. pre_nt_w1()
  3108. ******************************************************/
  3109. int WINAPI pre_nt_w1(ps)
  3110. int ps;
  3111. {
  3112. unit_length=2;
  3113. word_long=1;
  3114. cmp_yj=wp.yj[ps];
  3115. cmp_head=wp.syj[ps];
  3116. cmp_bx=wp.bx_stack[ps];
  3117. cmp_state=wp.cmp_stack[ps];
  3118. find_one_hi();
  3119. w1_no_tune();
  3120. return(group_no);
  3121. }
  3122. /********************************************************
  3123. w1_no_tune()
  3124. *********************************************************/
  3125. void WINAPI w1_no_tune()
  3126. {
  3127. out_svw_cnt=0;
  3128. sc_gb();
  3129. sc_gbdy();
  3130. group_no=out_svw_cnt;
  3131. paidui(group_no);
  3132. }
  3133. /*********************************************************
  3134. sc_gb()
  3135. **********************************************************/
  3136. int WINAPI sc_gb()
  3137. {
  3138. BYTE x;
  3139. int cnt,i;
  3140. cnt=(87-15)*94;
  3141. if (cmp_state&4){
  3142. if (cmp_bx==0){
  3143. x=HIBYTE(cmp_yj);
  3144. if (x!='A'&&x!='O'&&x!='E'){
  3145. cnt=(55-15)*94;
  3146. cmp_state=cmp_state|0x80;
  3147. }// if (x=='A')
  3148. else
  3149. cmp_state=(cmp_state&0xfb)|QP_FLAG;
  3150. }// if (!cmp_bx)
  3151. }// if (cmp_state)
  3152. for (i=0; i<cnt; i++){
  3153. if (cmp_yj==cisu->t_bf1[i])
  3154. get_the_one(i);
  3155. else{
  3156. if (cmp_state&4){
  3157. if (cmp_head==HIBYTE(cisu->t_bf1[i]))
  3158. get_the_one(i);
  3159. else
  3160. if ( cmp_head==fu_sm(HIBYTE(cisu->t_bf1[i])) )
  3161. get_the_one(i);
  3162. }// if (cmp_state)
  3163. }//else
  3164. }//for()
  3165. return(0);
  3166. }
  3167. /*******************************************************
  3168. sc_gbdy()
  3169. *******************************************************/
  3170. int WINAPI sc_gbdy()
  3171. {
  3172. int cnt,i;
  3173. cnt=cisu->t_bf_start[2]/2;
  3174. for (i=0; i<cnt; i=i+2){
  3175. if (cmp_yj==cisu->t_bf2[i])
  3176. get_the_one2(i);
  3177. else{
  3178. if (cmp_state&4){
  3179. if (cmp_head==HIBYTE(cisu->t_bf2[i]))
  3180. get_the_one2(i);
  3181. else {
  3182. if (cmp_head==fu_sm(HIBYTE(cisu->t_bf2[i])))
  3183. get_the_one2(i);}
  3184. }// if (cmp_state)
  3185. }//else
  3186. }//for()
  3187. return(0);
  3188. }
  3189. /********************************************************
  3190. get_the_one()
  3191. *********************************************************/
  3192. int WINAPI get_the_one(i)
  3193. int i;
  3194. {
  3195. BYTE x;
  3196. WORD *out_svw_p=(WORD *)out_svw;
  3197. BYTE *msx_p=(BYTE *)msx_area;
  3198. if (cmp_bx1(i)!=0)
  3199. return(0);
  3200. out_svw_p[out_svw_cnt]=i+0x2020;
  3201. if (i>=(55-16+1)*94)
  3202. x=0x20;
  3203. else
  3204. x=pindu.pd_bf1[i];
  3205. if (cmp_state&0x80){
  3206. if (x<=(154+50)){
  3207. return(0);
  3208. }// if (x)
  3209. }// if (cmp_state)
  3210. msx_p[out_svw_cnt]=x;
  3211. out_svw_cnt++;
  3212. return(0);
  3213. }
  3214. /***********************************************************
  3215. cmp_bx1()
  3216. ************************************************************/
  3217. int WINAPI cmp_bx1(i)
  3218. int i;
  3219. {
  3220. BYTE x;
  3221. if (cmp_bx==0)
  3222. return(0);
  3223. x=spbx_tab[i];
  3224. if (x==cmp_bx)
  3225. return(0);
  3226. x=x&0xf0;
  3227. if (x==cmp_bx)
  3228. return(0);
  3229. return(1);
  3230. }
  3231. /********************************************************
  3232. get_the_one2()
  3233. *********************************************************/
  3234. int WINAPI get_the_one2(i)
  3235. int i;
  3236. {
  3237. BYTE x;
  3238. WORD *out_svw_p=(WORD *)out_svw;
  3239. BYTE *msx_p=(BYTE *)msx_area;
  3240. if (cmp_bx2(i)!=0)
  3241. return(0);
  3242. out_svw_p[out_svw_cnt]=i+0x8000;
  3243. if ((i/2)>=pindu.pd_bf0[2])
  3244. x=0x20;
  3245. else
  3246. x=pindu.pd_bf2[i/2];
  3247. if (cmp_state&0x80){
  3248. if (x<=(154+50)){
  3249. return(0);
  3250. }// if (x)
  3251. }// if (cmp_state)
  3252. msx_p[out_svw_cnt]=x;
  3253. out_svw_cnt++;
  3254. return(0);
  3255. }
  3256. /***********************************************************
  3257. cmp_bx2()
  3258. ************************************************************/
  3259. int WINAPI cmp_bx2(i)
  3260. int i;
  3261. {
  3262. BYTE x;
  3263. WORD y;
  3264. if (cmp_bx==0)
  3265. return(0);
  3266. i++;
  3267. y=cisu->t_bf2[i];
  3268. y=((BYTE)y-0xb0)*94+(HIBYTE(y)-0xa1);
  3269. x=spbx_tab[y];
  3270. if (x==cmp_bx)
  3271. return(0);
  3272. x=x&0xf0;
  3273. if (x==cmp_bx)
  3274. return(0);
  3275. return(1);
  3276. }
  3277. /***********************************************************
  3278. paidui()
  3279. ************************************************************/
  3280. int WINAPI paidui(cnt)
  3281. int cnt;
  3282. {
  3283. int i,j,n,flag;
  3284. BYTE x1,y1;
  3285. WORD x,y;
  3286. WORD *out_p;
  3287. BYTE *msx_p=(BYTE *)msx_area;
  3288. out_p=(WORD *)out_svw;
  3289. if (cnt<=1)
  3290. return(0);
  3291. for (n=cnt-1; n>0; n--){
  3292. flag=0;
  3293. for (i=0; i<n; i++){
  3294. if (msx_p[i]==msx_p[i+1]){
  3295. if (out_p[i]>out_p[i+1]){
  3296. x=out_p[i];
  3297. out_p[i]=out_p[i+1];
  3298. out_p[i+1]=x;
  3299. flag++;
  3300. }//if (out_p)
  3301. }// if (msx_p)
  3302. else{
  3303. if (msx_p[i]<msx_p[i+1]){
  3304. x1=msx_p[i];
  3305. msx_p[i]=msx_p[i+1];
  3306. msx_p[i+1]=x1;
  3307. x=out_p[i];
  3308. out_p[i]=out_p[i+1];
  3309. out_p[i+1]=x;
  3310. flag++;
  3311. }
  3312. }//else
  3313. }// for(i)
  3314. if (flag==0)
  3315. break;
  3316. }// for(n)
  3317. return (0);
  3318. }
  3319. void WINAPI s_tune()
  3320. {
  3321. }
  3322. int WINAPI fu_sm(fy)
  3323. BYTE fy;
  3324. {
  3325. switch(fy){
  3326. case 1:
  3327. return('Z');
  3328. case 2:
  3329. return('S');
  3330. case 3:
  3331. return('C');
  3332. default:
  3333. return(fy);
  3334. }
  3335. }
  3336. /**********************************************
  3337. find_one_hi()
  3338. ***********************************************/
  3339. int WINAPI find_one_hi()
  3340. {
  3341. WORD foh_save=0;
  3342. int i;
  3343. if (!cmp_bx)
  3344. if (cmp_state&4)
  3345. return(0);
  3346. sImeG.cp_ajust_flag=0;
  3347. i=0;
  3348. do{
  3349. if (czcx(&tmmr.stack1[i])){
  3350. if (!foh_save)
  3351. foh_save=cmp_cisu;
  3352. else{
  3353. if (foh_save==cmp_cisu){
  3354. sImeG.cp_ajust_flag=1;
  3355. result_area[result_area_pointer++]=LOBYTE(cmp_cisu);
  3356. result_area[result_area_pointer++]=HIBYTE(cmp_cisu);
  3357. return(0);
  3358. }//if (foh_save)
  3359. }//else
  3360. }//if (czcx)
  3361. i++;
  3362. }while(i<(sizeof tmmr.stack1)/2); //94.1 add div 2
  3363. return (0);
  3364. }
  3365. /*************************************************
  3366. czcx()
  3367. **************************************************/
  3368. int WINAPI czcx(stack)
  3369. WORD *stack;
  3370. {
  3371. cmp_cisu=stack[0];
  3372. if (!cmp_cisu)
  3373. return(STC);
  3374. if (cmp_bx)
  3375. if (HIBYTE(cmp_cisu)&0x40)
  3376. cmp_cisu&=0xbfff;
  3377. if (cmp_a_slbl_with_bx())
  3378. return(CLC);
  3379. return(STC);
  3380. }
  3381. /********************************************
  3382. find_multy_hi()
  3383. *********************************************/
  3384. int WINAPI find_multy_hi()
  3385. {
  3386. if (word_long==2)
  3387. find_two_hi();
  3388. if (word_long==3)
  3389. find_three_hi();
  3390. return(0);
  3391. }
  3392. /********************************************
  3393. find_two_hi()
  3394. *********************************************/
  3395. int WINAPI find_two_hi()
  3396. {
  3397. int i,j;
  3398. WORD *result_p;
  3399. result_p=(WORD *)result_area;
  3400. for (i=0; i<(sizeof tmmr.stack2)/(2*2); i=i+2){ //94.1 add *2
  3401. if (!tmmr.stack2[i]){
  3402. sImeG.cp_ajust_flag=0;
  3403. return(0);
  3404. }
  3405. if (cmp_2_and_3(&tmmr.stack2[i])){
  3406. sImeG.cp_ajust_flag=1;
  3407. for (j=0; j<word_long; j++)
  3408. result_p[result_area_pointer/2+j]=tmmr.stack2[j+i]&0xbfff;
  3409. result_area_pointer+=word_long*2;
  3410. return(0);
  3411. }//if
  3412. }//for
  3413. sImeG.cp_ajust_flag=0;
  3414. return(0);
  3415. }
  3416. /********************************************
  3417. find_three_hi()
  3418. *********************************************/
  3419. int WINAPI find_three_hi()
  3420. {
  3421. int i,j;
  3422. WORD *result_p;
  3423. result_p=(WORD *)result_area;
  3424. for (i=0; i<(sizeof tmmr.stack3)/(3*2); i=i+3){ //94.1 add *2
  3425. if (!tmmr.stack3[i]){
  3426. sImeG.cp_ajust_flag=0;
  3427. return(0);
  3428. }
  3429. if (cmp_2_and_3(&tmmr.stack3[i])){
  3430. sImeG.cp_ajust_flag=1;
  3431. for (j=0; j<word_long; j++)
  3432. result_p[result_area_pointer/2+j]=tmmr.stack3[j+i]&0xbfff;
  3433. result_area_pointer+=word_long*2;
  3434. return(0);
  3435. }// if (cmp_2_and_3)
  3436. }//for
  3437. sImeG.cp_ajust_flag=0;
  3438. return(0);
  3439. }
  3440. /***********************************************
  3441. cmp_2_and_3()
  3442. ************************************************/
  3443. int WINAPI cmp_2_and_3(t_stack)
  3444. WORD *t_stack;
  3445. {
  3446. int i,yj_p;
  3447. yj_p=wp.xsyjw; //1993,10,8
  3448. for (i=0; i<word_long; i++){
  3449. cmp_cisu=t_stack[i];
  3450. pre_cmp((WORD)yj_p);
  3451. if (word_long==2)
  3452. if (cmp_state&4)
  3453. if (!(HIBYTE(cmp_cisu)&0x40))
  3454. return(STC);
  3455. else
  3456. cmp_cisu&=0xbfff;
  3457. if (!cmp_a_slbl_with_bx())
  3458. return(STC);
  3459. yj_p++;
  3460. }
  3461. return(CLC);
  3462. }
  3463. void WINAPI find_that()
  3464. {
  3465. }
  3466. int WINAPI find_hz(x)
  3467. WORD x;
  3468. {
  3469. if (x>0xa000 || x<0x2020)
  3470. return(x);
  3471. if (x>=0x8000){
  3472. x=(x-0x8000)+1;
  3473. return(cisu->t_bf2[x]);
  3474. }
  3475. return((x-0x2020)/94+0xb0+((x-0x2020)%94+0xa1)*0x100);
  3476. }
  3477. /*************************************************
  3478. prepare_search1()
  3479. **************************************************/
  3480. int WINAPI prepare_search1()
  3481. {
  3482. BYTE f_ci1,f_ci2,x;
  3483. f_ci1=wp.syj[wp.xsyjw];
  3484. f_ci2=wp.syj[wp.xsyjw+1];
  3485. f_ci1=(BYTE)fu_sm(f_ci1);
  3486. f_ci2=(BYTE)fu_sm(f_ci2);
  3487. if(f_ci1<0x41)
  3488. f_ci1=0x41;
  3489. if (word_long>=5)
  3490. f_ci2=(BYTE)word_long;
  3491. search_and_read(f_ci1,f_ci2);
  3492. //
  3493. // After reading, counting the search place is needed
  3494. // First, count the STD dictionary buffers
  3495. //
  3496. search_start=6;
  3497. search_end=6;
  3498. if (word_lib_state&1){
  3499. x=word_long-2;
  3500. if (x>=3){
  3501. x-=3;
  3502. search_start+=4;}
  3503. if (x>0)
  3504. {
  3505. if (sizeof lib_w<lib_w[x-1])
  3506. search_start=sizeof lib_w;
  3507. else
  3508. search_start=lib_w[x-1];
  3509. }
  3510. search_end=lib_w[x];
  3511. if (sizeof lib_w<search_end)
  3512. search_end=sizeof lib_w;
  3513. }//if (word_lib_state)
  3514. //
  3515. // Second, count the User dic. area.
  3516. //
  3517. kzk_search_start=6;
  3518. kzk_search_end=6;
  3519. if (!(word_lib_state&2)) //Note exp: !word...&2
  3520. return(1); // and !(word&2)
  3521. x=word_long-2;
  3522. if (x>=3){
  3523. x-=3;
  3524. kzk_search_start+=4;}
  3525. if (x>0)
  3526. {
  3527. if (sizeof kzk_lib_w<kzk_lib_w[x-1])
  3528. kzk_search_start=sizeof kzk_lib_w;
  3529. else
  3530. kzk_search_start=kzk_lib_w[x-1];
  3531. }
  3532. kzk_search_end=kzk_lib_w[x];
  3533. if (sizeof kzk_lib_w<kzk_search_end)
  3534. kzk_search_end=sizeof kzk_lib_w;
  3535. return (0);
  3536. }
  3537. /********************************************
  3538. search_and_read()
  3539. entry: LOBYTE(f_ci)=the first letter,
  3540. HIBYTE(f_ci)=the second letter,
  3541. exit: NC success; C not success;
  3542. **********************************************/
  3543. int WINAPI search_and_read(f_ci1,f_ci2)
  3544. BYTE f_ci1,f_ci2;
  3545. {
  3546. if (if_already_in(f_ci1,f_ci2))
  3547. return(0);
  3548. count_basic_pera(f_ci1,f_ci2);
  3549. if (item_length!=0)
  3550. if (read_a_page(0,r_addr,item_length))
  3551. word_lib_state=word_lib_state|1;
  3552. read_kzk_lib();
  3553. return (1);
  3554. }
  3555. /***************************************************************
  3556. if_already_in(): adjust if the page has already in the memory
  3557. *****************************************************************/
  3558. int WINAPI if_already_in(f_ci1,f_ci2)
  3559. BYTE f_ci1,f_ci2;
  3560. {
  3561. WORD x;
  3562. (BYTE)x=f_ci2;
  3563. x=x*0x100+f_ci1;
  3564. if (x==last_item_name)
  3565. return(CLC);
  3566. if (f_ci1==(BYTE)last_item_name)
  3567. if (f_ci2>9)
  3568. return(STC);
  3569. else
  3570. if (HIBYTE(last_item_name)>9)
  3571. return(STC);
  3572. else
  3573. return(CLC);
  3574. return(STC);
  3575. }
  3576. /********************************************************
  3577. count_basic_pera(): count the sub_library address;
  3578. count the page address;
  3579. count the read_write length;
  3580. ********************************************************/
  3581. int WINAPI count_basic_pera(f_ci1,f_ci2)
  3582. BYTE f_ci1,f_ci2;
  3583. {
  3584. BYTE x;
  3585. word_lib_state=0;
  3586. item_addr=0xffff;
  3587. item_length=0;
  3588. (BYTE)last_item_name=f_ci2;
  3589. last_item_name=last_item_name*0x100+f_ci1;
  3590. if (f_ci1>'I'&& f_ci1<'U')
  3591. slib_addr=(f_ci1-0x41-1)*27;
  3592. else
  3593. if (f_ci1>'V')
  3594. slib_addr=(f_ci1-0x41-3)*27;
  3595. else
  3596. slib_addr=(f_ci1-0x41)*27;
  3597. r_addr=ndx.dir[slib_addr+1];
  3598. r_addr+=ndx.body_start;
  3599. r_addr=r_addr*16;
  3600. if (f_ci2<'A')
  3601. item_addr=slib_addr+MORE_THAN_5;
  3602. else
  3603. if (f_ci2>'I' && f_ci2<'U')
  3604. item_addr=slib_addr+(f_ci2-0x41-1);
  3605. else
  3606. if (f_ci2>'V')
  3607. item_addr=slib_addr+(f_ci2-0x41-3);
  3608. else
  3609. item_addr=slib_addr+(f_ci2-0x41);
  3610. r_addr=r_addr+ndx.dir[item_addr+1+1];
  3611. item_length=ndx.dir[item_addr+1+1+1];
  3612. item_length-=ndx.dir[item_addr+1+1];
  3613. return(0);
  3614. }
  3615. /***********************************************************
  3616. read_kzk_lib(): search the expended lib
  3617. ************************************************************/
  3618. int WINAPI read_kzk_lib()
  3619. {
  3620. r_addr=kzk_ndx.dir[slib_addr+1];
  3621. r_addr+=kzk_ndx.body_start;
  3622. r_addr=r_addr*16+KZK_BASE;
  3623. r_addr=r_addr+kzk_ndx.dir[item_addr+1+1];
  3624. kzk_item_length=kzk_ndx.dir[item_addr+1+1+1];
  3625. item_length-=kzk_ndx.dir[item_addr+1+1];
  3626. if (kzk_item_length<0)
  3627. kzk_item_length=0;
  3628. if (!kzk_item_length)
  3629. return(STC);
  3630. if (!read_a_page(1,r_addr,kzk_item_length))
  3631. return(STC);
  3632. word_lib_state|=2;
  3633. return(CLC);
  3634. }
  3635. ///////////////////////////////////////////////////////////////////////////
  3636. // ���ʿ� READ_A_PAGE() //
  3637. // ����: ����Ҫ�Ĵʿ�ҳ����ָ���Ļ����� //
  3638. // ����: START_PS ���ʿ�����ʼλ�� //
  3639. // FILE_FLAG =0 ����׼�� //
  3640. // =1 ��չ�� //
  3641. // SIZE ����ҳ��(�ֽ���) //
  3642. // ����: TRUE �ɹ� //
  3643. // FALSE ʧ�� //
  3644. // ע��:������Ҫ�ж�SIZE�Ĵ�С�Ƿ�Խ��,�Է�ֹ����. //
  3645. // ����Խ��,�����ջ������Ĵ�С�ض�. //
  3646. ///////////////////////////////////////////////////////////////////////////
  3647. int WINAPI read_a_page(file_flag, start_ps, size)
  3648. BYTE file_flag;
  3649. LONG start_ps;
  3650. WORD size;
  3651. {
  3652. // 94/4/16 HANDLE hd;
  3653. int hd = -1;
  3654. if ((last_flag==file_flag)&&(last_start_ps==start_ps)&&(last_size==size))
  3655. return(1);
  3656. //���ζ�д���ʹ���ȫ��ͬ,�����������̲���;
  3657. if (file_flag==0)
  3658. {
  3659. if (size> sizeof lib_w) size=sizeof lib_w;
  3660. hd=OpenFile(std_dct,&openbuf,OF_READ);
  3661. if (hd == -1) return(0);
  3662. _llseek(hd,start_ps,0);
  3663. if(_lread(hd,(LPSTR)lib_w,size)<=0)
  3664. {
  3665. _lclose(hd);
  3666. return(0);
  3667. }
  3668. }
  3669. if (file_flag==1)
  3670. {
  3671. hd=OpenFile(user_lib,&openbuf_kzk,OF_READ);
  3672. if (hd == -1) return(0);
  3673. if (size>sizeof kzk_lib_w) size=sizeof kzk_lib_w;
  3674. //�жϻ������Ƿ�Խ������
  3675. _llseek(hd,start_ps,0);
  3676. if(_lread(hd,(LPSTR)kzk_lib_w,size)<=0)
  3677. {
  3678. _lclose(hd);
  3679. return(0);
  3680. }
  3681. }
  3682. if ( hd != -1 )
  3683. _lclose(hd);
  3684. last_flag=file_flag;
  3685. last_start_ps=start_ps; // ����������
  3686. last_size=size;
  3687. return(1);
  3688. }
  3689. /**********************************************************************
  3690. Name: abbr_s1()
  3691. Popurse: Find match words arrcoding to the given input message.
  3692. Search order is:
  3693. Temp_rem area
  3694. Standard Dictionary
  3695. User Dictionary
  3696. If there are more than one words, judge what is the
  3697. suitable one.
  3698. **********************************************************************/
  3699. int WINAPI abbr_s1()
  3700. {
  3701. group_no=0;
  3702. msx_area_cnt=0;
  3703. out_svw_cnt=0;
  3704. find_new_word(); // Search temp rem_area
  3705. abbr_entry((BYTE *)kzk_lib_w+kzk_search_start,(BYTE *)kzk_lib_w+kzk_search_end,4);
  3706. // Search User dic.
  3707. abbr_entry((BYTE *)lib_w+search_start, (BYTE *)lib_w+search_end,0);
  3708. // Search stndard dic.
  3709. if (!group_no) return(STC); // Without any results...
  3710. if (group_no==1) return(CLC); // Only one!
  3711. order_result2(); // Results more than one...
  3712. if (sImeG.auto_mode) find_multy_hi(); // If in frenquency ajust mode...
  3713. return(CLC); // Return OK.
  3714. }
  3715. /********************************************************
  3716. find_new_word()
  3717. *********************************************************/
  3718. void WINAPI find_new_word()
  3719. {
  3720. fczs1((LPSTR)tmmr.temp_rem_area,sizeof tmmr.temp_rem_area,2);
  3721. fczs1((LPSTR)tmmr.rem_area,sizeof tmmr.rem_area,0x82);
  3722. }
  3723. /*****************************************************
  3724. fczs1()
  3725. ******************************************************/
  3726. int WINAPI fczs1(rem_p,end,area_flag)
  3727. BYTE *rem_p; //92-12-18 SZ
  3728. int end,area_flag;
  3729. {
  3730. int i=0,w_long,j;
  3731. WORD *p;
  3732. w_long=word_long*2;
  3733. while(i<end){
  3734. if (w_long==rem_p[i]){
  3735. if (find_long_word2(&rem_p[i])){
  3736. group_no+=1;
  3737. if (!trs_new_word(i,&rem_p[i],area_flag)) //
  3738. return(0);
  3739. }// if (find_long_word2)
  3740. }// if (w_long)
  3741. if (rem_p[i]==0)
  3742. return(0);
  3743. if (rem_p[i]>18||(rem_p[i]&1)){
  3744. p=(WORD *)&rem_p[i];
  3745. for (j=0; j<(end-i)/2; j++){ //94.2.3 ZHU (end-i)/2
  3746. if (p[j]!=0)
  3747. p[j]=0;
  3748. else
  3749. return(0);
  3750. }// for
  3751. }//if (rem_p)
  3752. i+=rem_p[i]+2;
  3753. }//while
  3754. return (0);
  3755. }
  3756. /************************************************
  3757. find_long_word2()
  3758. *************************************************/
  3759. int WINAPI find_long_word2(buffer)
  3760. BYTE *buffer;
  3761. {
  3762. int yj_p,i;
  3763. yj_p=wp.xsyjw;
  3764. for (i=0; i<word_long*2; i=i+2){
  3765. cmp_cisu=buffer[i+2]+buffer[i+2+1]*0x100;
  3766. pre_cmp((WORD)yj_p);
  3767. if (!cmp_a_slbl_with_bx())
  3768. return(STC);
  3769. yj_p++;
  3770. }
  3771. return(CLC);
  3772. }
  3773. /*************************************************
  3774. trs_new_word()
  3775. **************************************************/
  3776. int WINAPI trs_new_word(word_addr,buffer,area_flag)
  3777. int word_addr,area_flag;
  3778. BYTE *buffer;
  3779. {
  3780. int i;
  3781. if (out_svw_cnt>=sizeof out_svw){
  3782. group_no--;
  3783. return(STC);
  3784. }// if (out_svw_cnt)
  3785. for (i=0;i<word_long*2; i++)
  3786. out_svw[out_svw_cnt++]=buffer[i+2];
  3787. msx_area[msx_area_cnt].pindu=0x70+(BYTE)group_no;
  3788. msx_area[msx_area_cnt].from=(BYTE)area_flag; //come from temp_area
  3789. msx_area[msx_area_cnt].addr=(WORD)word_addr;
  3790. if (buffer[1]&0x80)
  3791. msx_area[msx_area_cnt].pindu=0x31;
  3792. msx_area_cnt++;
  3793. return(CLC);
  3794. }
  3795. /****************************************
  3796. pre_cmp()
  3797. *****************************************/
  3798. void WINAPI pre_cmp(x)
  3799. WORD x;
  3800. {
  3801. cmp_yj=wp.yj[x];
  3802. cmp_head=wp.syj[x];
  3803. cmp_state=wp.cmp_stack[x];
  3804. cmp_bx=wp.bx_stack[x];
  3805. }
  3806. /******************************************
  3807. cmp_a_slbl_with_bx()
  3808. *******************************************/
  3809. int WINAPI cmp_a_slbl_with_bx()
  3810. {
  3811. if (cmp_cisu<0x2020)
  3812. return(STC);
  3813. if (cmp_cisu>=0x8000){
  3814. if ((cmp_cisu-0x8000)>=cisu->t_bf_start[2]/2)
  3815. return(STC);}
  3816. else{
  3817. if ((cmp_cisu-0x2020)>=cisu->t_bf_start[1]/2)
  3818. return(STC);}
  3819. if (!cmp_a_slbl())
  3820. return(STC);
  3821. if (!cmp_bx)
  3822. return(CLC);
  3823. if (!yjbx())
  3824. return(STC);
  3825. return(CLC);
  3826. }
  3827. /*******************************************
  3828. cmp_a_slbl()
  3829. ********************************************/
  3830. int WINAPI cmp_a_slbl()
  3831. {
  3832. if (cmp_state&2) {
  3833. if (cmp_cisu>=0x8000){
  3834. if (cmp_yj==cisu->t_bf2[cmp_cisu-0x8000])
  3835. return(CLC);
  3836. else
  3837. return(STC);
  3838. //?? return(cmp_first_letter());
  3839. } //if (cmp_cisu...
  3840. else{
  3841. if (cmp_yj==cisu->t_bf1[cmp_cisu-0x2020])
  3842. return(CLC);
  3843. else
  3844. return(STC);
  3845. }//else
  3846. }// if (cmp_state...
  3847. return(cmp_first_letter());
  3848. }
  3849. /************************************************
  3850. cmp_first_letter()
  3851. *************************************************/
  3852. int WINAPI cmp_first_letter()
  3853. {
  3854. WORD py_nm;
  3855. if (!(cmp_state&4)) //NOte!!!
  3856. return(STC);
  3857. py_nm=(WORD)cisu_to_py();
  3858. if ((HIBYTE(py_nm)&0x5f)==cmp_head)
  3859. return(CLC);
  3860. else{
  3861. py_nm=(WORD)get_head(HIBYTE(py_nm));
  3862. if ((LOBYTE(py_nm)&0xdf)==cmp_head)
  3863. return(CLC);
  3864. else
  3865. return(STC);
  3866. }
  3867. }
  3868. /***********************************************
  3869. cisu_to_py()
  3870. ************************************************/
  3871. int WINAPI cisu_to_py()
  3872. {
  3873. if (cmp_cisu>=0x8000)
  3874. return(cisu->t_bf2[(cmp_cisu-0x8000)]);
  3875. else
  3876. return(cisu->t_bf1[(cmp_cisu-0x2020)]);
  3877. }
  3878. /**************************************************
  3879. get_head()
  3880. ***************************************************/
  3881. int WINAPI get_head(first_letter)
  3882. BYTE first_letter;
  3883. {
  3884. if (first_letter>=0x41)
  3885. return(first_letter);
  3886. first_letter=(first_letter-1)*5;
  3887. return(slbl_tab[first_letter]);
  3888. }
  3889. /******************************************************
  3890. yjbx()
  3891. *******************************************************/
  3892. int WINAPI yjbx()
  3893. {
  3894. BYTE bx;
  3895. WORD pos;
  3896. if (cmp_cisu<0x8000)
  3897. pos = cmp_cisu-0x2020;
  3898. else{
  3899. pos =cisu->t_bf2[(cmp_cisu-0x8000)+1];
  3900. pos =(HIBYTE(pos)-0xa1)+(LOBYTE(pos)-0xb0)*94;
  3901. }
  3902. if (pos>= 94*94) return (STC);
  3903. bx=spbx_tab[pos];
  3904. if (cmp_bx==bx)
  3905. return(CLC);
  3906. else
  3907. if (cmp_bx==(bx&0xf0))
  3908. return(CLC);
  3909. else
  3910. return(STC);
  3911. }
  3912. /****************************************************
  3913. abbr_entry()
  3914. *****************************************************/
  3915. int WINAPI abbr_entry(s_start,s_end,ComeFrom)
  3916. BYTE *s_start,*s_end,ComeFrom; //Search start and Ending
  3917. { // position
  3918. int i;
  3919. while (s_start<s_end){
  3920. if (cmp_long_word2(s_start)){ //Compare word by word.
  3921. if (out_svw_cnt>=sizeof out_svw) // If buffer out_svw
  3922. // is full, sorry...
  3923. return(STC);
  3924. for (i=0; i<word_long*2; i++)
  3925. out_svw[out_svw_cnt++]=s_start[i]; //Move the words
  3926. msx_area[msx_area_cnt].pindu=s_start[i];
  3927. msx_area[msx_area_cnt].from=ComeFrom; //come from ...
  3928. msx_area[msx_area_cnt].addr=(WORD)s_start; // Where is the ...
  3929. msx_area_cnt++; // Increae the pointer
  3930. // for the attribue area
  3931. group_no+=1; // In case of OK, increaase
  3932. // results counter.
  3933. }//if(cmp..
  3934. s_start+=(word_long+word_long+1); // Push down the search pointer
  3935. // by word_long*2+1
  3936. }
  3937. return(CLC); // The value of return is no
  3938. // use for the route.
  3939. }
  3940. /******************************************************
  3941. cmp_long_word2()
  3942. *******************************************************/
  3943. int WINAPI cmp_long_word2(buffer)
  3944. BYTE *buffer;
  3945. {
  3946. int yj_p,i;
  3947. yj_p=wp.xsyjw;
  3948. for (i=0; i<word_long*2; i=i+2){
  3949. cmp_cisu=buffer[i]+buffer[i+1]*0x100;
  3950. if (cmp_cisu<0x2020)
  3951. return(STC);
  3952. pre_cmp((WORD)yj_p);
  3953. if (!cmp_a_slbl_with_bx())
  3954. return(STC);
  3955. yj_p++;
  3956. }
  3957. return(CLC);
  3958. }
  3959. /*******************************************************
  3960. order_result2()
  3961. ********************************************************/
  3962. int WINAPI order_result2()
  3963. {
  3964. int lng,i,j,n;
  3965. BYTE x,flag;
  3966. WORD y;
  3967. lng=word_long*2;
  3968. if (xs_flag==1){
  3969. xs_flag=0;
  3970. if (!fenli_daxie())
  3971. return(0);
  3972. }
  3973. if (msx_area_cnt==1)
  3974. return(0);
  3975. for (i=group_no-1; i>0; i--){
  3976. flag=0;
  3977. for (j=0; j<i; j++){
  3978. if (msx_area[j].pindu<msx_area[j+1].pindu){
  3979. for (n=j*lng; n<j*lng+lng; n++){
  3980. x=out_svw[n];
  3981. out_svw[n]=out_svw[n+lng];
  3982. out_svw[n+lng]=x;
  3983. }//for
  3984. x=msx_area[j].pindu;
  3985. msx_area[j].pindu=msx_area[j+1].pindu;
  3986. msx_area[j+1].pindu=x;
  3987. x=msx_area[j].from;
  3988. msx_area[j].from=msx_area[j+1].from;
  3989. msx_area[j+1].from=x;
  3990. y=msx_area[j].addr;
  3991. msx_area[j].addr=msx_area[j+1].addr;
  3992. msx_area[j+1].addr=y;
  3993. flag=1;
  3994. }// if (msx)
  3995. }//for(j)
  3996. if (!flag)
  3997. break;
  3998. }// for(i)
  3999. return (0);
  4000. }
  4001. /*****************************************************
  4002. fenli_daxie()
  4003. ******************************************************/
  4004. int WINAPI fenli_daxie()
  4005. {
  4006. int i,j,n,lng;
  4007. j=0;
  4008. lng=word_long*2;
  4009. for (i=0; i<msx_area_cnt; i++){
  4010. if (msx_area[i].pindu==0x31){
  4011. msx_area[j].pindu=msx_area[i].pindu;
  4012. msx_area[j].from=msx_area[i].from;
  4013. msx_area[j].addr=msx_area[i].addr;
  4014. for (n=0; n<lng; n++)
  4015. out_svw[j*lng+n]=out_svw[i*lng+n];
  4016. j++;
  4017. }//if
  4018. }// for
  4019. if (!j)
  4020. return(CLC); // there is no Caps;
  4021. group_no=j;
  4022. return(STC); // there has Caps;
  4023. }
  4024. /*************************************************
  4025. rzw()
  4026. **************************************************/
  4027. int WINAPI rzw()
  4028. {
  4029. if (!(system_info&1)) //if strength mode, ret
  4030. sfx_proc();
  4031. return(0);
  4032. }
  4033. /************************************************
  4034. abbr()
  4035. *************************************************/
  4036. int WINAPI abbr()
  4037. {
  4038. int i;
  4039. WORD x;
  4040. WORD *kbf_p;
  4041. if (in.true_length<2){
  4042. xs_flag=1;
  4043. jiyi_pindu|=0x80;
  4044. return(0);
  4045. }
  4046. for (i=0; i<in.true_length; i++){
  4047. if (in.buffer[i]&0x20){ //if not Caps
  4048. xs_flag=1;
  4049. jiyi_pindu|=0x80;
  4050. return(0);
  4051. }// if
  4052. }//for
  4053. kbf_p=(WORD *)kbf.buffer;
  4054. x=0x2d*0x100;
  4055. kbf.true_length=in.true_length*2;
  4056. for (i=0; i<in.true_length; i++){
  4057. (BYTE)x=in.buffer[i];
  4058. *(LPUNAWORD)&kbf_p[i]=x;
  4059. }
  4060. kbf.buffer[in.true_length*2]=0;
  4061. in.info_flag=VK_MULTIPLY;
  4062. return(0);
  4063. }
  4064. /***************************************************
  4065. sfx_proc()
  4066. ****************************************************/
  4067. int WINAPI sfx_proc()
  4068. {
  4069. int i,j;
  4070. WORD x,save_xsyjw;
  4071. WORD *result_p;
  4072. BYTE *sfx_p;
  4073. result_p=(WORD *)result_area;
  4074. sfx_p=(BYTE *)sfx_table;
  4075. if (sImeG.cp_ajust_flag==1)
  4076. return(0);
  4077. if (word_long>=3)
  4078. return(0);
  4079. save_xsyjw=(WORD)wp.xsyjw;
  4080. wp.xsyjw=wp.xsyjs;
  4081. i=0;
  4082. do{
  4083. x=sfx_table[i];
  4084. if (HIBYTE(x)&sfx_attr)
  4085. if (LOBYTE(x)==word_long*2)
  4086. if (cmp_long_word2(&sfx_p[i*2+2])){
  4087. for (j=0; j<word_long; j++)
  4088. result_p[result_area_pointer/2+j]=sfx_table[i+1+j];
  4089. result_area_pointer+=word_long*2;
  4090. wp.xsyjw=save_xsyjw;
  4091. sImeG.cp_ajust_flag=1;
  4092. return(0);
  4093. }//if (cmp_...
  4094. i+=LOBYTE(x)/2+1;
  4095. }while(i<sfx_table_size);
  4096. wp.xsyjw=save_xsyjw;
  4097. return (0);
  4098. }
  4099. void WINAPI zdyb()
  4100. {
  4101. }
  4102. /************************************************
  4103. recall_rc()
  4104. *************************************************/
  4105. int WINAPI recall_rc()
  4106. {
  4107. int i;
  4108. BYTE x;
  4109. word_long=wp.yjs-wp.xsyjw;
  4110. unit_length=word_long*2;
  4111. i=0;
  4112. do{
  4113. x=logging_stack[i];
  4114. if (!x)
  4115. break;
  4116. if (word_long*2>x)
  4117. i+=x+1;
  4118. else{
  4119. if (x>20) //if more than 10 chinese words?
  4120. break;
  4121. if ((i+x)>=logging_stack_size)
  4122. break; //if the last word is not completely
  4123. if (find_long_word3((WORD *)&logging_stack[i+1],(int)(x/2))){
  4124. trs_new_word3(x,i);
  4125. group_no++;
  4126. if (group_no>5)
  4127. break;
  4128. }
  4129. i+=x+1;
  4130. }//else
  4131. }while(i<logging_stack_size);
  4132. if (group_no){
  4133. word_long=4;
  4134. unit_length=8;
  4135. return(CLC);
  4136. }
  4137. return(STC);
  4138. }
  4139. /*********************************************
  4140. find_long_word3()
  4141. **********************************************/
  4142. int WINAPI find_long_word3(stack,length)
  4143. WORD *stack;
  4144. int length;
  4145. {
  4146. int yj_p,i,err_flg,m;
  4147. yj_p=wp.xsyjw;
  4148. m=0;
  4149. while ((length-m)>=word_long){
  4150. err_flg=0;
  4151. for (i=0; i<word_long; i++){
  4152. cmp_cisu=stack[m+i];
  4153. pre_cmp((WORD)(yj_p+i));
  4154. if (!cmp_a_slbl_with_bx()){
  4155. m++, err_flg=1;
  4156. break;
  4157. }
  4158. }//for
  4159. if (!err_flg)
  4160. return(CLC);
  4161. }
  4162. return(STC);
  4163. }
  4164. /*************************************************
  4165. trs_new_word3()
  4166. **************************************************/
  4167. void WINAPI trs_new_word3(length,addr)
  4168. int addr;
  4169. BYTE length;
  4170. {
  4171. int cnt,i;
  4172. char *msx_area_p;
  4173. cnt=8*group_no;
  4174. msx_area_p=(BYTE *)msx_area;
  4175. msx_area_p[22*group_no]=length;
  4176. addr++;
  4177. for (i=0; i<length; i++)
  4178. msx_area_p[22*group_no+1+i]=logging_stack[addr+i];
  4179. for (i=0; i<8; i++)
  4180. out_svw[cnt+i]=0xa1;
  4181. if ((length/2)<=4){
  4182. for (i=0; i<length; i++)
  4183. out_svw[cnt+i]=logging_stack[addr+i];
  4184. }
  4185. else{
  4186. for (i=0; i<4; i++)
  4187. out_svw[cnt+i]=logging_stack[addr+i];
  4188. out_svw[cnt+i]=0xa1,i++;
  4189. out_svw[cnt+i]=0xad,i++;
  4190. out_svw[cnt+i]=logging_stack[addr+length-2],i++;
  4191. out_svw[cnt+i]=logging_stack[addr+length-1],i++;
  4192. }
  4193. }
  4194. /******************************************************
  4195. new_word():
  4196. *******************************************************/
  4197. int WINAPI new_word()
  4198. {
  4199. WORD temp_save,suc_flag,i,j;
  4200. by_cchar_flag=0;
  4201. wp.xsyjw=0;
  4202. temp_save=sImeG.cp_ajust_flag;
  4203. suc_flag=0;
  4204. if (convert(0)){
  4205. sImeG.cp_ajust_flag=(BYTE)temp_save;
  4206. if (unit_length==new_no){
  4207. for (i=0; i<group_no; i++){
  4208. suc_flag = 0; //1993 11 4
  4209. for(j=0; j<new_no; j++){
  4210. if (result_area[j]!=out_svw[i*unit_length+j])
  4211. suc_flag=1;
  4212. }//for(j)
  4213. if (!suc_flag){
  4214. return(0);}
  4215. }//for(i)
  4216. }//if (unit_length)
  4217. }//if(convert)
  4218. sImeG.cp_ajust_flag=(BYTE)temp_save;
  4219. by_cchar_flag=1;
  4220. return(rem_new_word());
  4221. }
  4222. /***********************************************************
  4223. rem_new_word(): fill the new word in temp_rem_area
  4224. ************************************************************/
  4225. int WINAPI rem_new_word()
  4226. {
  4227. WORD i,count; //SZ
  4228. WORD *result_area_p;
  4229. count=(WORD)( (sizeof tmmr.temp_rem_area)-(new_no+2) ); //92-12-18 SZ
  4230. CopyMemory/*memmove*/(&tmmr.temp_rem_area[(new_no+2)/2],
  4231. tmmr.temp_rem_area,
  4232. count);
  4233. tmmr.temp_rem_area[0]=new_no+jiyi_pindu*0x100;
  4234. result_area_p=(WORD *)result_area;
  4235. for (i=0; i<new_no/2; i++)
  4236. tmmr.temp_rem_area[i+1]=result_area_p[i];
  4237. write_new_word(1);
  4238. return(0);
  4239. }
  4240. /**********************************************************************
  4241. Function: AddExtLib()
  4242. Purpose: Get a temperary rem word into high level depanding
  4243. how many times it has been used.
  4244. Entry: Must be called from out_result.
  4245. Out : None.
  4246. ***********************************************************************/
  4247. int WINAPI AddExtLib(){
  4248. int x,count,i;
  4249. if((unit_length>=4)&&(unit_length<=18)) //rem word limited
  4250. if(msx_area[current_no].from==2)
  4251. { // If a rem word?
  4252. x=msx_area[current_no].addr/2; //get word addr in temp...
  4253. if (x<sizeof tmmr.temp_rem_area/2)
  4254. { //Insure random errof out limited
  4255. if ((tmmr.temp_rem_area[x]&0xff)!=unit_length)
  4256. return(STC);
  4257. tmmr.temp_rem_area[x]+=0x100; //Increase used times.
  4258. if((tmmr.temp_rem_area[x]&0xf00)>=0x300)
  4259. {
  4260. count=(sizeof tmmr.rem_area)
  4261. -(unit_length+2); // Push down middle rem area
  4262. CopyMemory(&tmmr.rem_area[(unit_length+2)/2],
  4263. tmmr.rem_area,
  4264. count);
  4265. for(i=0; i<unit_length/2+1; i++)
  4266. tmmr.rem_area[i]=tmmr.temp_rem_area[x+i];
  4267. //move to middle rem area.
  4268. count=sizeof tmmr.temp_rem_area-x*2
  4269. -(unit_length+2); //delete it from temp ...
  4270. CopyMemory(&tmmr.temp_rem_area[x],
  4271. &tmmr.temp_rem_area[x+unit_length/2+1],
  4272. count);
  4273. write_new_word(0);
  4274. if(tmmr.rem_area[50]) //[400]) //1994.4.21
  4275. {
  4276. UpdateProc();
  4277. }
  4278. } //write changes
  4279. else
  4280. write_new_word(1);
  4281. }
  4282. }
  4283. return (0);
  4284. }
  4285. /********************************************************
  4286. write_new_word():
  4287. *********************************************************/
  4288. void WINAPI write_new_word(flag)
  4289. int flag;
  4290. {
  4291. int count;
  4292. LONG distance;
  4293. WORD *p;
  4294. distance=sizeof tmmr.stack1+sizeof tmmr.stack2+sizeof tmmr.stack3;
  4295. count=sizeof tmmr.temp_rem_area;
  4296. p=tmmr.temp_rem_area;
  4297. if (flag!=1){
  4298. distance=sizeof tmmr.stack1+sizeof tmmr.stack2
  4299. +sizeof tmmr.stack3+sizeof tmmr.temp_rem_area;
  4300. p=tmmr.rem_area;
  4301. if (flag<1){
  4302. distance=sizeof tmmr.stack1
  4303. +sizeof tmmr.stack2
  4304. +sizeof tmmr.stack3; //92-12-18 SZ
  4305. p=tmmr.temp_rem_area;
  4306. count=(sizeof tmmr.temp_rem_area)+(sizeof tmmr.rem_area);
  4307. }
  4308. }
  4309. writefile(tmmr_rem,distance,(LPSTR)p,count);
  4310. }
  4311. /*******************************************************
  4312. writefile(): write file in disk
  4313. ********************************************************/
  4314. int WINAPI writefile(file_n,distance,p,count)
  4315. BYTE *file_n;
  4316. LONG distance;
  4317. LPSTR p; //WORD *p;
  4318. int count;
  4319. {
  4320. int hd;
  4321. int write_c;
  4322. hd=OpenFile(file_n,&open_tmmr,OF_WRITE);
  4323. if (hd==-1) return(STC);
  4324. _llseek(hd,distance,0);
  4325. write_c=_lwrite(hd,(LPSTR)p,count);
  4326. if (write_c!=count)
  4327. {
  4328. _lclose(hd);
  4329. return(STC);
  4330. }
  4331. hd=_lclose(hd);
  4332. return(CLC);
  4333. }
  4334. /***************************************************************
  4335. look_for_code(): search if the code is in the index
  4336. ****************************************************************/
  4337. int WINAPI look_for_code()
  4338. {
  4339. int i,rec_cnt;
  4340. rec_cnt=0;
  4341. for (i=0x10; i<(mulu_true_length+0x10); i=i+mulu_record_length){
  4342. if (if_code_equ(i))
  4343. return(rec_cnt+1); //find the code, rec_cnt+1 in order to avoid
  4344. else //confusing with STC
  4345. rec_cnt++;
  4346. }
  4347. return(STC); // not found
  4348. }
  4349. /**************************************************************
  4350. read_data(): read the record correspond to the code
  4351. ***************************************************************/
  4352. int WINAPI read_data(rec_cnt)
  4353. int rec_cnt;
  4354. {
  4355. int hd;
  4356. int op_count;
  4357. hd=OpenFile(user_lib,&open_user, OF_READ);
  4358. if (hd==-1)
  4359. return(FALSE);
  4360. _llseek(hd,(data_start+rec_cnt*data_record_length), 0);
  4361. op_count=_lread(hd,(LPSTR)&out_svw,data_record_length);
  4362. if (op_count!=data_record_length)
  4363. {
  4364. _lclose(hd);
  4365. return(FALSE);
  4366. }
  4367. _lclose(hd);
  4368. if (out_svw[0]<2)
  4369. return(STC);
  4370. if ((out_svw[0]-0x30)>30)
  4371. return(STC);
  4372. return(CLC);
  4373. }
  4374. int WINAPI UpdateProc()
  4375. {
  4376. UpdateFlag=1;
  4377. ExeCmdLine[ParaPos]='7';
  4378. WinExec(ExeCmdLine,SW_SHOW);
  4379. return(0);
  4380. }
  4381. /***********************************************
  4382. rem_pd1()
  4383. ************************************************/
  4384. int WINAPI rem_pd1(buffer)
  4385. WORD *buffer;
  4386. {
  4387. WORD temp;
  4388. temp=buffer[0];
  4389. if (wp.bx_stack[wp.xsyjs])
  4390. temp|=0x4000;
  4391. else
  4392. if (wp.cmp_stack[wp.xsyjs]==4)
  4393. return(0);
  4394. push_down_stack1();
  4395. tmmr.stack1[0]=temp;
  4396. return(0);
  4397. }
  4398. /**********************************************
  4399. push_down_stack1()
  4400. ***********************************************/
  4401. int WINAPI push_down_stack1()
  4402. {
  4403. int i;
  4404. i=(sizeof tmmr.stack1-2);
  4405. CopyMemory/*memmove*/((BYTE *)&tmmr.stack1[1],(BYTE *)&tmmr.stack1[0],i);
  4406. stack1_move_counter++;
  4407. if (stack1_move_counter>=4)
  4408. writefile(tmmr_rem, 0l, (LPSTR)&tmmr.stack1, sizeof tmmr.stack1);
  4409. return(0);
  4410. }
  4411. /***********************************************
  4412. rem_pd2()
  4413. ************************************************/
  4414. void WINAPI rem_pd2(buffer)
  4415. WORD *buffer;
  4416. {
  4417. WORD temp1,temp2;
  4418. int i;
  4419. temp1=buffer[0], temp2=buffer[1];
  4420. if (wp.cmp_stack[wp.xsyjs]!=2)
  4421. temp1|=0x4000;
  4422. if (wp.cmp_stack[wp.xsyjs+1]!=2)
  4423. temp2|=0x4000;
  4424. i=(sizeof tmmr.stack2-4-4);
  4425. CopyMemory/*memmove*/((BYTE *)&tmmr.stack2[2],(BYTE *)&tmmr.stack2[0],i);
  4426. tmmr.stack2[0]=temp1;
  4427. tmmr.stack2[1]=temp2;
  4428. writefile(tmmr_rem, (LONG)sizeof tmmr.stack1,
  4429. (LPSTR)&tmmr.stack2, sizeof tmmr.stack2);
  4430. }
  4431. /***********************************************
  4432. rem_pd3()
  4433. ************************************************/
  4434. void WINAPI rem_pd3(buffer)
  4435. WORD *buffer;
  4436. {
  4437. int i;
  4438. i=(sizeof tmmr.stack3-6);
  4439. CopyMemory/*memmove*/((BYTE *)&tmmr.stack3[3],(BYTE *)&tmmr.stack3[0],i);
  4440. for (i=0; i<3; i++)
  4441. tmmr.stack3[i]=buffer[i];
  4442. writefile(tmmr_rem, (LONG)(sizeof tmmr.stack1+sizeof tmmr.stack2),
  4443. (LPSTR)&tmmr.stack3, sizeof tmmr.stack3);
  4444. }
  4445. //this module is come from ABCWIN.EXE
  4446. INT_PTR CALLBACK ImeAboutDlgProc(
  4447. HWND hDlg, /* window handle of the dialog box */
  4448. UINT message, /* type of message */
  4449. WPARAM wParam, /* message-specific information */
  4450. LPARAM lParam
  4451. )
  4452. {
  4453. RECT rc;
  4454. LONG DlgWidth, DlgHeight;
  4455. switch (message) {
  4456. case WM_INITDIALOG: /* message: initialize dialog box */
  4457. hCrtDlg = hDlg;
  4458. CenterWindow(hDlg);
  4459. return (TRUE); // don't want to set focus to special control
  4460. case WM_CLOSE:
  4461. EndDialog(hDlg, TRUE);
  4462. return (TRUE);
  4463. case WM_PAINT:
  4464. {
  4465. RECT Rect;
  4466. HDC hDC;
  4467. PAINTSTRUCT ps;
  4468. GetClientRect(hDlg, &Rect); //get the whole window area
  4469. InvalidateRect(hDlg, &Rect, 1);
  4470. hDC=BeginPaint(hDlg, &ps);
  4471. // FillRect(hDC, &Rect, GetStockObject(LTGRAY_BRUSH)); //paint the whole area
  4472. Rect.left+=10;//5;
  4473. Rect.top+=8;//5;
  4474. Rect.right-=10;//5;
  4475. Rect.bottom-=40;//5;
  4476. DrawEdge(hDC, &Rect, EDGE_RAISED,/*EDGE_SUNKEN,*/ BF_RECT);
  4477. //FrameRect(hDC, &Rect, GetStockObject(WHITE_BRUSH)); //draw the frame
  4478. EndPaint(hDlg, &ps);
  4479. break;
  4480. }
  4481. case WM_COMMAND:
  4482. switch (wParam) {
  4483. case IDOK:
  4484. EndDialog(hDlg, FALSE);
  4485. break;
  4486. case IDCANCEL:
  4487. EndDialog(hDlg, FALSE);
  4488. break;
  4489. default:
  4490. return (FALSE);
  4491. break;
  4492. }
  4493. return (TRUE);
  4494. }
  4495. return (FALSE); /* Didn't process a message */
  4496. }
  4497. int CommandProc(WPARAM wParam,HWND hWnd)
  4498. {
  4499. lpImeL->TempUIWnd = hWnd;
  4500. switch(wParam){
  4501. case IDM_SKL1:
  4502. case IDM_SKL2:
  4503. case IDM_SKL3:
  4504. case IDM_SKL4:
  4505. case IDM_SKL5:
  4506. case IDM_SKL6:
  4507. case IDM_SKL7:
  4508. case IDM_SKL8:
  4509. case IDM_SKL9:
  4510. case IDM_SKL10:
  4511. case IDM_SKL11:
  4512. case IDM_SKL12:
  4513. case IDM_SKL13:
  4514. {
  4515. HIMC hIMC;
  4516. LPINPUTCONTEXT lpIMC;
  4517. LPPRIVCONTEXT lpImcP;
  4518. DWORD fdwConversion;
  4519. hIMC =(HIMC)GetWindowLongPtr(GetWindow(hWnd,GW_OWNER),IMMGWLP_IMC);
  4520. lpIMC = (LPINPUTCONTEXT)ImmLockIMC(hIMC);
  4521. if (!lpIMC) {
  4522. return (0L);
  4523. }
  4524. lpImcP = (LPPRIVCONTEXT)ImmLockIMCC(lpIMC->hPrivate);
  4525. if (!lpImcP) {
  4526. return (0L);
  4527. }
  4528. {
  4529. UINT i;
  4530. lpImeL->dwSKWant = LOWORD(wParam) - IDM_SKL1;
  4531. lpImeL->dwSKState[lpImeL->dwSKWant] =
  4532. lpImeL->dwSKState[lpImeL->dwSKWant]^1;
  4533. // clear other SK State
  4534. for(i=0; i<NumsSK; i++) {
  4535. if(i == lpImeL->dwSKWant) continue;
  4536. lpImeL->dwSKState[i] = 0;
  4537. }
  4538. if(lpImeL->dwSKState[lpImeL->dwSKWant]) {
  4539. if(LOWORD(wParam) == IDM_SKL1)
  4540. lpImcP->iImeState = CST_INIT;
  4541. else
  4542. lpImcP->iImeState = CST_SOFTKB;
  4543. fdwConversion = lpIMC->fdwConversion | IME_CMODE_SOFTKBD;
  4544. } else {
  4545. lpImcP->iImeState = CST_INIT;
  4546. fdwConversion = lpIMC->fdwConversion & ~(IME_CMODE_SOFTKBD);
  4547. }
  4548. }
  4549. ImmSetConversionStatus(hIMC, (fdwConversion & ~(IME_CMODE_SOFTKBD)),
  4550. lpIMC->fdwSentence);
  4551. ImmSetConversionStatus(hIMC, fdwConversion, lpIMC->fdwSentence);
  4552. ImmUnlockIMCC(lpIMC->hPrivate);
  4553. ImmUnlockIMC(hIMC);
  4554. break;
  4555. }
  4556. case SC_METHOD0:
  4557. break;
  4558. case SC_METHOD9:
  4559. DoPropertySheet(GetActiveWindow(),hWnd);
  4560. ReInitIme( hWnd , lpImeL->wImeStyle );
  4561. break;
  4562. case SC_METHOD4:
  4563. WinExec("ABCWM.exe", SW_SHOW);
  4564. break;
  4565. case SC_METHOD6:
  4566. return 0; // 4.20 94
  4567. case SC_METHOD7:
  4568. WinHelp(hWnd,"winabc.hlp", HELP_FINDER ,0l);
  4569. return 0;
  4570. case SC_METHOD8:
  4571. MessageBeep(0);
  4572. return 0;
  4573. case SC_METHOD10:
  4574. {
  4575. HIMC hIMC;
  4576. LPINPUTCONTEXT lpIMC;
  4577. HWND hUIWnd;
  4578. hUIWnd = GetWindow(hWnd, GW_OWNER);
  4579. if (!hUIWnd) {
  4580. return (0L);
  4581. }
  4582. hIMC = (HIMC)GetWindowLongPtr(hUIWnd, IMMGWLP_IMC);
  4583. if (!hIMC) {
  4584. return (0L);
  4585. }
  4586. lpIMC = (LPINPUTCONTEXT)ImmLockIMC(hIMC);
  4587. if (!lpIMC) {
  4588. return (0L);
  4589. }
  4590. DialogBox(hInst,"wfc", lpIMC->hWnd, OpenDlg);
  4591. ImmUnlockIMC(hIMC);
  4592. break;
  4593. }
  4594. case SC_METHODA:
  4595. return(0);
  4596. case SC_ABOUT:
  4597. {
  4598. HIMC hIMC;
  4599. LPINPUTCONTEXT lpIMC;
  4600. HWND hUIWnd;
  4601. hUIWnd = GetWindow(hWnd, GW_OWNER);
  4602. if (!hUIWnd) {
  4603. return (0L);
  4604. }
  4605. hIMC = (HIMC)GetWindowLongPtr(hUIWnd, IMMGWLP_IMC);
  4606. if (!hIMC) {
  4607. return (0L);
  4608. }
  4609. lpIMC = (LPINPUTCONTEXT)ImmLockIMC(hIMC);
  4610. if (!lpIMC) {
  4611. return (0L);
  4612. }
  4613. DialogBox(hInst, "ABOUT", lpIMC->hWnd, ImeAboutDlgProc);
  4614. ImmUnlockIMC(hIMC);
  4615. break;
  4616. }
  4617. default:
  4618. break;
  4619. }
  4620. return 0;
  4621. }