TERM.LST 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154
  1. Listing:
  2. 1 (* Release 3.10 *)
  3. 2 (*-------------------------------------------------------------------------*
  4. 3 * *
  5. 4 * TERM.MOD - COMMS Toolkit terminal emulation *
  6. 5 * *
  7. 6 * COPYRIGHT (C) 1988..1992 Clarion Software Corporation. *
  8. 7 * All Rights Reserved *
  9. 8 * *
  10. 9 *--------------------------------------------------------------------------*)
  11. 10
  12. 11 IMPLEMENTATION MODULE Term;
  13. 12 IMPORT SYSTEM,Lib,IO,Str,Window,Keyboard;
  14. 13
  15. 14 TYPE
  16. 15 CharSets = (UK,US,SpecialChar);
  17. 16 Attributes = (Blue,Green,Red,Bold,BlueBack,GreenBack,RedBack,Blink);
  18. 17 AttrSet = SET OF Attributes;
  19. ***** ^ not supported yet
  20. 18 AttributeMap = ARRAY[0..23],[0..79] OF AttrSet;
  21. ***** ^ not supported yet
  22. 19 CharMap = ARRAY[0..23],[0..79] OF CHAR;
  23. 20
  24. 21 CONST
  25. 22 NormalAttr = AttrSet{Blue,Green,Red}; (* Lightgray on Black *)
  26. 23
  27. 24 VAR
  28. 25 G0,G1,CurrCharSet : CharSets;
  29. 26 (* for handling protected field attributes *)
  30. 27 CurrAttr,ProtAttr : AttrSet;
  31. 28 Map : AttributeMap;
  32. 29 ScrMap : CharMap;
  33. 30 cx,cy,p1,p2,
  34. 31 ScreenTop,
  35. 32 ScreenBottom : CARDINAL;
  36. 33 DECPrivate,
  37. 34 OriginMode,AutoWrap,
  38. 35 NewLineMode,KbdLocked,
  39. 36 LocalEcho,ANSIKeys,
  40. 37 NumKeyPad,Protected,
  41. 38 EditMode,DeferredEdit,
  42. 39 DeferredTransmit,
  43. 40 TransmitOK,
  44. 41 WantsFullPage,
  45. 42 Initialised : BOOLEAN;
  46. 43 TransmitMode : (Line,PartialPage,FullPage);
  47. 44 VTMode : Emulations;
  48. 45 RxState : (Normal,GotESC,GotBrack,GotLParen,GotRParen,GotHash,ReadingP1,ReadingP2,VT52Line,VT52Col,ANSICmd);
  49. 46 TabStop : ARRAY[0..79] OF BOOLEAN;
  50. 47 CSave : RECORD
  51. 48 cx,cy : CARDINAL;
  52. 49 Top,Bottom : CARDINAL;
  53. 50 OrgMode : BOOLEAN;
  54. 51 END;
  55. 52 Kbd : RECORD
  56. 53 rptr,wptr : CARDINAL;
  57. 54 Buff : ARRAY[0..255] OF CHAR;
  58. 55 END;
  59. 56
  60. 57 (*.............................................*)
  61. 58
  62. 59 PROCEDURE SetColor(NewAttr:AttrSet);
  63. 60 BEGIN
  64. 61 Window.TextColor(VAL(Window.Color,SHORTCARD(NewAttr) MOD 16));
  65. 62 Window.TextBackground(VAL(Window.Color,SHORTCARD(NewAttr) DIV 16));
  66. 63 END SetColor;
  67. 64
  68. 65 (*.............................................*)
  69. 66
  70. 67 PROCEDURE ResetTerm;
  71. 68 VAR
  72. 69 i : CARDINAL;
  73. 70 BEGIN
  74. 71 VTMode := EmVT100;
  75. 72 RxState := Normal;
  76. 73 G0 := US;
  77. 74 G1 := SpecialChar;
  78. 75 CurrCharSet := G0;
  79. 76 ScreenTop := 0;
  80. 77 ScreenBottom := 23;
  81. 78 OriginMode := FALSE;
  82. 79 AutoWrap := TRUE;
  83. 80 NewLineMode := FALSE;
  84. 81 KbdLocked := FALSE;
  85. 82 LocalEcho := FALSE;
  86. 83 ANSIKeys := TRUE;
  87. 84 NumKeyPad := TRUE;
  88. 85 Protected := FALSE;
  89. 86 EditMode := FALSE;
  90. 87 DeferredEdit := FALSE;
  91. 88 DeferredTransmit := FALSE;
  92. 89 TransmitMode := Line;
  93. 90 WantsFullPage := FALSE;
  94. 91 CurrAttr := NormalAttr;
  95. 92 ProtAttr := CurrAttr;
  96. 93 SetColor(CurrAttr);
  97. 94 Lib.Fill(ADR(Map),SIZE(Map),NormalAttr);
  98. 95 Lib.Fill(ADR(ScrMap),SIZE(ScrMap),' ');
  99. 96 cx := 0;
  100. 97 cy := 0;
  101. 98 WITH CSave DO
  102. 99 cx := 0;
  103. 100 cy := 0;
  104. 101 Top := 0;
  105. 102 Bottom := 23;
  106. 103 OrgMode := FALSE;
  107. 104 END;
  108. 105 FOR i:=0 TO 79 DO
  109. 106 TabStop[i] := (i MOD 8)=0;
  110. 107 END;
  111. 108 WITH Kbd DO
  112. 109 rptr := 0;
  113. 110 wptr := 0;
  114. 111 END;
  115. 112 END ResetTerm;
  116. 113
  117. 114 (*.............................................*)
  118. 115
  119. 116 PROCEDURE StuffKbdBuffer(s:ARRAY OF CHAR; Lnth:CARDINAL);
  120. 117 VAR
  121. 118 i : CARDINAL;
  122. 119 BEGIN
  123. 120 i:=0;
  124. 121 WHILE i<Lnth DO
  125. 122 WITH Kbd DO
  126. 123 Buff[wptr]:=s[i];
  127. 124 wptr := (wptr+1) MOD 100H;
  128. 125 END;
  129. 126 INC(i);
  130. 127 END;
  131. 128 END StuffKbdBuffer;
  132. 129
  133. 130 (*.............................................*)
  134. 131
  135. 132 PROCEDURE GotoXY(x,y:CARDINAL);
  136. 133 BEGIN
  137. 134 IF y>23 THEN
  138. 135 y:=23;
  139. 136 END;
  140. 137 IF x>79 THEN
  141. 138 x:=79;
  142. 139 END;
  143. 140 Window.GotoXY(x+1,y+1);
  144. 141 cx:=x;
  145. 142 cy:=y;
  146. 143 END GotoXY;
  147. 144
  148. 145 (*.............................................*)
  149. 146
  150. 147 PROCEDURE SelectEmulation(Which:Emulations);
  151. 148 BEGIN
  152. 149 ResetTerm;
  153. 150 Window.Clear;
  154. 151 GotoXY(0,0);
  155. 152 VTMode := Which;
  156. 153 END SelectEmulation;
  157. 154
  158. 155 (*.............................................*)
  159. 156
  160. 157 PROCEDURE Scroll(lines:INTEGER);
  161. 158 VAR
  162. 159 i : CARDINAL;
  163. 160 x,y : CARDINAL;
  164. 161 l : ARRAY[0..Window.ScreenWidth-1] OF WORD;
  165. 162 BEGIN
  166. 163 (* Do physical scroll *)
  167. 164 x := Window.WhereX();
  168. 165 y := Window.WhereY();
  169. 166 IF lines = 0 THEN
  170. 167 FOR i := ScreenTop+1 TO ScreenBottom+1 DO
  171. 168 Window.GotoXY(1,i);
  172. 169 Window.ClrEol;
  173. 170 END;
  174. 171 ELSE
  175. 172 REPEAT
  176. 173 IF lines < 0 THEN
  177. 174 FOR i := ScreenBottom TO ScreenTop+1 BY -1 DO
  178. 175 Window.RdBufferLn(Window.Used(),1,i,SYSTEM.ADR(l),80);
  179. 176 Window.WrBufferLn(Window.Used(),1,i+1,SYSTEM.ADR(l),80);
  180. 177 END;
  181. 178 Window.GotoXY(1,ScreenTop+1);
  182. 179 Window.ClrEol;
  183. 180 INC(lines);
  184. 181 ELSE
  185. 182 FOR i := ScreenTop+2 TO ScreenBottom+1 DO
  186. 183 Window.RdBufferLn(Window.Used(),1,i,SYSTEM.ADR(l),80);
  187. 184 Window.WrBufferLn(Window.Used(),1,i-1,SYSTEM.ADR(l),80);
  188. 185 END;
  189. 186 Window.GotoXY(1,ScreenBottom+1);
  190. 187 Window.ClrEol;
  191. 188 DEC(lines);
  192. 189 END;
  193. 190 UNTIL ABS(lines) = 0;
  194. 191 END;
  195. 192 Window.GotoXY(x,y);
  196. 193 (* Now scroll attribute map *)
  197. 194 IF lines<>0 THEN
  198. 195 IF lines>0 THEN (* Scroll up *)
  199. 196 i:=ScreenTop;
  200. 197 REPEAT
  201. 198 Map[i] := Map[i+1];
  202. 199 ScrMap[i] := ScrMap[i+1];
  203. 200 INC(i);
  204. 201 UNTIL i=ScreenBottom;
  205. 202 ELSE (* Scroll down *)
  206. 203 i:=ScreenBottom;
  207. 204 REPEAT
  208. 205 Map[i] := Map[i-1];
  209. 206 ScrMap[i] := ScrMap[i-1];
  210. 207 DEC(i);
  211. 208 UNTIL i=ScreenTop;
  212. 209 END;
  213. 210 Lib.Fill(ADR(Map[i]),80,NormalAttr);
  214. 211 Lib.Fill(ADR(ScrMap[i]),80,' ');
  215. 212 END;
  216. 213 END Scroll;
  217. 214
  218. 215 (*.......................................*)
  219. 216
  220. 217 PROCEDURE Translate(c:CHAR):CHAR;
  221. 218 CONST
  222. 219 FormChars = ' ±????øñ??Ù¿ÚÀÅÄÄÄÄÄôÁ³óòãØœ=';
  223. 220 BEGIN
  224. 221 IF CurrCharSet<>US THEN
  225. 222 IF CurrCharSet=SpecialChar THEN
  226. 223 IF (c>=CHR(95)) AND (c<=CHR(126)) THEN
  227. 224 c := FormChars[ORD(c)-95];
  228. 225 END;
  229. 226 ELSIF c='#' THEN (* Must be UK char set *)
  230. 227 c := 'œ';
  231. 228 END;
  232. 229 END;
  233. 230 RETURN c;
  234. 231 END Translate;
  235. 232
  236. 233 (*.............................................*)
  237. 234
  238. 235 PROCEDURE FindUnprotected():BOOLEAN;
  239. 236 BEGIN
  240. 237 IF Map[cy,cx]-ProtAttr<>AttrSet{} THEN RETURN(TRUE) END;
  241. 238 LOOP
  242. 239 IF Map[cy,cx]-ProtAttr=AttrSet{} THEN
  243. 240 (* on a protected char position - skip! *)
  244. 241 IF cx=79 THEN
  245. 242 IF cy<ScreenBottom THEN
  246. 243 INC(cy); cx:=0
  247. 244 ELSE
  248. 245 RETURN FALSE
  249. 246 END
  250. 247 ELSE
  251. 248 INC(cx);
  252. 249 END;
  253. 250 ELSE
  254. 251 GotoXY(cx,cy);
  255. 252 RETURN TRUE
  256. 253 END;
  257. 254 END;
  258. 255 END FindUnprotected;
  259. 256
  260. 257 (*.............................................*)
  261. 258
  262. 259 PROCEDURE Output(c:CHAR);
  263. 260 BEGIN
  264. 261 IF (c<' ') OR (c=CHR(127)) THEN
  265. 262 CASE ORD(c) OF
  266. 263 7 : IO.WrChar(c); |
  267. 264 8 : IF cx>0 THEN
  268. 265 GotoXY(cx-1,cy);
  269. 266 END; |
  270. 267 9 : IF cx<79 THEN
  271. 268 REPEAT
  272. 269 INC(cx);
  273. 270 UNTIL (cx=79) OR (TabStop[cx]);
  274. 271 GotoXY(cx,cy);
  275. 272 END; |
  276. 273 10..12 : IF NewLineMode THEN
  277. 274 cx:=0;
  278. 275 END;
  279. 276 IF cy=ScreenBottom THEN
  280. 277 Scroll(1);
  281. 278 ELSE
  282. 279 INC(cy);
  283. 280 END;
  284. 281 GotoXY(cx,cy); |
  285. 282 13 : GotoXY(0,cy); |
  286. 283 14 : CurrCharSet := G1; |
  287. 284 15 : CurrCharSet := G0; |
  288. 285 END
  289. 286 ELSE
  290. 287 IF (NOT Protected) OR FindUnprotected() THEN
  291. 288 Map[cy,cx] := CurrAttr;
  292. 289 ScrMap[cy,cx] := c;
  293. 290 IO.WrChar(Translate(c));
  294. 291 IF (cx=79) AND (AutoWrap) THEN
  295. 292 Output(CHR(10)); GotoXY(0,cy);
  296. 293 ELSIF cx<79 THEN
  297. 294 INC(cx);
  298. 295 END;
  299. 296 END;
  300. 297 END;
  301. 298 END Output;
  302. 299
  303. 300 (*.............................................*)
  304. 301
  305. 302 PROCEDURE DECModeChange(c:CHAR);
  306. 303 VAR
  307. 304 Lnth : CARDINAL;
  308. 305 Seq : ARRAY[0..9] OF CHAR;
  309. 306 BEGIN
  310. 307 CASE p1 OF
  311. 308 0 : (*Error -ignore*) |
  312. 309 1 : (*Cursor Key*)
  313. 310 IF NOT NumKeyPad THEN
  314. 311 ANSIKeys := c='l';
  315. 312 END; |
  316. 313 2 : IF c='l' THEN
  317. 314 SelectEmulation(EmVT52);
  318. 315 END; |
  319. 316 3 : (*Select 80/132 Columns - not supported*) |
  320. 317 4 : (*Select smooth/jump scrolling - not supported*)|
  321. 318 5 : (*Normal or Reverse Screen - not implemented*) |
  322. 319 6 : (*origin*)
  323. 320 OriginMode := c='h'; |
  324. 321 7 : (*Auto-wrap*)
  325. 322 AutoWrap := c='h'; |
  326. 323 8 : (*Kbd Auto-repeat on/off - not supported*) |
  327. 324 10 : (*Editing*)
  328. 325 EditMode := c='h'; |
  329. 326 11 : (*Line Transmit*)
  330. 327 IF c='h' THEN
  331. 328 TransmitMode := Line
  332. 329 ELSIF WantsFullPage THEN
  333. 330 TransmitMode := FullPage
  334. 331 ELSE
  335. 332 TransmitMode := PartialPage
  336. 333 END; |
  337. 334 13 : (*Space compression / Field delimiter*) |
  338. 335 14 : (*Transmit execution*)
  339. 336 DeferredTransmit := (c='l'); |
  340. 337 15 : (* Printer status request *)
  341. 338 IF c='n' THEN
  342. 339 Seq:=' [?13n';
  343. 340 Seq[0]:=CHR(27);
  344. 341 StuffKbdBuffer(Seq,6);
  345. 342 END; |
  346. 343 16 : (*Edit key execution*)
  347. 344 DeferredEdit := c='l'; |
  348. 345 18 : (*Printer form feed*) |
  349. 346 19 : (*Printer extent*) |
  350. 347 END;
  351. 348 END DECModeChange;
  352. 349
  353. 350 (*.............................................*)
  354. 351
  355. 352 PROCEDURE EraseField(x,y,w:CARDINAL);
  356. 353 VAR
  357. 354 i,oldx,oldy : CARDINAL;
  358. 355 BEGIN
  359. 356 (* This routine is only called if protected fields are in effect *)
  360. 357 oldx:=cx;
  361. 358 oldy:=cy;
  362. 359 i:=0;
  363. 360 GotoXY(x,y);
  364. 361 WHILE i<w DO
  365. 362 IF Map[y,x+i]-ProtAttr<>AttrSet{} THEN
  366. 363 Map[y,x+i] := CurrAttr;
  367. 364 ScrMap[y,x+i] := ' ';
  368. 365 IO.WrChar(' ');
  369. 366 ELSE
  370. 367 GotoXY(x+i+1,cy);
  371. 368 END;
  372. 369 INC(i);
  373. 370 END;
  374. 371 GotoXY(oldx,oldy);
  375. 372 END EraseField;
  376. 373
  377. 374 (*.............................................*)
  378. 375
  379. 376 PROCEDURE EraseLineToCursor;
  380. 377 BEGIN
  381. 378 IF Protected THEN
  382. 379 EraseField(0,cy,cx+1);
  383. 380 ELSE
  384. 381 Lib.Fill(ADR(Map[cy]),cx+1,NormalAttr);
  385. 382 Lib.Fill(ADR(ScrMap[cy]),cx+1,' ');
  386. 383 Window.DirectWrite(0,cy,ADR(ScrMap[cy]),cx);
  387. 384 END;
  388. 385 END EraseLineToCursor;
  389. 386
  390. 387 (*.............................................*)
  391. 388
  392. 389 PROCEDURE EraseCursorToEol;
  393. 390 BEGIN
  394. 391 IF Protected THEN
  395. 392 EraseField(cx,cy,cx+1);
  396. 393 ELSE
  397. 394 Window.ClrEol;
  398. 395 END;
  399. 396 END EraseCursorToEol;
  400. 397
  401. 398 (*.............................................*)
  402. 399
  403. 400 PROCEDURE EraseScreenToCursor;
  404. 401 VAR
  405. 402 i,x,y : CARDINAL;
  406. 403 BEGIN
  407. 404 i:=0;
  408. 405 x:=cx;
  409. 406 y:=cy;
  410. 407 WHILE i<y DO
  411. 408 GotoXY(0,i);
  412. 409 EraseCursorToEol;
  413. 410 INC(i);
  414. 411 END;
  415. 412 GotoXY(x,y);
  416. 413 EraseLineToCursor;
  417. 414 END EraseScreenToCursor;
  418. 415
  419. 416 (*.............................................*)
  420. 417
  421. 418 PROCEDURE ClrEos;
  422. 419 VAR
  423. 420 i,x,y : CARDINAL;
  424. 421 BEGIN
  425. 422 i:=0;
  426. 423 x:=cx;
  427. 424 y:=cy;
  428. 425 EraseCursorToEol;
  429. 426 i:=y+1;
  430. 427 WHILE i<=23 DO
  431. 428 GotoXY(0,i);
  432. 429 EraseCursorToEol;
  433. 430 INC(i);
  434. 431 END;
  435. 432 GotoXY(x,y);
  436. 433 END ClrEos;
  437. 434
  438. 435 (*.............................................*)
  439. 436
  440. 437 PROCEDURE FieldWidth():CARDINAL;
  441. 438 VAR
  442. 439 i,Max : CARDINAL;
  443. 440 BEGIN
  444. 441 IF Protected THEN
  445. 442 i:=cx;
  446. 443 IF Map[cy,i]=ProtAttr THEN
  447. 444 RETURN(0);
  448. 445 END;
  449. 446 WHILE (i<80) AND (Map[cy,i]<>ProtAttr) DO
  450. 447 INC(i);
  451. 448 END;
  452. 449 Max := i-1;
  453. 450 ELSE
  454. 451 Max := 79;
  455. 452 END;
  456. 453 RETURN Max;
  457. 454 END FieldWidth;
  458. 455
  459. 456 (*.............................................*)
  460. 457
  461. 458 PROCEDURE DelChar;
  462. 459 VAR
  463. 460 i,Max : CARDINAL;
  464. 461 a : AttrSet;
  465. 462 BEGIN
  466. 463 Max := FieldWidth();
  467. 464 IF Max=0 THEN
  468. 465 RETURN;
  469. 466 END;
  470. 467 i:=cx;
  471. 468 a:=Map[cy,i];
  472. 469 SetColor(a);
  473. 470 WHILE i<Max DO
  474. 471 Map[cy,i] := Map[cy,i+1];
  475. 472 ScrMap[cy,i] := ScrMap[cy,i+1];
  476. 473 IF Map[cy,i]<>a THEN
  477. 474 a:=Map[cy,i]; SetColor(a);
  478. 475 END;
  479. 476 IO.WrChar(ScrMap[cy,i]);
  480. 477 INC(i);
  481. 478 END;
  482. 479 IF Map[cy,i]<>a THEN
  483. 480 a:=Map[cy,i];
  484. 481 SetColor(a);
  485. 482 END;
  486. 483 ScrMap[cy,i]:=' ';
  487. 484 IO.WrChar(' ');
  488. 485 GotoXY(cx,cy);
  489. 486 END DelChar;
  490. 487
  491. 488 (*.............................................*)
  492. 489
  493. 490 PROCEDURE GetCursorPosition(VAR s:ARRAY OF CHAR; VAR Lnth:CARDINAL);
  494. 491 VAR
  495. 492 TempStr : ARRAY[0..9] OF CHAR;
  496. 493 Ok : BOOLEAN;
  497. 494 BEGIN
  498. 495 Str.CardToStr(LONGCARD(cy+1),TempStr,10,Ok);
  499. 496 Str.CardToStr(LONGCARD(cx+1),s,10,Ok);
  500. 497 Lnth := Str.Length(TempStr)+Str.Length(s)+4;
  501. 498 Str.Concat(TempStr,' [',TempStr);
  502. 499 Str.Concat(s,';',s);
  503. 500 Str.Concat(s,TempStr,s);
  504. 501 Str.Concat(s,s,'R');
  505. 502 s[0]:=CHR(27);
  506. 503 END GetCursorPosition;
  507. 504
  508. 505 (*.............................................*)
  509. 506
  510. 507 PROCEDURE Transmit;
  511. 508 (* not implemented *)
  512. 509 END Transmit;
  513. 510
  514. 511 (*.............................................*)
  515. 512
  516. 513 PROCEDURE CursorMovement ( dir : CHAR ; dist : CARDINAL );
  517. 514 BEGIN
  518. 515 IF dist=0 THEN
  519. 516 dist:=1;
  520. 517 END ;
  521. 518 CASE dir OF
  522. 519 'A' : IF dist>cy THEN
  523. 520 cy:=0;
  524. 521 ELSE
  525. 522 DEC(cy,dist);
  526. 523 END; |
  527. 524 'B' : INC(cy,dist);
  528. 525 IF cy>ScreenBottom THEN
  529. 526 cy := ScreenBottom;
  530. 527 END; |
  531. 528 'C' : INC(cx,dist);
  532. 529 IF cy>79 THEN
  533. 530 cy := 79;
  534. 531 END; |
  535. 532 'D' : IF dist>cx THEN
  536. 533 cx:=0;
  537. 534 ELSE
  538. 535 DEC(cx,dist);
  539. 536 END; |
  540. 537 END;
  541. 538 GotoXY(cx,cy);
  542. 539 END CursorMovement ;
  543. 540
  544. 541 (*.............................................*)
  545. 542
  546. 543
  547. 544 PROCEDURE EraseCommand ( type : CHAR ; function : CARDINAL );
  548. 545 VAR
  549. 546 x,y : CARDINAL;
  550. 547 BEGIN
  551. 548 CASE type OF
  552. 549 'J' : CASE function OF
  553. 550 0 : ClrEos; |
  554. 551 1 : EraseScreenToCursor; |
  555. 552 2 : x:=cx;
  556. 553 y:=cy;
  557. 554 GotoXY(0,0);
  558. 555 ClrEos;
  559. 556 GotoXY(x,y); |
  560. 557 END; |
  561. 558 'K' : CASE function OF
  562. 559 0 : EraseCursorToEol; |
  563. 560 1 : EraseLineToCursor; |
  564. 561 2 : x:=cx;
  565. 562 GotoXY(0,cy);
  566. 563 EraseCursorToEol;
  567. 564 GotoXY(x,cy); |
  568. 565 END; |
  569. 566 END ;
  570. 567 END EraseCommand ;
  571. 568
  572. 569 (*.............................................*)
  573. 570
  574. 571 PROCEDURE CheckCode(c:CHAR);
  575. 572 VAR
  576. 573 x,y : CARDINAL;
  577. 574 Seq : ARRAY[0..9] OF CHAR;
  578. 575 BEGIN
  579. 576 IF DECPrivate THEN
  580. 577 DECModeChange(c)
  581. 578 ELSE
  582. 579 CASE c OF
  583. 580 'A'..'D' : CursorMovement(c,p1); |
  584. 581 'c' : (* Device attributes request *)
  585. 582 Seq:=' [?7c';
  586. 583 Seq[0]:=CHR(27);
  587. 584 StuffKbdBuffer(Seq,5); |
  588. 585 'g' : IF p1=0 THEN
  589. 586 TabStop[cx]:=FALSE;
  590. 587 ELSIF p1=3 THEN
  591. 588 FOR x:=0 TO 79 DO
  592. 589 TabStop[x]:=FALSE;
  593. 590 END;
  594. 591 END; |
  595. 592 'H','f' : IF p1=0 THEN
  596. 593 p1:=1;
  597. 594 END;
  598. 595 IF p2=0 THEN
  599. 596 p2:=1;
  600. 597 END;
  601. 598 GotoXY(p2-1,p1-1); |
  602. 599 'h','l' : CASE p1 OF
  603. 600 2 : KbdLocked := (c='h'); |
  604. 601 6 : Protected := (c='l'); |
  605. 602 12 : LocalEcho := (c='l'); |
  606. 603 16 : WantsFullPage := (c='h'); |
  607. 604 20 : NewLineMode := (c='h'); |
  608. 605 END; |
  609. 606 'J','K' : EraseCommand(c,p1); |
  610. 607 'L' : IF (cy>=ScreenTop) AND (cy<=ScreenBottom) THEN
  611. 608 y:=ScreenTop;
  612. 609 ScreenTop:=cy;
  613. 610 WHILE p1>0 DO
  614. 611 Scroll(-1);
  615. 612 DEC(p1);
  616. 613 END;
  617. 614 ScreenTop:=y;
  618. 615 END; |
  619. 616 'M' : IF (cy>=ScreenTop) AND (cy<=ScreenBottom) THEN
  620. 617 y:=ScreenTop;
  621. 618 ScreenTop:=cy;
  622. 619 WHILE p1>0 DO
  623. 620 Scroll(1);
  624. 621 DEC(p1);
  625. 622 END;
  626. 623 ScreenTop:=y;
  627. 624 END; |
  628. 625 'm' : (* Select graphic rendition *)
  629. 626 CASE p1 OF
  630. 627 0 : CurrAttr := NormalAttr ; |
  631. 628 1 : INCL(CurrAttr,Bold); |
  632. 629 4 : CurrAttr := CurrAttr-AttrSet{Red,Green}+AttrSet{Blue};|
  633. 630 5 : INCL(CurrAttr,Blink); |
  634. 631 7 : CurrAttr := AttrSet(
  635. 632 (SHORTCARD(CurrAttr*AttrSet{Red,Green,Blue})<<4)+
  636. 633 (SHORTCARD(CurrAttr*AttrSet{RedBack,GreenBack,BlueBack})>>4)+
  637. 634 (SHORTCARD(CurrAttr*AttrSet{Bold,Blink})));|
  638. 635 8 : CurrAttr := AttrSet{}; |
  639. 636 END;
  640. 637 SetColor(CurrAttr); |
  641. 638 'n' : (* Device status reports *)
  642. 639 Seq[0]:=CHR(27);
  643. 640 Seq[1]:='[';
  644. 641 Seq[3]:='n';
  645. 642 x:=4;
  646. 643 CASE p1 OF
  647. 644 5 : Seq[2]:='0';(* VDU status request *) |
  648. 645 6 : GetCursorPosition(Seq,x); |
  649. 646 ELSE
  650. 647 x := 0;
  651. 648 END;
  652. 649 IF x>0 THEN
  653. 650 StuffKbdBuffer(Seq,x);
  654. 651 END; |
  655. 652 'P' : WHILE p1>0 DO
  656. 653 DelChar;
  657. 654 DEC(p1);
  658. 655 END; |
  659. 656 'r' : IF (p1>=1) AND (p2>0) AND (p2<=24) AND (p1<p2) THEN
  660. 657 ScreenTop := p1-1;
  661. 658 ScreenBottom := p2-1;
  662. 659 ELSE
  663. 660 ScreenTop:=0;
  664. 661 ScreenBottom:=23;
  665. 662 END;
  666. 663 GotoXY(0,ScreenTop); |
  667. 664 '}' : (* Set protection attributes *)
  668. 665 CASE p1 OF
  669. 666 0 : ProtAttr := NormalAttr; |
  670. 667 1 : INCL(ProtAttr,Bold); |
  671. 668 4 : ProtAttr := ProtAttr-AttrSet{Red,Green}+AttrSet{Blue};|
  672. 669 5 : INCL(ProtAttr,Blink); |
  673. 670 7 : ProtAttr := AttrSet(
  674. 671 (SHORTCARD(ProtAttr*AttrSet{Red,Green,Blue})<<4)+
  675. 672 (SHORTCARD(ProtAttr*AttrSet{RedBack,GreenBack,BlueBack})>>4)+
  676. 673 (SHORTCARD(ProtAttr*AttrSet{Bold,Blink})));|
  677. 674 8 : ProtAttr := AttrSet{}; |
  678. 675 ELSE
  679. 676 IF p1=254 THEN
  680. 677 ProtAttr:=NormalAttr;
  681. 678 END;
  682. 679 END;
  683. 680
  684. 681 END;
  685. 682 END;
  686. 683 END CheckCode;
  687. 684
  688. 685 (*.............................................*)
  689. 686
  690. 687 PROCEDURE ShortCode(c:CHAR);
  691. 688 VAR
  692. 689 x,y : CARDINAL;
  693. 690 Seq : ARRAY[0..9] OF CHAR;
  694. 691 BEGIN
  695. 692 CASE c OF
  696. 693 'c' : (* Reset *)
  697. 694 SelectEmulation(EmVT100); |
  698. 695 'D' : IF cy<23 THEN
  699. 696 GotoXY(cx,cy+1);
  700. 697 ELSE
  701. 698 Scroll(1);
  702. 699 END; |
  703. 700 'E' : Output(CHR(10));
  704. 701 GotoXY(0,cy); |
  705. 702 'H' : TabStop[cx]:=TRUE; |
  706. 703 'M' : IF cy>0 THEN
  707. 704 GotoXY(cx,cy-1);
  708. 705 ELSE
  709. 706 Scroll(-1);
  710. 707 END; |
  711. 708 'N' : (* G2 char set - not supported *) |
  712. 709 'Z' : (* Identity Request *)
  713. 710 Seq:=' [?7c';
  714. 711 Seq[0]:=CHR(27);
  715. 712 StuffKbdBuffer(Seq,5); |
  716. 713 'O' : (* G3 char set - not supported *) |
  717. 714 '7' : CSave.cx:=cx;
  718. 715 CSave.cy:=cy;
  719. 716 WITH CSave DO
  720. 717 Top:=ScreenTop;
  721. 718 Bottom:=ScreenBottom;
  722. 719 OrgMode:=OriginMode;
  723. 720 END; |
  724. 721 '8' : WITH CSave DO
  725. 722 ScreenTop:=Top;
  726. 723 ScreenBottom:=Bottom;
  727. 724 OriginMode:=OrgMode;
  728. 725 GotoXY(cx,cy);
  729. 726 END; |
  730. 727 '=' : NumKeyPad := FALSE;(* application keypad mode *)|
  731. 728 '>' : NumKeyPad := TRUE;
  732. 729 ANSIKeys := TRUE; |
  733. 730 END;
  734. 731 END ShortCode;
  735. 732
  736. 733 (*.............................................*)
  737. 734
  738. 735 PROCEDURE NewCharSet(c:CHAR; VAR Gx:CharSets);
  739. 736 BEGIN
  740. 737 CASE c OF
  741. 738 'A' : Gx:=UK; |
  742. 739 'B' : Gx:=US; |
  743. 740 '0' : Gx:=SpecialChar; |
  744. 741 '1' : (* not supported *) |
  745. 742 '2' : (* not supported *) |
  746. 743 END;
  747. 744 END NewCharSet;
  748. 745
  749. 746 (*.............................................*)
  750. 747
  751. 748 PROCEDURE VT100RxSM(c:CHAR);
  752. 749 BEGIN
  753. 750 CASE RxState OF
  754. 751 Normal : IF c=CHR(27) THEN
  755. 752 DECPrivate := FALSE;
  756. 753 p1:=0;
  757. 754 p2:=0;
  758. 755 RxState := GotESC
  759. 756 ELSE
  760. 757 Output(c)
  761. 758 END; |
  762. 759 GotESC : IF c='[' THEN
  763. 760 RxState := GotBrack
  764. 761 ELSIF c='(' THEN
  765. 762 RxState := GotLParen
  766. 763 ELSIF c=')' THEN
  767. 764 RxState := GotRParen
  768. 765 ELSIF c='#' THEN
  769. 766 RxState := GotHash
  770. 767 ELSE
  771. 768 ShortCode(c);
  772. 769 RxState := Normal;
  773. 770 END; |
  774. 771 GotBrack : IF c='?' THEN
  775. 772 DECPrivate := TRUE;
  776. 773 RxState := ReadingP1;
  777. 774 ELSIF (c>='0') AND (c<='9') THEN
  778. 775 p1 := ORD(c)-48;
  779. 776 RxState := ReadingP1;
  780. 777 ELSIF (c=';') THEN
  781. 778 RxState := ReadingP2;
  782. 779 ELSE
  783. 780 CheckCode(c);
  784. 781 RxState := Normal;
  785. 782 END; |
  786. 783 GotLParen : NewCharSet(c,G0);
  787. 784 RxState := Normal; |
  788. 785 GotRParen : NewCharSet(c,G1);
  789. 786 RxState := Normal; |
  790. 787 GotHash : RxState := Normal; (* ignore line attributes *) |
  791. 788 ReadingP1 : IF (c>='0') AND (c<='9') THEN
  792. 789 p1 := p1*10 + ORD(c)-48;
  793. 790 ELSIF c=';' THEN
  794. 791 RxState := ReadingP2
  795. 792 ELSE
  796. 793 CheckCode(c);
  797. 794 RxState := Normal;
  798. 795 END; |
  799. 796 ReadingP2 : IF (c>='0') AND (c<='9') THEN
  800. 797 p2 := p2*10 + ORD(c)-48;
  801. 798 ELSE
  802. 799 CheckCode(c);
  803. 800 RxState := Normal;
  804. 801 END; |
  805. 802 END;
  806. 803 END VT100RxSM;
  807. 804
  808. 805 (*.............................................*)
  809. 806
  810. 807 VAR
  811. 808 CursorY : CARDINAL;
  812. 809
  813. 810 PROCEDURE VT52RxSM(c:CHAR);
  814. 811 VAR
  815. 812 Seq : ARRAY[0..3] OF CHAR;
  816. 813 BEGIN
  817. 814 CASE RxState OF
  818. 815 Normal : IF c=CHR(27) THEN
  819. 816 RxState:=GotESC
  820. 817 ELSE
  821. 818 Output(c)
  822. 819 END; |
  823. 820 GotESC : CASE c OF
  824. 821 '<' : SelectEmulation(EmVT100); |
  825. 822 '=' : NumKeyPad:=FALSE; |
  826. 823 '>' : NumKeyPad:=TRUE; |
  827. 824 'F' : CurrCharSet:=SpecialChar; |
  828. 825 'G' : CurrCharSet:=US; |
  829. 826 'A'..'D' : CursorMovement(c,1); |
  830. 827 'H' : GotoXY(0,0); |
  831. 828 'Y' : RxState := VT52Line; |
  832. 829 'I' : IF cy>ScreenTop THEN
  833. 830 DEC(cy);
  834. 831 ELSE
  835. 832 Scroll(-1);
  836. 833 END;
  837. 834 GotoXY(cx,cy); |
  838. 835 'K' : EraseCursorToEol; |
  839. 836 'J' : ClrEos; |
  840. 837 'Z' : Seq:=' /Z';
  841. 838 Seq[0]:=CHR(27);
  842. 839 StuffKbdBuffer(Seq,3); |
  843. 840 END;
  844. 841 IF RxState<>VT52Line THEN
  845. 842 RxState:=Normal;
  846. 843 END; |
  847. 844 VT52Line : IF c>=' ' THEN
  848. 845 CursorY := ORD(c)-32;
  849. 846 RxState := VT52Col;
  850. 847 ELSE
  851. 848 RxState := Normal;
  852. 849 END; |
  853. 850 VT52Col : IF c>=' ' THEN
  854. 851 GotoXY(ORD(c)-32,CursorY);
  855. 852 END;
  856. 853 RxState := Normal; |
  857. 854 END;
  858. 855 END VT52RxSM;
  859. 856
  860. 857 (*.............................................*)
  861. 858 VAR
  862. 859 ANSIp : ARRAY[1..9] OF CARDINAL ;
  863. 860 ANSIn : [0..9];
  864. 861 PROCEDURE ANSIRxSM(c:CHAR);
  865. 862 (* Reduced PC compatible ANSI driver *)
  866. 863 VAR
  867. 864 i : CARDINAL;
  868. 865 W : Window.WinType;
  869. 866 wc : Window.Color;
  870. 867 Seq : ARRAY[0..9] OF CHAR;
  871. 868 BEGIN
  872. 869 CASE RxState OF
  873. 870 Normal : IF c=CHR(27) THEN
  874. 871 RxState:=GotESC;
  875. 872 ELSE
  876. 873 Output(c);
  877. 874 END; |
  878. 875 GotESC : IF c='[' THEN
  879. 876 RxState:=ANSICmd;
  880. 877 FOR i := 1 TO 9 DO
  881. 878 ANSIp[i] := 0;
  882. 879 END ;
  883. 880 ANSIn := 1;
  884. 881 ELSE
  885. 882 Output(c);
  886. 883 RxState:=Normal;
  887. 884 END; |
  888. 885 ANSICmd : RxState:=Normal;
  889. 886 CASE c OF
  890. 887 '0'..'9' : ANSIp[ANSIn] := ANSIp[ANSIn]*10+ORD(c)-ORD('0');
  891. 888 RxState:=ANSICmd; |
  892. 889 ';' : IF ANSIn<9 THEN
  893. 890 INC(ANSIn);
  894. 891 END;
  895. 892 RxState:=ANSICmd; |
  896. 893 'f','H' : IF ANSIp[1] > 0 THEN
  897. 894 DEC(ANSIp[1]);
  898. 895 END;
  899. 896 IF ANSIp[2] > 0 THEN
  900. 897 DEC(ANSIp[2]);
  901. 898 END;
  902. 899 GotoXY(ANSIp[2],ANSIp[1]); |
  903. 900 'A'..'D' : CursorMovement(c,ANSIp[1]); |
  904. 901 'J','K' : EraseCommand(c,ANSIp[1]); |
  905. 902 's' : CSave.cx:=cx;
  906. 903 CSave.cy:=cy; |
  907. 904 'u' : GotoXY(CSave.cx,CSave.cy); |
  908. 905 'n' : IF ANSIp[1]=6 THEN
  909. 906 GetCursorPosition(Seq,i);
  910. 907 IF i>0 THEN
  911. 908 StuffKbdBuffer(Seq,i);
  912. 909 END;
  913. 910 END; |
  914. 911 'm' : FOR i := 1 TO ANSIn DO
  915. 912 CASE ANSIp[i] OF
  916. 913 0 : CurrAttr := NormalAttr; |
  917. 914 1 : INCL(CurrAttr,Bold); |
  918. 915 4 : CurrAttr := CurrAttr-AttrSet{Red,Green}+AttrSet{Blue}; |
  919. 916 5 : INCL(CurrAttr,Blink); |
  920. 917 7 : CurrAttr := AttrSet((SHORTCARD(CurrAttr*AttrSet{Red,Green,Blue})<<4)+(SHORTCARD(CurrAttr*AttrSet{RedBack,GreenBack,BlueBack})>>4)+(SHORTCARD(CurrAttr*AttrSet{Bold,Blink})));|
  921. 918 8 : CurrAttr := AttrSet{}; |
  922. 919 30 : CurrAttr := CurrAttr-AttrSet{Red,Green,Blue}; |
  923. 920 31 : CurrAttr := CurrAttr-AttrSet{Green,Blue}+AttrSet{Red}; |
  924. 921 32 : CurrAttr := CurrAttr-AttrSet{Red,Blue}+AttrSet{Green}; |
  925. 922 33 : CurrAttr := CurrAttr-AttrSet{Blue}+AttrSet{Red,Green}; |
  926. 923 34 : CurrAttr := CurrAttr-AttrSet{Red,Green}+AttrSet{Blue}; |
  927. 924 35 : CurrAttr := CurrAttr-AttrSet{Green}+AttrSet{Red,Blue}; |
  928. 925 36 : CurrAttr := CurrAttr-AttrSet{Red}+AttrSet{Blue,Green}; |
  929. 926 37 : CurrAttr := CurrAttr+AttrSet{Red,Blue,Green}; |
  930. 927 40 : CurrAttr := CurrAttr-AttrSet{RedBack,GreenBack,BlueBack}; |
  931. 928 41 : CurrAttr := CurrAttr-AttrSet{GreenBack,BlueBack}+AttrSet{RedBack}; |
  932. 929 42 : CurrAttr := CurrAttr-AttrSet{RedBack,BlueBack}+AttrSet{GreenBack}; |
  933. 930 43 : CurrAttr := CurrAttr-AttrSet{BlueBack}+AttrSet{RedBack,GreenBack}; |
  934. 931 44 : CurrAttr := CurrAttr-AttrSet{RedBack,GreenBack}+AttrSet{BlueBack}; |
  935. 932 45 : CurrAttr := CurrAttr-AttrSet{GreenBack}+AttrSet{RedBack,BlueBack}; |
  936. 933 46 : CurrAttr := CurrAttr-AttrSet{RedBack}+AttrSet{BlueBack,GreenBack}; |
  937. 934 47 : CurrAttr := CurrAttr+AttrSet{RedBack,BlueBack,GreenBack}; |
  938. 935 END;
  939. 936 SetColor(CurrAttr);
  940. 937 END;
  941. 938 ELSE
  942. 939 Output(c);
  943. 940 END;
  944. 941 END;
  945. 942 END ANSIRxSM;
  946. 943
  947. 944 (*.............................................*)
  948. 945
  949. 946 PROCEDURE WrChar(c:CHAR);
  950. 947 BEGIN
  951. 948 IF ORD(c)>127 THEN
  952. 949 c:=CHR(ORD(c)-128);
  953. 950 END;
  954. 951 CASE VTMode OF
  955. 952 EmVT100: VT100RxSM(c); (* call VT100 receive state machine *) |
  956. 953 EmVT52: VT52RxSM(c); (* call VT52 receive state machine *) |
  957. 954 EmANSI: ANSIRxSM(c); (* call ANSI receive state machine *) |
  958. 955 END;
  959. 956 END WrChar;
  960. 957
  961. 958 (*.............................................*)
  962. 959
  963. 960 PROCEDURE KeyTranslate;
  964. 961 (* Emulate sequences produced by VT100 or VT52 keyboard. There is a *)
  965. 962 (* dearth of keypad keys on the IBM for this, so instead, to use *)
  966. 963 (* cursor keys you use the unshifted keys. To access the numeric *)
  967. 964 (* keypad (or the application keys in alterate mode) you hold down *)
  968. 965 (* shift while pressing the appropriate keys. This still leaves us *)
  969. 966 (* five keys short for the keypad "enter" and PF1..PF4. The "Enter" *)
  970. 967 (* key is produced by F6 on the PC, and PF1..PF4 correspond to F7..F8*)
  971. 968 (* on the PC. *)
  972. 969 VAR
  973. 970 c : CHAR;
  974. 971 Lnth : CARDINAL;
  975. 972 Seq : ARRAY[0..2] OF CHAR;
  976. 973 BEGIN
  977. 974 c := Keyboard.RdKey();
  978. 975 IF c=0C THEN
  979. 976 (* NOTE: Alt-Key combinations are reserved for use by the comms *)
  980. 977 (* package, so if this turns out to be one we need to insert the*)
  981. 978 (* preceding NUL into the kbd.buff also, otherwise the equivalent*)
  982. 979 (* VT100 sequence gets stuffed into the keyboard buffer. *)
  983. 980 c := Keyboard.RdKey();
  984. 981 Seq[0]:=CHR(27);
  985. 982 Lnth:=3;
  986. 983 IF c=CHR(64) THEN
  987. 984 IF NumKeyPad THEN
  988. 985 Seq[0]:=CHR(13);
  989. 986 Lnth:=1;
  990. 987 IF NewLineMode THEN
  991. 988 Seq[1]:=CHR(10);
  992. 989 Lnth:=2;
  993. 990 END;
  994. 991 ELSE
  995. 992 Seq[1]:='O';
  996. 993 Seq[2]:='M';
  997. 994 END;
  998. 995 ELSIF (c>=CHR(65)) AND (c<=CHR(68)) THEN
  999. 996 IF VTMode=EmVT100 THEN
  1000. 997 Seq[1]:='O';
  1001. 998 ELSE
  1002. 999 Seq[1]:='?';
  1003. 1000 END;
  1004. 1001 CASE ORD(c) OF
  1005. 1002 65 : Seq[2]:='P'; |
  1006. 1003 66 : Seq[2]:='Q'; |
  1007. 1004 67 : Seq[2]:='R'; |
  1008. 1005 68 : Seq[2]:='S'; |
  1009. 1006 END;
  1010. 1007 IF (VTMode=EmVT52) AND (NumKeyPad) THEN
  1011. 1008 Seq[1]:=Seq[2];
  1012. 1009 Lnth:=2;
  1013. 1010 END;
  1014. 1011 ELSE
  1015. 1012 IF ANSIKeys THEN
  1016. 1013 Seq[1]:='[';
  1017. 1014 ELSE
  1018. 1015 Seq[1]:='O';
  1019. 1016 END;
  1020. 1017 CASE ORD(c) OF
  1021. 1018 72 : Seq[2]:='A'; (* cursor up *) |
  1022. 1019 75 : Seq[2]:='D'; (* cursor left *) |
  1023. 1020 77 : Seq[2]:='C'; (* cursor right *) |
  1024. 1021 80 : Seq[2]:='B'; (* cursor down *) |
  1025. 1022 ELSE
  1026. 1023 Seq[0]:=0C; Seq[1]:=c; StuffKbdBuffer(Seq,2);
  1027. 1024 RETURN
  1028. 1025 END;
  1029. 1026 IF VTMode=EmVT52 THEN
  1030. 1027 Seq[1]:=Seq[2];
  1031. 1028 Lnth:=2;
  1032. 1029 END;
  1033. 1030 END;
  1034. 1031 StuffKbdBuffer(Seq,Lnth);
  1035. 1032 ELSIF (Keyboard.ScanCode>=CHR(71)) AND (Keyboard.ScanCode<=CHR(83)) THEN
  1036. 1033 IF NumKeyPad THEN
  1037. 1034 IF c='+' THEN
  1038. 1035 c:=',';
  1039. 1036 END;
  1040. 1037 StuffKbdBuffer(c,1);
  1041. 1038 ELSE
  1042. 1039 Seq[0]:=CHR(27);
  1043. 1040 IF VTMode=EmVT100 THEN
  1044. 1041 Seq[1]:='O';
  1045. 1042 ELSE
  1046. 1043 Seq[1]:='?';
  1047. 1044 END;
  1048. 1045 CASE c OF
  1049. 1046 '0' : Seq[2]:='p'; |
  1050. 1047 '1' : Seq[2]:='q'; |
  1051. 1048 '2' : Seq[2]:='r'; |
  1052. 1049 '3' : Seq[2]:='s'; |
  1053. 1050 '4' : Seq[2]:='t'; |
  1054. 1051 '5' : Seq[2]:='u'; |
  1055. 1052 '6' : Seq[2]:='v'; |
  1056. 1053 '7' : Seq[2]:='w'; |
  1057. 1054 '8' : Seq[2]:='x'; |
  1058. 1055 '9' : Seq[2]:='y'; |
  1059. 1056 '-' : Seq[2]:='m'; |
  1060. 1057 '+' : Seq[2]:='l'; |
  1061. 1058 '.' : Seq[2]:='n'; |
  1062. 1059 END;
  1063. 1060 StuffKbdBuffer(Seq,3);
  1064. 1061 END;
  1065. 1062 ELSE
  1066. 1063 Seq[0]:=c;
  1067. 1064 Lnth:=1;
  1068. 1065 IF (c=CHR(13)) AND (NewLineMode) THEN
  1069. 1066 Seq[1]:=CHR(10); Lnth:=2;
  1070. 1067 END;
  1071. 1068 StuffKbdBuffer(Seq,Lnth);
  1072. 1069 END;
  1073. 1070 END KeyTranslate;
  1074. 1071
  1075. 1072 (*.............................................*)
  1076. 1073
  1077. 1074 PROCEDURE RdKey():CHAR;
  1078. 1075 VAR
  1079. 1076 c : CHAR;
  1080. 1077 BEGIN
  1081. 1078 LOOP
  1082. 1079 WITH Kbd DO
  1083. 1080 IF rptr<>wptr THEN
  1084. 1081 c:=Buff[rptr];
  1085. 1082 rptr:=(rptr+1) MOD 100H;
  1086. 1083 EXIT
  1087. 1084 ELSE
  1088. 1085 KeyTranslate();
  1089. 1086 END;
  1090. 1087 END;
  1091. 1088 END;
  1092. 1089 RETURN c;
  1093. 1090 END RdKey;
  1094. 1091
  1095. 1092 (*.............................................*)
  1096. 1093
  1097. 1094 PROCEDURE KeyPressed():BOOLEAN;
  1098. 1095 BEGIN
  1099. 1096 IF Kbd.rptr<>Kbd.wptr THEN
  1100. 1097 RETURN TRUE
  1101. 1098 ELSIF Keyboard.KeyPressed() THEN
  1102. 1099 KeyTranslate();
  1103. 1100 RETURN KeyPressed();
  1104. 1101 ELSE
  1105. 1102 RETURN FALSE
  1106. 1103 END;
  1107. 1104 END KeyPressed;
  1108. 1105
  1109. 1106 (*.............................................*)
  1110. 1107
  1111. 1108 PROCEDURE ClearScreen;
  1112. 1109 BEGIN
  1113. 1110 GotoXY(0,0);
  1114. 1111 ClrEos;
  1115. 1112 END ClearScreen;
  1116. 1113
  1117. 1114 (*.............................................*)
  1118. 1115
  1119. 1116 PROCEDURE EmulateVT100;
  1120. 1117 BEGIN
  1121. 1118 SelectEmulation(EmVT100);
  1122. 1119 END EmulateVT100;
  1123. 1120
  1124. 1121 (*.............................................*)
  1125. 1122
  1126. 1123 PROCEDURE EmulateVT52;
  1127. 1124 BEGIN
  1128. 1125 SelectEmulation(EmVT52);
  1129. 1126 END EmulateVT52;
  1130. 1127
  1131. 1128 (*.............................................*)
  1132. 1129
  1133. 1130 PROCEDURE EmulateANSI;
  1134. 1131 BEGIN
  1135. 1132 SelectEmulation(EmANSI);
  1136. 1133 END EmulateANSI;
  1137. 1134
  1138. 1135 (*.............................................*)
  1139. 1136
  1140. 1137 PROCEDURE Emulation():Emulations;
  1141. 1138 BEGIN
  1142. 1139 RETURN VTMode;
  1143. 1140 END Emulation;
  1144. 1141
  1145. 1142 (*.............................................*)
  1146. 1143
  1147. 1144 BEGIN
  1148. 1145 ResetTerm;
  1149. 1146 END Term.
  1150. 2 errors