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.

169 lines
5.2 KiB

  1. /* File: D:\WACKER\emu\vt52init.c (Created: 28-Dec-1993)
  2. *
  3. * Copyright 1994, 1998 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 3 $
  7. * $Date: 5/09/01 4:48p $
  8. */
  9. #include <windows.h>
  10. #pragma hdrstop
  11. #include <tdll\stdtyp.h>
  12. #include <tdll\session.h>
  13. #include <tdll\assert.h>
  14. #include <tdll\mc.h>
  15. #include <tdll\backscrl.h>
  16. #include <tdll\htchar.h>
  17. #include "emu.h"
  18. #include "emu.hh"
  19. #include "emuid.h"
  20. #include "emudec.hh"
  21. #include "keytbls.h"
  22. static void vt52char_reset(const HHEMU hhEmu);
  23. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  24. * vt52_init
  25. *
  26. * DESCRIPTION:
  27. * Loads and initializes the VT52 emulator.
  28. *
  29. * ARGUMENTS:
  30. * new_emu -- TRUE if emulating a power up on the real thing.
  31. *
  32. * RETURNS:
  33. * nothing
  34. */
  35. void vt52_init(const HHEMU hhEmu)
  36. {
  37. PSTDECPRIVATE pstPRI;
  38. static struct trans_entry const vt52_tbl[] =
  39. {
  40. {NEW_STATE, 0, 0, 0}, // State 0
  41. {0, ETEXT('\x20'), ETEXT('\x7E'), emuStdGraphic}, // Space - ~
  42. {1, ETEXT('\x1B'), ETEXT('\x1B'), nothing}, // Esc
  43. {0, ETEXT('\x07'), ETEXT('\x07'), emu_bell}, // Ctrl-G
  44. {0, ETEXT('\x08'), ETEXT('\x08'), vt_backspace}, // Backspace
  45. {0, ETEXT('\x09'), ETEXT('\x09'), tabn}, // Tab
  46. {0, ETEXT('\x0A'), ETEXT('\x0A'), emuLineFeed}, // New Line
  47. {0, ETEXT('\x0D'), ETEXT('\x0D'), carriagereturn}, // CR
  48. {5, ETEXT('\x18'), ETEXT('\x18'), EmuStdChkZmdm}, // Ctrl-X
  49. {NEW_STATE, 0, 0, 0}, // State 1 // Esc
  50. {2, ETEXT('\x59'), ETEXT('\x59'), nothing}, // Y
  51. {0, ETEXT('\x3C'), ETEXT('\x3C'), vt52_toANSI}, // <
  52. {0, ETEXT('\x3D'), ETEXT('\x3E'), vt_alt_kpmode}, // = - >
  53. {0, ETEXT('\x41'), ETEXT('\x41'), ANSI_CUU}, // A
  54. {0, ETEXT('\x42'), ETEXT('\x42'), ANSI_CUD}, // B
  55. {0, ETEXT('\x43'), ETEXT('\x43'), ANSI_CUF}, // C
  56. {0, ETEXT('\x44'), ETEXT('\x44'), vt_CUB}, // D
  57. {0, ETEXT('\x46'), ETEXT('\x47'), vt_charshift}, // F - G
  58. {0, ETEXT('\x48'), ETEXT('\x48'), ANSI_CUP}, // H
  59. {0, ETEXT('\x49'), ETEXT('\x49'), ANSI_RI}, // I
  60. {0, ETEXT('\x4A'), ETEXT('\x4A'), ANSI_ED}, // J
  61. {0, ETEXT('\x4B'), ETEXT('\x4B'), ANSI_EL}, // K
  62. {0, ETEXT('\x56'), ETEXT('\x56'), vt52PrintCommands}, // V
  63. {4, ETEXT('\x57'), ETEXT('\x57'), nothing}, // W
  64. {0, ETEXT('\x58'), ETEXT('\x58'), nothing}, // X
  65. {0, ETEXT('\x5A'), ETEXT('\x5A'), vt52_id}, // Z
  66. {0, ETEXT('\x5D'), ETEXT('\x5D'), vt52PrintCommands}, // ]
  67. {0, ETEXT('\x5E'), ETEXT('\x5E'), vt52PrintCommands}, // ^
  68. {0, ETEXT('\x5F'), ETEXT('\x5F'), vt52PrintCommands}, // _
  69. {NEW_STATE, 0, 0, 0}, // State 2 // EscY
  70. // Accept all data--CUP will set the limits. Needed for more than 24 rows.
  71. {3, ETEXT('\x00'), ETEXT('\xFF'), char_pn}, // Space - 8
  72. // {3, ETEXT('\x20'), ETEXT('\x38'), char_pn}, // Space - 8
  73. {NEW_STATE, 0, 0, 0}, // State 3 // EscYn
  74. // Accept all data--CUP will set the limits. Needed for more than 80 columns.
  75. {0, ETEXT('\x00'), ETEXT('\xFF'), vt52_CUP}, // Space - o
  76. // {0, ETEXT('\x20'), ETEXT('\x6F'), vt52_CUP}, // Space - o
  77. {NEW_STATE, 0, 0, 0}, // State 4 // EscW
  78. {4, ETEXT('\x00'), ETEXT('\xFF'), vt52Print}, // All
  79. {NEW_STATE, 0, 0, 0}, // State 5 // Ctrl-X
  80. {5, ETEXT('\x00'), ETEXT('\xFF'), EmuStdChkZmdm}, // All
  81. };
  82. emuInstallStateTable(hhEmu, vt52_tbl, DIM(vt52_tbl));
  83. // Allocate space for and initialize data that is used only by the
  84. // VT52 emulator.
  85. //
  86. if (hhEmu->pvPrivate != 0)
  87. {
  88. free(hhEmu->pvPrivate);
  89. hhEmu->pvPrivate = 0;
  90. }
  91. hhEmu->pvPrivate = malloc(sizeof(DECPRIVATE));
  92. if (hhEmu->pvPrivate == 0)
  93. {
  94. assert(FALSE);
  95. return;
  96. }
  97. pstPRI = (PSTDECPRIVATE)hhEmu->pvPrivate;
  98. CnvrtMBCStoECHAR(pstPRI->terminate, sizeof(pstPRI->terminate), TEXT("\033X"),
  99. StrCharGetByteCount(TEXT("\033X")));
  100. pstPRI->len_t = 2;
  101. pstPRI->pntr = pstPRI->storage;
  102. pstPRI->len_s = 0;
  103. // Initialize standard hhEmu values.
  104. //
  105. hhEmu->emu_kbdin = vt52_kbdin;
  106. hhEmu->emu_highchar = 0x7E;
  107. hhEmu->emu_deinstall = emuVT52Unload;
  108. vt52char_reset(hhEmu);
  109. // emuKeyTableLoad(hhEmu, IDT_VT52_KEYS, &hhEmu->stEmuKeyTbl);
  110. // emuKeyTableLoad(hhEmu, IDT_VT52_KEYPAD_APP_MODE, &hhEmu->stEmuKeyTbl2);
  111. // emuKeyTableLoad(hhEmu, IDT_VT_MAP_PF_KEYS, &hhEmu->stEmuKeyTbl3);
  112. emuKeyTableLoad(hhEmu, VT52KeyTable,
  113. sizeof(VT52KeyTable)/sizeof(KEYTBLSTORAGE),
  114. &hhEmu->stEmuKeyTbl);
  115. emuKeyTableLoad(hhEmu, VT52_Keypad_KeyTable,
  116. sizeof(VT52_Keypad_KeyTable)/sizeof(KEYTBLSTORAGE),
  117. &hhEmu->stEmuKeyTbl2);
  118. emuKeyTableLoad(hhEmu, VT_PF_KeyTable,
  119. sizeof(VT_PF_KeyTable)/sizeof(KEYTBLSTORAGE),
  120. &hhEmu->stEmuKeyTbl3);
  121. backscrlSetShowFlag(sessQueryBackscrlHdl(hhEmu->hSession), TRUE);
  122. return;
  123. }
  124. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  125. * vt52char_reset
  126. *
  127. * DESCRIPTION:
  128. * Sets the VT52 emulator character set to its RESET conditions.
  129. *
  130. * ARGUMENTS:
  131. * none
  132. *
  133. * RETURNS:
  134. * nothing
  135. */
  136. static void vt52char_reset(const HHEMU hhEmu)
  137. {
  138. // Set up US ASCII character set as G0 and DEC graphics as G1
  139. //
  140. vt_charset_init(hhEmu);
  141. hhEmu->emu_code = ETEXT(')');
  142. vt_scs1(hhEmu);
  143. hhEmu->emu_code = (ECHAR)0;
  144. vt_scs2(hhEmu);
  145. }
  146. /* end of vt52init.c */