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.

734 lines
17 KiB

  1. /* File: D:\WACKER\emu\viewdata.c (Created: 31-Jan-1994)
  2. *
  3. * Copyright 1994 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 3 $
  7. * $Date: 5/09/01 4:46p $
  8. */
  9. #include <windows.h>
  10. #pragma hdrstop
  11. #include <tdll\stdtyp.h>
  12. #include <tdll\tdll.h>
  13. #include <tdll\session.h>
  14. #include <tdll\chars.h>
  15. #include <tdll\htchar.h>
  16. #include <tdll\print.h>
  17. #include <tdll\update.h>
  18. #include <tdll\assert.h>
  19. #include "emu.h"
  20. #include "emu.hh"
  21. #include "viewdata.hh"
  22. #if defined(INCL_VIEWDATA)
  23. static void EmuViewdataDisplayLine(const HHEMU hhEmu, const int iRow, const int iStartCol);
  24. static STATTR GetAttr(const HHEMU hhEmu, const int iRow, const int iCol);
  25. static ECHAR MapMosaics(const HHEMU hhEmu, ECHAR ch);
  26. static int RowHasDblHigh(const HHEMU hhEmu, const int iRow);
  27. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  28. * EmuViewdataAnswerback
  29. *
  30. * DESCRIPTION: Sends the answerback message defined on the menus.
  31. *
  32. * ARGUMENTS: none
  33. *
  34. * RETURNS: nothing
  35. */
  36. void EmuViewdataAnswerback(const HHEMU hhEmu)
  37. {
  38. TCHAR *sp;
  39. ECHAR *pech = NULL;
  40. sp = hhEmu->acAnswerback;
  41. // If there is nothing to send, there is nothing to send
  42. if (StrCharGetStrLength(sp) == 0)
  43. return;
  44. pech = malloc((unsigned int)StrCharGetByteCount(sp) + sizeof(TCHAR));
  45. if (pech == NULL)
  46. {
  47. assert(FALSE);
  48. return;
  49. }
  50. CnvrtMBCStoECHAR(pech, (unsigned long)StrCharGetByteCount(sp), sp,
  51. (unsigned long)StrCharGetByteCount(sp) + sizeof(TCHAR));
  52. emuSendString(hhEmu, pech, (int)StrCharGetEcharByteCount(pech));
  53. free(pech);
  54. pech = NULL;
  55. }
  56. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  57. * EmuViewdataCursorLeft
  58. *
  59. * DESCRIPTION: Moves cursor left one column. If cursor starts at left edge,
  60. * it moves cursor to the last column of the line above.
  61. *
  62. * ARGUMENTS: none
  63. *
  64. * RETURNS: nothing
  65. */
  66. void EmuViewdataCursorLeft(const HHEMU hhEmu)
  67. {
  68. int iRow, iCol;
  69. iRow = hhEmu->emu_currow;
  70. iCol = hhEmu->emu_curcol;
  71. if (hhEmu->emu_curcol > 0)
  72. {
  73. iCol -= 1;
  74. }
  75. else if (hhEmu->emu_currow > 0)
  76. {
  77. iRow -= 1;
  78. iCol = hhEmu->emu_maxcol;
  79. }
  80. (*hhEmu->emu_setcurpos)(hhEmu, iRow, iCol);
  81. return;
  82. }
  83. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  84. * EmuViewdataCursorRight
  85. *
  86. * DESCRIPTION: Moves cursor right one column. If cursor starts at right edge,
  87. * it moves cursor to the first column of the line below.
  88. *
  89. * ARGUMENTS: none
  90. *
  91. * RETURNS: nothing
  92. */
  93. void EmuViewdataCursorRight(const HHEMU hhEmu)
  94. {
  95. int iRow, iCol;
  96. iRow = hhEmu->emu_currow;
  97. iCol = hhEmu->emu_curcol;
  98. if (hhEmu->emu_curcol < hhEmu->emu_maxcol)
  99. {
  100. iCol += 1;
  101. }
  102. else if (hhEmu->emu_currow < hhEmu->emu_maxrow)
  103. {
  104. iRow += 1;
  105. iCol = 0;
  106. }
  107. (*hhEmu->emu_setcurpos)(hhEmu, iRow, iCol);
  108. return;
  109. }
  110. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  111. * EmuViewdataCursorDown
  112. *
  113. * DESCRIPTION: Moves cursor down to the next line while maintaining the same
  114. * column. If starting on the bottom line, the cursor moves to
  115. * the top line.
  116. *
  117. * ARGUMENTS: none
  118. *
  119. * RETURNS: nothing
  120. */
  121. void EmuViewdataCursorDown(const HHEMU hhEmu)
  122. {
  123. int iRow = hhEmu->emu_currow;
  124. (*hhEmu->emu_setcurpos)(hhEmu,
  125. (hhEmu->emu_currow < hhEmu->emu_maxrow ? ++iRow : 0),
  126. hhEmu->emu_curcol);
  127. return;
  128. }
  129. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  130. * EmuViewdataCursorUp
  131. *
  132. * DESCRIPTION: Moves cursor up to the next line while maintaining the same
  133. * column. If starting on the top line, the cursor moves to
  134. * the bottom line.
  135. *
  136. * ARGUMENTS: none
  137. *
  138. * RETURNS: nothing
  139. */
  140. void EmuViewdataCursorUp(const HHEMU hhEmu)
  141. {
  142. int iRow = hhEmu->emu_currow;
  143. (*hhEmu->emu_setcurpos)(hhEmu,
  144. (hhEmu->emu_currow > 0 ? --iRow : hhEmu->emu_maxrow),
  145. hhEmu->emu_curcol);
  146. return;
  147. }
  148. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  149. * EmuViewdataCursorHome
  150. *
  151. * DESCRIPTION: Moves cursor to upper left corner of screen.
  152. *
  153. * ARGUMENTS: none
  154. *
  155. * RETURNS: nothing
  156. */
  157. void EmuViewdataCursorHome(const HHEMU hhEmu)
  158. {
  159. (*hhEmu->emu_setcurpos)(hhEmu, 0,0);
  160. return;
  161. }
  162. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  163. * EmuViewdataCursorSet
  164. *
  165. * DESCRIPTION: Turns the cursor on and off.
  166. *
  167. * ARGUMENTS: none
  168. *
  169. * RETURNS: nothing
  170. */
  171. void EmuViewdataCursorSet(const HHEMU hhEmu)
  172. {
  173. switch(hhEmu->emu_code)
  174. {
  175. case ETEXT('\x11'):
  176. (*hhEmu->EmuSetCursorType)(hhEmu, EMU_CURSOR_BLOCK);
  177. break;
  178. case ETEXT('\x14'):
  179. (*hhEmu->EmuSetCursorType)(hhEmu, EMU_CURSOR_NONE);
  180. break;
  181. default:
  182. break;
  183. }
  184. return;
  185. }
  186. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  187. * EmuViewdataMosaicHold
  188. *
  189. * DESCRIPTION: Displays the last displayed mosaic TCHAR inn every attribute
  190. * space that was defined during mosaic mode. If no mosaic has
  191. * been displayed since the last change in alpha/mosaic setting
  192. * or normal/double height setting or the last mosaic release,
  193. * a space is displayed instead.
  194. *
  195. * ARGUMENTS: none
  196. *
  197. * RETURNS: nothing
  198. */
  199. void EmuViewdataMosaicHold(const HHEMU hhEmu)
  200. {
  201. hhEmu->emu_code = ETEXT('\x20');
  202. EmuViewdataCharDisplay(hhEmu);
  203. return;
  204. }
  205. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  206. * EmuViewdataMosaicRelease
  207. *
  208. * DESCRIPTION: Displays a space.
  209. *
  210. * ARGUMENTS: none
  211. *
  212. * RETURNS: nothing
  213. */
  214. void EmuViewdataMosaicRelease(const HHEMU hhEmu)
  215. {
  216. /* TODO write this function */
  217. hhEmu->emu_code = ETEXT('\x20');
  218. EmuViewdataCharDisplay(hhEmu);
  219. return;
  220. }
  221. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  222. * EmuViewdataSetAttr
  223. *
  224. * DESCRIPTION: Sets colors and alpha/mosaic modes.
  225. *
  226. * ARGUMENTS: none
  227. *
  228. * RETURNS: nothing
  229. */
  230. void EmuViewdataSetAttr(const HHEMU hhEmu)
  231. {
  232. const ECHAR uch = hhEmu->emu_code;
  233. const PSTVIEWDATAPRIVATE pstPRI = (PSTVIEWDATAPRIVATE)hhEmu->pvPrivate;
  234. // For readability.
  235. //
  236. PSTVIEWDATA *stAttr = pstPRI->apstVD;
  237. int iRow = hhEmu->emu_imgrow;
  238. int iCol = hhEmu->emu_curcol;
  239. unsigned int *aiColors = pstPRI->aMapColors;
  240. STATTR charattr;
  241. hhEmu->emu_code = ETEXT('\x20');
  242. pstPRI->fSetAttr = TRUE;
  243. if (uch >= ETEXT('\x41') && uch <= ETEXT('\x47')) // A thru G
  244. {
  245. stAttr[iRow][iCol].attr = ALPHA_ATTR;
  246. stAttr[iRow][iCol].clr = aiColors[uch - ETEXT('\x41')];
  247. }
  248. else if (uch >= ETEXT('\x51') && uch <= ETEXT('\x57')) // Q thru W
  249. {
  250. charattr = GetAttr(hhEmu, hhEmu->emu_currow, hhEmu->emu_curcol);
  251. stAttr[iRow][iCol].attr = MOSAIC_ATTR;
  252. stAttr[iRow][iCol].clr = aiColors[uch - ETEXT('\x51')];
  253. }
  254. else
  255. {
  256. switch(uch)
  257. {
  258. case ETEXT('\x48'): //'H':
  259. stAttr[iRow][iCol].attr = FLASH_ATTR;
  260. break;
  261. case ETEXT('\x49'): //'I':
  262. stAttr[iRow][iCol].attr = STEADY_ATTR;
  263. break;
  264. case ETEXT('\x4C'): //'L':
  265. stAttr[iRow][iCol].attr = NORMALSIZE_ATTR;
  266. break;
  267. case ETEXT('\x4D'): //'M':
  268. stAttr[iRow][iCol].attr = DOUBLESIZE_ATTR;
  269. break;
  270. case ETEXT('\x58'): //'X':
  271. stAttr[iRow][iCol].attr = CONCEAL_ATTR;
  272. break;
  273. case ETEXT('\x59'): //'Y':
  274. stAttr[iRow][iCol].attr = CONTIGUOUS_ATTR;
  275. break;
  276. case ETEXT('\x5A'): //'Z':
  277. stAttr[iRow][iCol].attr = SEPARATED_ATTR;
  278. break;
  279. case ETEXT('\x5C'): //'\\':
  280. stAttr[iRow][iCol].attr = NEW_BACKGROUND_ATTR;
  281. stAttr[iRow][iCol].clr = 0;
  282. break;
  283. case ETEXT('\x5D'): //']':
  284. stAttr[iRow][iCol].attr = NEW_BACKGROUND_ATTR;
  285. charattr = GetAttr(hhEmu, hhEmu->emu_currow, hhEmu->emu_curcol);
  286. stAttr[iRow][iCol].clr = charattr.txtclr;
  287. break;
  288. default:
  289. return;
  290. }
  291. }
  292. EmuViewdataCharDisplay(hhEmu);
  293. return;
  294. }
  295. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  296. * EmuViewdataCharDisplay
  297. *
  298. * DESCRIPTION: Displays a single character
  299. *
  300. * ARGUMENTS: none
  301. *
  302. * RETURNS: nothing
  303. */
  304. void EmuViewdataCharDisplay(const HHEMU hhEmu)
  305. {
  306. int iRow = hhEmu->emu_currow;
  307. int iCol = hhEmu->emu_curcol;
  308. ECHAR *tp = hhEmu->emu_apText[hhEmu->emu_imgrow];
  309. PSTATTR ap = hhEmu->emu_apAttr[hhEmu->emu_imgrow];
  310. const PSTVIEWDATAPRIVATE pstPRI = (PSTVIEWDATAPRIVATE)hhEmu->pvPrivate;
  311. // TODO: Temporary until we get Prestel font
  312. if (hhEmu->emu_code == ETEXT('\x7F'))
  313. hhEmu->emu_code = ETEXT('\x5B');
  314. if (RowHasDblHigh(hhEmu, iRow))
  315. goto SKIP;
  316. // Need to GetAtt() before calling MapMosaics() so vars are set right.
  317. //
  318. ap[iCol] = GetAttr(hhEmu, iRow, iCol);
  319. tp[iCol] = MapMosaics(hhEmu, hhEmu->emu_code);
  320. // Update the end of row index if necessary.
  321. //
  322. if (iCol > hhEmu->emu_aiEnd[hhEmu->emu_imgrow])
  323. hhEmu->emu_aiEnd[hhEmu->emu_imgrow] = iCol;
  324. /* --- check to see if we are overwriting an attribute space --- */
  325. if (!pstPRI->fSetAttr)
  326. {
  327. pstPRI->fSetAttr =
  328. (BOOL)pstPRI->apstVD[hhEmu->emu_imgrow][hhEmu->emu_curcol].attr;
  329. pstPRI->apstVD[hhEmu->emu_imgrow][hhEmu->emu_curcol].attr = 0;
  330. }
  331. updateChar(sessQueryUpdateHdl(hhEmu->hSession), iRow, iCol, iCol);
  332. if (ap[iCol].dblhihi)
  333. {
  334. const PSTATTR apl =
  335. hhEmu->emu_apAttr[row_index(hhEmu, hhEmu->emu_currow+1)];
  336. hhEmu->emu_apText[row_index(hhEmu, hhEmu->emu_currow+1)][iCol] =
  337. tp[iCol];
  338. apl[iCol] = ap[iCol];
  339. apl[iCol].dblhihi = 0;
  340. apl[iCol].dblhilo = 1;
  341. pstPRI->fSetAttr = TRUE; // need to redisplay line to get lower half to show.
  342. }
  343. if (pstPRI->fSetAttr)
  344. {
  345. EmuViewdataDisplayLine(hhEmu, iRow, iCol);
  346. pstPRI->fSetAttr = FALSE;
  347. }
  348. SKIP:
  349. if (++iCol > hhEmu->emu_maxcol)
  350. {
  351. if (hhEmu->print_echo)
  352. printEchoLine(hhEmu->hPrintEcho,
  353. tp,
  354. emuRowLen(hhEmu, hhEmu->emu_imgrow));
  355. if (++iRow > hhEmu->emu_maxrow)
  356. iRow = 0;
  357. iCol = 0;
  358. }
  359. (*hhEmu->emu_setcurpos)(hhEmu, iRow, iCol);
  360. return;
  361. }
  362. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  363. * EmuViewdataDisplayLine
  364. *
  365. * DESCRIPTION: Redisplays the specified row from the specified column
  366. * using the current emu_charattr and character type up to
  367. * the end of the line (the 1st nul) or the next attribute
  368. * space (whichever comes first).
  369. *
  370. * ARGUMENTS:
  371. * sRow -- screen row to redisplay
  372. * sCol -- screen column at which to start displaying
  373. *
  374. * RETURNS: nothing
  375. */
  376. static void EmuViewdataDisplayLine(const HHEMU hhEmu,
  377. const int iRow,
  378. const int iStartCol)
  379. {
  380. int iCol;
  381. int fDblHi = FALSE;
  382. ECHAR *tp = hhEmu->emu_apText[row_index(hhEmu, iRow)];
  383. PSTATTR ap = hhEmu->emu_apAttr[row_index(hhEmu, iRow)];
  384. const PSTATTR apl = hhEmu->emu_apAttr[row_index(hhEmu, iRow+1)];
  385. for (iCol = iStartCol ; iCol <= hhEmu->emu_maxcol ; ++iCol)
  386. {
  387. ap[iCol] = GetAttr(hhEmu, iRow, iCol);
  388. tp[iCol] = MapMosaics(hhEmu, tp[iCol]);
  389. if (iRow < hhEmu->emu_maxrow && ap[iCol].dblhihi)
  390. fDblHi = TRUE;
  391. }
  392. updateChar(sessQueryUpdateHdl(hhEmu->hSession),
  393. iRow,
  394. iStartCol,
  395. hhEmu->emu_maxcol);
  396. if (fDblHi)
  397. {
  398. for (iCol = 0 ; iCol <= hhEmu->emu_maxcol ; ++iCol)
  399. {
  400. apl[iCol].bkclr = ap[iCol].bkclr;
  401. if (!apl[iCol].dblhilo)
  402. apl[iCol].blank = 1;
  403. }
  404. updateLine(sessQueryUpdateHdl(hhEmu->hSession), iRow+1, iRow+1);
  405. }
  406. return;
  407. }
  408. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  409. * FUNCTION:
  410. * GetAttr
  411. *
  412. * DESCRIPTION:
  413. * Walks the current row and builds a composite attribute based on
  414. * the encountered attribute spaces.
  415. *
  416. * ARGUMENTS:
  417. * iRow - logical row
  418. * iCol - logical col
  419. *
  420. * RETURNS:
  421. * composite attribute.
  422. *
  423. */
  424. static STATTR GetAttr(const HHEMU hhEmu, const int iRow, const int iCol)
  425. {
  426. int i;
  427. STATTR stAttr;
  428. const PSTVIEWDATAPRIVATE pstPRI = (PSTVIEWDATAPRIVATE)hhEmu->pvPrivate;
  429. const PSTVIEWDATA pstVD = pstPRI->apstVD[row_index(hhEmu, iRow)];
  430. memset(&stAttr, 0, sizeof(STATTR));
  431. stAttr.txtclr = VC_BRT_WHITE;
  432. stAttr.bkclr = VC_BLACK;
  433. pstPRI->fMosaicMode = FALSE;
  434. pstPRI->fSeperatedMosaic = FALSE;
  435. for (i = 0 ; i <= iCol ; ++i)
  436. {
  437. if (pstVD[i].attr)
  438. {
  439. switch (pstVD[i].attr)
  440. {
  441. case ALPHA_ATTR:
  442. pstPRI->fMosaicMode = FALSE;
  443. stAttr.txtclr = pstVD[i].clr;
  444. stAttr.symbol = FALSE;
  445. break;
  446. case MOSAIC_ATTR:
  447. pstPRI->fMosaicMode = TRUE;
  448. stAttr.txtclr = pstVD[i].clr;
  449. stAttr.symbol = TRUE;
  450. break;
  451. case CONTIGUOUS_ATTR:
  452. pstPRI->fMosaicMode = TRUE;
  453. pstPRI->fSeperatedMosaic = FALSE;
  454. stAttr.txtclr = pstVD[i].clr;
  455. stAttr.symbol = TRUE;
  456. break;
  457. case SEPARATED_ATTR:
  458. pstPRI->fMosaicMode = TRUE;
  459. pstPRI->fSeperatedMosaic = TRUE;
  460. stAttr.txtclr = pstVD[i].clr;
  461. stAttr.symbol = TRUE;
  462. break;
  463. case NORMALSIZE_ATTR:
  464. stAttr.dblhihi = 0;
  465. break;
  466. case FLASH_ATTR:
  467. stAttr.blink = 1;
  468. break;
  469. case STEADY_ATTR:
  470. stAttr.blink = 0;
  471. break;
  472. case NEW_BACKGROUND_ATTR:
  473. stAttr.bkclr = pstVD[i].clr;
  474. break;
  475. case DOUBLESIZE_ATTR:
  476. stAttr.dblhihi = 1;
  477. break;
  478. case CONCEAL_ATTR:
  479. stAttr.blank = 0; // ??
  480. break;
  481. default:
  482. break;
  483. }
  484. }
  485. }
  486. return stAttr;
  487. }
  488. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  489. * FUNCTION:
  490. * MapMosaics
  491. *
  492. * DESCRIPTION:
  493. * Since attributes that come before characters affect the character
  494. * display (alpha vs. mosaic) we need to map mosaic chars back to their
  495. * alpha counterparts and vice-versa at anytime. Prestel uses 7 bit
  496. * ascii so we can map the mosaics to the upper 128 bytes. This
  497. * function just checks the current mode (mosaic/alpha) and if the
  498. * character is in the proper range, its converted to its counterpart.
  499. * Also converts NULL to a space. View data doesn't support an end
  500. * of line concept and instead always fills to the end of line.
  501. *
  502. * Note: This function assumes GetAttr() has been called since it
  503. * relies on fMosaic and fSeperatedMosaic to be set.
  504. *
  505. * ARGUMENTS:
  506. * ch - character to convert
  507. *
  508. * RETURNS:
  509. * converted or original character.
  510. *
  511. */
  512. static ECHAR MapMosaics(const HHEMU hhEmu, ECHAR ch)
  513. {
  514. const PSTVIEWDATAPRIVATE pstPRI = (PSTVIEWDATAPRIVATE)hhEmu->pvPrivate;
  515. if (pstPRI->fMosaicMode)
  516. {
  517. // This is temporary until the fonts get straightend out.
  518. //
  519. if (ch > ETEXT('\x21') && ch <= ETEXT('\x3F'))
  520. ch += ETEXT('\x1F');
  521. if (pstPRI->fSeperatedMosaic)
  522. ch += ETEXT('\x80');
  523. }
  524. else // convert to equivalent alpha
  525. {
  526. if (ch > ETEXT('\x80'))
  527. ch -= ETEXT('\x80');
  528. }
  529. return ch;
  530. }
  531. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  532. * FUNCTION:
  533. * EmuViewdataClearScreen
  534. *
  535. * DESCRIPTION:
  536. * We use AnsiFormFeed() to do most of the work but we have to
  537. * clear viewdata's attribute buffer as well.
  538. *
  539. * ARGUMENTS:
  540. * none
  541. *
  542. * RETURNS:
  543. * void
  544. *
  545. */
  546. void EmuViewdataClearScreen(const HHEMU hhEmu)
  547. {
  548. const PSTVIEWDATAPRIVATE pstPRI = (PSTVIEWDATAPRIVATE)hhEmu->pvPrivate;
  549. register int i;
  550. AnsiFormFeed(hhEmu);
  551. for (i = 0 ; i < hhEmu->emu_maxrow ; ++i)
  552. memset(pstPRI->apstVD[i],
  553. 0,
  554. sizeof(STVIEWDATA) * VIEWDATA_COLS_40MODE);
  555. return;
  556. }
  557. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  558. * EmuViewdataKbd
  559. *
  560. * DESCRIPTION:
  561. * Keyboard routine for processing local keys on Viewdata terminal
  562. *
  563. * ARGUMENTS:
  564. * kcode - Key
  565. *
  566. * RETURNS:
  567. * nothing
  568. */
  569. int EmuViewdataKbd(const HHEMU hhEmu, int kcode, const BOOL fTest)
  570. {
  571. switch (kcode)
  572. {
  573. case VK_ESCAPE | VIRTUAL_KEY:
  574. kcode = ETEXT('[') | CTRL_KEY;
  575. if (fTest)
  576. return kcode;
  577. break;
  578. case VK_TAB | VIRTUAL_KEY:
  579. kcode = ETEXT('I') | CTRL_KEY;
  580. if (fTest)
  581. return kcode;
  582. break;
  583. case VK_RETURN | VIRTUAL_KEY | CTRL_KEY:
  584. kcode = ETEXT('J') | CTRL_KEY;
  585. if (fTest)
  586. return kcode;
  587. break;
  588. default:
  589. break;
  590. }
  591. return std_kbdin(hhEmu, kcode, fTest);
  592. }
  593. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  594. * RowHasDblHigh
  595. *
  596. * DESCRIPTION:
  597. * Checks if we are in the second row of a double high sequence.
  598. *
  599. * ARGUMENTS:
  600. * void
  601. *
  602. * RETURNS:
  603. * 0=FALSE, 1=TRUE
  604. */
  605. static int RowHasDblHigh(const HHEMU hhEmu, const int iRow)
  606. {
  607. int i;
  608. const int r = row_index(hhEmu, iRow);
  609. const PSTATTR ap = hhEmu->emu_apAttr[r];
  610. if (hhEmu->emu_currow != 0)
  611. {
  612. for (i = 0 ; i < hhEmu->emu_maxcol ; ++i)
  613. {
  614. if (ap[i].dblhilo)
  615. return 1;
  616. }
  617. }
  618. return 0;
  619. }
  620. #endif // INCL_VIEWDATA
  621. /************************** end of viewdata.c *****************************/