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.

743 lines
16 KiB

  1. /* File: D:\WACKER\emu\vt100.c (Created: 09-Dec-1993)
  2. *
  3. * Copyright 1994 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 5 $
  7. * $Date: 5/21/01 4:38p $
  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\assert.h>
  15. #include <tdll\cloop.h>
  16. #include <tdll\print.h>
  17. #include <tdll\capture.h>
  18. #include <tdll\update.h>
  19. #include <tdll\htchar.h>
  20. #include "emu.h"
  21. #include "emu.hh"
  22. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  23. * ANSI_DSR
  24. *
  25. * DESCRIPTION:
  26. * Reports the current cursor position to the host.
  27. *
  28. * ARGUMENTS:
  29. * none
  30. *
  31. * RETURNS:
  32. * nothing
  33. */
  34. void ANSI_DSR(const HHEMU hhEmu)
  35. {
  36. int sel, fOldValue;
  37. TCHAR achTemp[10];
  38. ECHAR s[10];
  39. ECHAR *sp;
  40. memset(s, 0, sizeof(s));
  41. sel = hhEmu->selector[0];
  42. if (sel == 5)
  43. CnvrtMBCStoECHAR(s, sizeof(s), TEXT("\033[0n"),
  44. StrCharGetByteCount(TEXT("\033[0n")));
  45. else if (sel == 6)
  46. {
  47. wsprintf(achTemp, TEXT("\033[%d;%dR"), hhEmu->emu_currow + 1,
  48. (hhEmu->emu_curcol == hhEmu->emu_maxcol + 1) ?
  49. hhEmu->emu_curcol : hhEmu->emu_curcol + 1);
  50. CnvrtMBCStoECHAR(s, sizeof(s), achTemp, StrCharGetByteCount(achTemp));
  51. }
  52. /* 1st str is printer not ready */
  53. else if (sel == 0x0F25) /* are user-defined keys locked? */
  54. CnvrtMBCStoECHAR(s, sizeof(s), TEXT("\033[?20n"),
  55. StrCharGetByteCount(TEXT("\033[?20n")));
  56. else if (sel == 0x0F26) /* what is the keyboard language? */
  57. CnvrtMBCStoECHAR(s, sizeof(s), TEXT("\033[?27;1n"),
  58. StrCharGetByteCount(TEXT("\033[?27;1n")));
  59. else
  60. {
  61. commanderror(hhEmu);
  62. return;
  63. }
  64. sp = s;
  65. /* to not get recursive ANSI_DSR's if half duplex */
  66. fOldValue = CLoopGetLocalEcho(sessQueryCLoopHdl(hhEmu->hSession));
  67. CLoopSetLocalEcho(sessQueryCLoopHdl(hhEmu->hSession), FALSE);
  68. emuSendString(hhEmu, sp, StrCharGetEcharByteCount(sp));
  69. CLoopSetLocalEcho(sessQueryCLoopHdl(hhEmu->hSession), fOldValue);
  70. }
  71. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  72. * ANSI_RM
  73. *
  74. * DESCRIPTION:
  75. * Sets character display attributes.
  76. *
  77. * ARGUMENTS:
  78. * none
  79. *
  80. * RETURNS:
  81. * nothing
  82. */
  83. void ANSI_RM(const HHEMU hhEmu)
  84. {
  85. int mode_id, i;
  86. HCLOOP hCLoop = (HCLOOP)0;
  87. for (i = 0; i <= hhEmu->selector_cnt; i++)
  88. {
  89. mode_id = hhEmu->selector[i];
  90. switch (mode_id)
  91. {
  92. case 0x02:
  93. hhEmu->mode_KAM = RESET;
  94. hhEmu->emu_kbdin = vt100_kbdin;
  95. break;
  96. case 0x04:
  97. hhEmu->mode_IRM = RESET;
  98. break;
  99. case 0x07:
  100. hhEmu->mode_VEM = RESET;
  101. break;
  102. case 0x10:
  103. hhEmu->mode_HEM = RESET;
  104. break;
  105. case 0x12:
  106. hhEmu->mode_SRM = RESET;
  107. CLoopSetLocalEcho(sessQueryCLoopHdl(hhEmu->hSession), TRUE);
  108. break;
  109. case 0x18: /* actually ?18, but ? gets shifted out */
  110. hhEmu->mode_DECPFF = RESET;
  111. break;
  112. case 0x19: /* acutally ?19, see above */
  113. hhEmu->mode_DECPEX = RESET;
  114. break;
  115. case 0x20:
  116. hhEmu->mode_LNM = RESET;
  117. /* also affects transmission of RET key */
  118. hCLoop = sessQueryCLoopHdl(hhEmu->hSession);
  119. CLoopSetAddLF(hCLoop, FALSE);
  120. CLoopSetSendCRLF(hCLoop, FALSE);
  121. break;
  122. case 0xF1:
  123. hhEmu->mode_DECCKM = RESET;
  124. break;
  125. case 0xF2:
  126. emuLoad((HEMU)hhEmu, EMU_VT52);
  127. break;
  128. case 0xF3:
  129. // Switch to 80 column mode.
  130. //
  131. emuSetDecColumns(hhEmu, VT_MAXCOL_80MODE, TRUE);
  132. break;
  133. case 0xF4:
  134. /* select jump scroll */
  135. /* we're always in jump scroll, just ignore */
  136. break;
  137. case 0xf5:
  138. if (hhEmu->mode_DECSCNM == SET)
  139. {
  140. emu_reverse_image(hhEmu);
  141. hhEmu->mode_DECSCNM = RESET;
  142. }
  143. break;
  144. case 0xf6:
  145. hhEmu->mode_DECOM = RESET;
  146. // This command homes the cursor. Added 16 Mar 98 rde
  147. ANSI_Pn_Clr(hhEmu);
  148. ANSI_CUP(hhEmu);
  149. break;
  150. case 0xd7: /* for ANSI */
  151. case 0xf7:
  152. hhEmu->mode_AWM = RESET;
  153. break;
  154. case 0xF8:
  155. /* turn off auto repeat */
  156. break;
  157. case 0xF18:
  158. hhEmu->mode_DECPFF = RESET;
  159. break;
  160. case 0xF19:
  161. hhEmu->mode_DECPEX = RESET;
  162. break;
  163. case 0xF25:
  164. hhEmu->mode_DECTCEM = RESET;
  165. EmuStdSetCursorType(hhEmu, EMU_CURSOR_NONE);
  166. break;
  167. default:
  168. commanderror(hhEmu);
  169. break;
  170. }
  171. }
  172. }
  173. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  174. * ANSI_SM
  175. *
  176. * DESCRIPTION:
  177. * Sets a mode for current terminal emulator.
  178. *
  179. * ARGUMENTS:
  180. * none
  181. *
  182. * RETURNS:
  183. * nothing
  184. */
  185. void ANSI_SM(const HHEMU hhEmu)
  186. {
  187. int mode_id, i;
  188. HCLOOP hCLoop = (HCLOOP)0;
  189. for (i = 0; i <= hhEmu->selector_cnt; i++)
  190. {
  191. mode_id = hhEmu->selector[i];
  192. switch (mode_id)
  193. {
  194. case 0x02:
  195. hhEmu->mode_KAM = SET;
  196. hhEmu->emu_kbdin = emu_kbdlocked;
  197. break;
  198. case 0x04:
  199. hhEmu->mode_IRM = SET;
  200. break;
  201. case 0x07:
  202. hhEmu->mode_VEM = SET;
  203. break;
  204. case 0x10:
  205. hhEmu->mode_HEM = SET;
  206. break;
  207. case 0x12:
  208. hhEmu->mode_SRM = SET;
  209. CLoopSetLocalEcho(sessQueryCLoopHdl(hhEmu->hSession), FALSE);
  210. break;
  211. case 0x18: /* actually ?18, but ? gets shifted out */
  212. hhEmu->mode_DECPFF = SET;
  213. break;
  214. case 0x19: /* acutally ?19, see above */
  215. hhEmu->mode_DECPEX = SET;
  216. break;
  217. case 0x20:
  218. hhEmu->mode_LNM = SET;
  219. /* also affects sending of RET key */
  220. hCLoop = sessQueryCLoopHdl(hhEmu->hSession);
  221. CLoopSetAddLF(hCLoop, TRUE);
  222. CLoopSetSendCRLF(hCLoop, TRUE);
  223. break;
  224. case 0xF1:
  225. hhEmu->mode_DECCKM = SET;
  226. break;
  227. case 0xF2:
  228. vt52_toANSI(hhEmu);
  229. break;
  230. case 0xF3:
  231. // Set 132 column mode.
  232. //
  233. emuSetDecColumns(hhEmu, VT_MAXCOL_132MODE, TRUE);
  234. break;
  235. case 0xF4:
  236. /* set smooth scrolling (not implemented) */
  237. break;
  238. case 0xF5:
  239. if (hhEmu->mode_DECSCNM == RESET)
  240. {
  241. emu_reverse_image(hhEmu);
  242. hhEmu->mode_DECSCNM = SET;
  243. }
  244. break;
  245. case 0xF6:
  246. hhEmu->mode_DECOM = SET;
  247. // This command homes the cursor. Added 16 Mar 98 rde
  248. ANSI_Pn_Clr(hhEmu);
  249. ANSI_CUP(hhEmu);
  250. break;
  251. case 0xD7:
  252. case 0xF7:
  253. hhEmu->mode_AWM = SET;
  254. break;
  255. case 0xF8:
  256. /* select auto repeat mode */
  257. break;
  258. case 0xF18:
  259. hhEmu->mode_DECPFF = SET;
  260. break;
  261. case 0xF19:
  262. hhEmu->mode_DECPEX = SET;
  263. break;
  264. case 0xF25:
  265. hhEmu->mode_DECTCEM = SET;
  266. EmuStdSetCursorType(hhEmu, hhEmu->stUserSettings.nCursorType);
  267. break;
  268. default:
  269. commanderror(hhEmu); break;
  270. }
  271. }
  272. }
  273. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  274. * vt_alt_kpmode
  275. *
  276. * DESCRIPTION:
  277. * Sets up emulator for alternate keypad mode.
  278. *
  279. * ARGUMENTS:
  280. * none
  281. *
  282. * RETURNS:
  283. * nothing
  284. */
  285. void vt_alt_kpmode(const HHEMU hhEmu)
  286. {
  287. if (hhEmu->emu_code == ETEXT('='))
  288. hhEmu->mode_DECKPAM = SET;
  289. else if (hhEmu->emu_code == ETEXT('>'))
  290. hhEmu->mode_DECKPAM = RESET;
  291. }
  292. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  293. * vt_screen_adjust
  294. *
  295. * DESCRIPTION:
  296. * Fills the screen with E's.
  297. *
  298. * ARGUMENTS:
  299. * none
  300. *
  301. * RETURNS:
  302. * nothing
  303. */
  304. void vt_screen_adjust(const HHEMU hhEmu)
  305. {
  306. register int i, row, cols;
  307. PSTATTR pstAttr;
  308. cols = hhEmu->mode_DECCOLM ? 132 : 80;
  309. for (row = 0; row < MAX_EMUROWS; ++row)
  310. {
  311. ECHAR_Fill(hhEmu->emu_apText[row], TEXT('E'), (unsigned)MAX_EMUCOLS);
  312. hhEmu->emu_aiEnd[row] = cols - 1;
  313. pstAttr = hhEmu->emu_apAttr[row];
  314. for (i = 0 ; i <= MAX_EMUCOLS; ++i)
  315. pstAttr[i] = hhEmu->emu_clearattr;
  316. updateChar(sessQueryUpdateHdl(hhEmu->hSession),
  317. row,
  318. 0,
  319. hhEmu->emu_maxcol);
  320. }
  321. (*hhEmu->emu_setcurpos)(hhEmu, 0, 0);
  322. }
  323. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  324. * vt_scrollrgn
  325. *
  326. * DESCRIPTION:
  327. * Sets up a scrolling region
  328. *
  329. * ARGUMENTS:
  330. * none
  331. *
  332. * RETURNS:
  333. * nothing
  334. */
  335. void vt_scrollrgn(const HHEMU hhEmu)
  336. {
  337. int toprow, botmrow;
  338. toprow = hhEmu->num_param[0];
  339. botmrow = hhEmu->num_param_cnt > 0 ? hhEmu->num_param[1] : 0;
  340. DEC_STBM(hhEmu, toprow, botmrow);
  341. }
  342. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  343. * DEC_STBM
  344. *
  345. * DESCRIPTION:
  346. * Sets up a scrolling region
  347. *
  348. * ARGUMENTS:
  349. * top -- screen row to be top row of scrolling region
  350. * bottom -- screen row to be bottom row of scrolling region
  351. * NOTE - the top row of screen is row 1
  352. *
  353. * RETURNS:
  354. * nothing
  355. */
  356. void DEC_STBM(const HHEMU hhEmu, int top, int bottom)
  357. {
  358. if (top < 1)
  359. top = 1;
  360. if (bottom < 1 || bottom > (hhEmu->emu_maxrow+1))
  361. bottom = (hhEmu->emu_maxrow+1);
  362. if (top >= bottom)
  363. {
  364. commanderror(hhEmu);
  365. return;
  366. }
  367. hhEmu->top_margin = top - 1; /* convert one-based to zero-based */
  368. hhEmu->bottom_margin = bottom - 1;
  369. ANSI_Pn_Clr(hhEmu);
  370. ANSI_CUP(hhEmu); /* home cursor after setting */
  371. }
  372. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  373. * vt52_to_ANSI
  374. *
  375. * DESCRIPTION:
  376. * Switches from VT52 mode to ANSI mode
  377. *
  378. * ARGUMENTS:
  379. * none
  380. *
  381. * RETURNS:
  382. * nothing
  383. */
  384. void vt52_toANSI(const HHEMU hhEmu)
  385. {
  386. #if FALSE //DEADWOOD:rde 9 Mar 98
  387. emuLoad((HEMU)hhEmu, EMU_VT100);
  388. #endif
  389. if (!hhEmu)
  390. assert(FALSE);
  391. else
  392. {
  393. // Return to the original emu, not necessarily the VT100.
  394. if (hhEmu->mode_vt320)
  395. emuLoad((HEMU)hhEmu, EMU_VT320);
  396. else if (hhEmu->mode_vt220)
  397. emuLoad((HEMU)hhEmu, EMU_VT220);
  398. else
  399. emuLoad((HEMU)hhEmu, EMU_VT100);
  400. }
  401. }
  402. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  403. * vt_DCH
  404. *
  405. * DESCRIPTION:
  406. * Deletes the specified number of characters starting at the current
  407. * cursor position and moving right. It stops at the end of the current line.
  408. *
  409. * ARGUMENTS:
  410. * none
  411. *
  412. * RETURNS:
  413. * nothing
  414. */
  415. void vt_DCH(const HHEMU hhEmu)
  416. {
  417. int nchars;
  418. BOOL old_mode_protect;
  419. STATTR old_emu_charattr;
  420. nchars = hhEmu->num_param[hhEmu->num_param_cnt];
  421. if (nchars < 1)
  422. nchars = 1;
  423. if (hhEmu->emu_code == ETEXT('P')) /* delete & shift line left */
  424. {
  425. ANSI_DCH(hhEmu);
  426. }
  427. else /* emu_code == 'X', just delete */
  428. {
  429. old_mode_protect = hhEmu->mode_protect;
  430. old_emu_charattr = hhEmu->emu_charattr;
  431. hhEmu->mode_protect = FALSE;
  432. hhEmu->emu_charattr.undrln = hhEmu->emu_charattr.blink = 0;
  433. emu_clearword(hhEmu, hhEmu->emu_curcol, hhEmu->emu_curcol + nchars - 1);
  434. hhEmu->mode_protect = old_mode_protect;
  435. hhEmu->emu_charattr = old_emu_charattr;
  436. }
  437. updateChar(sessQueryUpdateHdl(hhEmu->hSession),
  438. hhEmu->emu_currow,
  439. hhEmu->emu_curcol,
  440. hhEmu->emu_maxcol);
  441. }
  442. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  443. * vt_IL
  444. *
  445. * DESCRIPTION:
  446. * Inserts the specified number of lines starting at the current
  447. * cursor row.
  448. *
  449. * ARGUMENTS:
  450. * none
  451. *
  452. * RETURNS:
  453. * nothing
  454. */
  455. void vt_IL(const HHEMU hhEmu)
  456. {
  457. int nlines;
  458. nlines = hhEmu->num_param[hhEmu->num_param_cnt];
  459. if (nlines < 1)
  460. nlines = 1;
  461. ANSI_IL(hhEmu);
  462. }
  463. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  464. * vt_DL
  465. *
  466. * DESCRIPTION:
  467. * Deletes the specified number of lines starting at the current
  468. * cursor line and moving down. It stops at the bottom of the scrolling
  469. * region.
  470. *
  471. * ARGUMENTS:
  472. * none
  473. *
  474. * RETURNS:
  475. * nothing
  476. */
  477. void vt_DL(const HHEMU hhEmu)
  478. {
  479. int nlines;
  480. nlines = hhEmu->num_param[hhEmu->num_param_cnt];
  481. if (nlines < 1)
  482. nlines = 1;
  483. ANSI_DL(hhEmu);
  484. }
  485. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  486. * vt_clearline
  487. *
  488. * DESCRIPTION:
  489. * Erases some or all of the current virtual screen line and corresponding
  490. * real screen line.
  491. *
  492. * ARGUMENTS:
  493. * select -- 0 to erase from cursor to end of line
  494. * -- 1 to erase from start of line to cursor
  495. * -- 2 to erase entire line
  496. *
  497. * RETURNS:
  498. * nothing
  499. */
  500. void vt_clearline(const HHEMU hhEmu, const int nSelect)
  501. {
  502. std_clearline(hhEmu, nSelect);
  503. }
  504. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  505. * vt_clearscreen
  506. *
  507. * DESCRIPTION:
  508. * Erases some or all of the virtual screen image.
  509. *
  510. * ARGUMENTS:
  511. * select -- 0 to erase from cursor to end of screen
  512. * -- 1 to erase from start of screen to cursor
  513. * -- 2 to erase entire screen
  514. *
  515. * RETURNS:
  516. * nothing
  517. */
  518. void vt_clearscreen(const HHEMU hhEmu, const int nSelect)
  519. {
  520. std_clearscreen(hhEmu, nSelect);
  521. }
  522. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  523. * vt_backspace
  524. *
  525. * DESCRIPTION: Moves the cursor backwards (to the left) 1 column, but stops
  526. * at the 1st character in the current line. The vt emus need
  527. * a special function to handle the virtual column beyond the
  528. * edge of the screen.
  529. *
  530. * ARGUMENTS: none
  531. *
  532. * RETURNS: nothing
  533. */
  534. void vt_backspace(const HHEMU hhEmu)
  535. {
  536. INT bWide = 1;
  537. INT iRow = row_index(hhEmu, hhEmu->emu_currow);
  538. INT iCol;
  539. //if (hhEmu->emu_curcol > 0)
  540. // {
  541. // (*hhEmu->emu_setcurpos)(hhEmu, hhEmu->emu_currow,
  542. // hhEmu->emu_curcol - 1);
  543. // }
  544. if (hhEmu->emu_curcol > 0)
  545. {
  546. bWide = hhEmu->emu_apAttr[iRow][hhEmu->emu_curcol - 1].wirt ? 2 : 1;
  547. bWide = hhEmu->emu_apAttr[iRow][hhEmu->emu_curcol].wirt ? 0 : bWide;
  548. (*hhEmu->emu_setcurpos)(hhEmu,
  549. hhEmu->emu_currow,
  550. hhEmu->emu_curcol - bWide);
  551. }
  552. if ((hhEmu->stUserSettings.nEmuId == EMU_TTY &&
  553. hhEmu->stUserSettings.fDestructiveBk) || (bWide == 0))
  554. {
  555. if (bWide == 0)
  556. iCol = hhEmu->emu_curcol - 1;
  557. else
  558. iCol = hhEmu->emu_curcol; // account for wide chars this way
  559. hhEmu->emu_code = ETEXT(' ');
  560. (*hhEmu->emu_graphic)(hhEmu);
  561. (*hhEmu->emu_setcurpos)(hhEmu,
  562. hhEmu->emu_currow,
  563. iCol); //MPT:12-8-97 hhEmu->emu_curcol - 1);
  564. }
  565. }
  566. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  567. * vt_CUB
  568. *
  569. * DESCRIPTION: Moves the cursor backwards (to the left) the specified number
  570. * of characters, but stops at the 1st character in the current
  571. * line. The vt emus need a special function to handle the
  572. * virtual column beyond the edge of the screen.
  573. *
  574. * ARGUMENTS: none
  575. *
  576. * RETURNS: nothing
  577. */
  578. void vt_CUB(const HHEMU hhEmu)
  579. {
  580. int nchars;
  581. nchars = hhEmu->num_param[hhEmu->num_param_cnt];
  582. if (nchars < 1)
  583. nchars = 1;
  584. (*hhEmu->emu_setcurpos)(hhEmu,
  585. hhEmu->emu_currow, (hhEmu->emu_curcol - nchars));
  586. }
  587. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  588. * FUNCTION:
  589. * emuSetDecColumns
  590. *
  591. * DESCRIPTION:
  592. * For DEC emulators only, this function sets either 80 or 132 columns.
  593. *
  594. * ARGUMENTS:
  595. * hhEmu - The internal emualtor handle.
  596. * nColumns - The number of columns to set. This may be either...
  597. * VT_MAXCOL_80MODE, or
  598. * VT_MAXCOL_132MODE.
  599. * fClear - clear screen if TRUE
  600. *
  601. * RETURNS:
  602. * void
  603. *
  604. */
  605. void emuSetDecColumns(const HHEMU hhEmu, const int nColumns, const int fClear)
  606. {
  607. if ((hhEmu->stUserSettings.nEmuId == EMU_VT100) ||
  608. (hhEmu->stUserSettings.nEmuId == EMU_VT220) ||
  609. (hhEmu->stUserSettings.nEmuId == EMU_VT320) ||
  610. (hhEmu->stUserSettings.nEmuId == EMU_VT100J) ||
  611. (hhEmu->stUserSettings.nEmuId == EMU_VT100PLUS) ||
  612. (hhEmu->stUserSettings.nEmuId == EMU_VTUTF8))
  613. ;
  614. else
  615. return;
  616. switch(nColumns)
  617. {
  618. case VT_MAXCOL_80MODE:
  619. hhEmu->mode_DECCOLM = RESET;
  620. hhEmu->emu_maxcol = VT_MAXCOL_80MODE;
  621. if (fClear)
  622. {
  623. DEC_STBM(hhEmu, 0, hhEmu->emu_maxrow + 1);
  624. (*hhEmu->emu_clearscreen)(hhEmu, 2);
  625. }
  626. NotifyClient(hhEmu->hSession, EVENT_EMU_SETTINGS, 0);
  627. break;
  628. case VT_MAXCOL_132MODE:
  629. hhEmu->mode_DECCOLM = SET;
  630. hhEmu->emu_maxcol = VT_MAXCOL_132MODE;
  631. if (fClear)
  632. {
  633. DEC_STBM(hhEmu, 0, hhEmu->emu_maxrow + 1);
  634. (*hhEmu->emu_clearscreen)(hhEmu, 2);
  635. }
  636. NotifyClient(hhEmu->hSession, EVENT_EMU_SETTINGS, 0);
  637. break;
  638. default:
  639. return;
  640. }
  641. }
  642. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  643. * FUNCTION:
  644. * DEC_HHC
  645. *
  646. * DESCRIPTION:
  647. * Sets cursor to home position which is 1, 0 in this case.
  648. *
  649. * ARGUMENTS:
  650. * hhEmu - private emulator handle
  651. *
  652. * RETURNS:
  653. * 0=OK,else error.
  654. *
  655. */
  656. int DEC_HHC(const HHEMU hhEmu)
  657. {
  658. if (hhEmu == 0)
  659. {
  660. assert(0);
  661. return -1;
  662. }
  663. (*hhEmu->emu_setcurpos)(hhEmu, 0, 0);
  664. return 0;
  665. }
  666. /* end of vt_xtra.c */