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.

631 lines
24 KiB

  1. /* File: \wacker\emu\vt220ini.c (Created: 24-Jan-1998)
  2. *
  3. * Copyright 1998 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 1 $
  7. * $Date: 10/05/98 12:28p $
  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 "emu.h"
  17. #include "emu.hh"
  18. #include "emuid.h"
  19. #include "emudec.hh"
  20. #include "keytbls.h"
  21. #if defined(INCL_VT220)
  22. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  23. * vt220_init
  24. *
  25. * DESCRIPTION:
  26. * Initializes the VT220 emulator.
  27. *
  28. * ARGUMENTS:
  29. *
  30. * RETURNS:
  31. * nothing
  32. */
  33. void vt220_init(const HHEMU hhEmu)
  34. {
  35. PSTDECPRIVATE pstPRI;
  36. int iRow;
  37. static struct trans_entry const vt220_tbl[] =
  38. {
  39. {NEW_STATE, 0, 0, 0}, // State 0
  40. #if !defined(FAR_EAST) // Left in from the VT100.
  41. {0, ETEXT('\x20'), ETEXT('\x7E'), emuDecGraphic}, // Space - ~
  42. {0, ETEXT('\xA0'), ETEXT('\xFF'), emuDecGraphic}, //
  43. #else
  44. {0, ETEXT('\x20'), ETEXT('\x7E'), emuDecGraphic}, // Space - ~
  45. {0, ETEXT('\xA0'), 0xFFFF, emuDecGraphic}, //
  46. #endif
  47. {1, ETEXT('\x1B'), ETEXT('\x1B'), nothing}, // Esc
  48. {2, ETEXT('\x9B'), ETEXT('\x9B'), nothing}, // CSI
  49. // 7 bit control codes
  50. // {13,TEXT('\x01'), ETEXT('\x01'), nothing}, // Ctrl-A
  51. {0, ETEXT('\x05'), ETEXT('\x05'), vt100_answerback}, // Ctrl-E
  52. {0, ETEXT('\x07'), ETEXT('\x07'), emu_bell}, // Ctrl-G
  53. {0, ETEXT('\x08'), ETEXT('\x08'), vt_backspace}, // BackSpace
  54. {0, ETEXT('\x09'), ETEXT('\x09'), emuDecTab}, // Tab
  55. {0, ETEXT('\x0A'), ETEXT('\x0C'), emuLineFeed}, // NL - FF
  56. {0, ETEXT('\x0D'), ETEXT('\x0D'), carriagereturn}, // CR
  57. {0, ETEXT('\x0E'), ETEXT('\x0F'), vt_charshift}, // Ctrl-N, Ctrl-O
  58. {12,ETEXT('\x18'), ETEXT('\x18'), EmuStdChkZmdm}, // Ctrl-X
  59. // 8 bit control codes
  60. {0, ETEXT('\x84'), ETEXT('\x84'), emuDecIND}, // Index cursor
  61. {0, ETEXT('\x85'), ETEXT('\x85'), ANSI_NEL}, // Next line
  62. {0, ETEXT('\x88'), ETEXT('\x88'), ANSI_HTS}, // Set Horizontal Tab
  63. {0, ETEXT('\x8D'), ETEXT('\x8D'), emuDecRI}, // Reverse index
  64. {0, ETEXT('\x8E'), ETEXT('\x8F'), vt_charshift}, // SingleShift G2,G3
  65. {5, ETEXT('\x90'), ETEXT('\x90'), nothing}, // Device Control String (DCS)
  66. // Ignore these codes. They just show what functionality is still missing.
  67. {0, ETEXT('\x00'), ETEXT('\x00'), nothing}, // ignore nuls
  68. {0, ETEXT('\x1A'), ETEXT('\x1A'), nothing}, // ignore Substitute
  69. {0, ETEXT('\x7F'), ETEXT('\x7F'), nothing}, // ignore Delete
  70. {0, ETEXT('\x9C'), ETEXT('\x9C'), nothing}, // ignore String Terminator
  71. {NEW_STATE, 0, 0, 0}, // State 1 // Esc
  72. {2, ETEXT('\x5B'), ETEXT('\x5B'), ANSI_Pn_Clr}, // '['
  73. {7, ETEXT('\x20'), ETEXT('\x20'), nothing}, // Space
  74. {3, ETEXT('\x23'), ETEXT('\x23'), nothing}, // #
  75. {4, ETEXT('\x28'), ETEXT('\x2B'), vt_scs1}, // ( - +
  76. {0, ETEXT('\x37'), ETEXT('\x38'), vt100_savecursor}, // 8
  77. {1, ETEXT('\x3B'), ETEXT('\x3B'), ANSI_Pn_End}, // ;
  78. {0, ETEXT('\x3D'), ETEXT('\x3E'), vt_alt_kpmode}, // = - >
  79. {0, ETEXT('\x44'), ETEXT('\x44'), emuDecIND}, // D
  80. {0, ETEXT('\x45'), ETEXT('\x45'), ANSI_NEL}, // E
  81. {0, ETEXT('\x48'), ETEXT('\x48'), ANSI_HTS}, // H
  82. {0, ETEXT('\x4D'), ETEXT('\x4D'), emuDecRI}, // M
  83. {0, ETEXT('\x4E'), ETEXT('\x4F'), vt_charshift}, // N - O
  84. {5, ETEXT('\x50'), ETEXT('\x50'), nothing}, // P
  85. {0, ETEXT('\x5A'), ETEXT('\x5A'), vt220_DA}, // Z
  86. {0, ETEXT('\\'), ETEXT('\\'), nothing}, // Backslash
  87. {0, ETEXT('\x63'), ETEXT('\x63'), vt220_hostreset}, // c
  88. {0, ETEXT('\x6E'), ETEXT('\x6F'), vt_charshift}, // n - o
  89. {0, ETEXT('\x7D'), ETEXT('\x7E'), vt_charshift}, // } - ~
  90. {NEW_STATE, 0, 0, 0}, // State 2 // ESC [
  91. {8, ETEXT('\x21'), ETEXT('\x21'), nothing}, // !
  92. {2, ETEXT('\x3B'), ETEXT('\x3B'), ANSI_Pn_End}, // ;
  93. {9, ETEXT('\x3E'), ETEXT('\x3E'), nothing}, // >
  94. {2, ETEXT('\x30'), ETEXT('\x3F'), ANSI_Pn}, // 0 - ?
  95. {11,ETEXT('\x22'), ETEXT('\x22'), nothing}, // "
  96. // {16,ETEXT('\x24'), ETEXT('\x24'), nothing}, // $
  97. {2, ETEXT('\x27'), ETEXT('\x27'), nothing}, // Eat Esc [ m ; m ; ' z
  98. {0, ETEXT('\x40'), ETEXT('\x40'), ANSI_ICH}, // @
  99. {0, ETEXT('\x41'), ETEXT('\x41'), emuDecCUU}, // A
  100. {0, ETEXT('\x42'), ETEXT('\x42'), emuDecCUD}, // B
  101. {0, ETEXT('\x43'), ETEXT('\x43'), emuDecCUF}, // C
  102. {0, ETEXT('\x44'), ETEXT('\x44'), emuDecCUB}, // D
  103. {0, ETEXT('\x48'), ETEXT('\x48'), emuDecCUP}, // H
  104. {0, ETEXT('\x4A'), ETEXT('\x4A'), emuVT220ED}, // J
  105. {0, ETEXT('\x4B'), ETEXT('\x4B'), emuDecEL}, // K
  106. {0, ETEXT('\x4C'), ETEXT('\x4C'), vt_IL}, // L
  107. {0, ETEXT('\x4D'), ETEXT('\x4D'), vt_DL}, // M
  108. {0, ETEXT('\x50'), ETEXT('\x50'), vt_DCH}, // P
  109. {0, ETEXT('\x58'), ETEXT('\x58'), vt_DCH}, // X
  110. {0, ETEXT('\x63'), ETEXT('\x63'), vt220_DA}, // c
  111. {0, ETEXT('\x66'), ETEXT('\x66'), emuDecCUP}, // f
  112. {0, ETEXT('\x67'), ETEXT('\x67'), ANSI_TBC}, // g
  113. {0, ETEXT('\x68'), ETEXT('\x68'), ANSI_SM}, // h
  114. {0, ETEXT('\x69'), ETEXT('\x69'), vt100PrintCommands},// i
  115. {0, ETEXT('\x6C'), ETEXT('\x6C'), ANSI_RM}, // l
  116. {0, ETEXT('\x6D'), ETEXT('\x6D'), ANSI_SGR}, // m
  117. {0, ETEXT('\x6E'), ETEXT('\x6E'), ANSI_DSR}, // n
  118. {0, ETEXT('\x71'), ETEXT('\x71'), nothing}, // q
  119. {0, ETEXT('\x72'), ETEXT('\x72'), vt_scrollrgn}, // r
  120. {0, ETEXT('\x75'), ETEXT('\x75'), nothing}, // u
  121. {0, ETEXT('\x79'), ETEXT('\x79'), nothing}, // y
  122. {0, ETEXT('\x7A'), ETEXT('\x7A'), nothing}, // z
  123. {NEW_STATE, 0, 0, 0}, // State 3 // Esc #
  124. {0, ETEXT('\x33'), ETEXT('\x36'), emuSetDoubleAttr}, // 3 - 6
  125. {0, ETEXT('\x38'), ETEXT('\x38'), vt_screen_adjust}, // 8
  126. {NEW_STATE, 0, 0, 0}, // State 4 // Esc ( - +
  127. {0, ETEXT('\x01'), ETEXT('\xFF'), vt_scs2}, // All
  128. {NEW_STATE, 0, 0, 0}, // State 5 // Esc P
  129. {5, ETEXT('\x3B'), ETEXT('\x3B'), ANSI_Pn_End}, // ;
  130. {5, ETEXT('\x30'), ETEXT('\x3F'), ANSI_Pn}, // 0 - ?
  131. {10,ETEXT('\x7C'), ETEXT('\x7C'), emuDecClearUDK}, // |
  132. {NEW_STATE, 0, 0, 0}, // State 6
  133. {6, ETEXT('\x00'), ETEXT('\xFF'), vt100_prnc}, // All
  134. {NEW_STATE, 0, 0, 0}, // State 7 // Esc Sapce
  135. {0, ETEXT('\x46'), ETEXT('\x47'), nothing}, // F - G
  136. {NEW_STATE, 0, 0, 0}, // State 8 // Esc [ !
  137. {0, ETEXT('\x70'), ETEXT('\x70'), vt220_softreset}, // p
  138. {NEW_STATE, 0, 0, 0}, // State 9 // Esc [ >
  139. {0, ETEXT('\x63'), ETEXT('\x63'), vt220_2ndDA}, // c
  140. {NEW_STATE, 0, 0, 0}, // State 10 // Esc P n;n |
  141. {10,ETEXT('\x00'), ETEXT('\xFF'), emuDecDefineUDK}, // All
  142. {NEW_STATE, 0, 0, 0}, // State 11 // Esc [ "
  143. {0, ETEXT('\x70'), ETEXT('\x70'), vt220_level}, // p
  144. {0, ETEXT('\x71'), ETEXT('\x71'), vt220_protmode}, // q
  145. {NEW_STATE, 0, 0, 0}, // State 12 // Ctrl-X
  146. {12,ETEXT('\x00'), ETEXT('\xFF'), EmuStdChkZmdm}, // All
  147. // States 13-17 are not used in HT but included for reference.
  148. // {NEW_STATE, 0, 0, 0}, // State 13 // Ctrl-A
  149. // {14,ETEXT('\x08'), ETEXT('\x08'), emuSerialNbr}, // Backspace
  150. // {15,ETEXT('\x48'), ETEXT('\x48'), EmuStdChkHprP}, // H
  151. // {NEW_STATE, 0, 0, 0}, // State 14 // Ctrl-A bs
  152. // {14,ETEXT('\x00'), ETEXT('\xFF'), emuSerialNbr}, // All
  153. // {NEW_STATE, 0, 0, 0}, // State 15 // Ctrl-A H
  154. // {15,ETEXT('\x00'), ETEXT('\xFF'), EmuStdChkHprP}, // All
  155. // A real VT220/320 does not support the status line sequences.
  156. // {NEW_STATE, 0, 0, 0}, // State 16 // Esc [ n $
  157. // {16,ETEXT('\x7E'), ETEXT('\x7E'), emuDecSelectStatusLine}, // ~
  158. // {17,ETEXT('\x7D'), ETEXT('\x7D'), emuDecSelectActiveDisplay}, // }
  159. // {NEW_STATE, 0, 0, 0}, // State 17
  160. // {17,ETEXT('\x00'), ETEXT('\xFF'), emuDecStatusLineToss}, // All
  161. };
  162. // The following key tables were copied from \shared\emulator\vt220ini.c
  163. // because they support user-defined keys. The tables have been modified
  164. // so keydef.h is not needed and to match HT's use of keys. rde 2 Feb 98
  165. // The following key tables are defined in the order that they
  166. // are searched.
  167. //
  168. // These are the (standard) F1 thru F4 keys on the top and left of the
  169. // keyboard. Note that these keys may be mapped to the top row of the
  170. // numeric keypad. In that case, these keys (at the standard locations),
  171. // are not mapped to emulator keys. NOTE: HTPE does not use this mapping.
  172. //
  173. // Please note that the sequences defined in this table are the
  174. // 8-bit versions of the responses. The function emuDecSendKeyString
  175. // will convert this sequence to the 7-bit equivalent if necessary.
  176. //
  177. static STEMUKEYDATA const VT220StdPfKeyTable[] =
  178. {
  179. EMUKEY(VK_F1, 1, 0, 0, 0, 0, "\x8F\x50", 2), // P
  180. EMUKEY(VK_F2, 1, 0, 0, 0, 0, "\x8F\x51", 2), // Q
  181. EMUKEY(VK_F3, 1, 0, 0, 0, 0, "\x8F\x52", 2), // R
  182. EMUKEY(VK_F4, 1, 0, 0, 0, 0, "\x8F\x53", 2), // S
  183. EMUKEY(VK_F1, 1, 0, 0, 0, 1, "\x8F\x50", 2), // P
  184. EMUKEY(VK_F2, 1, 0, 0, 0, 1, "\x8F\x51", 2), // Q
  185. EMUKEY(VK_F3, 1, 0, 0, 0, 1, "\x8F\x52", 2), // R
  186. EMUKEY(VK_F4, 1, 0, 0, 0, 1, "\x8F\x53", 2), // S
  187. };
  188. // When the user has selected the option to map the top 4 keys of the
  189. // numeric keypad to be the same as F1 thru F4, these key sequences are
  190. // used. NOTE: This is the mapping HTPE uses.
  191. //
  192. // Please note that the sequences defined in this table are the
  193. // 8-bit versions of the responses. The function emuDecSendKeyString
  194. // will convert this sequence to the 7-bit equivalent if necessary.
  195. //
  196. static STEMUKEYDATA const VT220MovedPfKeyTable[] =
  197. {
  198. EMUKEY(VK_NUMLOCK, 1, 0, 0, 0, 1, "\x8F\x50", 2), // P
  199. EMUKEY(VK_DIVIDE, 1, 0, 0, 0, 1, "\x8F\x51", 2), // Q
  200. EMUKEY(VK_MULTIPLY, 1, 0, 0, 0, 1, "\x8F\x52", 2), // R
  201. EMUKEY(VK_SUBTRACT, 1, 0, 0, 0, 1, "\x8F\x53", 2), // S
  202. };
  203. // VT220 Keypad Numeric Mode.
  204. //
  205. static STEMUKEYDATA const VT220KeypadNumericMode[] =
  206. {
  207. // Keypad keys with Numlock off.
  208. //
  209. EMUKEY(VK_INSERT, 1, 0, 0, 0, 0, "\x30", 1), // 0
  210. EMUKEY(VK_END, 1, 0, 0, 0, 0, "\x31", 1), // 1
  211. EMUKEY(VK_DOWN, 1, 0, 0, 0, 0, "\x32", 1), // 2
  212. EMUKEY(VK_NEXT, 1, 0, 0, 0, 0, "\x33", 1), // 3
  213. EMUKEY(VK_LEFT, 1, 0, 0, 0, 0, "\x34", 1), // 4
  214. EMUKEY(VK_NUMPAD5, 1, 0, 0, 0, 0, "\x35", 1), // 5
  215. EMUKEY(VK_RIGHT, 1, 0, 0, 0, 0, "\x36", 1), // 6
  216. EMUKEY(VK_HOME, 1, 0, 0, 0, 0, "\x37", 1), // 7
  217. EMUKEY(VK_UP, 1, 0, 0, 0, 0, "\x38", 1), // 8
  218. EMUKEY(VK_PRIOR, 1, 0, 0, 0, 0, "\x39", 1), // 9
  219. EMUKEY(VK_DELETE, 1, 0, 0, 0, 0, "\x2E", 1), // .
  220. // Keypad keys with Numlock on.
  221. //
  222. EMUKEY(VK_NUMPAD0, 1, 0, 0, 0, 0, "\x30", 1), // 0
  223. EMUKEY(VK_NUMPAD1, 1, 0, 0, 0, 0, "\x31", 1), // 1
  224. EMUKEY(VK_NUMPAD2, 1, 0, 0, 0, 0, "\x32", 1), // 2
  225. EMUKEY(VK_NUMPAD3, 1, 0, 0, 0, 0, "\x33", 1), // 3
  226. EMUKEY(VK_NUMPAD4, 1, 0, 0, 0, 0, "\x34", 1), // 4
  227. EMUKEY(VK_NUMPAD5, 1, 0, 0, 0, 0, "\x35", 1), // 5
  228. EMUKEY(VK_NUMPAD6, 1, 0, 0, 0, 0, "\x36", 1), // 6
  229. EMUKEY(VK_NUMPAD7, 1, 0, 0, 0, 0, "\x37", 1), // 7
  230. EMUKEY(VK_NUMPAD8, 1, 0, 0, 0, 0, "\x38", 1), // 8
  231. EMUKEY(VK_NUMPAD9, 1, 0, 0, 0, 0, "\x39", 1), // 9
  232. EMUKEY(VK_DECIMAL, 1, 0, 0, 0, 0, "\x2E", 1), // .
  233. // Other keypad keys (minus, plus, Enter).
  234. //
  235. EMUKEY(VK_SUBTRACT, 1, 0, 0, 0, 0, "\x2D", 1), // -
  236. EMUKEY(VK_ADD, 1, 0, 0, 0, 0, "\x2C", 1), // ,
  237. EMUKEY(VK_RETURN, 1, 0, 0, 0, 1, "\x0D", 1), // CR
  238. };
  239. // VT220 Keypad Application Mode.
  240. //
  241. // Please note that the sequences defined in this table are the
  242. // 8-bit versions of the responses. The function emuDecSendKeyString
  243. // will convert this sequence to the 7-bit equivalent if necessary.
  244. //
  245. static STEMUKEYDATA const VT220KeypadApplicationMode[] =
  246. {
  247. // Keypad keys with Numlock off.
  248. //
  249. EMUKEY(VK_NUMPAD0, 1, 0, 0, 0, 0, "\x8F\x70", 2), // p
  250. EMUKEY(VK_NUMPAD1, 1, 0, 0, 0, 0, "\x8F\x71", 2), // q
  251. EMUKEY(VK_NUMPAD2, 1, 0, 0, 0, 0, "\x8F\x72", 2), // r
  252. EMUKEY(VK_NUMPAD3, 1, 0, 0, 0, 0, "\x8F\x73", 2), // s
  253. EMUKEY(VK_NUMPAD4, 1, 0, 0, 0, 0, "\x8F\x74", 2), // t
  254. EMUKEY(VK_NUMPAD5, 1, 0, 0, 0, 0, "\x8F\x75", 2), // u
  255. EMUKEY(VK_NUMPAD6, 1, 0, 0, 0, 0, "\x8F\x76", 2), // v
  256. EMUKEY(VK_NUMPAD7, 1, 0, 0, 0, 0, "\x8F\x77", 2), // w
  257. EMUKEY(VK_NUMPAD8, 1, 0, 0, 0, 0, "\x8F\x78", 2), // x
  258. EMUKEY(VK_NUMPAD9, 1, 0, 0, 0, 0, "\x8F\x79", 2), // y
  259. EMUKEY(VK_DECIMAL, 1, 0, 0, 0, 0, "\x8F\x6E", 2), // n
  260. // Keypad keys with Numlock on.
  261. //
  262. EMUKEY(VK_NUMPAD0, 1, 0, 0, 0, 0, "\x8F\x70", 2), // p
  263. EMUKEY(VK_NUMPAD1, 1, 0, 0, 0, 0, "\x8F\x71", 2), // q
  264. EMUKEY(VK_NUMPAD2, 1, 0, 0, 0, 0, "\x8F\x72", 2), // r
  265. EMUKEY(VK_NUMPAD3, 1, 0, 0, 0, 0, "\x8F\x73", 2), // s
  266. EMUKEY(VK_NUMPAD4, 1, 0, 0, 0, 0, "\x8F\x74", 2), // t
  267. EMUKEY(VK_NUMPAD5, 1, 0, 0, 0, 0, "\x8F\x75", 2), // u
  268. EMUKEY(VK_NUMPAD6, 1, 0, 0, 0, 0, "\x8F\x76", 2), // v
  269. EMUKEY(VK_NUMPAD7, 1, 0, 0, 0, 0, "\x8F\x77", 2), // w
  270. EMUKEY(VK_NUMPAD8, 1, 0, 0, 0, 0, "\x8F\x78", 2), // x
  271. EMUKEY(VK_NUMPAD9, 1, 0, 0, 0, 0, "\x8F\x79", 2), // y
  272. EMUKEY(VK_DECIMAL, 1, 0, 0, 0, 0, "\x8F\x6E", 2), // n
  273. // Other keypad keys (minus, plus, Enter).
  274. //
  275. EMUKEY(VK_SUBTRACT, 1, 0, 0, 0, 0, "\x8F\x6D", 2), // m
  276. EMUKEY(VK_ADD, 1, 0, 0, 0, 0, "\x8F\x6C", 2), // l
  277. EMUKEY(VK_RETURN, 1, 0, 0, 0, 1, "\x8F\x4D", 2), // M
  278. };
  279. // VT220 Cursor Key Mode.
  280. //
  281. // Please note that the sequences defined in this table are the
  282. // 8-bit versions of the responses. The function emuDecSendKeyString
  283. // will convert this sequence to the 7-bit equivalent if necessary.
  284. //
  285. static STEMUKEYDATA const VT220CursorKeyMode[] =
  286. {
  287. // Arrow keys on the numeric keypad. These sequences are used
  288. // when the emulator is using Cursor Key Mode (Application Keys).
  289. //
  290. EMUKEY(VK_UP, 1, 0, 0, 0, 0, "\x8F\x41", 2), // A
  291. EMUKEY(VK_DOWN, 1, 0, 0, 0, 0, "\x8F\x42", 2), // B
  292. EMUKEY(VK_RIGHT, 1, 0, 0, 0, 0, "\x8F\x43", 2), // C
  293. EMUKEY(VK_LEFT, 1, 0, 0, 0, 0, "\x8F\x44", 2), // D
  294. // Arrow keys on the edit pad. These sequences are used
  295. // when the emulator is using Cursor Key Mode (Application Keys).
  296. //
  297. EMUKEY(VK_UP, 1, 0, 0, 0, 1, "\x8F\x41", 2), // A
  298. EMUKEY(VK_DOWN, 1, 0, 0, 0, 1, "\x8F\x42", 2), // B
  299. EMUKEY(VK_RIGHT, 1, 0, 0, 0, 1, "\x8F\x43", 2), // C
  300. EMUKEY(VK_LEFT, 1, 0, 0, 0, 1, "\x8F\x44", 2), // D
  301. };
  302. // VT220 Standard Key Table.
  303. //
  304. static STEMUKEYDATA const VT220StandardKeys[] =
  305. {
  306. // Some keys on the numeric keypad will respond in the same
  307. // way the corresponding keys on the edit pad respond.
  308. //
  309. EMUKEY(VK_HOME, 1, 0, 0, 0, 0, "\x9B\x31\x7E", 3), // 1 ~
  310. EMUKEY(VK_INSERT, 1, 0, 0, 0, 0, "\x9B\x32\x7E", 3), // 2 ~
  311. EMUKEY(VK_DELETE, 1, 0, 0, 0, 0, "\x9B\x33\x7E", 3), // 3 ~
  312. EMUKEY(VK_END, 1, 0, 0, 0, 0, "\x9B\x34\x7E", 3), // 4 ~
  313. EMUKEY(VK_PRIOR, 1, 0, 0, 0, 0, "\x9B\x35\x7E", 3), // 5 ~
  314. EMUKEY(VK_NEXT, 1, 0, 0, 0, 0, "\x9B\x36\x7E", 3), // 6 ~
  315. // These are the keys on the edit pad.
  316. //
  317. EMUKEY(VK_HOME, 1, 0, 0, 0, 1, "\x9B\x31\x7E", 3), // 1 ~
  318. EMUKEY(VK_INSERT, 1, 0, 0, 0, 1, "\x9B\x32\x7E", 3), // 2 ~
  319. EMUKEY(VK_DELETE, 1, 0, 0, 0, 1, "\x9B\x33\x7E", 3), // 3 ~
  320. EMUKEY(VK_END, 1, 0, 0, 0, 1, "\x9B\x34\x7E", 3), // 4 ~
  321. EMUKEY(VK_PRIOR, 1, 0, 0, 0, 1, "\x9B\x35\x7E", 3), // 5 ~
  322. EMUKEY(VK_NEXT, 1, 0, 0, 0, 1, "\x9B\x36\x7E", 3), // 6 ~
  323. // Arrow keys on the numeric keypad.
  324. //
  325. EMUKEY(VK_UP, 1, 0, 0, 0, 0, "\x9B\x41", 2), // A
  326. EMUKEY(VK_DOWN, 1, 0, 0, 0, 0, "\x9B\x42", 2), // B
  327. EMUKEY(VK_RIGHT, 1, 0, 0, 0, 0, "\x9B\x43", 2), // C
  328. EMUKEY(VK_LEFT, 1, 0, 0, 0, 0, "\x9B\x44", 2), // D
  329. // Arrow keys on the edit pad.
  330. //
  331. EMUKEY(VK_UP, 1, 0, 0, 0, 1, "\x9B\x41", 2), // A
  332. EMUKEY(VK_DOWN, 1, 0, 0, 0, 1, "\x9B\x42", 2), // B
  333. EMUKEY(VK_RIGHT, 1, 0, 0, 0, 1, "\x9B\x43", 2), // C
  334. EMUKEY(VK_LEFT, 1, 0, 0, 0, 1, "\x9B\x44", 2), // D
  335. // Function keys (F5)F6 thru F10.
  336. //
  337. #if defined(INCL_ULTC_VERSION)
  338. EMUKEY(VK_F5, 1, 0, 0, 0, 0, "\x9B\x31\x36\x7E", 4), // 1 6 ~
  339. #endif
  340. EMUKEY(VK_F6, 1, 0, 0, 0, 0, "\x9B\x31\x37\x7E", 4), // 1 7 ~
  341. EMUKEY(VK_F7, 1, 0, 0, 0, 0, "\x9B\x31\x38\x7E", 4), // 1 8 ~
  342. EMUKEY(VK_F8, 1, 0, 0, 0, 0, "\x9B\x31\x39\x7E", 4), // 1 9 ~
  343. EMUKEY(VK_F9, 1, 0, 0, 0, 0, "\x9B\x32\x30\x7E", 4), // 2 0 ~
  344. EMUKEY(VK_F10, 1, 0, 0, 0, 0, "\x9B\x32\x31\x7E", 4), // 2 1 ~
  345. #if defined(INCL_ULTC_VERSION)
  346. EMUKEY(VK_F5, 1, 0, 0, 0, 1, "\x9B\x31\x36\x7E", 4), // 1 6 ~
  347. #endif
  348. EMUKEY(VK_F6, 1, 0, 0, 0, 1, "\x9B\x31\x37\x7E", 4), // 1 7 ~
  349. EMUKEY(VK_F7, 1, 0, 0, 0, 1, "\x9B\x31\x38\x7E", 4), // 1 8 ~
  350. EMUKEY(VK_F8, 1, 0, 0, 0, 1, "\x9B\x31\x39\x7E", 4), // 1 9 ~
  351. EMUKEY(VK_F9, 1, 0, 0, 0, 1, "\x9B\x32\x30\x7E", 4), // 2 0 ~
  352. EMUKEY(VK_F10, 1, 0, 0, 0, 1, "\x9B\x32\x31\x7E", 4), // 2 1 ~
  353. // Function keys F11 thru F20 are invoked by the user pressing
  354. // Ctrl-F1 thru Ctrl-F10.
  355. //
  356. // Function keys Ctrl-F1 thru Ctrl-F10 (Top row).
  357. //
  358. EMUKEY(VK_F1, 1, 1, 0, 0, 0, "\x9B\x32\x33\x7E", 4), // 2 3 ~
  359. EMUKEY(VK_F2, 1, 1, 0, 0, 0, "\x9B\x32\x34\x7E", 4), // 2 4 ~
  360. EMUKEY(VK_F3, 1, 1, 0, 0, 0, "\x9B\x32\x35\x7E", 4), // 2 5 ~
  361. EMUKEY(VK_F4, 1, 1, 0, 0, 0, "\x9B\x32\x36\x7E", 4), // 2 6 ~
  362. EMUKEY(VK_F5, 1, 1, 0, 0, 0, "\x9B\x32\x38\x7E", 4), // 2 8 ~
  363. EMUKEY(VK_F6, 1, 1, 0, 0, 0, "\x9B\x32\x39\x7E", 4), // 2 9 ~
  364. EMUKEY(VK_F7, 1, 1, 0, 0, 0, "\x9B\x33\x31\x7E", 4), // 3 1 ~
  365. EMUKEY(VK_F8, 1, 1, 0, 0, 0, "\x9B\x33\x32\x7E", 4), // 3 2 ~
  366. EMUKEY(VK_F9, 1, 1, 0, 0, 0, "\x9B\x33\x33\x7E", 4), // 3 3 ~
  367. EMUKEY(VK_F10, 1, 1, 0, 0, 0, "\x9B\x33\x34\x7E", 4), // 3 4 ~
  368. EMUKEY(VK_F1, 1, 1, 0, 0, 1, "\x9B\x32\x33\x7E", 4), // 2 3 ~
  369. EMUKEY(VK_F2, 1, 1, 0, 0, 1, "\x9B\x32\x34\x7E", 4), // 2 4 ~
  370. EMUKEY(VK_F3, 1, 1, 0, 0, 1, "\x9B\x32\x35\x7E", 4), // 2 5 ~
  371. EMUKEY(VK_F4, 1, 1, 0, 0, 1, "\x9B\x32\x36\x7E", 4), // 2 6 ~
  372. EMUKEY(VK_F5, 1, 1, 0, 0, 1, "\x9B\x32\x38\x7E", 4), // 2 8 ~
  373. EMUKEY(VK_F6, 1, 1, 0, 0, 1, "\x9B\x32\x39\x7E", 4), // 2 9 ~
  374. EMUKEY(VK_F7, 1, 1, 0, 0, 1, "\x9B\x33\x31\x7E", 4), // 3 1 ~
  375. EMUKEY(VK_F8, 1, 1, 0, 0, 1, "\x9B\x33\x32\x7E", 4), // 3 2 ~
  376. EMUKEY(VK_F9, 1, 1, 0, 0, 1, "\x9B\x33\x33\x7E", 4), // 3 3 ~
  377. EMUKEY(VK_F10, 1, 1, 0, 0, 1, "\x9B\x33\x34\x7E", 4), // 3 4 ~
  378. EMUKEY(VK_F1, 1, 0, 0, 0, 0, "\x8FP", 2),
  379. EMUKEY(VK_F2, 1, 0, 0, 0, 0, "\x8FQ", 2),
  380. EMUKEY(VK_F3, 1, 0, 0, 0, 0, "\x8FR", 2),
  381. EMUKEY(VK_F4, 1, 0, 0, 0, 0, "\x8FS", 2),
  382. EMUKEY(VK_F1, 1, 0, 0, 0, 1, "\x8FP", 2),
  383. EMUKEY(VK_F2, 1, 0, 0, 0, 1, "\x8FQ", 2),
  384. EMUKEY(VK_F3, 1, 0, 0, 0, 1, "\x8FR", 2),
  385. EMUKEY(VK_F4, 1, 0, 0, 0, 1, "\x8FS", 2),
  386. EMUKEY(VK_DELETE, 1, 0, 0, 0, 0, "\x7F", 1), // KN_DEL
  387. EMUKEY(VK_DELETE, 1, 0, 0, 0, 1, "\x7F", 1), // KN_DEL
  388. EMUKEY(VK_ADD, 1, 0, 0, 0, 0, ",", 1),
  389. // Ctrl-2.
  390. // Ctrl-@.
  391. //
  392. EMUKEY(0x32, 1, 1, 0, 0, 0, "\x00", 1),
  393. EMUKEY(0x32, 1, 1, 0, 1, 0, "\x00", 1),
  394. // Ctrl-6.
  395. // Ctrl-^.
  396. EMUKEY(0x36, 1, 1, 0, 0, 0, "\x1E", 1),
  397. EMUKEY(0x36, 1, 1, 0, 1, 0, "\x1E", 1),
  398. // Ctrl-Space
  399. //
  400. EMUKEY(VK_SPACE, 1, 1, 0, 0, 0, "\x00", 1),
  401. // Ctrl-- key.
  402. //
  403. EMUKEY(VK_SUBTRACT, 1, 1, 0, 0, 1, "\x1F", 1),
  404. };
  405. // VT220 User Defined keys.
  406. static STEMUKEYDATA VT220UserDefinedKeys[MAX_UDK_KEYS] =
  407. {
  408. // NOTE: Do not change the order of these user defined entries.
  409. // emuDecDefineUDK assumes a 1:1 correspondance with this
  410. // table and the UDKSelector table defined below.
  411. //
  412. // Initialize Virtual and Shift flags.
  413. //
  414. EMUKEY(VK_F6, 1, 0, 0, 1, 0, 0, 0),
  415. EMUKEY(VK_F7, 1, 0, 0, 1, 0, 0, 0),
  416. EMUKEY(VK_F8, 1, 0, 0, 1, 0, 0, 0),
  417. EMUKEY(VK_F9, 1, 0, 0, 1, 0, 0, 0),
  418. EMUKEY(VK_F10, 1, 0, 0, 1, 0, 0, 0),
  419. // Initialize Virtual and Alt flags.
  420. //
  421. EMUKEY(VK_F1, 1, 0, 1, 0, 0, 0, 0),
  422. EMUKEY(VK_F2, 1, 0, 1, 0, 0, 0, 0),
  423. EMUKEY(VK_F3, 1, 0, 1, 0, 0, 0, 0),
  424. EMUKEY(VK_F4, 1, 0, 1, 0, 0, 0, 0),
  425. EMUKEY(VK_F5, 1, 0, 1, 0, 0, 0, 0),
  426. EMUKEY(VK_F6, 1, 0, 1, 0, 0, 0, 0),
  427. EMUKEY(VK_F7, 1, 0, 1, 0, 0, 0, 0),
  428. EMUKEY(VK_F8, 1, 0, 1, 0, 0, 0, 0),
  429. EMUKEY(VK_F9, 1, 0, 1, 0, 0, 0, 0),
  430. EMUKEY(VK_F10, 1, 0, 1, 0, 0, 0, 0),
  431. };
  432. // NOTE: Do not change the order of these entries.
  433. // There is a 1:1 correspondance between this table and the
  434. // user defined key table defined above.
  435. //
  436. static TCHAR const acUDKSelectors[MAX_UDK_KEYS] =
  437. {
  438. TEXT('\x17'), TEXT('\x18'), TEXT('\x19'), TEXT('\x20'), // F6 - F9
  439. TEXT('\x21'), TEXT('\x23'), TEXT('\x24'), TEXT('\x25'), // F10 - F13
  440. TEXT('\x26'), TEXT('\x28'), TEXT('\x29'), TEXT('\x31'), // F14 - F17
  441. TEXT('\x32'), TEXT('\x33'), TEXT('\x34'), // F18 - F20
  442. };
  443. emuInstallStateTable(hhEmu, vt220_tbl, DIM(vt220_tbl));
  444. // Allocate space for and initialize data that is used only by the
  445. // VT220 emulator.
  446. //
  447. hhEmu->pvPrivate = malloc(sizeof(DECPRIVATE));
  448. if (hhEmu->pvPrivate == 0)
  449. {
  450. assert(FALSE);
  451. return;
  452. }
  453. pstPRI = (PSTDECPRIVATE)hhEmu->pvPrivate;
  454. memset(pstPRI, 0, sizeof(DECPRIVATE));
  455. // NOTE: The order of these definitions directly correspond to the
  456. // search order used by the emuDecKeyboardIn function.
  457. // Don't change these.
  458. //
  459. // In shared code, these are all part of hhEmu.
  460. pstPRI->pstcEmuKeyTbl1 = VT220StdPfKeyTable;
  461. pstPRI->pstcEmuKeyTbl2 = VT220MovedPfKeyTable;
  462. pstPRI->pstcEmuKeyTbl3 = VT220KeypadNumericMode;
  463. pstPRI->pstcEmuKeyTbl4 = VT220KeypadApplicationMode;
  464. pstPRI->pstcEmuKeyTbl5 = VT220CursorKeyMode;
  465. pstPRI->pstcEmuKeyTbl6 = VT220StandardKeys;
  466. pstPRI->iKeyTable1Entries = DIM(VT220StdPfKeyTable);
  467. pstPRI->iKeyTable2Entries = DIM(VT220MovedPfKeyTable);
  468. pstPRI->iKeyTable3Entries = DIM(VT220KeypadNumericMode);
  469. pstPRI->iKeyTable4Entries = DIM(VT220KeypadApplicationMode);
  470. pstPRI->iKeyTable5Entries = DIM(VT220CursorKeyMode);
  471. pstPRI->iKeyTable6Entries = DIM(VT220StandardKeys);
  472. // Allocate an array to hold line attribute values.
  473. //
  474. pstPRI->aiLineAttr = malloc(MAX_EMUROWS * sizeof(int) );
  475. if (pstPRI->aiLineAttr == 0)
  476. {
  477. assert(FALSE);
  478. return;
  479. }
  480. for (iRow = 0; iRow < MAX_EMUROWS; iRow++)
  481. pstPRI->aiLineAttr[iRow] = NO_LINE_ATTR;
  482. pstPRI->sv_row = 0;
  483. pstPRI->sv_col = 0;
  484. pstPRI->gn = 0;
  485. pstPRI->sv_AWM = RESET;
  486. pstPRI->sv_DECOM = RESET;
  487. pstPRI->sv_protectmode = FALSE;
  488. pstPRI->fAttrsSaved = FALSE;
  489. pstPRI->pntr = pstPRI->storage;
  490. // Initialize hhEmu values for VT220.
  491. //
  492. hhEmu->emu_setcurpos = emuDecSetCurPos;
  493. hhEmu->emu_deinstall = emuDecUnload;
  494. hhEmu->emu_clearline = emuDecClearLine;
  495. hhEmu->emu_clearscreen = emuDecClearScreen;
  496. hhEmu->emu_kbdin = emuDecKeyboardIn;
  497. hhEmu->emuResetTerminal = vt220_reset;
  498. hhEmu->emu_graphic = emuDecGraphic;
  499. // hhEmu->emu_scroll = emuDecScroll;
  500. #if !defined(FAR_EAST)
  501. hhEmu->emu_highchar = 0x7E;
  502. #else
  503. hhEmu->emu_highchar = 0xFFFF;
  504. #endif
  505. hhEmu->emu_maxcol = VT_MAXCOL_80MODE;
  506. hhEmu->fUse8BitCodes = FALSE;
  507. hhEmu->mode_vt220 = FALSE;
  508. hhEmu->mode_vt320 = FALSE;
  509. //hhEmu->vt220_protectmode = FALSE;
  510. hhEmu->mode_protect = FALSE;
  511. if (hhEmu->nEmuLoaded == EMU_VT220)
  512. hhEmu->mode_vt220 = TRUE;
  513. else if (hhEmu->nEmuLoaded == EMU_VT320)
  514. hhEmu->mode_vt320 = TRUE;
  515. else
  516. assert(FALSE);
  517. // UNDO:rde
  518. // pstPRI->vt220_protimg = 0;
  519. pstPRI->pstUDK = VT220UserDefinedKeys;
  520. pstPRI->iUDKTableEntries= DIM(VT220UserDefinedKeys);
  521. pstPRI->pacUDKSelectors = acUDKSelectors;
  522. pstPRI->iUDKState = KEY_NUMBER_NEXT;
  523. std_dsptbl(hhEmu, TRUE);
  524. vt_charset_init(hhEmu);
  525. switch(hhEmu->stUserSettings.nEmuId)
  526. {
  527. case EMU_VT220:
  528. hhEmu->mode_vt220 = TRUE;
  529. hhEmu->mode_vt320 = FALSE;
  530. vt220_reset(hhEmu, FALSE);
  531. break;
  532. case EMU_VT320:
  533. hhEmu->mode_vt220 = FALSE;
  534. hhEmu->mode_vt320 = TRUE;
  535. break;
  536. default:
  537. assert(FALSE);
  538. break;
  539. }
  540. backscrlSetShowFlag(sessQueryBackscrlHdl(hhEmu->hSession), TRUE);
  541. return;
  542. }
  543. #endif // INCL_VT220
  544. /* end of vt220ini.c */