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.

290 lines
5.0 KiB

  1. /* File: D:\WACKER\emu\ansi.c (Created: 08-Dec-1993)
  2. *
  3. * Copyright 1994 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 2 $
  7. * $Date: 12/20/00 5:28p $
  8. */
  9. #include <windows.h>
  10. #pragma hdrstop
  11. #include <tdll\stdtyp.h>
  12. #include <tdll\chars.h>
  13. #include <tdll\session.h>
  14. #include <tdll\mc.h>
  15. #include <tdll\assert.h>
  16. #include "emu.h"
  17. #include "emu.hh"
  18. #include "ansi.hh"
  19. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  20. * ansi_setmode
  21. *
  22. * DESCRIPTION:
  23. * Sets a mode for ANSI emulator
  24. *
  25. * ARGUMENTS:
  26. * none
  27. *
  28. * RETURNS:
  29. * nothing
  30. */
  31. void ansi_setmode(const HHEMU hhEmu)
  32. {
  33. int mode_id, i;
  34. for (i = 0; i <= hhEmu->selector_cnt; i++)
  35. {
  36. mode_id = hhEmu->selector[i];
  37. switch (mode_id)
  38. {
  39. case 0x02:
  40. break;
  41. case 0x04:
  42. break;
  43. case 0x07:
  44. break;
  45. case 0x10:
  46. break;
  47. case 0x12:
  48. break;
  49. case 0x18:
  50. break;
  51. case 0x19:
  52. break;
  53. case 0x20:
  54. break;
  55. case 0xF1:
  56. break;
  57. case 0xF2:
  58. break;
  59. case 0xF3:
  60. break;
  61. case 0xF4:
  62. break;
  63. case 0xF5:
  64. break;
  65. case 0xF6:
  66. case 0xD7:
  67. case 0xF7:
  68. hhEmu->mode_AWM = SET;
  69. break;
  70. case 0xF8:
  71. /* select auto repeat mode */
  72. break;
  73. case 0xF18:
  74. break;
  75. case 0xF19:
  76. break;
  77. default:
  78. commanderror(hhEmu);
  79. break;
  80. }
  81. }
  82. }
  83. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  84. * ansi_resetmode
  85. *
  86. * DESCRIPTION:
  87. * Resets a mode for the ANSI emulator.
  88. *
  89. * ARGUMENTS:
  90. * none
  91. *
  92. * RETURNS:
  93. * nothing
  94. */
  95. void ansi_resetmode(const HHEMU hhEmu)
  96. {
  97. int mode_id, i;
  98. for (i = 0; i <= hhEmu->selector_cnt; i++)
  99. {
  100. mode_id = hhEmu->selector[i];
  101. switch (mode_id)
  102. {
  103. case 0x02:
  104. break;
  105. case 0x04:
  106. break;
  107. case 0x07:
  108. break;
  109. case 0x10:
  110. break;
  111. case 0x12:
  112. break;
  113. case 0x18:
  114. break;
  115. case 0x19:
  116. break;
  117. case 0x20:
  118. break;
  119. case 0xF1:
  120. break;
  121. case 0xF2:
  122. break;
  123. case 0xF3:
  124. break;
  125. case 0xF4:
  126. break;
  127. case 0xF5:
  128. break;
  129. case 0xF6:
  130. case 0xD7:
  131. case 0xF7:
  132. hhEmu->mode_AWM = RESET; break;
  133. case 0xF8:
  134. /* select auto repeat mode */
  135. break;
  136. case 0xF18:
  137. break;
  138. case 0xF19:
  139. break;
  140. default:
  141. commanderror(hhEmu); break;
  142. }
  143. }
  144. }
  145. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  146. * ansi_savecursor
  147. *
  148. * DESCRIPTION:
  149. * Saves the current cursor postion
  150. *
  151. * ARGUMENTS:
  152. * none
  153. *
  154. * RETURNS:
  155. * nothing
  156. */
  157. void ansi_savecursor(const HHEMU hhEmu)
  158. {
  159. const PSTANSIPRIVATE pstPRI = (PSTANSIPRIVATE)hhEmu->pvPrivate;
  160. // Save or restor the cursor position.
  161. //
  162. if (hhEmu->emu_code == ETEXT('s'))
  163. (*hhEmu->emu_getcurpos)
  164. (hhEmu, &pstPRI->iSavedRow, &pstPRI->iSavedColumn);
  165. else
  166. (*hhEmu->emu_setcurpos)
  167. (hhEmu, pstPRI->iSavedRow, pstPRI->iSavedColumn);
  168. }
  169. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  170. * ansi_kbdin
  171. *
  172. * DESCRIPTION:
  173. * Processes local keyboard keys for the ANSI emulator.
  174. *
  175. * ARGUMENTS:
  176. * key -- key to process
  177. *
  178. * RETURNS:
  179. * nothing
  180. */
  181. int ansi_kbdin(const HHEMU hhEmu, int key, const int fTest)
  182. {
  183. int index;
  184. /* -------------- Check Backspace & Delete keys ------------- */
  185. if (hhEmu->stUserSettings.fReverseDelBk && ((key == VK_BACKSPACE) ||
  186. (key == DELETE_KEY) || (key == DELETE_KEY_EXT)))
  187. {
  188. key = (key == VK_BACKSPACE) ? DELETE_KEY : VK_BACKSPACE;
  189. }
  190. if (hhEmu->stUserSettings.nTermKeys == EMU_KEYS_SCAN)
  191. {
  192. if ((index = emuKbdKeyLookup(hhEmu, key, &hhEmu->stEmuKeyTbl2)) != -1)
  193. {
  194. if (!fTest)
  195. emuSendKeyString(hhEmu, index, &hhEmu->stEmuKeyTbl2);
  196. }
  197. else
  198. {
  199. index = std_kbdin(hhEmu, key, fTest);
  200. }
  201. }
  202. else if ((index = emuKbdKeyLookup(hhEmu, key, &hhEmu->stEmuKeyTbl)) != -1)
  203. {
  204. if (!fTest)
  205. emuSendKeyString(hhEmu, index, &hhEmu->stEmuKeyTbl);
  206. }
  207. else
  208. {
  209. index = std_kbdin(hhEmu, key, fTest);
  210. }
  211. return index;
  212. }
  213. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  214. * FUNCTION:
  215. * DoorwayMode
  216. *
  217. * DESCRIPTION:
  218. *
  219. * ARGUMENTS:
  220. *
  221. * RETURNS:
  222. *
  223. */
  224. void DoorwayMode(const HHEMU hhEmu)
  225. {
  226. static INT iOldUseTermKeys;
  227. ECHAR ccode = hhEmu->emu_code;
  228. if (hhEmu->num_param[hhEmu->num_param_cnt] != 255)
  229. return;
  230. if (ccode == ETEXT('h'))
  231. {
  232. iOldUseTermKeys = hhEmu->stUserSettings.nTermKeys;
  233. hhEmu->stUserSettings.nTermKeys = EMU_KEYS_SCAN;
  234. }
  235. else if (ccode == ETEXT('l'))
  236. {
  237. hhEmu->stUserSettings.nTermKeys = iOldUseTermKeys;
  238. }
  239. NotifyClient(hhEmu->hSession, EVENT_EMU_SETTINGS, 0);
  240. return;
  241. }
  242. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  243. * FUNCTION:
  244. * emuAnsiUnload
  245. *
  246. * DESCRIPTION:
  247. *
  248. * ARGUMENTS:
  249. *
  250. * RETURNS:
  251. *
  252. */
  253. void emuAnsiUnload(const HHEMU hhEmu)
  254. {
  255. assert(hhEmu);
  256. if (hhEmu->pvPrivate)
  257. {
  258. free(hhEmu->pvPrivate);
  259. hhEmu->pvPrivate = NULL;
  260. }
  261. emuKeyTableFree(&hhEmu->stEmuKeyTbl);
  262. emuKeyTableFree(&hhEmu->stEmuKeyTbl2);
  263. return;
  264. }