home *** CD-ROM | disk | FTP | other *** search
/ WordPerfect for Linux Bible / WP4LinuxBible.iso / sdk / wpx / code / wt / client / wtcltmsg.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-06-25  |  17.7 KB  |  583 lines

  1. /* SOURCE FILE *****************************************************
  2.  * WTCLTMSG.C  -  Writing Tool product specific message handling
  3.  *                routines.  A seperate (but similar) set of routines
  4.  *                should be written for each WTAPI-aware product.
  5.  *******************************************************************
  6.  *Copyright (C) 1993 WordPerfect Corp., All Rights Reserved
  7.  *******************************************************************/
  8.  
  9. #include "wtclient.h"
  10.  
  11. #include <string.h>
  12.  
  13. #include <wtapi.h>
  14. #include <wtcomm.h>  
  15.  
  16. extern TOOLRECORD toolRecords[];        /* writing tool records */
  17. extern char FileName[];                    /* current file name */
  18.  
  19. /*----------------------------------------------------------
  20.         External Functions
  21. ------------------------------------------------------------*/
  22. void quitTool(char *);
  23. WTSTATUS GetText(WTUNIT, WTPOS, WTCOUNT, WTUNIT, WTPOS, WTCOUNT, WTTBQTYPE,
  24.     WTSIZE, WTTBQTYPE *, WTBUFP, WTSIZE *);
  25. unsigned SelectedLen(void);
  26. WTSTATUS GoToPos(WTPOS, WTCOUNT, WTPOS, WTCOUNT, unsigned *);
  27. long Hilite(long);
  28. long DeHilite(long);
  29. WTCOUNT ReplaceText(WTCOUNT, WTSIZE, WTBUFP);
  30. unsigned FindCurrBlock(unsigned);
  31. void NativeToWord(WTBUFP, WTSIZE *);
  32. void WordToNative(WTBUFP, WTSIZE *);
  33.  
  34. /*----------------------------------------------------------
  35.         Internal Functions
  36. ------------------------------------------------------------*/
  37. WTSTATUS WTQInfoBlockRcv(WTPTR, WTQINFOBLOCKP, WTRINFOBLOCKP, WTBUFP);
  38. WTSTATUS WTCRqInitRcv(WTPTR, WTCRQINITP, WTBUFP);
  39. WTSTATUS WTCTlTermRcv(WTPTR);
  40. WTSTATUS WTQInfoBlockRcv(WTPTR, WTQINFOBLOCKP, WTRINFOBLOCKP, WTBUFP);
  41. WTSTATUS WTQUnitInfoRcv(WTPTR, WTRUNITINFOP);
  42. WTSTATUS WTQReadToolDataRcv(WTPTR, WTQREADTOOLDATAP, WTRREADTOOLDATAP, WTBUFP);
  43. WTSTATUS WTQWriteToolDataRcv(WTPTR, WTQWRITETOOLDATAP, WTBUFP, WTRWRITETOOLDATAP);
  44. WTSTATUS WTQTextBlockRcv(WTPTR, WTQTEXTBLOCKP, WTRTEXTBLOCKP, WTBUFP);
  45. WTSTATUS WTQNextTextBlockRcv(WTPTR, WTQNEXTTEXTBLOCKP, WTRTEXTBLOCKP, WTBUFP);
  46. WTSTATUS WTQReadTextObjectRcv(WTPTR, WTQREADTEXTOBJECTP, WTRREADTEXTOBJECTP, WTBUFP);
  47. WTSTATUS WTQWriteTextObjectRcv(WTPTR, WTQWRITETEXTOBJECTP, WTBUFP, WTRWRITETEXTOBJECTP);
  48. WTSTATUS WTQGotoRcv(WTPTR, WTQGOTOP, WTRGOTOP);
  49. WTSTATUS WTQHiliteRcv(WTPTR, WTQHILITEP, WTRHILITEP);
  50. WTSTATUS WTQDehiliteRcv(WTPTR, WTQDEHILITEP, WTRDEHILITEP);
  51. WTSTATUS WTQReplaceRcv(WTPTR, WTQREPLACEP, WTBUFP, WTRREPLACEP);
  52. WTSTATUS WTQUndoReplaceRcv(WTPTR, WTRREPLACEP);
  53. WTSTATUS WTCRqClActiveRcv(WTPTR);
  54. WTSTATUS WTCTlInactiveRcv(WTPTR);
  55. WTSTATUS WTQTlActiveRcv(WTPTR, WTRTLACTIVEP);
  56.  
  57. /*COMMENT********************************************************
  58. ;WTCInitSend
  59. Title:    Send the WTC_INIT message
  60. In:        comm = comm info for this session
  61.         msg = message buffer filled with product data
  62. Out:    none
  63. Xin:    none
  64. XOut:    none
  65. Return:    WTSTATUS
  66. Notes:    
  67. *****************************************************************/
  68. WTSTATUS WTCInitSend(WTCOMM comm, WTCINITP msg)
  69. {
  70.     return wtcClSend(comm, WTC_INIT,
  71.         (WTBUFP)msg, (WTSIZE)sizeof(WTCINIT), (WTBUFP)0, 0);
  72. } /* WTCInitSend */
  73.  
  74. /*COMMENT********************************************************
  75. ;WTCClActiveSend
  76. Title:    Send the WTC_CLACTIVE message
  77. In:        comm = comm info for this session
  78.         msg = message buffer filled with product data
  79. Out:    none
  80. Xin:    none
  81. XOut:    none
  82. Return:    WTSTATUS
  83. Notes:    
  84. *****************************************************************/
  85. WTSTATUS WTCClActiveSend(WTCOMM comm, WTCCLACTIVEP msg)
  86. {
  87.     return wtcClSend(comm, WTC_CLACTIVE,
  88.         (WTBUFP)msg, (WTSIZE)sizeof(WTCCLACTIVE), (WTBUFP)0, 0);
  89. } /* WTCClActiveSend */
  90.  
  91. /*COMMENT********************************************************
  92. ;WTCClInactiveSend
  93. Title:    Send the WTC_CLINACTIVE message
  94. In:        comm = comm info for this session
  95.         msg = message buffer filled with product data
  96. Out:    none
  97. Xin:    none
  98. XOut:    none
  99. Return:    WTSTATUS
  100. Notes:    
  101. *****************************************************************/
  102. WTSTATUS WTCClInactiveSend(WTCOMM comm, WTCCLINACTIVEP msg)
  103. {
  104.     return wtcClSend(comm, WTC_CLINACTIVE,
  105.         (WTBUFP)msg, (WTSIZE)sizeof(WTCCLINACTIVE), (WTBUFP)0, 0);
  106. } /* WTCClInactiveSend */
  107.  
  108. /*COMMENT********************************************************
  109. ;WTCRqTlTermSend
  110. Title:    Send the WTQ_CLTERM message
  111. In:        comm = comm info for this session
  112.         inmsg = message buffer filled with product data
  113. Out:    rtmsg = buffer to hold returning WTR_CLTERM message
  114. Xin:    none
  115. XOut:    none
  116. Return:    WTSTATUS
  117. Notes:    
  118. *****************************************************************/
  119. WTSTATUS WTCRqTlTermSend(WTCOMM comm, WTCRQTLTERMP inmsg)
  120. {
  121.     return wtcClSend(comm, WTC_RQTLTERM,
  122.         (WTBUFP)inmsg, (WTSIZE)sizeof(WTCRQTLTERM), (WTBUFP)0, 0);
  123. } /* WTCRqTlTermSend */
  124.  
  125. /*COMMENT********************************************************
  126. ;WTQInfoBlockRcv
  127. Title:    Reply to infoblock message
  128. In:        wtsess = global app data
  129.         inmsg - input message data
  130. Out:    rtmsg - output message data
  131.         rtbuf - location of returned data
  132. Return:    status of process
  133. Notes:    
  134. *****************************************************************/
  135. WTSTATUS WTQInfoBlockRcv(WTPTR wtsess,
  136.     WTQINFOBLOCKP inmsg, WTRINFOBLOCKP rtmsg, WTBUFP rtbuf)
  137. {
  138.     rtmsg->msgid = WTR_INFOBLOCK;    /* WTR_INFOBLOCK msg id */
  139.  
  140.     if (inmsg->resume) {
  141.         rtmsg->status = WTS_CLIENTERROR;
  142.         return WTS_OK;
  143.     }
  144.     if (!((inmsg->suptext & WTX_NATIVE) || (inmsg->suptext & WTX_WPWRD))) {
  145.         rtmsg->status = WTS_COMERROR;
  146.         return WTS_OK;
  147.     }
  148.     wtsess->toolType = inmsg->tooltype;        /* type of writing tool */
  149.     if (inmsg->version != WTAPI_VERSION) {    /* current WTAPI version */
  150.         rtmsg->status = WTS_NOTSUPPORTED;
  151.         return WTS_OK;
  152.     }
  153.     
  154.     rtmsg->status = WTS_OK;        /* return status from client */
  155.     if (inmsg->suptext & WTX_NATIVE) {  /* mode of representing text */
  156.         rtmsg->textmode = WTX_NATIVE;    
  157.     } else if (inmsg->suptext & WTX_WPWRD) {
  158.         rtmsg->textmode = WTX_WPWRD;
  159.     } else {
  160.         rtmsg->textmode = WTX_NATIVE;
  161.     }
  162.     wtsess->textmode = rtmsg->textmode;
  163.     rtmsg->tdamode = 0;                /* supported tool data area modes */
  164.     rtmsg->userlang.script = 0x00;    /* user interface language: US English */
  165.     rtmsg->userlang.language = 0x00;    
  166.     rtmsg->userlang.region = 0x01;    
  167.  
  168.     rtmsg->textlang.script = 0x00;    /* text language: US English */
  169.     rtmsg->textlang.language = 0x00;
  170.     rtmsg->textlang.region = 0x01;
  171.  
  172.     if (SelectedLen()) {
  173.         rtmsg->hastext = 1;        /* the client has default text */
  174.     } else {
  175.         rtmsg->hastext = 0;        /* the client has NO default text */
  176.     }           
  177.     rtmsg->service = 0;            /* writing tool service requested */
  178.     rtmsg->mysize = MYMAXBLOCKSIZE;        /* maximum size block to the client */
  179.     
  180.     strcpy(wtsess->rtText, "WTClient - ");
  181.     if (strlen(FileName)) {
  182.         strcat(wtsess->rtText, FileName);
  183.     } else {
  184.         strcat(wtsess->rtText, "(Untitled)");
  185.     }    
  186.     
  187.     rtmsg->winsize = strlen(wtsess->rtText);    /* size of window name text */
  188.     
  189. #if 0
  190.     if ((wtsess->textmode == WTX_WPWRD) && /* not WP tool */ ) {
  191.         rtmsg->winsize <<= 1;         /* double size */
  192.            NativeToWord(wtsess->rtText, &rtmsg->winsize);
  193.     }
  194. #endif /* 0 */
  195.     
  196.     if (rtmsg->winsize > inmsg->size) {
  197.         rtmsg->complete = 0;                /* text request NOT complete? */
  198.         rtmsg->winsize = inmsg->size;
  199.     } else {
  200.         rtmsg->complete = 1;                /* text request complete. */
  201.     }
  202.     memcpy(rtbuf, wtsess->rtText, (unsigned)rtmsg->winsize);    
  203. } /* WTQInfoBlockRcv */
  204.  
  205. /*COMMENT********************************************************
  206. ;WTCTlTermRcv
  207. Title:    Reply to WTAPI message
  208. In:        wtsess = global app data
  209. Out:    rtmsg - output message data
  210. Return:    status of process
  211. Notes:    
  212. *****************************************************************/
  213. WTSTATUS WTCTlTermRcv(WTPTR wtsess)
  214. {
  215.     quitTool(0);
  216.     return  WTS_OK;
  217. } /* WTCTlTermRcv */
  218.  
  219. /*COMMENT********************************************************
  220. ;WTCRqInitRcv
  221. Title:    Request Writing Tool Initialization
  222. In:        wtsess = global app data
  223. Out:    
  224. Return:    status of process
  225. Notes:    
  226. *****************************************************************/
  227. WTSTATUS WTCRqInitRcv(WTPTR wtsess, WTCRQINITP inmsg, WTBUFP inbuf)
  228. {
  229.     return  WTS_NOTSUPPORTED;
  230. } /* WTCRqInitRcv */
  231.  
  232. /*COMMENT********************************************************
  233. ;WTQUnitInfoRcv
  234. Title:    Reply to UNITINFO message
  235. In:        wtsess - global app data
  236. Out:    rtmsg - output message data
  237. Return:    status of process
  238. Notes:    
  239. *****************************************************************/
  240. WTSTATUS WTQUnitInfoRcv(WTPTR wtsess,  WTRUNITINFOP rtmsg)
  241. {
  242.     rtmsg->msgid = WTR_UNITINFO;
  243.     rtmsg->status = WTS_OK;
  244.     rtmsg->supunit = WTU_DOCUMENT|WTU_SELECTION|WTU_CHAR;
  245.     rtmsg->curunit = WTU_DOCUMENT|WTU_CHAR;
  246.     rtmsg->defunit = WTU_DOCUMENT;
  247.     rtmsg->size = 0;
  248.     return WTS_OK;
  249. } /* WTQUnitInfoRcv */
  250.  
  251. /*COMMENT********************************************************
  252. ;WTQReadToolDataRcv
  253. Title:    Reply to READTOOLDATA message
  254. In:        wtsess = global app data
  255.         inmsg - input message data
  256. Out:    rtmsg - output message data
  257.         rtbuf - output buffer
  258. Return:    status of process
  259. Notes:    
  260. *****************************************************************/
  261. WTSTATUS WTQReadToolDataRcv(WTPTR wtsess,
  262.     WTQREADTOOLDATAP inmsg, WTRREADTOOLDATAP rtmsg, WTBUFP rtbuf)
  263. {
  264.     rtmsg->msgid = WTR_READTOOLDATA;
  265.     rtmsg->status = WTS_NOTSUPPORTED;
  266.     return WTS_OK;
  267. } /* WTQReadToolDataRcv */
  268.  
  269. /*COMMENT********************************************************
  270. ;WTQWriteToolDataRcv
  271. Title:    Reply to WRITETOOLDATA message
  272. In:        wtsess - global app data
  273.         inmsg - input message data
  274.         inbuf - input buffer
  275. Out:    rtmsg - output message data
  276. Return:    status of process
  277. Notes:    
  278. *****************************************************************/
  279. WTSTATUS WTQWriteToolDataRcv(WTPTR wtsess,
  280.     WTQWRITETOOLDATAP inmsg, WTBUFP inbuf, WTRWRITETOOLDATAP rtmsg)
  281. {
  282.     rtmsg->status = WTS_NOTSUPPORTED;
  283.     rtmsg->msgid = WTR_WRITETOOLDATA;
  284.     return WTS_OK;
  285. } /* WTQWriteToolDataRcv */
  286.  
  287. /*COMMENT********************************************************
  288. ;WTQReadTextObjectRcv
  289. Title:    Reply to READTEXTOBJECT message
  290. In:        wtsess = global app data
  291.         inmsg - input message data
  292. Out:    rtmsg - output message data
  293.         rtbuf - output buffer
  294. Return:    status of process
  295. Notes:    
  296. *****************************************************************/
  297. WTSTATUS WTQReadTextObjectRcv(WTPTR wtsess,  WTQREADTEXTOBJECTP inmsg, WTRREADTEXTOBJECTP rtmsg, WTBUFP rtbuf)
  298. {
  299.     rtmsg->msgid = WTR_READTEXTOBJECT;
  300.     rtmsg->status = WTS_NOTSUPPORTED;
  301.     return WTS_OK;
  302. } /* WTQReadTextObjectRcv */
  303.  
  304. /*COMMENT********************************************************
  305. ;WTQWriteTextObjectRcv
  306. Title:    Reply to WRITETEXTOBJECT message
  307. In:        wtsess - global app data
  308.         inmsg - input message data
  309.         inbuf - input buffer
  310. Out:    rtmsg - output message data
  311. Return:    status of process
  312. Notes:    
  313. *****************************************************************/
  314. WTSTATUS WTQWriteTextObjectRcv(WTPTR wtsess,  WTQWRITETEXTOBJECTP inmsg, WTBUFP inbuf, WTRWRITETEXTOBJECTP rtmsg)
  315. {
  316.     rtmsg->status = WTS_NOTSUPPORTED;
  317.     rtmsg->msgid = WTR_WRITETEXTOBJECT;
  318.     return WTS_OK;
  319. } /* WTQWriteTextObjectRcv */
  320.  
  321. /*COMMENT********************************************************
  322. ;WTQTextBlockRcv
  323. Title:    Reply to TEXTBLOCK message
  324. In:        wtsess - global app data
  325.         inmsg - input message data
  326. Out:    rtmsg - output message data
  327.         rtbuf - output buffer
  328. Return:    status of process
  329. Notes:    
  330. *****************************************************************/
  331. WTSTATUS WTQTextBlockRcv(WTPTR wtsess,
  332.     WTQTEXTBLOCKP inmsg, WTRTEXTBLOCKP rtmsg, WTBUFP rtbuf)
  333. {
  334.     WTSTATUS status;
  335.         
  336.     rtmsg->msgid = WTR_TEXTBLOCK;
  337.     
  338.     if (wtsess->textmode == WTX_WPWRD) {
  339.         rtmsg->size >>= 1;    /* 1/2 buffer size */
  340.     }
  341.         
  342.     status = GetText(inmsg->fromunit, inmsg->frompos, inmsg->fromloc, 
  343.             inmsg->tounit, inmsg->topos, inmsg->toloc, 
  344.             inmsg->qtype, inmsg->size, &rtmsg->endblock, rtbuf, &rtmsg->size);
  345.     rtmsg->status = status;
  346.     
  347.     if (wtsess->textmode == WTX_WPWRD) {
  348.         NativeToWord(rtbuf, &rtmsg->size);
  349.     }
  350.     
  351.     if (status != WTS_OK) {
  352.         rtmsg->size = 0;
  353.     }
  354.     rtmsg->language.script = 0;        /* English U.S. */
  355.     rtmsg->language.language = 0;
  356.     rtmsg->language.region = 1;
  357.     rtmsg->depth = 0;
  358.     /* rtmsg->blocknum = wtsess->lastBlock; */
  359.     rtmsg->depth = wtsess->lastBlock;
  360.     return status;
  361. } /* WTQTextBlockRcv */
  362.  
  363. /*COMMENT********************************************************
  364. ;WTQNextTextBlockRcv
  365. Title:    Reply to NEXTTEXTBLOCK message
  366. In:        wtsess = global app data
  367.         inmsg - input message data
  368. Out:    rtmsg - output message data
  369.         rtbuf - output buffer
  370. Return:    status of process
  371. Notes:    
  372. *****************************************************************/
  373. WTSTATUS WTQNextTextBlockRcv(WTPTR wtsess,
  374.     WTQNEXTTEXTBLOCKP inmsg, WTRTEXTBLOCKP rtmsg, WTBUFP rtbuf)
  375. {        
  376.     rtmsg->msgid = WTR_TEXTBLOCK;
  377.     
  378.     if (wtsess->textmode == WTX_WPWRD) {
  379.         rtmsg->size >>= 1;    /* 1/2 buffer size */
  380.     }
  381.  
  382.     rtmsg->status = GetText(0, 0, 0, 
  383.             wtsess->tounit, wtsess->topos, wtsess->toloc, 
  384.             WTB_RESUME, inmsg->size, &rtmsg->endblock, rtbuf, &rtmsg->size);
  385.  
  386.     if (wtsess->textmode == WTX_WPWRD) {
  387.         NativeToWord(rtbuf, &rtmsg->size);
  388.     }
  389.  
  390.     if (rtmsg->status != WTS_OK) {
  391.         rtmsg->size = 0;
  392.     }
  393.     rtmsg->language.script = 0;        /* English U.S. */
  394.     rtmsg->language.language = 0;
  395.     rtmsg->language.region = 1;
  396.     rtmsg->depth = 0;
  397.     /* rtmsg->blocknum = wtsess->lastBlock; */
  398.     rtmsg->depth = wtsess->lastBlock;
  399.     return WTS_OK;
  400. } /* WTQNextTextBlockRcv */
  401.  
  402. /*COMMENT********************************************************
  403. ;WTQGotoRcv
  404. Title:    Reply to GOTO message
  405. In:        wtsess = global app data
  406.         inmsg - input message data
  407. Out:    rtmsg - output message data
  408. Return:    status of process
  409. Notes:    
  410. *****************************************************************/
  411. WTSTATUS WTQGotoRcv(WTPTR wtsess,  WTQGOTOP inmsg, WTRGOTOP rtmsg)
  412. {
  413.     unsigned position=0;
  414.  
  415.     rtmsg->msgid = WTR_GOTO;
  416.  
  417.     if (wtsess->textmode == WTX_WPWRD) {
  418.         inmsg->offsetloc >>= 1;    /* 1/2 len */
  419.     }
  420.  
  421.     rtmsg->status = GoToPos(inmsg->blockpos, inmsg->blocknum,
  422.                     inmsg->offsetpos, inmsg->offsetloc, &position);
  423.     if (rtmsg->status == WTS_OK) {    
  424.         rtmsg->count = position - wtsess->absPos;
  425.         wtsess->absPos = position;
  426.         
  427.         /* get current block & position in block */
  428.         wtsess->currBlock = FindCurrBlock(position);
  429.         wtsess->absPos = position;
  430.     }
  431.  
  432.     rtmsg->offset = wtsess->absPos - wtsess->textInfo[wtsess->currBlock].offset;
  433.     
  434.     if (wtsess->textmode == WTX_WPWRD) {
  435.         rtmsg->offset <<= 1;    /* double offset */
  436.     }
  437.     rtmsg->block = wtsess->currBlock;
  438.     return WTS_OK;
  439. } /* WTQGotoRcv */
  440.  
  441. /*COMMENT********************************************************
  442. ;WTQHiliteRcv
  443. Title:    Reply to HILITE message
  444. In:        wtsess = global app data
  445.         inmsg - input message data
  446. Out:    rtmsg - output message data
  447. Return:    status of process
  448. Notes:    
  449. *****************************************************************/
  450. WTSTATUS WTQHiliteRcv(WTPTR wtsess,  WTQHILITEP inmsg, WTRHILITEP rtmsg)
  451. {
  452.     rtmsg->msgid = WTR_HILITE;
  453.     rtmsg->status = WTS_OK;
  454.  
  455.     if (wtsess->textmode == WTX_WPWRD) {
  456.         rtmsg->count = (Hilite(inmsg->count >> 1) << 1);
  457.     } else {
  458.         rtmsg->count = Hilite(inmsg->count);
  459.     }
  460.     return WTS_OK;
  461. } /* WTQHiliteRcv */
  462.  
  463. /*COMMENT********************************************************
  464. ;WTQDehiliteRcv
  465. Title:    Reply to WTAPI message
  466. In:        wtsess = global app data
  467.         inmsg - input message data
  468. Out:    rtmsg - output message data
  469. Return:    status of process
  470. Notes:    
  471. *****************************************************************/
  472. WTSTATUS WTQDehiliteRcv(WTPTR wtsess,  WTQDEHILITEP inmsg, WTRDEHILITEP rtmsg)
  473. {
  474.     rtmsg->msgid = WTR_DEHILITE;
  475.     rtmsg->status = WTS_OK;
  476.     if (wtsess->textmode == WTX_WPWRD) {
  477.         rtmsg->count = (DeHilite(inmsg->count >> 1) << 1);
  478.     } else {
  479.         rtmsg->count = DeHilite(inmsg->count);
  480.     }
  481.     return WTS_OK;
  482. } /* WTQDehiliteRcv */
  483.  
  484. /*COMMENT********************************************************
  485. ;WTQReplaceRcv
  486. Title:    Reply to WTAPI message
  487. In:        wtsess = global app data
  488.         inmsg - input message data
  489.         inbuf - input buffer
  490. Out:    rtmsg - output message data
  491. Return:    status of process
  492. Notes:    
  493. *****************************************************************/
  494. WTSTATUS WTQReplaceRcv(WTPTR wtsess,
  495.     WTQREPLACEP inmsg, WTBUFP inbuf, WTRREPLACEP rtmsg)
  496. {
  497.     char replace[MYMAXBLOCKSIZE];
  498.  
  499.     if (inmsg->size < MYMAXBLOCKSIZE) {
  500.         memcpy(replace, (char *)inbuf, inmsg->size);
  501.         replace[inmsg->size] = 0;    /* make sure is null-terminated */
  502.     } else {
  503.         memcpy(replace, inbuf, MYMAXBLOCKSIZE);
  504.         replace[MYMAXBLOCKSIZE-1] = 0;
  505.     }
  506.  
  507.     rtmsg->msgid = WTR_REPLACE;
  508.  
  509.     if (wtsess->textmode == WTX_WPWRD) {
  510.         WordToNative(replace, &inmsg->size);
  511.         inmsg->count >>= 1;        /* 1/2 of count */
  512.     }
  513.  
  514.     rtmsg->status = WTS_OK;
  515.     rtmsg->count = ReplaceText(inmsg->count, inmsg->size, replace);
  516.     rtmsg->size = inmsg->size;    /* bytes inserted */
  517.  
  518.     rtmsg->block = wtsess->currBlock;
  519.     rtmsg->offset = wtsess->absPos - wtsess->textInfo[wtsess->currBlock].offset;
  520.     if (wtsess->textmode == WTX_WPWRD) {
  521.         rtmsg->count <<= 1;
  522.         rtmsg->size <<= 1;
  523.         rtmsg->offset <<= 1;
  524.     }
  525.     return WTS_OK;
  526. } /* WTQReplaceRcv */
  527.  
  528. /*COMMENT********************************************************
  529. ;WTQUndoReplaceRcv
  530. Title:    Reply to WTAPI message
  531. In:        wtsess = global app data
  532. Out:    rtmsg - output message data
  533. Return:    status of process
  534. Notes:    
  535. *****************************************************************/
  536. WTSTATUS WTQUndoReplaceRcv(WTPTR wtsess, WTRREPLACEP rtmsg)
  537. {
  538.     rtmsg->status = WTS_NOTSUPPORTED;
  539.     rtmsg->msgid = WTR_REPLACE;
  540.     return WTS_OK;
  541. } /* WTQUndoReplaceRcv */
  542.  
  543. /*COMMENT********************************************************
  544. ;WTCRqClActiveRcv
  545. Title:    Reply to WTAPI message
  546. In:        wtsess = global app data
  547. Out:    
  548. Return:    status of process
  549. Notes:    
  550. *****************************************************************/
  551. WTSTATUS WTCRqClActiveRcv(WTPTR wtsess)
  552. {
  553.     return WTS_OK;
  554. } /* WTCRqClActiveRcv */
  555.  
  556. /*COMMENT********************************************************
  557. ;WTCTlInactiveRcv
  558. Title:    Reply to WTAPI message
  559. In:        wtsess = global app data
  560. Out:    
  561. Return:    status of process
  562. Notes:    
  563. *****************************************************************/
  564. WTSTATUS WTCTlInactiveRcv(WTPTR wtsess)
  565. {
  566.     return WTS_OK;
  567. } /* WTCTlInactiveRcv */
  568.  
  569. /*COMMENT********************************************************
  570. ;WTQTlActiveRcv
  571. Title:    Reply to WTAPI message
  572. In:        wtsess = global app data
  573. Out:    rtmsg - output message data
  574. Return:    status of process
  575. Notes:    
  576. *****************************************************************/
  577. WTSTATUS WTQTlActiveRcv(WTPTR wtsess, WTRTLACTIVEP rtmsg)
  578. {
  579.     rtmsg->status = WTS_NOTSUPPORTED;
  580.     rtmsg->msgid = WTR_TLACTIVE;
  581.     return WTS_OK;
  582. } /* WTQTlActiveRcv */
  583.