Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2597 lines
66 KiB

  1. /*===========================================================================*/
  2. /* Copyright (c) 1987 - 1988, Future Soft Engineering, Inc. */
  3. /* Houston, Texas */
  4. /*===========================================================================*/
  5. #define NOLSTRING TRUE /* jtf win3 mod */
  6. #include <windows.h>
  7. #include "port1632.h"
  8. #include "dcrc.h"
  9. #include "dynacomm.h"
  10. #include "task.h"
  11. #include "video.h"
  12. #include "printfil.h"
  13. static BOOL decPrivate; /* True if ? in set mode string */
  14. static BOOL heathPrivate; /* True if > in set mode string */
  15. #define MAXANSIARGS 10
  16. static INT argNdx;
  17. static INT argCount;
  18. static INT ansiArg;
  19. static INT argList[MAXANSIARGS+1];
  20. static INT vidFG;
  21. static INT p1;
  22. static INT p2;
  23. static INT saveCol = 0;
  24. static INT saveLin = 0;
  25. /*---------------------------------------------------------------------------*/
  26. /* valIndex() - Return index into buffer given current line & column. [scf] */
  27. /*---------------------------------------------------------------------------*/
  28. INT valIndex ()
  29. {
  30. return ((curLin + savTopLine) * (maxChars + 2) + curCol);
  31. }
  32. /*---------------------------------------------------------------------------*/
  33. /* cleanRect() - Erase nLines starting at line */
  34. /*---------------------------------------------------------------------------*/
  35. VOID cleanRect(INT line, INT nLines)
  36. {
  37. RECT eraseRect;
  38. INT eraseLine;
  39. eraseRect = hTE.viewRect;
  40. eraseRect.top = (line + (savTopLine - curTopLine)) * chrHeight;
  41. if((eraseLine = eraseRect.top + (nLines * chrHeight)) < eraseRect.bottom)
  42. eraseRect.bottom = eraseLine;
  43. if(eraseRect.top < eraseRect.bottom)
  44. {
  45. eraseColorRect((HDC) getPort(), (LPRECT) &eraseRect, ANORMAL);
  46. releasePort();
  47. }
  48. }
  49. /*---------------------------------------------------------------------------*/
  50. /* scrollBuffer() - [scf] */
  51. /*---------------------------------------------------------------------------*/
  52. proc scrollBuffer ()
  53. {
  54. register INT line; // sdj: was unref- count;
  55. INT buffLines;
  56. RECT scrollRect, notScrollRect;
  57. buffLines = savTopLine - curTopLine;
  58. buffLines = min (buffLines, visScreenLine + 1);
  59. if (buffLines > 0)
  60. {
  61. scrollRect = notScrollRect = hTE.viewRect;
  62. if (lineFeeds < buffLines)
  63. {
  64. scrollRect.bottom = buffLines * chrHeight;
  65. ScrollWindow (hTermWnd, 0, -(lineFeeds * chrHeight),
  66. (LPRECT) &scrollRect, (LPRECT) &scrollRect);
  67. }
  68. lineFeeds = min (buffLines, lineFeeds);
  69. line = -lineFeeds;
  70. if(curTopLine == 0)
  71. line += (visScreenLine+1) - savTopLine;
  72. reDrawTermScreen(0, lineFeeds, line);
  73. notScrollRect.top = scrollRect.bottom; /* Only validate our */
  74. ValidateRect (hTermWnd, (LPRECT) &notScrollRect); /* stuff that we */
  75. } /* repaint */
  76. lineFeeds = 0;
  77. }
  78. /*---------------------------------------------------------------------------*/
  79. /* doScroll() - */
  80. /*---------------------------------------------------------------------------*/
  81. proc doScroll ()
  82. {
  83. INT top, bottom, line, nLines; //sdj: was unref- buffLines;
  84. RECT scrollRect, uncoveredRect;
  85. top = savTopLine - curTopLine + scrollBegin;
  86. bottom = top + (scrollEnd + 1 - scrollBegin);
  87. top = max (top, 0);
  88. bottom = min (bottom, visScreenLine + 1);
  89. scrollRect.top = top * chrHeight;
  90. scrollRect.bottom = bottom * chrHeight;
  91. scrollRect.right = hTE.viewRect.right;
  92. scrollRect.left = hTE.viewRect.left;
  93. getPort ();
  94. clipRect (&hTE.viewRect);
  95. if (scrollRect.bottom > scrollRect.top)
  96. {
  97. hideTermCursor ();
  98. if (abs(nScroll) < bottom - top)
  99. {
  100. ScrollWindow (hTermWnd, 0, -(nScroll * chrHeight),
  101. (LPRECT) &scrollRect, (LPRECT) &scrollRect);
  102. uncoveredRect.right = hTE.viewRect.right;
  103. uncoveredRect.left = hTE.viewRect.left;
  104. if (nScroll < 0) /* Inserting lines */
  105. {
  106. uncoveredRect.top = scrollRect.top;
  107. uncoveredRect.bottom = scrollRect.top + ((-nScroll) * chrHeight);
  108. } else /* Line feeds or deleting lines */
  109. {
  110. uncoveredRect.top = scrollRect.bottom - nScroll * chrHeight;
  111. uncoveredRect.bottom = scrollRect.bottom;
  112. }
  113. ValidateRect (hTermWnd, (LPRECT) &uncoveredRect);
  114. }
  115. nLines = min (abs(nScroll), bottom - top);
  116. if (nScroll > 0)
  117. top = bottom - nLines + curTopLine - savTopLine;
  118. else
  119. top = top + curTopLine - savTopLine;
  120. for (line = top; line < top + nLines; line++)
  121. attrib[line][LFLAGS] = (LDIRTY | LCLEAR);
  122. showTermCursor ();
  123. }
  124. releasePort ();
  125. nScroll = 0;
  126. }
  127. /*---------------------------------------------------------------------------*/
  128. /* termCleanUp() - */
  129. /*---------------------------------------------------------------------------*/
  130. VOID termCleanUp ()
  131. {
  132. register INT line, lin2;
  133. BYTE lattr;
  134. // sdj: was unref local - BYTE *attr;
  135. checkSelect();
  136. if(nScroll != 0)
  137. doScroll();
  138. if(lineFeeds != 0)
  139. scrollBuffer();
  140. for(line = 0; line <= maxScreenLine+1; )
  141. {
  142. lattr = attrib[line][LFLAGS];
  143. if(lattr & LDIRTY)
  144. {
  145. updateLine(line);
  146. line++;
  147. }
  148. else if(lattr & LCLEAR)
  149. {
  150. attrib[line][LFLAGS] = 0;
  151. for(lin2 = line+1; lin2 <= maxScreenLine; lin2++)
  152. {
  153. if (lattr != attrib[lin2][LFLAGS])
  154. break;
  155. attrib[lin2][LFLAGS] = 0;
  156. }
  157. cleanRect (line, lin2 - line);
  158. line = lin2;
  159. }
  160. else
  161. line++;
  162. }
  163. termDirty = FALSE; /* mbbx: termLine -> termDirty */
  164. }
  165. /*---------------------------------------------------------------------------*/
  166. /* putChar() - Put received characters into buffer [scf] */
  167. /*---------------------------------------------------------------------------*/
  168. proc putChar(BYTE ch)
  169. {
  170. INT ndx;
  171. LPBYTE txtPtr;
  172. LPBYTE txtSrc;
  173. LPBYTE txtDst;
  174. INT theLine;
  175. INT len;
  176. BYTE *attr;
  177. txtPtr = GlobalLock(hTE.hText);
  178. if(!statusLine)
  179. {
  180. ndx = (curLin + savTopLine) * (maxChars + 2) + curCol;
  181. theLine = curLin;
  182. }
  183. else
  184. {
  185. ndx = curCol;
  186. txtPtr = (LPBYTE) line25;
  187. theLine = maxScreenLine + 1;
  188. }
  189. attr = attrib[theLine];
  190. // if (attr[curCol] & ADIRTY)
  191. // termCleanUp();
  192. if (chInsMode)
  193. {
  194. len = maxChars - curCol - 2;
  195. if (len > 0)
  196. {
  197. txtSrc = txtPtr + ndx;
  198. txtDst = txtSrc + 1;
  199. blockMove (txtSrc, txtDst, len);
  200. txtSrc = (LPBYTE) attrib + theLine * ATTRROWLEN + curCol;
  201. txtDst = txtSrc + 1;
  202. blockMove (txtSrc, txtDst, len);
  203. attr[LFLAGS] = LCLEAR;
  204. }
  205. }
  206. if(!(termData.flags & TF_DIM))
  207. txtPtr[ndx] = ch;
  208. GlobalUnlock (hTE.hText);
  209. attr[curCol] = curAttrib | ADIRTY;
  210. attr[LFLAGS] |= LDIRTY;
  211. termDirty = TRUE;
  212. termCleanUp();
  213. }
  214. /*---------------------------------------------------------------------------*/
  215. /* checkSelect() - [scf] */
  216. /*---------------------------------------------------------------------------*/
  217. VOID checkSelect()
  218. {
  219. LONG savTopNdx;
  220. if (activSelect)
  221. {
  222. noSelect = FALSE;
  223. savTopNdx = savTopLine*(maxChars + 2);
  224. if (hTE.selEnd > savTopNdx)
  225. if (savTopNdx <= hTE.selStart)
  226. {
  227. termSetSelect (MAXINTL, MAXINTL);
  228. activSelect = FALSE;
  229. }
  230. else
  231. termSetSelect (hTE.selStart, savTopNdx);
  232. }
  233. else
  234. if(!noSelect)
  235. {
  236. termSetSelect (MAXINTL, MAXINTL);
  237. noSelect = TRUE;
  238. }
  239. }
  240. /*---------------------------------------------------------------------------*/
  241. /* clrAttrib() - [scf] */
  242. /*---------------------------------------------------------------------------*/
  243. VOID clrAttrib (INT startLin, INT endLin, INT startCol, INT endCol)
  244. {
  245. INT lin, col;
  246. for (lin = startLin; lin <= endLin; lin++)
  247. for (col = startCol; col <= endCol; col++)
  248. attrib[lin][col] = 0;
  249. }
  250. /*---------------------------------------------------------------------------*/
  251. /* clrLines() - */
  252. /*---------------------------------------------------------------------------*/
  253. proc clrLines (INT lin1, INT lin2)
  254. {
  255. LPBYTE txt, attr;
  256. register INT line;
  257. txt = (LPBYTE)GlobalLock (hTE.hText) + (savTopLine + lin1) * (maxChars + 2);
  258. if(lin1 == 24)
  259. txt = (LPBYTE) line25;
  260. for(line = lin1; line <= lin2; line++)
  261. {
  262. if(!protectMode) /* mbbx: protected fields */
  263. {
  264. attr = attrib[line];
  265. if(attr[LFLAGS])
  266. termCleanUp();
  267. lsetmem(txt, CHFILL, maxChars);
  268. lsetmem(attr, 0, maxChars);
  269. attr[LFLAGS] = LCLEAR;
  270. attr[LATTRIB] = LNORMAL; /* mbbx: mac version */
  271. txt += maxChars + 2;
  272. attr += ATTRROWLEN;
  273. }
  274. else
  275. clrChars(line, 0, maxChars-1);
  276. }
  277. GlobalUnlock (hTE.hText);
  278. termDirty = TRUE; /* mbbx: set dirty flag */
  279. }
  280. /*---------------------------------------------------------------------------*/
  281. /* clrChars() - */
  282. /*---------------------------------------------------------------------------*/
  283. proc clrChars (INT line, INT col1, INT col2)
  284. {
  285. LPBYTE txt, attr;
  286. register INT col;
  287. txt = (LPBYTE)GlobalLock(hTE.hText) + (savTopLine + line) * (maxChars + 2) + col1;
  288. if(line == 24)
  289. txt = (LPBYTE) line25 + col1;
  290. attr = attrib[line] + col1;
  291. for(col = col1; col <= col2; col++)
  292. {
  293. if(*attr & ADIRTY)
  294. termCleanUp();
  295. if(!protectMode || !(*attr & APROTECT)) /* mbbx: protected fields */
  296. {
  297. *txt = CHFILL;
  298. *attr |= ADIRTY;
  299. }
  300. txt += 1;
  301. attr += 1;
  302. }
  303. attrib[line][LFLAGS] = LDIRTY;
  304. GlobalUnlock (hTE.hText);
  305. termDirty = TRUE; /* mbbx: set dirty flag */
  306. }
  307. /*---------------------------------------------------------------------------*/
  308. /* getUnprot() - [mbb] */
  309. /*---------------------------------------------------------------------------*/
  310. VOID getUnprot(INT begLin, INT begCol, INT *lin, INT *col)
  311. {
  312. INT iLin;
  313. INT iCol;
  314. *lin = 0;
  315. *col = 0;
  316. for(iLin = begLin; iLin < maxScreenLine; iLin++) /* MBBX: TEST LIMITS!!! */
  317. for(iCol = begCol; iCol < maxChars; iCol++)
  318. if(!(attrib[iLin][iCol] & APROTECT))
  319. {
  320. *lin = iLin;
  321. *col = iCol;
  322. break;
  323. }
  324. }
  325. /*---------------------------------------------------------------------------*/
  326. /* getProtCol() - [mbb] */
  327. /*---------------------------------------------------------------------------*/
  328. INT getProtCol()
  329. {
  330. INT col;
  331. for(col = curCol; col+1 < maxChars; col++)
  332. if(attrib[curLin][col+1] & APROTECT)
  333. break;
  334. return(col);
  335. }
  336. /*---------------------------------------------------------------------------*/
  337. /* pCursToggle() - [scf] */
  338. /*---------------------------------------------------------------------------*/
  339. proc pCursToggle ()
  340. {
  341. if (cursorOn == 1)
  342. offCursor ();
  343. else if (cursorOn == 0)
  344. onCursor ();
  345. termState = NULL;
  346. }
  347. /*---------------------------------------------------------------------------*/
  348. /* pCursOn() - [scf] */
  349. /*---------------------------------------------------------------------------*/
  350. proc pCursOn ()
  351. {
  352. onCursor ();
  353. termState = NULL;
  354. }
  355. /*---------------------------------------------------------------------------*/
  356. /* pCursOff() - [scf] */
  357. /*---------------------------------------------------------------------------*/
  358. proc pCursOff ()
  359. {
  360. offCursor ();
  361. termState = NULL;
  362. }
  363. /*---------------------------------------------------------------------------*/
  364. /* pCursRC() - [scf] */
  365. /*---------------------------------------------------------------------------*/
  366. proc pCursRC ()
  367. {
  368. INT maxWide;
  369. if (escLin == -1)
  370. {
  371. escLin = ch - ' ';
  372. if ((escLin < 0) || (escLin > maxScreenLine))
  373. termState = NULL;
  374. }
  375. else
  376. {
  377. escCol = ch - ' ';
  378. if ((escCol >= 0) && (escCol < maxChars))
  379. {
  380. curLin = escLin;
  381. curCol = escCol;
  382. maxWide = maxChars / 2 - 1;
  383. if (attrib[curLin][LATTRIB] != LNORMAL)
  384. if (curCol > maxWide)
  385. curCol = maxWide;
  386. }
  387. termState = NULL;
  388. }
  389. if (termState == NULL)
  390. escLin = -1;
  391. }
  392. /*---------------------------------------------------------------------------*/
  393. /* pSetStatusLine() - */
  394. /*---------------------------------------------------------------------------*/
  395. proc pSetStatusLine() /* mbbx 1.03: TV925 ... */
  396. {
  397. curLin = 24;
  398. curCol = 0;
  399. statusLine = TRUE;
  400. termState = NULL;
  401. }
  402. /*---------------------------------------------------------------------------*/
  403. /* pCursHome() - Home the terminal emulation cursor [scf] */
  404. /*---------------------------------------------------------------------------*/
  405. proc pCursHome ()
  406. {
  407. curLin = 0;
  408. curCol = 0;
  409. termState = NULL;
  410. }
  411. /*---------------------------------------------------------------------------*/
  412. /* pVideo() - [scf] */
  413. /*---------------------------------------------------------------------------*/
  414. proc pVideo(BYTE attr)
  415. {
  416. if(attr == 0)
  417. curAttrib = 0;
  418. else
  419. curAttrib |= attr;
  420. termState = NULL;
  421. }
  422. /*---------------------------------------------------------------------------*/
  423. /* pCursRelative() - Move cursor relative to current position [scf] */
  424. /*---------------------------------------------------------------------------*/
  425. proc pCursRelative (INT dh, INT dv)
  426. {
  427. INT maxWide;
  428. curLin += dv;
  429. curCol += dh;
  430. if (curLin < 0)
  431. curLin = 0;
  432. else if (curLin > maxScreenLine)
  433. curLin = maxScreenLine;
  434. if (curCol < 0)
  435. curCol = 0;
  436. else if (curCol > (maxChars - 1))
  437. curCol = maxChars - 1;
  438. if (attrib[curLin][LATTRIB] != LNORMAL)
  439. {
  440. maxWide = maxChars / 2 - 1;
  441. if (curCol > maxWide)
  442. curCol = maxWide;
  443. }
  444. termState = NULL;
  445. }
  446. /*---------------------------------------------------------------------------*/
  447. /* pCursUp() - Move terminal emulation cursor up one relative to curr [scf] */
  448. /*---------------------------------------------------------------------------*/
  449. proc pCursUp ()
  450. {
  451. pCursRelative (0, -1);
  452. }
  453. /*---------------------------------------------------------------------------*/
  454. /* pCursDn() - Move terminal emulation cursor down one relative to curr [scf]*/
  455. /*---------------------------------------------------------------------------*/
  456. proc pCursDn ()
  457. {
  458. pCursRelative (0, 1);
  459. }
  460. /*---------------------------------------------------------------------------*/
  461. /* pCursRt() - Move terminal emulation cursor right one relative to curr[scf]*/
  462. /*---------------------------------------------------------------------------*/
  463. proc pCursRt ()
  464. {
  465. pCursRelative (1, 0);
  466. }
  467. /*---------------------------------------------------------------------------*/
  468. /* pCursLt() - Move terminal emulation cursor left one relative to curr [scf]*/
  469. /*---------------------------------------------------------------------------*/
  470. proc pCursLt ()
  471. {
  472. pCursRelative (-1, 0);
  473. }
  474. /*---------------------------------------------------------------------------*/
  475. /* pVPosAbsolute() - [scf] */
  476. /*---------------------------------------------------------------------------*/
  477. proc pVPosAbsolute ()
  478. {
  479. INT vPos;
  480. vPos = chAscii & 0x1f;
  481. curLin = vPos % (maxScreenLine + 1);
  482. escSeq = FALSE;
  483. escExtend = EXNONE;
  484. termState = NULL;
  485. }
  486. /*---------------------------------------------------------------------------*/
  487. /* pHPosAbsolute() -- [scf] */
  488. /*---------------------------------------------------------------------------*/
  489. proc pHPosAbsolute ()
  490. {
  491. INT hPos;
  492. hPos = ((chAscii & 0x70) / 16) * 10; /* to BCD! */
  493. hPos += chAscii & 0x0f;
  494. curCol = hPos % 80;
  495. termState = NULL;
  496. }
  497. /*---------------------------------------------------------------------------*/
  498. /* pClrScr() - Clear the screen including attributes. */
  499. /*---------------------------------------------------------------------------*/
  500. VOID NEAR pClrScr()
  501. {
  502. pCursHome();
  503. clrLines(0, maxScreenLine);
  504. termState = NULL;
  505. }
  506. VOID FAR fpClrScr() /* mbbx: called from aFAR ... */
  507. {
  508. pClrScr();
  509. }
  510. /*---------------------------------------------------------------------------*/
  511. /* pClrBol() - Clear terminal emulation video from current to beg. of line. */
  512. /*---------------------------------------------------------------------------*/
  513. proc pClrBol ()
  514. {
  515. if (curCol == maxChars-1)
  516. clrLines (curLin, curLin);
  517. else
  518. clrChars (curLin, 0, curCol);
  519. termState = NULL;
  520. }
  521. /*---------------------------------------------------------------------------*/
  522. /* pClrBop() - Clear terminal emulation video from curr to beg. of page. */
  523. /*---------------------------------------------------------------------------*/
  524. proc pClrBop ()
  525. {
  526. pClrBol ();
  527. if (curLin > 0)
  528. clrLines (0, curLin-1);
  529. termState = NULL;
  530. }
  531. /*---------------------------------------------------------------------------*/
  532. /* pClrEol() - Clear logical IT video from present to end of line. [scf] */
  533. /*---------------------------------------------------------------------------*/
  534. proc pClrEol ()
  535. {
  536. if (curCol == 0)
  537. clrLines (curLin, curLin);
  538. else
  539. clrChars (curLin, curCol, maxChars-1);
  540. termState = NULL;
  541. }
  542. /*---------------------------------------------------------------------------*/
  543. /* pClrEop() - Clear the logical IT video from present to end of page. [scf] */
  544. /*---------------------------------------------------------------------------*/
  545. proc pClrEop ()
  546. {
  547. pClrEol ();
  548. if (curLin < maxScreenLine)
  549. clrLines (curLin + 1, maxScreenLine);
  550. termState = NULL;
  551. }
  552. /*---------------------------------------------------------------------------*/
  553. /* pClrLine () Clear logical IT video from beginning to end of line. [scf] */
  554. /*---------------------------------------------------------------------------*/
  555. proc pClrLine ()
  556. {
  557. clrLines (curLin, curLin);
  558. }
  559. /*---------------------------------------------------------------------------*/
  560. /* scrollAttrib () - [scf] */
  561. /*---------------------------------------------------------------------------*/
  562. proc scrollAttrib (INT startLin, INT endLin, INT nLines, BOOL up)
  563. {
  564. LPBYTE txtSrc;
  565. LPBYTE txtDst;
  566. INT len;
  567. // sdj: was unref local - INT lin;
  568. // sdj: was unref local - INT col;
  569. if ((endLin - startLin) >= nLines)
  570. {
  571. txtSrc = (LPBYTE) attrib[0] + startLin*ATTRROWLEN;
  572. txtDst = txtSrc + nLines*ATTRROWLEN;
  573. len = (endLin - startLin + 1 - nLines)*ATTRROWLEN;
  574. if (up)
  575. blockMove(txtDst, txtSrc, len);
  576. else
  577. blockMove(txtSrc, txtDst, len);
  578. }
  579. }
  580. /*---------------------------------------------------------------------------*/
  581. /* pLF() - */
  582. /*---------------------------------------------------------------------------*/
  583. proc pLF()
  584. {
  585. LPBYTE txtDst, txtSrc;
  586. // sdj: was unref local - LONG newStart, newEnd;
  587. INT len; // sdj: was unref local - maxLin, savLin, bottomLine;
  588. // sdj: was unref local - INT width, height;
  589. checkSelect ();
  590. UpdateWindow(hTermWnd); /* jtf 3.30 */
  591. if(curLin == scrRgnEnd)
  592. {
  593. if(savTopLine == (maxLines - (maxScreenLine + 2))) /* no buffer left */
  594. {
  595. if(savTopLine > 0) /* mbbx 1.01: (maxLines == 25) */
  596. {
  597. txtDst = GlobalLock (hTE.hText);
  598. txtSrc = txtDst + maxChars + 2;
  599. len = (savTopLine - 1) * (maxChars + 2);
  600. blockMove(txtSrc, txtDst, len);
  601. txtSrc = txtDst + (savTopLine + scrRgnBeg) * (maxChars + 2);
  602. txtDst = txtDst + len;
  603. blockMove(txtSrc, txtDst, (DWORD) maxChars);
  604. GlobalUnlock(hTE.hText);
  605. if(curTopLine + visScreenLine < savTopLine)
  606. {
  607. if (curTopLine > 0)
  608. curTopLine--;
  609. else
  610. lineFeeds++;
  611. }
  612. else
  613. lineFeeds++;
  614. }
  615. pDelLin(scrRgnBeg, scrRgnEnd, 1);
  616. }
  617. else /* plenty of buffer */
  618. {
  619. if (scrRgnBeg != 0 || scrRgnEnd != maxScreenLine)
  620. {
  621. txtSrc = (LPBYTE)GlobalLock (hTE.hText) + savTopLine * (maxChars + 2);
  622. txtDst = txtSrc + maxChars + 2;
  623. blockMove (txtSrc, txtDst,
  624. (DWORD) (maxScreenLine + 1) * (maxChars + 2));
  625. txtDst = txtSrc;
  626. txtSrc += (scrRgnBeg + 1) * (maxChars + 2);
  627. blockMove (txtSrc, txtDst, (DWORD) maxChars);
  628. GlobalUnlock (hTE.hText);
  629. if (curTopLine + visScreenLine >= savTopLine)
  630. {
  631. curTopLine++;
  632. lineFeeds++;
  633. }
  634. savTopLine++;
  635. pDelLin (scrRgnBeg, scrRgnEnd, 1);
  636. }
  637. else
  638. {
  639. if(nScroll > 0)
  640. {
  641. if(((scrollBegin == scrRgnBeg) && (scrollEnd == scrRgnEnd)) &&
  642. ((nScroll + 1) < ((scrRgnEnd + 1 - scrRgnBeg) >> 2)))
  643. {
  644. nScroll++;
  645. }
  646. else
  647. termCleanUp();
  648. }
  649. else if(nScroll < 0)
  650. termCleanUp ();
  651. if(nScroll == 0)
  652. {
  653. scrollBegin = scrRgnBeg;
  654. scrollEnd = scrRgnEnd;
  655. nScroll = 1;
  656. }
  657. if (curTopLine + visScreenLine >= savTopLine)
  658. {
  659. curTopLine++;
  660. lineFeeds++;
  661. }
  662. savTopLine++;
  663. scrollAttrib (scrRgnBeg, scrRgnEnd, 1, TRUE);
  664. attrib[scrRgnEnd][LFLAGS] = 0;
  665. clrLines (scrRgnEnd, scrRgnEnd);
  666. }
  667. }
  668. nScrollPos.y = curTopLine;
  669. updateTermScrollBars(FALSE);
  670. termDirty = TRUE;
  671. }
  672. else
  673. {
  674. pCursRelative(0, 1);
  675. if((curLin - savTopLine) - nScrollPos.y == visScreenLine+1) /* mbbx: TEST */
  676. scrollDown(SB_VERT, SB_LINEDOWN, 1);
  677. }
  678. }
  679. /*---------------------------------------------------------------------------*/
  680. /* pInsLin() - Insert a line into the logical video screen. [scf] */
  681. /*---------------------------------------------------------------------------*/
  682. proc pInsLin (INT maxLin, INT nLines)
  683. {
  684. INT line, lin1;
  685. INT len;
  686. LPBYTE txtSrc;
  687. LPBYTE txtDst;
  688. if (statusLine)
  689. clrLines (24,24);
  690. else
  691. {
  692. if(nScroll < 0)
  693. {
  694. if(((scrollBegin == curLin) && (scrollEnd == maxLin)) &&
  695. ((abs(nScroll) + nLines) <= ((maxLin + 1 - curLin) >> 1)))
  696. {
  697. nScroll -= nLines;
  698. }
  699. else
  700. termCleanUp();
  701. }
  702. else if(nScroll > 0)
  703. termCleanUp();
  704. if(nScroll == 0)
  705. {
  706. scrollBegin = curLin;
  707. scrollEnd = maxLin;
  708. nScroll = -nLines;
  709. }
  710. for(line = maxLin - nLines + 1; line <= maxLin; line++)
  711. if(attrib[line][LFLAGS])
  712. {
  713. termCleanUp();
  714. break;
  715. }
  716. scrollAttrib (curLin, maxLin, nLines, FALSE);
  717. txtSrc = (LPBYTE)GlobalLock (hTE.hText) +
  718. (curLin + savTopLine) * (maxChars + 2);
  719. txtDst = txtSrc + nLines * (maxChars + 2);
  720. len = (maxLin + 1 - curLin - nLines) * (maxChars + 2);
  721. if (len > 0)
  722. blockMove (txtSrc, txtDst, (DWORD) len);
  723. line = curLin + nLines - 1;
  724. for (lin1 = curLin; lin1 <= line; lin1++)
  725. attrib[lin1][LFLAGS] = 0;
  726. clrLines (curLin, line);
  727. GlobalUnlock (hTE.hText);
  728. }
  729. termState = NULL;
  730. }
  731. /*---------------------------------------------------------------------------*/
  732. /* pDelLin() - Delete a line */
  733. /*---------------------------------------------------------------------------*/
  734. proc pDelLin (INT curLin, INT maxLin, INT nLines)
  735. {
  736. INT line, lin1;
  737. INT len;
  738. LPBYTE txtSrc;
  739. LPBYTE txtDst;
  740. if(statusLine)
  741. clrLines(24, 24);
  742. else
  743. {
  744. if(nScroll > 0)
  745. {
  746. if(((scrollBegin == curLin) && (scrollEnd == maxLin)) &&
  747. ((nScroll + nLines) <= ((maxLin + 1 - curLin) >> 2)))
  748. {
  749. nScroll += nLines;
  750. }
  751. else
  752. termCleanUp();
  753. }
  754. else if(nScroll < 0)
  755. termCleanUp();
  756. if(nScroll == 0)
  757. {
  758. scrollBegin = curLin;
  759. scrollEnd = maxLin;
  760. nScroll = nLines;
  761. }
  762. for(line = curLin; line < curLin + nLines; line++)
  763. if(attrib[line][LFLAGS])
  764. {
  765. termCleanUp();
  766. break;
  767. }
  768. scrollAttrib (curLin, maxLin, nLines, TRUE);
  769. txtDst = (LPBYTE)GlobalLock (hTE.hText) +
  770. (curLin + savTopLine) * (maxChars + 2);
  771. txtSrc = txtDst + nLines * (maxChars + 2);
  772. len = (maxLin + 1 - curLin - nLines) * (maxChars + 2);
  773. if (len > 0)
  774. blockMove (txtSrc, txtDst, (DWORD) len);
  775. line = maxLin - nLines + 1;
  776. for (lin1 = line; lin1 <= maxLin; lin1++)
  777. attrib[lin1][LFLAGS] = 0;
  778. clrLines (line, maxLin);
  779. GlobalUnlock (hTE.hText);
  780. }
  781. termState = NULL;
  782. }
  783. /*---------------------------------------------------------------------------*/
  784. /* pDelChar() - Delete a char from the terminal emulation video. [scf] */
  785. /*---------------------------------------------------------------------------*/
  786. proc pDelChar(INT nChars)
  787. {
  788. INT ndx;
  789. // sdj: was unref local - INT savCol;
  790. INT theLine;
  791. DWORD len;
  792. LPBYTE txtSrc;
  793. LPBYTE txtDst;
  794. // sdj: was unref local - LPBYTE txtPtr;
  795. LPBYTE globalHeap;
  796. globalHeap = GlobalLock(hTE.hText);
  797. if(!protectMode) /* mbbx: protected fields */
  798. len = maxChars - nChars - curCol;
  799. else
  800. len = getProtCol() - nChars - (curCol+1);
  801. if(statusLine)
  802. {
  803. theLine = maxScreenLine + 1;
  804. txtDst = (LPBYTE) line25 + curCol;
  805. }
  806. else
  807. {
  808. theLine = curLin;
  809. txtDst = globalHeap + valIndex ();
  810. }
  811. if (len > 0)
  812. {
  813. txtSrc = txtDst + nChars;
  814. blockMove (txtSrc, txtDst, len);
  815. }
  816. else
  817. {
  818. nChars = maxChars - curCol;
  819. len = 0;
  820. }
  821. txtSrc = txtDst + len;
  822. for (ndx = 0; ndx <= (nChars - 1); ndx++)
  823. txtSrc[ndx] = CHFILL;
  824. GlobalUnlock (hTE.hText);
  825. attrib[theLine][LFLAGS] = LCLEAR | LDIRTY;
  826. }
  827. /*---------------------------------------------------------------------------*/
  828. /* begGraphics() - [scf] */
  829. /*---------------------------------------------------------------------------*/
  830. VOID begGraphics () /* macx */
  831. {
  832. termCleanUp ();
  833. offCursor ();
  834. }
  835. /*---------------------------------------------------------------------------*/
  836. /* endGraphics() - [scf] */
  837. /*---------------------------------------------------------------------------*/
  838. VOID endGraphics () /* macx */
  839. {
  840. onCursor ();
  841. }
  842. /*---------------------------------------------------------------------------*/
  843. /* pGrChar () - */
  844. /*---------------------------------------------------------------------------*/
  845. static HDC graphicsPort;
  846. #define GRCOLBEG 48
  847. #define GRLINBEG 0
  848. #define MAXGRCOL 512
  849. proc pGrSemi ()
  850. {
  851. /* jtfterm */
  852. }
  853. /*---------------------------------------------------------------------------*/
  854. /* pGrDoIt() - */
  855. /*---------------------------------------------------------------------------*/
  856. proc pGrDoIt (INT len, HBRUSH p)
  857. {
  858. /* jtfterm */
  859. }
  860. /*---------------------------------------------------------------------------*/
  861. /* pGrFill() - [scf] */
  862. /*---------------------------------------------------------------------------*/
  863. proc pGrFill ()
  864. {
  865. ch = theChar;
  866. if (ch == 7)
  867. {
  868. sysBeep ();
  869. vidGraphics = GRNONE;
  870. termState = NULL;
  871. chrWidth = stdChrWidth;
  872. chrHeight = stdChrHeight;
  873. endGraphics ();
  874. }
  875. else if (ch != CR && ch != LF)
  876. {
  877. if (vidBG == -1)
  878. vidBG = (ch - ' ')*chrWidth;
  879. else
  880. {
  881. vidFG = (ch - ' ')*chrWidth;
  882. if (vidBG > 0)
  883. pGrDoIt(vidBG, blackBrush);
  884. if (vidFG > 0)
  885. pGrDoIt(vidFG, theBrush);
  886. vidBG = -1;
  887. }
  888. }
  889. else
  890. termState = NULL;
  891. }
  892. /*---------------------------------------------------------------------------*/
  893. /* pGrChar() */
  894. /*---------------------------------------------------------------------------*/
  895. proc pGrChar ()
  896. {
  897. HRGN hClipRgn;
  898. RECT clpRect;
  899. getPort ();
  900. graphicsPort = thePort;
  901. GetClientRect (hTermWnd, (LPRECT) &clpRect);
  902. hClipRgn = CreateRectRgnIndirect ((LPRECT) &clpRect);
  903. SelectClipRgn(thePort, hClipRgn);
  904. DeleteObject (hClipRgn);
  905. ch = the8Char;
  906. if (vidGraphics == GRSEMI)
  907. if ((the8Char & 0x80) != 0)
  908. pGrSemi ();
  909. else
  910. termState = NULL;
  911. else
  912. pGrFill ();
  913. releasePort ();
  914. }
  915. /*---------------------------------------------------------------------------*/
  916. /* pSetGrMode() - [scf] */
  917. /*---------------------------------------------------------------------------*/
  918. proc pSetGrMode()
  919. {
  920. /* jtfterm */
  921. }
  922. /*---------------------------------------------------------------------------*/
  923. /* pSetMode() - [scf] */
  924. /*---------------------------------------------------------------------------*/
  925. proc pSetMode ()
  926. {
  927. BYTE chSet;
  928. termState = NULL;
  929. if((trmParams.emulate >= ITMVT52) && (trmParams.emulate <= ITMVT220)) /* mbbx: why VT52??? */
  930. switch (ch)
  931. {
  932. case 0x0e:
  933. case 0x0f:
  934. if (ch == 0x0e)
  935. shiftCharSet = 1;
  936. else
  937. shiftCharSet = 0;
  938. chSet = charSet[shiftCharSet];
  939. if ((chSet == '0') || (chSet == '2'))
  940. curAttrib |= AGRAPHICS;
  941. else
  942. curAttrib &= ANOTGRAPHICS;
  943. break;
  944. case 'x': /* VT52/Heath*/
  945. escExtend = EXSETMODE;
  946. termState = pSetMode;
  947. break;
  948. case 'y': /* VT52/Heath */
  949. escExtend = EXRESETMODE;
  950. termState = pSetMode;
  951. break;
  952. case '=':
  953. keyPadAppMode = TRUE;
  954. break;
  955. case '>':
  956. keyPadAppMode = FALSE;
  957. break;
  958. case '<':
  959. trmParams.emulate = ITMVT100;
  960. resetEmul ();
  961. break;
  962. case '5': /* VT52/Heath */
  963. if (escExtend == EXSETMODE)
  964. pCursOff ();
  965. else
  966. pCursOn ();
  967. break;
  968. case '7': /* VT52/Heath */
  969. keyPadAppMode = (escExtend == EXSETMODE);
  970. break;
  971. case '@':
  972. chInsMode = TRUE;
  973. break;
  974. case 'O':
  975. chInsMode = FALSE;
  976. break;
  977. }
  978. }
  979. /*---------------------------------------------------------------------------*/
  980. /* pDecScs() - VT-100 character set selection. [scf] */
  981. /*---------------------------------------------------------------------------*/
  982. proc pDecScs ()
  983. {
  984. BYTE chSet;
  985. termState = NULL;
  986. switch (ch)
  987. {
  988. case '(':
  989. decScs = 0;
  990. termState = pDecScs;
  991. break;
  992. case ')':
  993. decScs = 1;
  994. termState = pDecScs;
  995. break;
  996. case 'A':
  997. case 'B':
  998. case '0':
  999. case '1':
  1000. case '2':
  1001. charSet[decScs] = ch;
  1002. chSet = charSet[shiftCharSet];
  1003. if ((chSet == '0') || (chSet == '2'))
  1004. curAttrib |= AGRAPHICS;
  1005. else
  1006. curAttrib &= ANOTGRAPHICS;
  1007. break;
  1008. }
  1009. }
  1010. /*---------------------------------------------------------------------------*/
  1011. /* getArg() - */
  1012. /*---------------------------------------------------------------------------*/
  1013. #define getArg ((argNdx < argCount) ? argList[argNdx++] : 0)
  1014. /*---------------------------------------------------------------------------*/
  1015. /* getParms () */
  1016. /*---------------------------------------------------------------------------*/
  1017. proc getParms ()
  1018. {
  1019. p1 = getArg;
  1020. p2 = getArg;
  1021. }
  1022. /*---------------------------------------------------------------------------*/
  1023. /* pInquire() - [scf] */
  1024. /*---------------------------------------------------------------------------*/
  1025. proc pInquire() /* mbbx 1.04: VT220... */
  1026. {
  1027. STRING respStr[32];
  1028. *respStr = 0;
  1029. switch(trmParams.emulate)
  1030. {
  1031. case ITMVT100:
  1032. getParms();
  1033. if(p1 == 0)
  1034. memcpy(respStr, "\7\033[?1;2c", 9);
  1035. break;
  1036. case ITMVT52:
  1037. memcpy(respStr, "\3\033/Z", 5);
  1038. break;
  1039. }
  1040. if(*respStr)
  1041. termStr(respStr, 0, FALSE);
  1042. termState = NULL;
  1043. }
  1044. /*---------------------------------------------------------------------------*/
  1045. /* pTab() - [scf] */
  1046. /*---------------------------------------------------------------------------*/
  1047. proc pTab()
  1048. {
  1049. INT ndx;
  1050. INT savCol;
  1051. INT lin, col;
  1052. if(!protectMode)
  1053. {
  1054. savCol = curCol;
  1055. ndx = curCol + 1;
  1056. while (ndx <= 131)
  1057. if(tabs[ndx] == 1)
  1058. {
  1059. curCol = ndx;
  1060. ndx = 133;
  1061. }
  1062. else
  1063. ndx++;
  1064. }
  1065. else /* mbbx: tab for protected mode */
  1066. {
  1067. lin = 0;
  1068. col = 0;
  1069. repeat
  1070. getUnprot(lin, col, &lin, &col);
  1071. until((lin >= curLin) && (col >= curCol));
  1072. ndx = 0;
  1073. curLin = lin;
  1074. curCol = col;
  1075. }
  1076. if((ndx == 132) || (curCol >= maxChars))
  1077. curCol = maxChars - 1;
  1078. termState = NULL;
  1079. }
  1080. /*---------------------------------------------------------------------------*/
  1081. /* pClearAllTabs() - [scf] */
  1082. /*---------------------------------------------------------------------------*/
  1083. proc pClearAllTabs ()
  1084. {
  1085. INT ndx;
  1086. for (ndx = 0; ndx <= 131; ndx++)
  1087. tabs[ndx] = 0;
  1088. termState = NULL;
  1089. }
  1090. /*---------------------------------------------------------------------------*/
  1091. /* pSetTab() - [scf] */
  1092. /*---------------------------------------------------------------------------*/
  1093. proc pSetTab ()
  1094. {
  1095. tabs[curCol] = 1;
  1096. termState = NULL;
  1097. }
  1098. /*---------------------------------------------------------------------------*/
  1099. /* pClearTab() - [scf] */
  1100. /*---------------------------------------------------------------------------*/
  1101. proc pClearTab ()
  1102. {
  1103. tabs[curCol] = 0;
  1104. termState = NULL;
  1105. }
  1106. /*---------------------------------------------------------------------------*/
  1107. /* pCmpSrvResponse() - [scf] */
  1108. /*---------------------------------------------------------------------------*/
  1109. proc pCmpSrvResponse ()
  1110. {
  1111. /* jtfterm */
  1112. }
  1113. /*---------------------------------------------------------------------------*/
  1114. /* pSndCursor() - [scf] */
  1115. /*---------------------------------------------------------------------------*/
  1116. proc pSndCursor()
  1117. {
  1118. LONG finalTicks;
  1119. termState = NULL;
  1120. switch(trmParams.emulate)
  1121. {
  1122. case ITMVT52:
  1123. modemWr (0x1b); delay (5, &finalTicks);
  1124. modemWr ('Y'); delay (5, &finalTicks);
  1125. modemWr ((BYTE) curLin + ' '); delay (5, &finalTicks);
  1126. modemWr ((BYTE) curCol + ' '); delay (5, &finalTicks);
  1127. break;
  1128. }
  1129. }
  1130. /*---------------------------------------------------------------------------*/
  1131. /* pIndex() - */
  1132. /*---------------------------------------------------------------------------*/
  1133. proc pIndex ()
  1134. {
  1135. if (curLin == scrRgnEnd)
  1136. pDelLin (scrRgnBeg, scrRgnEnd, 1);
  1137. else
  1138. pCursRelative (0, 1);
  1139. }
  1140. /*---------------------------------------------------------------------------*/
  1141. /* pRevIndex() - [scf] */
  1142. /*---------------------------------------------------------------------------*/
  1143. proc pRevIndex ()
  1144. {
  1145. if (curLin == scrRgnBeg)
  1146. pInsLin (scrRgnEnd, 1);
  1147. else
  1148. pCursRelative (0, -1);
  1149. }
  1150. /*---------------------------------------------------------------------------*/
  1151. /* pSetLineAttrib() - [scf] */
  1152. /*---------------------------------------------------------------------------*/
  1153. proc pSetLineAttrib ()
  1154. {
  1155. BYTE lAttr;
  1156. INT theLin;
  1157. INT savCol;
  1158. INT ndx;
  1159. INT half;
  1160. LPBYTE txtPtr;
  1161. LPBYTE globalHeap;
  1162. lAttr = -1;
  1163. switch (ch)
  1164. {
  1165. case '3':
  1166. lAttr = LHIGHTOP;
  1167. break;
  1168. case '4':
  1169. lAttr = LHIGHBOTTOM;
  1170. break;
  1171. case '5':
  1172. lAttr = LNORMAL;
  1173. break;
  1174. case '6':
  1175. lAttr = LWIDE;
  1176. break;
  1177. }
  1178. if (statusLine)
  1179. theLin = 24;
  1180. else
  1181. theLin = curLin;
  1182. if (lAttr != -1)
  1183. if (lAttr != attrib[theLin][LATTRIB])
  1184. {
  1185. savCol = curCol;
  1186. curCol = 0;
  1187. half = maxChars;
  1188. if (lAttr != LNORMAL)
  1189. {
  1190. half = maxChars / 2;
  1191. globalHeap = GlobalLock (hTE.hText);
  1192. txtPtr = globalHeap + valIndex ();
  1193. for (ndx = half; ndx <= (maxChars - 1); ndx++)
  1194. {
  1195. txtPtr[ndx] = ' ';
  1196. attrib[theLin][ndx] = 0;
  1197. }
  1198. GlobalUnlock (hTE.hText);
  1199. }
  1200. attrib[theLin][LATTRIB] = lAttr;
  1201. attrib[theLin][LFLAGS] = LCLEAR | LDIRTY; /* mbbx: mac version */
  1202. reDrawTermLine (theLin, 0, half);
  1203. curCol = savCol;
  1204. }
  1205. termState = NULL;
  1206. }
  1207. /*---------------------------------------------------------------------------*/
  1208. /* pInsChar() - [scf] */
  1209. /*---------------------------------------------------------------------------*/
  1210. proc pInsChar ()
  1211. {
  1212. BOOL savMode;
  1213. if(!protectMode)
  1214. {
  1215. savMode = chInsMode;
  1216. chInsMode = TRUE;
  1217. putChar (' ');
  1218. chInsMode = savMode;
  1219. termState = NULL;
  1220. }
  1221. else
  1222. pDelChar(1);
  1223. }
  1224. /*---------------------------------------------------------------------------*/
  1225. /* pSaveCursorPos() - */
  1226. /*---------------------------------------------------------------------------*/
  1227. proc pSaveCursorPos ()
  1228. {
  1229. saveCol = curCol;
  1230. saveLin = curLin;
  1231. termState = NULL;
  1232. }
  1233. /*---------------------------------------------------------------------------*/
  1234. /* pRestoreCursorPos() - */
  1235. /*---------------------------------------------------------------------------*/
  1236. proc pRestoreCursorPos ()
  1237. {
  1238. curCol = saveCol;
  1239. curLin = saveLin;
  1240. termState = NULL;
  1241. }
  1242. /*---------------------------------------------------------------------------*/
  1243. /* pEscSkip */
  1244. /*---------------------------------------------------------------------------*/
  1245. proc pEscSkip ()
  1246. {
  1247. escSkip--;
  1248. if (escSkip <= 0)
  1249. termState = NULL;
  1250. }
  1251. /*---------------------------------------------------------------------------*/
  1252. /* Some change of state procedures */
  1253. /*---------------------------------------------------------------------------*/
  1254. proc pNullState ()
  1255. {
  1256. termState = NULL;
  1257. }
  1258. proc pCursorState ()
  1259. {
  1260. termState = pCursRC;
  1261. }
  1262. proc pVPosState ()
  1263. {
  1264. termState = pVPosAbsolute;
  1265. }
  1266. proc pHPosState ()
  1267. {
  1268. termState = pHPosAbsolute;
  1269. }
  1270. proc pLAttrState ()
  1271. {
  1272. termState = pSetLineAttrib;
  1273. }
  1274. /*---------------------------------------------------------------------------*/
  1275. /* pAnsi() - [scf] */
  1276. /*---------------------------------------------------------------------------*/
  1277. proc pAnsi()
  1278. {
  1279. if((chAscii >= '0') && (chAscii <= '?'))
  1280. (*ansiParseTable[chAscii-'0'])();
  1281. else
  1282. {
  1283. if(ansiArg)
  1284. argList[argCount++] = ansiArg;
  1285. (*aEscTable[chAscii &= 0x7F])(); /* mbbx 1.06: modemInp() not masking 8th bit */
  1286. if(termState != aEscTable[chAscii]) /* mbbx 1.10: VT220 8BIT patch !!! */
  1287. termState = NULL;
  1288. }
  1289. }
  1290. proc pAnsiState ()
  1291. {
  1292. termState = pAnsi;
  1293. argNdx = 0;
  1294. argCount = 0;
  1295. ansiArg = 0;
  1296. decPrivate = FALSE;
  1297. heathPrivate = FALSE;
  1298. }
  1299. proc pGrState ()
  1300. {
  1301. termState = pSetGrMode;
  1302. }
  1303. proc pSkipState ()
  1304. {
  1305. escSkip = emulInfo[chAscii] - 128;
  1306. termState = pEscSkip;
  1307. }
  1308. proc pReverseOff() /* mbbx: pProtOff -> pReverseOff */
  1309. {
  1310. pVideo(0);
  1311. }
  1312. proc pReverseOn() /* mbbx: pProtOn -> pReverseOn */
  1313. {
  1314. pVideo(ABOLD); /* mbbx per jtfx */
  1315. }
  1316. proc pProtOff() /* mbbx */
  1317. {
  1318. protectMode = FALSE;
  1319. termState = NULL;
  1320. }
  1321. proc pProtOn() /* mbbx */
  1322. {
  1323. protectMode = TRUE;
  1324. termState = NULL;
  1325. }
  1326. proc pBegProtect() /* mbbx 1.03: TV925... */
  1327. {
  1328. pVideo(APROTECT);
  1329. pVideo(ABOLD);
  1330. }
  1331. proc pEndProtect() /* mbbx 1.03: TV925... */
  1332. {
  1333. pVideo(ANORMAL);
  1334. }
  1335. proc pBegGraphics() /* mbbx 1.03: TV925... */
  1336. {
  1337. curAttrib |= AGRAPHICS;
  1338. termState = NULL;
  1339. }
  1340. proc pEndGraphics() /* mbbx 1.03: TV925... */
  1341. {
  1342. curAttrib &= ANOTGRAPHICS;
  1343. termState = NULL;
  1344. }
  1345. /*---------------------------------------------------------------------------*/
  1346. /* Some patches */
  1347. /*---------------------------------------------------------------------------*/
  1348. proc pLinDel ()
  1349. {
  1350. pDelLin(curLin, maxScreenLine, 1); /* mbbx per slcx */
  1351. }
  1352. proc pCharDel ()
  1353. {
  1354. pDelChar(1);
  1355. }
  1356. proc pLinIns ()
  1357. {
  1358. pInsLin(maxScreenLine, 1);
  1359. }
  1360. proc pNextLine ()
  1361. {
  1362. pLF ();
  1363. curCol = 0;
  1364. }
  1365. proc pClrAll()
  1366. {
  1367. protectMode = FALSE;
  1368. pClrScr();
  1369. }
  1370. proc pPrintOn()
  1371. {
  1372. PrintFileComm(TRUE); /* mbbx 1.03: prAction(!prtFlag); */
  1373. termState = NULL;
  1374. }
  1375. proc pPrintOff()
  1376. {
  1377. // sdj: was unref local - BYTE work[STR255];
  1378. PrintFileComm(FALSE); /* mbbx 1.03: prAction(!prtFlag); */
  1379. termState = NULL;
  1380. }
  1381. /*---------------------------------------------------------------------------*/
  1382. #define TRANS_PRINT_BUFFER 4
  1383. STRING transPrtBuf[TRANS_PRINT_BUFFER+1];
  1384. proc pTransPrint() /* mbbx 2.01.32 ... */
  1385. {
  1386. if(trmParams.emulate == ITMVT100)
  1387. {
  1388. getParms();
  1389. switch(p1)
  1390. {
  1391. case 5:
  1392. transPrintFlag = TRUE;
  1393. *transPrtBuf = 0; /* slc gold 017 */
  1394. break;
  1395. case 4:
  1396. PrintFileComm(FALSE);
  1397. transPrintFlag = FALSE;
  1398. break;
  1399. case 1:
  1400. /* print cursor line */
  1401. break;
  1402. case 0:
  1403. /* print screen */
  1404. break;
  1405. }
  1406. }
  1407. else
  1408. transPrintFlag = TRUE;
  1409. if(transPrintFlag)
  1410. PrintFileComm(TRUE);
  1411. termState = NULL;
  1412. }
  1413. /*---------------------------------------------------------------------------*/
  1414. proc pVideoAttrib() /* mbbx 1.03: added breaks !!! */
  1415. {
  1416. switch(trmParams.emulate)
  1417. {
  1418. /* jtfterm */
  1419. }
  1420. termState = NULL;
  1421. }
  1422. proc pVideoAttribState()
  1423. {
  1424. termState = pVideoAttrib;
  1425. }
  1426. proc pCursorOnOff()
  1427. {
  1428. if(chAscii != '0')
  1429. pCursOn();
  1430. else
  1431. pCursOff();
  1432. }
  1433. proc pCursorOnOffState()
  1434. {
  1435. termState = pCursorOnOff;
  1436. }
  1437. /*---------------------------------------------------------------------------*/
  1438. /* pAnswerBack() - [mbb] */
  1439. /*---------------------------------------------------------------------------*/
  1440. proc pAnswerBack()
  1441. {
  1442. #ifdef ORGCODE
  1443. INT i;
  1444. #else
  1445. DWORD i;
  1446. #endif
  1447. BYTE saveEcho;
  1448. LONG finalTicks;
  1449. STRING temp[DCS_ANSWERBACKSZ+1]; /* rkhx 2.00 */
  1450. saveEcho = trmParams.localEcho;
  1451. trmParams.localEcho = FALSE; /* mbbx 1.10: CUA */
  1452. strcpy(temp+1, trmParams.answerBack); /* rkhx 2.00 */
  1453. *temp = strlen(temp+1);
  1454. stripControl(temp);
  1455. for(i = 1; i <= *temp; i++)
  1456. {
  1457. modemWr(temp[i]);
  1458. delay(2, &finalTicks);
  1459. }
  1460. trmParams.localEcho = saveEcho;
  1461. termState = NULL;
  1462. }
  1463. /*---------------------------------------------------------------------------*/
  1464. /* pEchoOff() - [mbb] */
  1465. /*---------------------------------------------------------------------------*/
  1466. proc pEchoOff()
  1467. {
  1468. trmParams.localEcho = FALSE; /* mbbx 1.10: CUA */
  1469. termState = NULL;
  1470. }
  1471. /*---------------------------------------------------------------------------*/
  1472. /* pEchoOn() - [mbb] */
  1473. /*---------------------------------------------------------------------------*/
  1474. proc pEchoOn()
  1475. {
  1476. trmParams.localEcho = TRUE; /* mbbx 1.10: CUA */
  1477. termState = NULL;
  1478. }
  1479. /* mbbx: added to make the TABLE handling consistent 1/6/88 */
  1480. proc pCR()
  1481. {
  1482. if((trmParams.emulate == ITMDELTA) && (curCol > 0))
  1483. {
  1484. while(curCol < maxChars)
  1485. {
  1486. putChar(SP);
  1487. curCol++;
  1488. }
  1489. }
  1490. curCol = 0;
  1491. if(statusLine) /* mbbx 1.03: TV925 per slcx... */
  1492. {
  1493. curLin = 0;
  1494. statusLine = FALSE;
  1495. }
  1496. }
  1497. proc pBackSpace()
  1498. {
  1499. if(curCol > 0) /* jtf 3.14 */
  1500. curCol--;
  1501. /* jtf 3.33 putChar(SP); */ /* desctructive backspace 3.17 */
  1502. }
  1503. proc pBeep()
  1504. {
  1505. if(trmParams.sound) /* mbbx 1.04: synch */
  1506. sysBeep();
  1507. }
  1508. /*---------------------------------------------------------------------------*/
  1509. /* pEscSequence */
  1510. /*---------------------------------------------------------------------------*/
  1511. proc pEscSequence()
  1512. {
  1513. (*pEscTable[chAscii & 0x7F])(); /* mbbx 2.00: modemInp() not masking 8th bit */
  1514. }
  1515. /*------------------ >>> pAnsi() Global Declarations <<< ------------------*/
  1516. /* Procedure pAnsi () */
  1517. /*---------------------------------------------------------------------------*/
  1518. /* aSetCompLevel() - set VT220 Compatibility Level [mbb/rkh] */
  1519. /*---------------------------------------------------------------------------*/
  1520. VOID NEAR aSetCompLevel() /* mbbx 1.10: VT220 8BIT... */
  1521. {
  1522. BYTE newEmul;
  1523. termState = NULL;
  1524. switch(ch)
  1525. {
  1526. case '"':
  1527. termState = aSetCompLevel;
  1528. break;
  1529. case 'p':
  1530. switch(getArg)
  1531. {
  1532. case 61:
  1533. newEmul = ITMVT100;
  1534. break;
  1535. case 62:
  1536. newEmul = ITMVT220;
  1537. trmParams.fCtrlBits = !(getArg == 1);
  1538. break;
  1539. default:
  1540. return;
  1541. }
  1542. if(newEmul != trmParams.emulate)
  1543. {
  1544. trmParams.emulate = newEmul;
  1545. resetEmul();
  1546. }
  1547. break;
  1548. }
  1549. }
  1550. VOID NEAR pSetCtrlBits() /* mbbx 2.00: VT220 8BIT... */
  1551. {
  1552. termState = NULL;
  1553. switch(ch)
  1554. {
  1555. case ' ':
  1556. termState = pSetCtrlBits;
  1557. break;
  1558. case 'F':
  1559. trmParams.fCtrlBits = FALSE;
  1560. break;
  1561. case 'G':
  1562. trmParams.fCtrlBits = TRUE;
  1563. break;
  1564. }
  1565. }
  1566. /*---------------------------------------------------------------------------*/
  1567. /* aCursor() [scf] */
  1568. /*---------------------------------------------------------------------------*/
  1569. proc aCursor()
  1570. {
  1571. register INT lin, col;
  1572. getParms ();
  1573. if (p1 == 0)
  1574. p1 = 1;
  1575. if (p2 == 0)
  1576. p2 = 1;
  1577. lin = p1 - 1;
  1578. col = p2 - 1;
  1579. if (originMode)
  1580. {
  1581. lin += scrRgnBeg;
  1582. if (lin < scrRgnEnd)
  1583. curLin = lin;
  1584. else
  1585. curLin = scrRgnEnd;
  1586. }
  1587. else
  1588. if (lin <= maxScreenLine)
  1589. {
  1590. if (statusLine)
  1591. {
  1592. statusLine = FALSE;
  1593. }
  1594. curLin = lin;
  1595. }
  1596. else
  1597. {
  1598. if (!statusLine)
  1599. {
  1600. statusLine = TRUE;
  1601. }
  1602. curLin = maxScreenLine;
  1603. }
  1604. if (col < maxChars)
  1605. curCol = col;
  1606. }
  1607. /*---------------------------------------------------------------------------*/
  1608. /* aClrEol() - [scf] */
  1609. /*---------------------------------------------------------------------------*/
  1610. proc aClrEol ()
  1611. {
  1612. getParms ();
  1613. if (p1 == 0)
  1614. pClrEol ();
  1615. else if (p1 == 1)
  1616. pClrBol ();
  1617. else if (p1 == 2)
  1618. {
  1619. pClrBol ();
  1620. pClrEol ();
  1621. }
  1622. }
  1623. /*---------------------------------------------------------------------------*/
  1624. /* aClrEop() - [scf] */
  1625. /*---------------------------------------------------------------------------*/
  1626. proc aClrEop ()
  1627. {
  1628. getParms ();
  1629. if (p1 == 0)
  1630. pClrEop ();
  1631. else if (p1 == 2)
  1632. pClrScr ();
  1633. else if (p1 == 1)
  1634. pClrBop ();
  1635. }
  1636. /*---------------------------------------------------------------------------*/
  1637. /* aCursUp() - [scf] */
  1638. /*---------------------------------------------------------------------------*/
  1639. proc aCursUp ()
  1640. {
  1641. getParms ();
  1642. if (p1 == 0)
  1643. p1 = 1;
  1644. pCursRelative (0, (INT) -p1);
  1645. }
  1646. /*---------------------------------------------------------------------------*/
  1647. /* aCursDn() - [scf] */
  1648. /*---------------------------------------------------------------------------*/
  1649. proc aCursDn ()
  1650. {
  1651. getParms ();
  1652. if (p1 == 0)
  1653. p1 = 1;
  1654. pCursRelative (0, (INT) p1);
  1655. }
  1656. /*---------------------------------------------------------------------------*/
  1657. /* aCursRt() - [scf] */
  1658. /*---------------------------------------------------------------------------*/
  1659. proc aCursRt ()
  1660. {
  1661. getParms ();
  1662. if (p1 == 0)
  1663. p1 = 1;
  1664. pCursRelative ((INT) p1, 0);
  1665. }
  1666. /*---------------------------------------------------------------------------*/
  1667. /* aCursLt() - [scf] */
  1668. /*---------------------------------------------------------------------------*/
  1669. proc aCursLt ()
  1670. {
  1671. getParms ();
  1672. if (p1 == 0)
  1673. p1 = 1;
  1674. pCursRelative ((INT) -p1, 0);
  1675. }
  1676. /*---------------------------------------------------------------------------*/
  1677. /* aClearTabs() - [scf] */
  1678. /*---------------------------------------------------------------------------*/
  1679. proc aClearTabs ()
  1680. {
  1681. getParms ();
  1682. if (p1 == 3)
  1683. pClearAllTabs ();
  1684. else if (p1 == 0)
  1685. pClearTab ();
  1686. }
  1687. /*---------------------------------------------------------------------------*/
  1688. /* aVideo() - [scf] */
  1689. /*---------------------------------------------------------------------------*/
  1690. proc aVideo ()
  1691. {
  1692. repeat
  1693. {
  1694. switch ((WORD) getArg)
  1695. {
  1696. case 0:
  1697. curAttrib &= AGRAPHICS;
  1698. break;
  1699. case 1:
  1700. curAttrib |= ABOLD;
  1701. break;
  1702. case 4:
  1703. curAttrib |= AUNDERLINE;
  1704. break;
  1705. case 5:
  1706. curAttrib |= ABLINK;
  1707. break;
  1708. case 7:
  1709. curAttrib |= AREVERSE;
  1710. break;
  1711. }
  1712. }
  1713. until (argNdx == argCount);
  1714. }
  1715. /*---------------------------------------------------------------------------*/
  1716. /* aSetMode() - [mbb] */
  1717. /*---------------------------------------------------------------------------*/
  1718. proc aSetMode() /* mbbx 2.00: cleanup... */
  1719. {
  1720. while(argNdx < argCount)
  1721. {
  1722. switch(ch)
  1723. {
  1724. case 'h':
  1725. if(decPrivate) /* SET DEC private modes */
  1726. {
  1727. switch(getArg)
  1728. {
  1729. case 1:
  1730. cursorKeyMode = TRUE;
  1731. break;
  1732. case 6:
  1733. originMode = TRUE;
  1734. curLin = scrRgnBeg;
  1735. curCol = 0;
  1736. break;
  1737. case 7:
  1738. trmParams.lineWrap = TRUE; /* mbbx 1.10: CUA... */
  1739. break;
  1740. }
  1741. }
  1742. else if(heathPrivate) /* RESET heath private modes */
  1743. {
  1744. switch(getArg)
  1745. {
  1746. case 5:
  1747. pCursOn();
  1748. break;
  1749. case 7:
  1750. keyPadAppMode = FALSE;
  1751. break;
  1752. }
  1753. }
  1754. else
  1755. {
  1756. switch(getArg)
  1757. {
  1758. case 4:
  1759. chInsMode = TRUE;
  1760. break;
  1761. }
  1762. }
  1763. break;
  1764. case 'l':
  1765. if(decPrivate) /* RESET DEC private modes */
  1766. {
  1767. switch(getArg)
  1768. {
  1769. case 1:
  1770. cursorKeyMode = FALSE;
  1771. break;
  1772. case 2:
  1773. trmParams.emulate = ITMVT52;
  1774. resetEmul ();
  1775. break;
  1776. case 6:
  1777. originMode = FALSE;
  1778. pCursHome();
  1779. break;
  1780. case 7:
  1781. trmParams.lineWrap = FALSE; /* mbbx 1.10: CUA... */
  1782. break;
  1783. }
  1784. }
  1785. else if(heathPrivate)
  1786. {
  1787. switch(getArg) /* SET HEATH private modes */
  1788. {
  1789. case 5:
  1790. pCursOff();
  1791. break;
  1792. case 7:
  1793. keyPadAppMode = TRUE;
  1794. break;
  1795. }
  1796. }
  1797. else
  1798. {
  1799. switch(getArg)
  1800. {
  1801. case 4:
  1802. chInsMode = FALSE;
  1803. break;
  1804. }
  1805. }
  1806. break;
  1807. }
  1808. }
  1809. }
  1810. /*---------------------------------------------------------------------------*/
  1811. /* aReport() - [scf] */
  1812. /*---------------------------------------------------------------------------*/
  1813. proc aReport() /* mbbx 1.04: cleanup... */
  1814. {
  1815. STRING respStr[16];
  1816. getParms();
  1817. switch(p1)
  1818. {
  1819. case 6:
  1820. sprintf(respStr+1, "\033[%d;%dR", curLin+1, curCol+1);
  1821. *respStr = strlen(respStr+1);
  1822. break;
  1823. case 5:
  1824. memcpy(respStr, "\4\033[0n", 5);
  1825. break;
  1826. }
  1827. if(*respStr != 0)
  1828. termStr(respStr, 0, FALSE);
  1829. }
  1830. /*---------------------------------------------------------------------------*/
  1831. /* aSetScrRgn() - [scf] */
  1832. /*---------------------------------------------------------------------------*/
  1833. proc aSetScrRgn ()
  1834. {
  1835. getParms ();
  1836. if (p1 == 0)
  1837. p1 = 1;
  1838. if (p2 == 0)
  1839. p2 = 1;
  1840. if ((p2 > p1) && (p2 <= (maxScreenLine + 1)))
  1841. {
  1842. scrRgnBeg = p1 - 1;
  1843. scrRgnEnd = p2 - 1;
  1844. }
  1845. else if (p2 == 1)
  1846. {
  1847. scrRgnBeg = 0;
  1848. scrRgnEnd = maxScreenLine;
  1849. }
  1850. if (originMode)
  1851. curLin = scrRgnBeg;
  1852. else
  1853. curLin = 0;
  1854. curCol = 0;
  1855. }
  1856. /*---------------------------------------------------------------------------*/
  1857. /* aDelLin() - [scf] */
  1858. /*---------------------------------------------------------------------------*/
  1859. proc aDelLin ()
  1860. {
  1861. INT len;
  1862. getParms ();
  1863. if (p1 == 0)
  1864. p1 = 1;
  1865. if ((curLin >= scrRgnBeg) && (curLin <= scrRgnEnd))
  1866. {
  1867. len = scrRgnEnd - curLin + 1;
  1868. if (p1 > len)
  1869. p1 = len;
  1870. pDelLin(curLin, scrRgnEnd, (INT) p1); /* mbbx per slcx */
  1871. curCol = 0;
  1872. }
  1873. }
  1874. /*---------------------------------------------------------------------------*/
  1875. /* aInsLin() - [scf] */
  1876. /*---------------------------------------------------------------------------*/
  1877. proc aInsLin ()
  1878. {
  1879. INT len;
  1880. getParms ();
  1881. if (p1 == 0)
  1882. p1 = 1;
  1883. if ((curLin >= scrRgnBeg) && (curLin <= scrRgnEnd))
  1884. {
  1885. len = scrRgnEnd - curLin + 1;
  1886. if (p1 > len)
  1887. p1 = len;
  1888. pInsLin (scrRgnEnd, (INT) p1);
  1889. curCol = 0;
  1890. }
  1891. }
  1892. /*---------------------------------------------------------------------------*/
  1893. /* aDelChar() - [scf] */
  1894. /*---------------------------------------------------------------------------*/
  1895. proc aDelChar ()
  1896. {
  1897. getParms ();
  1898. if (p1 == 0)
  1899. p1 = 1;
  1900. pDelChar ((INT) p1);
  1901. }
  1902. /*---------------------------------------------------------------------------*/
  1903. /* VT-100 exceptions (same terminator for ANSI and non-Ansi sequence) */
  1904. /*---------------------------------------------------------------------------*/
  1905. proc pVT100H ()
  1906. {
  1907. if (termState == pAnsi)
  1908. aCursor ();
  1909. else
  1910. pSetTab ();
  1911. termState = NULL;
  1912. }
  1913. proc pVT100D ()
  1914. {
  1915. if (termState == pAnsi)
  1916. aCursLt ();
  1917. else
  1918. pLF ();
  1919. termState = NULL;
  1920. }
  1921. proc pVT100M ()
  1922. {
  1923. if (termState == pAnsi)
  1924. aDelLin ();
  1925. else
  1926. pRevIndex ();
  1927. termState = NULL;
  1928. }
  1929. proc pVT100c()
  1930. {
  1931. if(termState == pAnsi)
  1932. pInquire(); /* mbbx 1.10: aReport() was wrong! */
  1933. else
  1934. {
  1935. resetEmul();
  1936. pClrScr();
  1937. }
  1938. termState = NULL;
  1939. }
  1940. proc pVT100P() /* mbbx: new routine */
  1941. {
  1942. if(termState == pAnsi)
  1943. aDelChar();
  1944. else
  1945. termState = pDCS; /* mbbx: yterm */
  1946. }
  1947. /*---------------------------------------------------------------------------*/
  1948. /* pDCS() - */
  1949. /*---------------------------------------------------------------------------*/
  1950. proc pDCS()
  1951. {
  1952. termState = NULL;
  1953. }
  1954. /*---------------------------------------------------------------------------*/
  1955. /* pDCSTerminate() - */
  1956. /*---------------------------------------------------------------------------*/
  1957. proc pDCSTerminate()
  1958. {
  1959. termState = NULL;
  1960. }
  1961. /*---------------------------------------------------------------------------*/
  1962. /* Ansi Parser Routines */
  1963. /*---------------------------------------------------------------------------*/
  1964. proc ansiArgument () /* chAscii IN ['0' .. '9'] */
  1965. {
  1966. ansiArg = (ansiArg*10) + chAscii - '0';
  1967. }
  1968. proc ansiDelimiter () /* chAscii == ';' */
  1969. {
  1970. if (argCount < MAXANSIARGS)
  1971. argList[argCount++] = ansiArg;
  1972. ansiArg = 0;
  1973. }
  1974. proc ansiHeathPrivate () /* chAscii == '>' */
  1975. {
  1976. heathPrivate = TRUE;
  1977. }
  1978. proc ansiDecPrivate () /* chAscii == '?' */
  1979. {
  1980. decPrivate = TRUE;
  1981. }
  1982. /*---------------------------------------------------------------------------*/
  1983. /* putRcvChar() - [mbb] */
  1984. /*---------------------------------------------------------------------------*/
  1985. BOOL NEAR writeRcvChar(BYTE theChar)
  1986. {
  1987. LPSTR lpBuffer; /* rjs bugs 016 */
  1988. lpBuffer = GlobalLock(xferBufferHandle); /* rjs bugs 016 */
  1989. if((!xferSaveCtlChr) && ((theChar == BS) || (theChar == DEL))) /* rjs bugs 016 */
  1990. {
  1991. // sdj: if the very first character in the 1k pkt happens to
  1992. // sdj: be BS or DEL, then --xferBufferCount is going to be
  1993. // sdj: 64K! causing the access violation.
  1994. // sdj: lets not write the BS,DEL into the text file in these
  1995. // sdj: cases because what needs to be changed is the last byte
  1996. // sdj: of the last pkt which was written to the file! forget
  1997. // sdj: that for the time being and avoid the access violation.
  1998. if (xferBufferCount)
  1999. lpBuffer[--xferBufferCount] = 0x00; /* rjs bugs 016 */
  2000. }
  2001. else /* rjs bugs 016 */
  2002. lpBuffer[xferBufferCount++] = theChar; /* rjs bugs 016 */
  2003. if (xferBufferCount == 1024) /* rjs bugs 016 */
  2004. if (_lwrite((INT)xferRefNo, (LPSTR)lpBuffer,(INT) 1024) != 1024) /* rjs bugs 016 */
  2005. {
  2006. GlobalUnlock(xferBufferHandle); /* rjs bugs 016 */
  2007. xferEnd();
  2008. TF_ErrProc(STREWRERR, MB_OK | MB_ICONHAND, 999);
  2009. return(FALSE);
  2010. }
  2011. GlobalUnlock(xferBufferHandle); /* rjs bugs 016 */
  2012. if (xferBufferCount==1024) xferBufferCount = 0; /* rjs bugs 016 */
  2013. if(( (xferLength += 1) % 0x0400 ) == 0L ) /* rjs bugs 016 */
  2014. showBBytes(xferLength, FALSE);
  2015. return(TRUE);
  2016. }
  2017. VOID NEAR putRcvChar(BYTE theChar)
  2018. {
  2019. BYTE the7Char = theChar & 0x7F;
  2020. if(xferTableSave)
  2021. {
  2022. switch(the7Char)
  2023. {
  2024. case CR:
  2025. tblPos = TBLBEGINLINE;
  2026. break;
  2027. case TAB:
  2028. tblPos = TBLSPACES;
  2029. return;
  2030. case SP:
  2031. if(tblPos < TBLSPACES)
  2032. tblPos += 1;
  2033. return;
  2034. default:
  2035. if(xferSaveCtlChr || (the7Char == FF) || (the7Char == LF) ||
  2036. ((the7Char >= 0x20) && (the7Char <= 0x7E)))
  2037. {
  2038. switch(tblPos)
  2039. {
  2040. case TBLONESPACE:
  2041. if(!writeRcvChar(SP))
  2042. return;
  2043. break;
  2044. case TBLSPACES:
  2045. if(!writeRcvChar(TAB))
  2046. return;
  2047. break;
  2048. }
  2049. tblPos = TBLNONSPACE;
  2050. }
  2051. break;
  2052. }
  2053. }
  2054. if(xferSaveCtlChr || (the7Char == TAB) || (the7Char == FF) || (the7Char == LF) ||
  2055. (the7Char == CR) || (the7Char == BS) || (the7Char == DEL) || /* rjs bugs 016 -> add BS and DEL */
  2056. ((the7Char >= 0x20) && (the7Char <= 0x7E)))
  2057. {
  2058. writeRcvChar(theChar);
  2059. }
  2060. }
  2061. /*---------------------------------------------------------------------------*/
  2062. /* checkTransPrint() - [mbb] */
  2063. /*---------------------------------------------------------------------------*/
  2064. #define TRANS_PRINT_BUFFER 4
  2065. STRING transPrtBuf[TRANS_PRINT_BUFFER+1];
  2066. VOID NEAR checkTransPrint(BYTE theChar)
  2067. {
  2068. switch(theChar)
  2069. {
  2070. case 0x14:
  2071. if((trmParams.emulate == ITMADDS) || (trmParams.emulate == ITMTVI925))
  2072. transPrintFlag |= 0x8000;
  2073. break;
  2074. case '4':
  2075. if((trmParams.emulate == ITMADDS) && (*transPrtBuf == 1))
  2076. transPrintFlag = FALSE;
  2077. break;
  2078. case 'a':
  2079. if((trmParams.emulate == ITMTVI925) && (*transPrtBuf == 1))
  2080. transPrintFlag = FALSE;
  2081. break;
  2082. case 'i':
  2083. if(((trmParams.emulate == ITMVT220) || (trmParams.emulate == ITMVT100)) &&
  2084. (*transPrtBuf == 3) && (transPrtBuf[2] == '[') && (transPrtBuf[3] == '4'))
  2085. {
  2086. if(transPrintFlag)
  2087. {
  2088. transPrintFlag = FALSE;
  2089. PrintFileComm(FALSE);
  2090. }
  2091. }
  2092. break;
  2093. }
  2094. if(transPrintFlag || (prtFlag && !prtPause))
  2095. {
  2096. if(((theChar & 0x7F) != ESC) && !(transPrintFlag & 0x8000))
  2097. transPrtBuf[++(*transPrtBuf)] = theChar;
  2098. if(((theChar & 0x7F) == ESC) || (transPrintFlag & 0x8000) || (*transPrtBuf == 1) || (*transPrtBuf >= TRANS_PRINT_BUFFER))
  2099. {
  2100. if(*transPrtBuf > 0)
  2101. {
  2102. PrintFileString((LPSTR) transPrtBuf+1, (LONG) *transPrtBuf, FALSE);
  2103. *transPrtBuf = 0;
  2104. }
  2105. if((theChar & 0x7F) == ESC)
  2106. {
  2107. transPrtBuf[++(*transPrtBuf)] = ESC;
  2108. if((theChar == 0x9B) && (trmParams.emulate == ITMVT220))
  2109. transPrtBuf[++(*transPrtBuf)] = '[';
  2110. }
  2111. if(transPrintFlag & 0x8000)
  2112. transPrintFlag = FALSE;
  2113. }
  2114. }
  2115. if(transPrintFlag && !prtFlag)
  2116. PrintFileComm(TRUE);
  2117. }
  2118. /*---------------------------------------------------------------------------*/
  2119. /* modemInp () - [mbb] */
  2120. /*---------------------------------------------------------------------------*/
  2121. VOID modemInp(INT theChar, BOOL bRcvComm)
  2122. {
  2123. cursorValid = FALSE;
  2124. the8Char = (BYTE) theChar;
  2125. if(bRcvComm) /* mbbx 2.00: not restricted... */
  2126. {
  2127. if((xferFlag == XFRRCV) && !xferPaused)
  2128. putRcvChar(the8Char);
  2129. }
  2130. if(transPrintFlag || (prtFlag && !prtPause))
  2131. checkTransPrint(the8Char);
  2132. chAscii = the8Char; /* ... mbbx 2.00: mask done in getMdmChar() */
  2133. ch = chAscii; /* mbbx: patch */
  2134. if((chAscii & 0x7F) == ESC) /* mbbx 2.00: not masking 8th bit... */
  2135. {
  2136. if((the8Char & 0x80) && (trmParams.emulate == ITMVT220)) /* mbbx 1.10: CSI = ESC + '[' */
  2137. pAnsiState();
  2138. else
  2139. termState = escHandler;
  2140. }
  2141. else if(termState) /* mbbx 2.00: do this AFTER checking for ESC... */
  2142. (*termState)();
  2143. else if((chAscii >= 0x20) && (chAscii != 0x7F)) /* mbbx 1.04: ics... */
  2144. {
  2145. putChar(chAscii);
  2146. if(curCol < maxChars-1)
  2147. curCol += 1;
  2148. else if(trmParams.lineWrap) /* mbbx 1.10: CUA... */
  2149. {
  2150. curCol = 0;
  2151. pLF();
  2152. }
  2153. }
  2154. else
  2155. (*escHandler)();
  2156. }