Bladeren bron

première version des librairies

Eric Streit 2 weken geleden
bovenliggende
commit
fac9ea8cc2
81 gewijzigde bestanden met toevoegingen van 4965 en 0 verwijderingen
  1. 1 0
      .gitignore
  2. 101 0
      Ansi.def
  3. 229 0
      Ansi.mod
  4. 24 0
      Old/T.mod
  5. 40 0
      Old/TestVT100N13.mod
  6. 290 0
      Old/VT100.def
  7. 5 0
      Old/VT100.def.firsttest
  8. 999 0
      Old/VT100.mod
  9. 21 0
      Old/VT100.mod.firsttest
  10. 74 0
      Regis.def
  11. 211 0
      Regis.mod
  12. 59 0
      SUMMARY.md
  13. 28 0
      SplitV1.def
  14. 157 0
      SplitV1.mod
  15. 123 0
      VT100.def
  16. 228 0
      VT100.mod
  17. 36 0
      VT52.def
  18. 74 0
      VT52.mod
  19. 33 0
      build.sh
  20. BIN
      docs/TerminalEscapeCodes.pdf
  21. 233 0
      docs/VT100 commands.html
  22. BIN
      docs/VT100-2.odt
  23. 321 0
      docs/VT100-3.txt
  24. 209 0
      docs/VT100-escape codes.txt
  25. 232 0
      docs/VT100.txt
  26. BIN
      docs/VT52 - Wikipedia.pdf
  27. 60 0
      docs/regis-cli.txt
  28. 44 0
      docs/regis.txt
  29. 36 0
      tests/Test1.mod
  30. BIN
      tests/TestAnsiColor
  31. 35 0
      tests/TestAnsiColor.mod
  32. BIN
      tests/TestAnsiCursor
  33. 50 0
      tests/TestAnsiCursor.mod
  34. BIN
      tests/TestAnsiErase
  35. 46 0
      tests/TestAnsiErase.mod
  36. BIN
      tests/TestAnsiModes
  37. 31 0
      tests/TestAnsiModes.mod
  38. BIN
      tests/TestAnsiPrint
  39. 25 0
      tests/TestAnsiPrint.mod
  40. BIN
      tests/TestAnsiRequestPosition
  41. 51 0
      tests/TestAnsiRequestPosition.mod
  42. BIN
      tests/TestAnsiSGR
  43. 36 0
      tests/TestAnsiSGR.mod
  44. BIN
      tests/TestRegisColor
  45. 36 0
      tests/TestRegisColor.mod
  46. BIN
      tests/TestRegisDemo
  47. 31 0
      tests/TestRegisDemo.mod
  48. BIN
      tests/TestRegisMacro
  49. 27 0
      tests/TestRegisMacro.mod
  50. BIN
      tests/TestVT100Charset
  51. 35 0
      tests/TestVT100Charset.mod
  52. BIN
      tests/TestVT100Cursor
  53. 34 0
      tests/TestVT100Cursor.mod
  54. BIN
      tests/TestVT100Erase
  55. 54 0
      tests/TestVT100Erase.mod
  56. BIN
      tests/TestVT100Keypad
  57. 21 0
      tests/TestVT100Keypad.mod
  58. BIN
      tests/TestVT100LedTest
  59. 34 0
      tests/TestVT100LedTest.mod
  60. BIN
      tests/TestVT100Modes
  61. 49 0
      tests/TestVT100Modes.mod
  62. BIN
      tests/TestVT100Reports
  63. 37 0
      tests/TestVT100Reports.mod
  64. BIN
      tests/TestVT100SGR
  65. 36 0
      tests/TestVT100SGR.mod
  66. BIN
      tests/TestVT100Scroll
  67. 39 0
      tests/TestVT100Scroll.mod
  68. BIN
      tests/TestVT100Size
  69. 37 0
      tests/TestVT100Size.mod
  70. BIN
      tests/TestVT100Tabs
  71. 30 0
      tests/TestVT100Tabs.mod
  72. BIN
      tests/TestVT52Cursor
  73. 34 0
      tests/TestVT52Cursor.mod
  74. BIN
      tests/TestVT52Erase
  75. 38 0
      tests/TestVT52Erase.mod
  76. BIN
      tests/TestVT52Ident
  77. 22 0
      tests/TestVT52Ident.mod
  78. BIN
      tests/TestVT52Mode
  79. 29 0
      tests/TestVT52Mode.mod
  80. BIN
      tests/testSpliV1
  81. 200 0
      tests/testSplit.mod

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+*.o

+ 101 - 0
Ansi.def

@@ -0,0 +1,101 @@
+DEFINITION MODULE Ansi;
+
+(*
+  ANSI escape sequences per docs/VT100-3.txt, docs/VT100.txt.
+  Modern terminal superset: CSI cursor/erase/SGR/colors,
+  DOS screen modes ESC[=, private modes ESC[?, print.
+  Pure emitter, same pattern as VT100/VT52, plus
+  Unbuffered/Buffered input-mode helpers (termios).
+*)
+
+TYPE
+  Attr = (ResetA, BoldA, DimA, ItalicA, UnderlineA, BlinkA,
+          InverseA, HiddenA, StrikeA);
+  Color = (Black, Red, Green, Yellow, Blue, Magenta, Cyan, White,
+           Default,
+           BrightBlack, BrightRed, BrightGreen, BrightYellow,
+           BrightBlue, BrightMagenta, BrightCyan, BrightWhite);
+
+(* Cursor *)
+PROCEDURE Home;                            (* ESC[H *)
+PROCEDURE Position(line, col : CARDINAL);   (* ESC[line;colH *)
+PROCEDURE HVPosition(line, col : CARDINAL); (* ESC[line;colf *)
+PROCEDURE Up(n : CARDINAL);                 (* ESC[nA *)
+PROCEDURE Down(n : CARDINAL);               (* ESC[nB *)
+PROCEDURE Right(n : CARDINAL);              (* ESC[nC *)
+PROCEDURE Left(n : CARDINAL);               (* ESC[nD *)
+PROCEDURE NextLine(n : CARDINAL);           (* ESC[nE *)
+PROCEDURE PrevLine(n : CARDINAL);           (* ESC[nF *)
+PROCEDURE ToColumn(n : CARDINAL);           (* ESC[nG *)
+PROCEDURE CursorUpScroll;                   (* ESC M *)
+PROCEDURE SaveDEC;                          (* ESC 7 *)
+PROCEDURE RestoreDEC;                       (* ESC 8 *)
+PROCEDURE SaveSCO;                          (* ESC[s *)
+PROCEDURE RestoreSCO;                       (* ESC[u *)
+PROCEDURE RequestPosition;                  (* ESC[6n *)
+
+(* Erase *)
+PROCEDURE EraseDown;        (* ESC[J / ESC[0J *)
+PROCEDURE EraseUp;          (* ESC[1J *)
+PROCEDURE EraseScreen;      (* ESC[2J *)
+PROCEDURE EraseSavedLines;  (* ESC[3J *)
+PROCEDURE EraseLineRight;   (* ESC[K / ESC[0K *)
+PROCEDURE EraseLineLeft;    (* ESC[1K *)
+PROCEDURE EraseLine;        (* ESC[2K *)
+
+(* SGR attributes *)
+PROCEDURE SGR(a : Attr);
+PROCEDURE SGRReset;         (* ESC[0m *)
+PROCEDURE SGRResetBoldDim;  (* ESC[22m *)
+PROCEDURE SGRResetItalic;   (* ESC[23m *)
+PROCEDURE SGRResetUnderline;(* ESC[24m *)
+PROCEDURE SGRResetBlink;    (* ESC[25m *)
+PROCEDURE SGRResetInverse;  (* ESC[27m *)
+PROCEDURE SGRResetHidden;   (* ESC[28m *)
+PROCEDURE SGRResetStrike;   (* ESC[29m *)
+PROCEDURE SetAttr(a : Attr; fg, bg : Color); (* ESC[a;fg;bgm *)
+
+(* Colors *)
+PROCEDURE FG(c : Color);    (* ESC[30..37/90..97/39m *)
+PROCEDURE BG(c : Color);    (* ESC[40..47/100..107/49m *)
+PROCEDURE FG256(id : CARDINAL); (* ESC[38;5;IDm *)
+PROCEDURE BG256(id : CARDINAL); (* ESC[48;5;IDm *)
+PROCEDURE FGRGB(r, g, b : CARDINAL); (* ESC[38;2;r;g;bm *)
+PROCEDURE BGRGB(r, g, b : CARDINAL); (* ESC[48;2;r;g;bm *)
+
+(* DOS screen modes ESC[= *)
+PROCEDURE DosMode(v : CARDINAL);   (* ESC[=vh, 0..7,13..19 *)
+PROCEDURE DosModeReset(v : CARDINAL); (* ESC[=vl *)
+PROCEDURE WrapOn;             (* ESC[=7h *)
+PROCEDURE WrapOff;            (* ESC[=7l, spec exception *)
+
+(* Private modes ESC[? *)
+PROCEDURE CursorInvisible;  (* ESC[?25l *)
+PROCEDURE CursorVisible;    (* ESC[?25h *)
+PROCEDURE ScreenSave;       (* ESC[?47h *)
+PROCEDURE ScreenRestore;    (* ESC[?47l *)
+PROCEDURE AltBufferOn;      (* ESC[?1049h *)
+PROCEDURE AltBufferOff;     (* ESC[?1049l *)
+
+(* Print *)
+PROCEDURE PrintScreen;  (* ESC[i *)
+PROCEDURE PrintLine;    (* ESC[1i *)
+PROCEDURE StopLog;      (* ESC[4i *)
+PROCEDURE StartLog;     (* ESC[5i *)
+
+(* Control chars *)
+PROCEDURE Bell;       (* BEL 07 *)
+PROCEDURE Backspace;  (* BS 08 *)
+PROCEDURE HTab;       (* HT 09 *)
+PROCEDURE LineFeed;   (* LF 10 *)
+PROCEDURE VTab;       (* VT 11 *)
+PROCEDURE FormFeed;   (* FF 12 *)
+PROCEDURE CarriageReturn; (* CR 13 *)
+
+(* Terminal input mode: call Unbuffered before reading device
+   replies (e.g. CPR) so no RETURN key is needed; call
+   Buffered afterwards to restore the saved state. *)
+PROCEDURE Unbuffered;
+PROCEDURE Buffered;
+
+END Ansi.

+ 229 - 0
Ansi.mod

@@ -0,0 +1,229 @@
+IMPLEMENTATION MODULE Ansi;
+
+IMPORT ASCII;
+FROM STextIO IMPORT WriteChar, WriteString;
+FROM NumberIO IMPORT WriteCard;
+IMPORT IO, termios, FIO;
+
+VAR
+  savedTerm : termios.TERMIOS;
+  flushFlag : INTEGER;
+  haveTerm : BOOLEAN;
+
+PROCEDURE CSI;
+BEGIN WriteChar(ASCII.esc); WriteChar("["); END CSI;
+
+PROCEDURE CSIq;
+BEGIN WriteChar(ASCII.esc); WriteString("[?"); END CSIq;
+
+PROCEDURE CSIe;
+BEGIN WriteChar(ASCII.esc); WriteString("[="); END CSIe;
+
+PROCEDURE ESC1(c : CHAR);
+BEGIN WriteChar(ASCII.esc); WriteChar(c); END ESC1;
+
+(* Cursor *)
+PROCEDURE Home; BEGIN CSI; WriteChar("H"); END Home;
+
+PROCEDURE Position(line, col : CARDINAL);
+BEGIN CSI; WriteCard(line, 1); WriteChar(";"); WriteCard(col, 1); WriteChar("H"); END Position;
+
+PROCEDURE HVPosition(line, col : CARDINAL);
+BEGIN CSI; WriteCard(line, 1); WriteChar(";"); WriteCard(col, 1); WriteChar("f"); END HVPosition;
+
+PROCEDURE Up(n : CARDINAL); BEGIN CSI; WriteCard(n, 1); WriteChar("A"); END Up;
+PROCEDURE Down(n : CARDINAL); BEGIN CSI; WriteCard(n, 1); WriteChar("B"); END Down;
+PROCEDURE Right(n : CARDINAL); BEGIN CSI; WriteCard(n, 1); WriteChar("C"); END Right;
+PROCEDURE Left(n : CARDINAL); BEGIN CSI; WriteCard(n, 1); WriteChar("D"); END Left;
+PROCEDURE NextLine(n : CARDINAL); BEGIN CSI; WriteCard(n, 1); WriteChar("E"); END NextLine;
+PROCEDURE PrevLine(n : CARDINAL); BEGIN CSI; WriteCard(n, 1); WriteChar("F"); END PrevLine;
+PROCEDURE ToColumn(n : CARDINAL); BEGIN CSI; WriteCard(n, 1); WriteChar("G"); END ToColumn;
+PROCEDURE CursorUpScroll; BEGIN ESC1("M"); END CursorUpScroll;
+PROCEDURE SaveDEC; BEGIN ESC1("7"); END SaveDEC;
+PROCEDURE RestoreDEC; BEGIN ESC1("8"); END RestoreDEC;
+PROCEDURE SaveSCO; BEGIN CSI; WriteChar("s"); END SaveSCO;
+PROCEDURE RestoreSCO; BEGIN CSI; WriteChar("u"); END RestoreSCO;
+PROCEDURE RequestPosition; BEGIN CSI; WriteString("6n"); END RequestPosition;
+
+(* Erase *)
+PROCEDURE EraseDown; BEGIN CSI; WriteChar("J"); END EraseDown;
+PROCEDURE EraseUp; BEGIN CSI; WriteString("1J"); END EraseUp;
+PROCEDURE EraseScreen; BEGIN CSI; WriteString("2J"); END EraseScreen;
+PROCEDURE EraseSavedLines; BEGIN CSI; WriteString("3J"); END EraseSavedLines;
+PROCEDURE EraseLineRight; BEGIN CSI; WriteChar("K"); END EraseLineRight;
+PROCEDURE EraseLineLeft; BEGIN CSI; WriteString("1K"); END EraseLineLeft;
+PROCEDURE EraseLine; BEGIN CSI; WriteString("2K"); END EraseLine;
+
+(* SGR *)
+PROCEDURE SGRCode(n : CARDINAL);
+BEGIN CSI; WriteCard(n, 1); WriteChar("m"); END SGRCode;
+
+PROCEDURE SGR(a : Attr);
+BEGIN
+  CASE a OF
+    ResetA : SGRCode(0) |
+    BoldA : SGRCode(1) |
+    DimA : SGRCode(2) |
+    ItalicA : SGRCode(3) |
+    UnderlineA : SGRCode(4) |
+    BlinkA : SGRCode(5) |
+    InverseA : SGRCode(7) |
+    HiddenA : SGRCode(8) |
+    StrikeA : SGRCode(9)
+  END;
+END SGR;
+
+PROCEDURE SGRReset; BEGIN SGRCode(0); END SGRReset;
+PROCEDURE SGRResetBoldDim; BEGIN CSI; WriteString("22m"); END SGRResetBoldDim;
+PROCEDURE SGRResetItalic; BEGIN CSI; WriteString("23m"); END SGRResetItalic;
+PROCEDURE SGRResetUnderline; BEGIN CSI; WriteString("24m"); END SGRResetUnderline;
+PROCEDURE SGRResetBlink; BEGIN CSI; WriteString("25m"); END SGRResetBlink;
+PROCEDURE SGRResetInverse; BEGIN CSI; WriteString("27m"); END SGRResetInverse;
+PROCEDURE SGRResetHidden; BEGIN CSI; WriteString("28m"); END SGRResetHidden;
+PROCEDURE SGRResetStrike; BEGIN CSI; WriteString("29m"); END SGRResetStrike;
+
+PROCEDURE FGCode(n : CARDINAL);
+BEGIN CSI; WriteCard(n, 1); WriteChar("m"); END FGCode;
+
+PROCEDURE FGNum(c : Color) : CARDINAL;
+BEGIN
+  CASE c OF
+    Black : RETURN 30 |
+    Red : RETURN 31 |
+    Green : RETURN 32 |
+    Yellow : RETURN 33 |
+    Blue : RETURN 34 |
+    Magenta : RETURN 35 |
+    Cyan : RETURN 36 |
+    White : RETURN 37 |
+    Default : RETURN 39 |
+    BrightBlack : RETURN 90 |
+    BrightRed : RETURN 91 |
+    BrightGreen : RETURN 92 |
+    BrightYellow : RETURN 93 |
+    BrightBlue : RETURN 94 |
+    BrightMagenta : RETURN 95 |
+    BrightCyan : RETURN 96 |
+    BrightWhite : RETURN 97
+  END;
+END FGNum;
+
+PROCEDURE BGNum(c : Color) : CARDINAL;
+BEGIN
+  CASE c OF
+    Black : RETURN 40 |
+    Red : RETURN 41 |
+    Green : RETURN 42 |
+    Yellow : RETURN 43 |
+    Blue : RETURN 44 |
+    Magenta : RETURN 45 |
+    Cyan : RETURN 46 |
+    White : RETURN 47 |
+    Default : RETURN 49 |
+    BrightBlack : RETURN 100 |
+    BrightRed : RETURN 101 |
+    BrightGreen : RETURN 102 |
+    BrightYellow : RETURN 103 |
+    BrightBlue : RETURN 104 |
+    BrightMagenta : RETURN 105 |
+    BrightCyan : RETURN 106 |
+    BrightWhite : RETURN 107
+  END;
+END BGNum;
+
+PROCEDURE AttrNum(a : Attr) : CARDINAL;
+BEGIN
+  CASE a OF
+    ResetA : RETURN 0 |
+    BoldA : RETURN 1 |
+    DimA : RETURN 2 |
+    ItalicA : RETURN 3 |
+    UnderlineA : RETURN 4 |
+    BlinkA : RETURN 5 |
+    InverseA : RETURN 7 |
+    HiddenA : RETURN 8 |
+    StrikeA : RETURN 9
+  END;
+END AttrNum;
+
+PROCEDURE FG(c : Color); BEGIN FGCode(FGNum(c)); END FG;
+PROCEDURE BG(c : Color); BEGIN FGCode(BGNum(c)); END BG;
+
+PROCEDURE SetAttr(a : Attr; fg, bg : Color);
+BEGIN
+  CSI; WriteCard(AttrNum(a), 1); WriteChar(";");
+  WriteCard(FGNum(fg), 1); WriteChar(";");
+  WriteCard(BGNum(bg), 1); WriteChar("m");
+END SetAttr;
+
+PROCEDURE FG256(id : CARDINAL);
+BEGIN CSI; WriteString("38;5;"); WriteCard(id, 1); WriteChar("m"); END FG256;
+
+PROCEDURE BG256(id : CARDINAL);
+BEGIN CSI; WriteString("48;5;"); WriteCard(id, 1); WriteChar("m"); END BG256;
+
+PROCEDURE FGRGB(r, g, b : CARDINAL);
+BEGIN CSI; WriteString("38;2;"); WriteCard(r, 1); WriteChar(";");
+  WriteCard(g, 1); WriteChar(";"); WriteCard(b, 1); WriteChar("m"); END FGRGB;
+
+PROCEDURE BGRGB(r, g, b : CARDINAL);
+BEGIN CSI; WriteString("48;2;"); WriteCard(r, 1); WriteChar(";");
+  WriteCard(g, 1); WriteChar(";"); WriteCard(b, 1); WriteChar("m"); END BGRGB;
+
+(* DOS modes *)
+PROCEDURE DosMode(v : CARDINAL);
+BEGIN CSIe; WriteCard(v, 1); WriteChar("h"); END DosMode;
+
+PROCEDURE DosModeReset(v : CARDINAL);
+BEGIN CSIe; WriteCard(v, 1); WriteChar("l"); END DosModeReset;
+
+PROCEDURE WrapOn; BEGIN CSIe; WriteString("7h"); END WrapOn;
+PROCEDURE WrapOff; BEGIN CSIe; WriteString("7l"); END WrapOff;
+
+(* Private *)
+PROCEDURE CursorInvisible; BEGIN CSIq; WriteString("25l"); END CursorInvisible;
+PROCEDURE CursorVisible; BEGIN CSIq; WriteString("25h"); END CursorVisible;
+PROCEDURE ScreenSave; BEGIN CSIq; WriteString("47h"); END ScreenSave;
+PROCEDURE ScreenRestore; BEGIN CSIq; WriteString("47l"); END ScreenRestore;
+PROCEDURE AltBufferOn; BEGIN CSIq; WriteString("1049h"); END AltBufferOn;
+PROCEDURE AltBufferOff; BEGIN CSIq; WriteString("1049l"); END AltBufferOff;
+
+(* Print *)
+PROCEDURE PrintScreen; BEGIN CSI; WriteChar("i"); END PrintScreen;
+PROCEDURE PrintLine; BEGIN CSI; WriteString("1i"); END PrintLine;
+PROCEDURE StopLog; BEGIN CSI; WriteString("4i"); END StopLog;
+PROCEDURE StartLog; BEGIN CSI; WriteString("5i"); END StartLog;
+
+(* Control chars *)
+PROCEDURE Bell; BEGIN WriteChar(CHR(7)); END Bell;
+PROCEDURE Backspace; BEGIN WriteChar(CHR(8)); END Backspace;
+PROCEDURE HTab; BEGIN WriteChar(CHR(9)); END HTab;
+PROCEDURE LineFeed; BEGIN WriteChar(CHR(10)); END LineFeed;
+PROCEDURE VTab; BEGIN WriteChar(CHR(11)); END VTab;
+PROCEDURE FormFeed; BEGIN WriteChar(CHR(12)); END FormFeed;
+PROCEDURE CarriageReturn; BEGIN WriteChar(CHR(13)); END CarriageReturn;
+
+(* Terminal input mode (cf. Editor/Tests/T17.mod): Unbuffered
+   saves the termios state and disables line buffering so device
+   replies can be read char by char; Buffered restores it. *)
+PROCEDURE Unbuffered;
+BEGIN
+  flushFlag := termios.tcsflush();
+  savedTerm := termios.InitTermios();
+  haveTerm := termios.tcgetattr(FIO.StdIn, savedTerm) # -1;
+  IO.UnBufferedMode(0, TRUE);
+  IO.UnBufferedMode(1, TRUE);
+END Unbuffered;
+
+PROCEDURE Buffered;
+VAR res : INTEGER;
+BEGIN
+  IO.BufferedMode(0, TRUE);
+  IO.BufferedMode(1, TRUE);
+  IF haveTerm THEN
+    haveTerm := FALSE;
+    res := termios.tcsetattr(FIO.StdIn, flushFlag, savedTerm);
+  END;
+END Buffered;
+
+END Ansi.

+ 24 - 0
Old/T.mod

@@ -0,0 +1,24 @@
+MODULE TestVT100N?;
+
+(* first test in VT52 mode *)
+
+IMPORT VT100;
+FROM Delay IMPORT Delay;
+FROM STextIO IMPORT WriteString,WriteLn, WriteChar;
+
+VAR
+    i : CARDINAL;
+
+BEGIN
+    (* VT100 mode*)
+   
+    (* clear Screen *)
+    VT100.clearscreen;(* OK *)
+    Delay(2000);
+
+    (* here work to be done*)
+
+    (* set a clean terminal at the end *)
+    Delay(2000);
+    VT100.clearscreen;
+END TestVT100N?.

+ 40 - 0
Old/TestVT100N13.mod

@@ -0,0 +1,40 @@
+MODULE TestVT100N13;
+
+(* first test in VT52 mode *)
+
+IMPORT VT100;
+FROM Delay IMPORT Delay;
+FROM STextIO IMPORT WriteString,WriteLn, WriteChar;
+FROM ASCII IMPORT esc;
+FROM Strings IMPORT Concat, String1, Length;
+FROM NumberIO IMPORT WriteCard, CardToStr, WriteHex;
+
+VAR
+    i           : CARDINAL;
+    str         : ARRAY [0..10] OF CHAR;
+    print       : ARRAY [0..256] OF CHAR;
+    tmpString   : ARRAY [0..10] OF CHAR;
+    tmpString1  : String1;
+    x,y         : CARDINAL;
+ 
+
+
+BEGIN
+    (* VT100 mode*)
+    VT100.InitTerminal;
+    (* clear Screen *)
+    VT100.clearscreen;
+    Delay(2000);
+
+    (* here work to be done*)
+    (* VT100.cursorpos(10,10);
+    VT100.requestCursorPosition(x,y);
+    WriteString("Voici les coordonnées : ");
+    WriteCard(x,5);
+    WriteCard(y,5); *)
+   
+    (* set a clean terminal at the end *)
+    (* Delay(2000); *)
+    (* VT100.clearscreen; *)
+    VT100.CloseTerminal;
+END TestVT100N13.

+ 290 - 0
Old/VT100.def

@@ -0,0 +1,290 @@
+DEFINITION MODULE VT100;
+
+(*
+ The POSIX function cfmakeraw() sets the canonical
+ combination. Applications typically use tcgetattr()
+ to save the current settings, call cfmakeraw() 
+ to switch to raw mode, and call tcsetattr() with 
+ the saved settings on exit to restore the terminal.
+*)
+
+TYPE 
+    screenModes = (M40x25BW,M40x25C,M80x25BW,M80x25C,M320x200C4,M320x200BW,M640x200BW,
+                   M320x200C256,M640x200C,M640x350BW,M640x350C,M640x480BW,M640x480C,M320x200C);
+    Attribut    = (boldAt,dimAt,italicAt,underlineAt,blinkingAt,inverseAt,hiddenAt,
+                   strikethroughAt,doubleunderlineAt);
+
+    Colors      = (Black, Red, Green, Yellow, Blue, Magenta, Cyan, White, Default,
+                    BrightBlack, BrightRed, BrightGreen, BrightYellow, 
+                    BrightBlue, BrighMagenta, BrightCyan, BrightWhite);
+
+
+(*
+ESC Code Sequence 	Reset Sequence 	Description
+ESC[1;34;{...}m 		Set graphics modes for cell, separated by semicolon (;).
+ESC[1m 	ESC[22m 	set bold mode.
+ESC[2m 	ESC[22m 	set dim/faint mode.
+ESC[3m 	ESC[23m 	set italic mode.
+ESC[4m 	ESC[24m 	set underline mode.
+ESC[5m 	ESC[25m 	set blinking mode
+ESC[7m 	ESC[27m 	set inverse/reverse mode
+ESC[8m 	ESC[28m 	set hidden/invisible mode
+ESC[9m 	ESC[29m 	set strikethrough mode.
+ESC[21m ESC[24m    set double underline
+*)
+
+PROCEDURE modesoff; (*OK*)
+(* SGR0 Turn off character attributes          ^[[m *)
+
+PROCEDURE modesoff1; (*OK*)
+(* SGR0 Turn off character attributes          ^[[0m *)
+
+PROCEDURE bold; (*OK*)
+(* SGR1 Turn bold mode on                      ^[[1m *)
+
+PROCEDURE lowint; (*OK*)
+(* SGR2 Turn low intensity mode on             ^[[2m *)
+
+PROCEDURE italic; (*OK*)
+(* set italic mode                              ESC[3m *)
+
+PROCEDURE underline; (*OK*)
+(* SGR4 Turn underline mode on                 ^[[4m *)
+
+PROCEDURE blink; (*OK*)
+(* SGR5 Turn blinking mode on                  ^[[5m *)
+
+PROCEDURE reverse; (*OK*)
+(* SGR7 Turn reverse video on                  ^[[7m *)
+
+PROCEDURE invisible; (*OK*)
+(* SGR8 Turn invisible text mode on            ^[[8m *)
+
+PROCEDURE strikethrough; (*OK*)
+(* ESC[9m 	ESC[29m 	set strikethrough mode. *)
+
+PROCEDURE doubleUnderline;
+(* ESC[21m *)
+
+PROCEDURE resetbold; (*OK*)
+(* SGR1 Turn bold mode on                      ^[[1m *)
+
+PROCEDURE resetlowint; (*OK*)
+(* SGR2 Turn low intensity mode on             ^[[2m *)
+
+PROCEDURE resetitalic; (*OK*)
+(* set italic mode                              ESC[3m *)
+
+PROCEDURE resetunderline; (*OK*)
+(* SGR4 Turn underline mode on                 ^[[4m *)
+
+PROCEDURE resetblink; (*OK*)
+(* SGR5 Turn blinking mode on                  ^[[5m *)
+
+PROCEDURE resetreverse; (*OK*)
+(* SGR7 Turn reverse video on                  ^[[7m *)
+
+PROCEDURE resetinvisible; (*OK*)
+(* SGR8 Turn invisible text mode on            ^[[8m *)
+
+PROCEDURE resetstrikethrough; (*OK*)
+(* ESC[9m 	ESC[29m 	set strikethrough mode. *)
+
+PROCEDURE resetDoubleUnderline;
+(* ESC[24m. *)
+
+(*
+ESC Code Sequence 	Description
+ESC[H 	moves cursor to home position (0, 0)
+ESC[{line};{column}H
+ESC[{line};{column}f 	moves cursor to line #, column #
+ESC[#A 	moves cursor up # lines
+ESC[#B 	moves cursor down # lines
+ESC[#C 	moves cursor right # columns
+ESC[#D 	moves cursor left # columns
+ESC[#E 	moves cursor to beginning of next line, # lines down
+ESC[#F 	moves cursor to beginning of previous line, # lines up
+ESC[#G 	moves cursor to column #
+
+ESC[6n 	request cursor position (reports as ESC[#;#R)
+ESC M 	moves cursor one line up, scrolling if needed
+ESC 7 	save cursor position (DEC)
+ESC 8 	restores the cursor to the last saved position (DEC)
+ESC[s 	save cursor position (SCO)
+ESC[u 	restores the cursor to the last saved position (SCO)
+*)
+
+
+PROCEDURE requestCursorPosition(VAR x,y : CARDINAL);
+(* ESC[6n 	request cursor position (reports as ESC[#;#R) *)
+
+PROCEDURE cursorhome; (*OK*)
+(* Move cursor to upper left corner       ^[[H *)
+
+PROCEDURE cursorhome1; (*OK*)
+(* Move cursor to upper left corner       ^[[;H *)
+
+PROCEDURE cursorpos(x,y: CARDINAL); (*OK*)
+(* CUP Move cursor to screen location v,h     ^[[<v>;<h>H *)
+
+PROCEDURE clearscreen; (* OK *)
+(* ED2 Clear entire screen                    ^[[2J *)
+
+(*
+Screen Modes
+Set Mode
+ESC Code Sequence 	Description
+ESC[={value}h 	Changes the screen width or type to the mode specified by value.
+ESC[=0h 	40 x 25 monochrome (text)
+ESC[=1h 	40 x 25 color (text)
+ESC[=2h 	80 x 25 monochrome (text)
+ESC[=3h 	80 x 25 color (text)
+ESC[=4h 	320 x 200 4-color (graphics)
+ESC[=5h 	320 x 200 monochrome (graphics)
+ESC[=6h 	640 x 200 monochrome (graphics)
+ESC[=7h 	Enables line wrapping
+ESC[=13h 	320 x 200 color (graphics)
+ESC[=14h 	640 x 200 color (16-color graphics)
+ESC[=15h 	640 x 350 monochrome (2-color graphics)
+ESC[=16h 	640 x 350 color (16-color graphics)
+ESC[=17h 	640 x 480 monochrome (2-color graphics)
+ESC[=18h 	640 x 480 color (16-color graphics)
+ESC[=19h 	320 x 200 color (256-color graphics)
+ESC[={value}l 	Resets the mode by using the same values that Set Mode uses, except for 7, which disables line wrapping. The last character in this escape sequence is a lowercase L.
+Common Private Modes
+*)
+PROCEDURE screenMode(mode : screenModes);
+
+PROCEDURE resetScreenMode(mode : screenModes);
+
+PROCEDURE lineWrapping;
+
+PROCEDURE resetLineWrapping;
+
+(*
+These are some examples of private modes, which are not defined by the specification, but are implemented in most terminals.
+ESC Code Sequence 	Description
+ESC[?25l 	make cursor invisible
+ESC[?25h 	make cursor visible
+ESC[?47l 	restore screen
+ESC[?47h 	save screen
+ESC[?1049h 	enables the alternative buffer
+ESC[?1049l 	disables the alternative buffer
+*)
+
+PROCEDURE makeCursorInvisible;
+
+PROCEDURE makeCursorVisible;
+
+PROCEDURE restoreScreen;
+
+PROCEDURE saveScreen;
+
+PROCEDURE enableAlternativeBuffer;
+
+PROCEDURE disableAlternativeBuffer;
+
+(*
+Color codes
+
+Most terminals support 8 and 16 colors, as well as 256 (8-bit) colors. These colors are set by the user, but have commonly defined meanings.
+8-16 Colors
+Color Name 	Foreground Color Code 	Background Color Code
+Black 	30 	40
+Red 	31 	41
+Green 	32 	42
+Yellow 	33 	43
+Blue 	34 	44
+Magenta 	35 	45
+Cyan 	36 	46
+White 	37 	47
+Default 	39 	49
+Reset 	0 	0
+
+    Note: the Reset color is the reset code that resets all colors and text effects, Use Default color to reset colors only.
+
+Most terminals, apart from the basic set of 8 colors, also support the "bright" or "bold" colors. These have their own set of codes, mirroring the normal colors, but with an additional ;1 in their codes:
+
+# Set style to bold, red foreground.
+\x1b[1;31mHello
+# Set style to dimmed white foreground with red background.
+\x1b[2;37;41mWorld
+
+Terminals that support the aixterm specification provides bright versions of the ISO colors, without the need to use the bold modifier:
+Color Name 	Foreground Color Code 	Background Color Code
+Bright Black 	90 	100
+Bright Red 	91 	101
+Bright Green 	92 	102
+Bright Yellow 	93 	103
+Bright Blue 	94 	104
+Bright Magenta 	95 	105
+Bright Cyan 	96 	106
+Bright White 	97 	107
+256 Colors
+
+*)
+
+PROCEDURE setAttribut ( attribut: Attribut; front, back : Colors);
+
+(* 
+#
+#  All codes below are for use in VT52 compatibility mode.
+# 
+*)
+
+PROCEDURE VT52setansi; (*OK*)
+               (* Enter/exit ANSI mode (VT52)            ^[< *)
+
+PROCEDURE VT52altkeypad;
+             (* Enter alternate keypad mode            ^[= *)
+
+PROCEDURE VT52numkeypad;
+             (* Exit alternate keypad mode             ^[> *)
+
+PROCEDURE VT52setgr; (* NOT OK*)
+                 (* Use special graphics character set     ^[F *)
+
+PROCEDURE VT52resetgr; (* NOT OK*)
+               (* Use normal US/UK character set         ^[G *)
+
+PROCEDURE VT52cursorup; (*OK*)
+              (* Move cursor up one line                ^[A *)
+
+PROCEDURE VT52cursordn; (*OK*)
+              (* Move cursor down one line              ^[B *)
+
+PROCEDURE VT52cursorrt; (*OK*)
+              (* Move cursor right one char             ^[C *)
+
+PROCEDURE VT52cursorlf; (*OK*)
+              (* Move cursor left one char              ^[D *)
+
+PROCEDURE VT52cursorhome; (*OK*)
+            (* Move cursor to upper left corner       ^[H *)
+
+PROCEDURE VT52cursorpos(x, y : CARDINAL); (* NOT OK*)
+        (* Move cursor to v,h location            ^[<v><h> *)
+
+PROCEDURE VT52revindex;
+              (* Generate a reverse line-feed           ^[I *)
+
+PROCEDURE VT52cleareol; (*OK*)
+              (* Erase to end of current line           ^[K *)
+
+PROCEDURE VT52cleareos; (*OK*)
+              (* Erase to end of screen                 ^[J *)
+
+PROCEDURE VT52ident;
+                 (* Identify what the terminal is          ^[Z *)
+
+PROCEDURE VT52identresp;
+             (*Correct response to ident             ^[/Z   *) 
+
+PROCEDURE CloseTerminal;
+    (* PROCEDURE tcsetattr (fd: INTEGER; option: INTEGER; t: TERMIOS) : INTEGER ; *)
+
+PROCEDURE InitTerminal;
+(* PROCEDURE tcgetattr (fd: INTEGER; t: TERMIOS) : INTEGER ; *)
+
+
+END VT100.

+ 5 - 0
Old/VT100.def.firsttest

@@ -0,0 +1,5 @@
+DEFINITION MODULE VT100;
+
+PROCEDURE cls;
+
+END VT100.

+ 999 - 0
Old/VT100.mod

@@ -0,0 +1,999 @@
+IMPLEMENTATION MODULE VT100;
+
+IMPORT ASCII;
+FROM STextIO IMPORT WriteString, WriteChar, WriteLn, ReadString;
+FROM NumberIO IMPORT WriteCard, CardToStr,StrToCard;
+FROM Strings IMPORT Concat, Length, String1, Assign, Delete;
+FROM NumberIO IMPORT WriteHex;
+FROM Delay IMPORT Delay;
+IMPORT SplitV1;
+IMPORT termios;
+
+(*
+Name                  DASCII.escription                            ASCII.esc Code
+
+setnl LMN             Set new line mode                      ^[[20h
+setappl DECCKM        Set cursor key to application          ^[[?1h
+setansi DECANM        Set ANSI (versus VT52)                 none
+setcol DECCOLM        Set number of columns to 132           ^[[?3h
+setsmooth DECSCLM     Set smooth scrolling                   ^[[?4h
+setrevscrn DECSCNM    Set reverse video on screen            ^[[?5h
+setorgrel DECOM       Set origin to relative                 ^[[?6h
+setwrap DECAWM        Set auto-wrap mode                     ^[[?7h
+setrep DECARM         Set auto-repeat mode                   ^[[?8h
+setinter DECINLM      Set interlacing mode                   ^[[?9h
+
+setlf LMN             Set line feed mode                     ^[[20l
+setcursor DECCKM      Set cursor key to cursor               ^[[?1l
+setvt52 DECANM        Set VT52 (versus ANSI)                 ^[[?2l
+resetcol DECCOLM      Set number of columns to 80            ^[[?3l
+setjump DECSCLM       Set jump scrolling                     ^[[?4l
+setnormscrn DECSCNM   Set normal video on screen             ^[[?5l
+setorgabs DECOM       Set origin to absolute                 ^[[?6l
+resetwrap DECAWM      Reset auto-wrap mode                   ^[[?7l
+resetrep DECARM       Reset auto-repeat mode                 ^[[?8l
+resetinter DECINLM    Reset interlacing mode                 ^[[?9l
+
+altkeypad DECKPAM     Set alternate keypad mode              ^[=
+numkeypad DECKPNM     Set numeric keypad mode                ^[>
+
+setukg0               Set United Kingdom G0 character set    ^[(A
+setukg1               Set United Kingdom G1 character set    ^[)A
+setusg0               Set United States G0 character set     ^[(B
+setusg1               Set United States G1 character set     ^[)B
+setspecg0             Set G0 special chars. & line set       ^[(0
+setspecg1             Set G1 special chars. & line set       ^[)0
+setaltg0              Set G0 alternate character ROM         ^[(1
+setaltg1              Set G1 alternate character ROM         ^[)1
+setaltspecg0          Set G0 alt char ROM and spec. graphics ^[(2
+setaltspecg1          Set G1 alt char ROM and spec. graphics ^[)2
+
+setss2 SS2            Set single shift 2                     ^[N
+setss3 SS3            Set single shift 3                     ^[O
+
+modesoff SGR0         Turn off character attributes          ^[[m
+modesoff SGR0         Turn off character attributes          ^[[0m
+bold SGR1             Turn bold mode on                      ^[[1m
+lowint SGR2           Turn low intensity mode on             ^[[2m
+underline SGR4        Turn underline mode on                 ^[[4m
+blink SGR5            Turn blinking mode on                  ^[[5m
+reverse SGR7          Turn reverse video on                  ^[[7m
+invisible SGR8        Turn invisible text mode on            ^[[8m
+
+setwin DECSTBM        Set top and bottom line#s of a window  ^[[<v>;<v>r
+
+cursorup(n) CUU       Move cursor up n lines                 ^[[<n>A
+cursordn(n) CUD       Move cursor down n lines               ^[[<n>B
+cursorrt(n) CUF       Move cursor right n lines              ^[[<n>C
+cursorlf(n) CUB       Move cursor left n lines               ^[[<n>D
+cursorhome            Move cursor to upper left corner       ^[[H
+cursorhome            Move cursor to upper left corner       ^[[;H
+cursorpos(v,h) CUP    Move cursor to screen location v,h     ^[[<v>;<h>H
+hvhome                Move cursor to upper left corner       ^[[f
+hvhome                Move cursor to upper left corner       ^[[;f
+hvpos(v,h) CUP        Move cursor to screen location v,h     ^[[<v>;<h>f
+index IND             Move/scroll window up one line         ^[D
+revindex RI           Move/scroll window down one line       ^[M
+nextline NEL          Move to next line                      ^[E
+savecursor DECSC      Save cursor position and attributes    ^[7
+restorecursor DECSC   Restore cursor position and attributes ^[8
+
+tabset HTS            Set a tab at the current column        ^[H
+tabclr TBC            Clear a tab at the current column      ^[[g
+tabclr TBC            Clear a tab at the current column      ^[[0g
+tabclrall TBC         Clear all tabs                         ^[[3g
+
+dhtop DECDHL          Double-height letters, top half        ^[#3
+dhbot DECDHL          Double-height letters, bottom half     ^[#4
+swsh DECSWL           Single width, single height letters    ^[#5
+dwsh DECDWL           Double width, single height letters    ^[#6
+
+cleareol EL0          Clear line from cursor right           ^[[K
+cleareol EL0          Clear line from cursor right           ^[[0K
+clearbol EL1          Clear line from cursor left            ^[[1K
+clearline EL2         Clear entire line                      ^[[2K
+
+cleareos ED0          Clear screen from cursor down          ^[[J
+cleareos ED0          Clear screen from cursor down          ^[[0J
+clearbos ED1          Clear screen from cursor up            ^[[1J
+clearscreen ED2       Clear entire screen                    ^[[2J
+
+devstat DSR           Device status report                   ^[5n
+termok DSR               Response: terminal is OK            ^[0n
+termnok DSR              Response: terminal is not OK        ^[3n
+
+getcursor DSR         Get cursor position                    ^[6n
+cursorpos CPR            Response: cursor is at v,h          ^[<v>;<h>R
+
+ident DA              Identify what terminal type            ^[[c
+ident DA              Identify what terminal type (another)  ^[[0c
+gettype DA               Response: terminal type code n      ^[[?1;<n>0c
+
+reset RIS             Reset terminal to initial state        ^[c
+
+align DECALN          Screen alignment display               ^[#8
+testpu DECTST         Confidence power up test               ^[[2;1y
+testlb DECTST         Confidence loopback test               ^[[2;2y
+testpurep DECTST      Repeat power up test                   ^[[2;9y
+testlbrep DECTST      Repeat loopback test                   ^[[2;10y
+
+ledsoff DECLL0        Turn off all four leds                 ^[[0q
+led1 DECLL1           Turn on LED #1                         ^[[1q
+led2 DECLL2           Turn on LED #2                         ^[[2q
+led3 DECLL3           Turn on LED #3                         ^[[3q
+led4 DECLL4           Turn on LED #4                         ^[[4q
+
+#
+#  All codes below are for use in VT52 compatibility mode.
+#
+
+setansi               Enter/exit ANSI mode (VT52)            ^[<
+
+altkeypad             Enter alternate keypad mode            ^[=
+numkeypad             Exit alternate keypad mode             ^[>
+
+setgr                 Use special graphics character set     ^[F
+resetgr               Use normal US/UK character set         ^[G
+
+cursorup              Move cursor up one line                ^[A
+cursordn              Move cursor down one line              ^[B
+cursorrt              Move cursor right one char             ^[C
+cursorlf              Move cursor left one char              ^[D
+cursorhome            Move cursor to upper left corner       ^[H
+cursorpos(v,h)        Move cursor to v,h location            ^[<v><h>
+revindex              Generate a reverse line-feed           ^[I
+
+cleareol              Erase to end of current line           ^[K
+cleareos              Erase to end of screen                 ^[J
+
+ident                 Identify what the terminal is          ^[Z
+identresp             Correct response to ident              ^[/Z
+
+*)
+
+(*                    VT52 compatibility mode                 *)
+
+TYPE 
+    Array2  = ARRAY[0..1] OF CHAR;  
+    Array3  = ARRAY[0..2] OF CHAR;
+    Array4  = ARRAY[0..3] OF CHAR;
+    Array5  = ARRAY[0..4] OF CHAR;
+    Array6  = ARRAY[0..5] OF CHAR;
+    Array7  = ARRAY[0..6] OF CHAR;
+    Array8  = ARRAY[0..7] OF CHAR;
+    Array10 = ARRAY[0..9] OF CHAR;
+
+
+VAR 
+    theterminal     : termios.TERMIOS;
+    savedFd         : INTEGER;
+
+VAR                 (* cursor *)
+    cursorupStr     : Array4;
+    cursordnStr     : Array4;
+    cursorrtStr     : Array4;
+    cursorlfStr     : Array4;
+    cursorhomeStr   : Array4;
+    cursorposStr    : ARRAY [0..10] OF CHAR;
+    revindexStr     : Array4;
+
+    cleareolStr     : Array4;
+    cleareosStr     : Array4;
+    
+VAR                 (* ident *)
+    identStr        : Array4;
+    identrespStr    : Array5;
+
+VAR                 (* graphic *)
+    setgrStr        : Array4;
+    resetgrStr      : Array4;
+
+VAR                 (* VT52 mode *)
+    setansiStr      : Array4;
+
+VAR                 (* keypad switch *)
+    altkeypadStr    : Array4;
+    numkeypadStr    : Array4;
+
+(*                                    VT100                                      *)
+VAR
+    setnlStr        : Array3;
+    setapplStr      : Array3;
+    setansi1Str     : Array3;
+    setcolStr       : Array3;
+    setsmoothStr    : Array3;
+    setrevscrnStr   : Array3;
+    setorgrelStr    : Array3;
+    setwrapStr      : Array3;
+    setrepStr       : Array3;
+    setinterStr     : Array3;
+
+    setlfStr        : Array3;
+    setcursorStr    : Array3;
+    setvt52Str      : Array3;
+    resetcolStr     : Array3;
+    setjumpStr      : Array3;
+    setnormscrnStr  : Array3;
+    setorgabsStr    : Array3;
+    resetwrapStr    : Array3;
+    resetrepStr     : Array3;
+    resetinterStr   : Array3;
+
+    altkeypad1Str   : Array3;
+    numkeypad1Str   : Array3;
+
+    setukg0Str      : Array3;
+    setukg1Str      : Array3;
+    setusg0Str      : Array3;
+    setusg1Str      : Array3;
+    setspecg0Str    : Array3;
+    setspecg1Str    : Array3;
+    setaltg0Str     : Array3;
+    setaltg1Str     : Array3;
+    setaltspecg0Str : Array3;
+    setaltspecg1Str : Array3;
+
+    setss2Str       : Array3;
+    setss3Str       : Array3;
+
+    modesoff0Str    : Array4;
+    modesoff1Str    : Array5;
+    boldStr         : Array5;
+    lowintStr       : Array5;
+    underlineStr    : Array5;
+    blinkStr        : Array5;
+    reverseStr      : Array5;
+    invisibleStr    : Array5;
+    italicStr       : Array5;
+    strikethroughStr : Array5;
+
+    resetboldStr    : Array6;
+    resetlowintStr  : Array6;
+    resetunderlineStr : Array6;
+    resetblinkStr   : Array6;
+    resetreverseStr : Array6;
+    resetinvisibleStr : Array6;
+    resetitalicStr  : Array6;
+    resetstrikethroughStr : Array6;
+
+    setwinStr       : Array3;
+
+    cursorhome0Str  : Array3;
+    cursorhome1Str  : Array5;
+    hvhome0Str      : Array3;
+    hvhome1Str      : Array3;
+    hvposStr        : Array3;
+    indexStr        : Array3;
+    revindex1Str    : Array3;
+    nextlineStr     : Array3;
+    savecursStr     : Array3;
+    restorecursorStr: Array3;
+    requestCursorPositionStr : Array5;
+    tabsetStr       : Array3;
+    tabclr0Str      : Array3;
+    tabclr1Str      : Array3;
+    tabclrallStr    : Array3;
+
+    dhtopStr        : Array3;
+    dhbotStr        : Array3;
+    swshStr         : Array3;
+    dwshStr         : Array3;
+
+    cleareol0Str    : Array3;
+    cleareol1Str    : Array3;
+    clearbol2Str    : Array3;
+    clearlineStr    : Array3;
+
+    cleareos0Str    : Array3;
+    cleareos1Str    : Array3;
+    clearbos2Str    : Array3;
+    clearscreenStr  : Array5;
+
+    devstatStr      : Array3;
+    termokStr       : Array3;
+    termnokStr      : Array3;
+
+    getcursorStr    : Array3;
+    cursorpos2Str   : Array3;
+    cursorbnlStr    : Array3;
+    cursorblplStr   : Array3;
+    cursottocolStr  : Array3;
+    ident1Str       : Array3;
+    ident2Str       : Array3;
+    gettypeStr      : Array3;
+
+    resetStr        : Array3;
+
+    alignStr        : Array3;
+    testpuStr       : Array3;
+    testlbStr       : Array3;
+    testpurepStr    : Array3;
+    testlbrepStr    : Array3;
+    (* screen modes *)
+    resetScreenModeStr : Array6;
+    ledsoffStr      : Array3;
+    led1Str         : Array3;
+    led2Str         : Array3;
+    led3Str         : Array3;
+    led4Str         : Array3;
+    M40x25BWStr     : Array6;
+    M40x25CStr      : Array6;
+    M80x25BWStr     : Array6;
+    M80x25CStr      : Array6;
+    M320x200C4Str   : Array6;
+    M320x200BWStr   : Array6;
+    M640x200BWStr   : Array6;
+    M320x200C256Str : Array6;
+    M640x200CStr    : Array7;
+    M640x350BWStr   : Array7;
+    M640x350CStr    : Array7;
+    M640x480BWStr   : Array7;
+    M640x480CStr    : Array7;
+    M320x200CStr    : Array7;
+    lineWrappingStr : Array6;
+    resetLineWrappingStr : Array6;
+
+    (* some proprietary extensions *)
+    makeCursorInvisibleStr  : Array7;
+    makeCursorVisibleStr    : Array7;
+    restoreScreenStr        : Array7;
+    saveScreenStr           : Array7;
+    enableAlternativeBufferStr  : Array10;
+    disableAlternativeBufferStr : Array10;
+
+    doubleUnderlineStr      : Array6;
+    resetDoubleUnderlineStr : Array6;
+    
+    (* colors *)
+
+VAR
+    i : CARDINAL;
+
+PROCEDURE affiche ( m : ARRAY OF CHAR; s : ARRAY OF CHAR);
+
+BEGIN
+    WriteString(m);WriteLn;
+    FOR i := 0 TO Length(s) DO
+        WriteHex(ORD(s[i]),2);
+        WriteChar(" ")
+    END; 
+    WriteLn;
+END affiche;
+
+PROCEDURE modesoff; (*OK*)
+(* SGR0 Turn off character attributes          ^[[m *)
+BEGIN
+    WriteString(modesoff0Str)
+END modesoff;
+
+PROCEDURE modesoff1; (*OK*)
+        (* SGR0 Turn off character attributes          ^[[0m *)
+BEGIN
+    WriteString(modesoff1Str)
+END modesoff1;
+
+PROCEDURE bold; (*OK*)
+    (* SGR1 Turn bold mode on                      ^[[1m *)
+BEGIN
+    WriteString(boldStr);
+END bold;
+
+PROCEDURE lowint; (*OK*)
+    (* SGR2 Turn low intensity mode on             ^[[2m *)
+BEGIN
+    WriteString(lowintStr)
+END lowint;
+
+PROCEDURE italic; (*OK*)
+    (* set italic mode                           ESC[3m *)
+BEGIN
+    WriteString(italicStr)
+END italic;
+
+PROCEDURE underline; (*OK*)
+    (* SGR4 Turn underline mode on                 ^[[4m *)
+BEGIN
+    WriteString(underlineStr)
+END underline;
+
+PROCEDURE blink; (*OK*)
+    (* SGR5 Turn blinking mode on                  ^[[5m *)
+BEGIN
+    WriteString(blinkStr)
+END blink;
+
+PROCEDURE reverse; (*OK*)
+    (* SGR7 Turn reverse video on                  ^[[7m *)
+BEGIN
+    WriteString(reverseStr)
+END reverse;
+
+PROCEDURE invisible; (*OK*)
+    (* SGR8 Turn invisible text mode on            ^[[8m *)
+BEGIN
+    WriteString(invisibleStr)
+END invisible;
+
+PROCEDURE strikethrough; (*OK*)
+BEGIN
+    WriteString(strikethroughStr)
+END strikethrough;
+
+PROCEDURE doubleUnderline;
+    (* ESC[21m *)
+BEGIN
+    WriteString(doubleUnderlineStr)
+END doubleUnderline;
+
+PROCEDURE resetbold; (*OK*)
+    (* SGR1 Turn bold mode on                      ^[[21m *)
+
+BEGIN
+    WriteString(resetboldStr)
+END resetbold;
+
+PROCEDURE resetlowint; (*OK*)
+    (* SGR2 Turn low intensity mode on             ^[[22m *)
+BEGIN
+    WriteString(resetlowintStr)
+END resetlowint;
+
+
+PROCEDURE resetitalic; (*OK*)
+    (* set italic mode                              ESC[23m *)
+BEGIN
+    WriteString(resetitalicStr)
+END resetitalic;
+
+
+PROCEDURE resetunderline; (*OK*)
+    (* SGR4 Turn underline mode on                 ^[[24m *)
+BEGIN
+    WriteString(resetunderlineStr)
+END resetunderline;
+
+
+PROCEDURE resetblink; (*OK*)
+    (* SGR5 Turn blinking mode on                  ^[[25m *)
+BEGIN
+    WriteString(resetblinkStr)
+END resetblink;
+
+
+PROCEDURE resetreverse; (*OK*)
+    (* SGR7 Turn reverse video on                  ^[[27m *)
+BEGIN
+    WriteString(resetreverseStr)
+END resetreverse;
+
+
+PROCEDURE resetinvisible; (*OK*)
+    (* SGR8 Turn invisible text mode on            ^[[28m *)
+BEGIN
+    WriteString(resetinvisibleStr)
+END resetinvisible;
+
+
+PROCEDURE resetstrikethrough; (*OK*)
+    (* ESC[9m 	ESC[29m 	set strikethrough mode. *)
+BEGIN
+    WriteString(resetstrikethroughStr)
+END resetstrikethrough;
+
+PROCEDURE resetDoubleUnderline;
+    (* ESC[24m. *)
+BEGIN
+    WriteString(resetDoubleUnderlineStr)
+END resetDoubleUnderline;
+
+
+
+PROCEDURE requestCursorPosition(VAR x,y : CARDINAL);
+    (* ESC[6n 	request cursor position (reports as ESC[#;#R) *)
+
+VAR
+    str          : ARRAY [0..15] OF CHAR;
+    theStructure : SplitV1.Structure;
+
+BEGIN
+    SplitV1.InitStructure(theStructure);
+    (* sending the request *)
+    WriteString(requestCursorPositionStr);
+    (* quering the answer *)
+    ReadString(str);
+    (* extracting coodinates from the answer *)
+    (*PROCEDURE Delete (VAR stringVar: ARRAY OF CHAR; startIndex, numberToDelete: CARDINAL);
+D   eletes at most numberToDelete characters from stringVar, starting at position startIndex.
+    *)
+    Delete(str,0,2);
+    Delete(str,Length(str) -1 ,1);
+    SplitV1.SplitStr(str, ";", theStructure);
+    StrToCard(theStructure[0].element,x);
+    StrToCard(theStructure[1].element,y);
+
+END requestCursorPosition;
+
+PROCEDURE cursorhome; (*OK*)
+    (* Move cursor to upper left corner       ^[[H *)
+BEGIN
+    WriteString(cursorhomeStr)
+END cursorhome;
+
+PROCEDURE cursorhome1; (*OK*)
+    (* Move cursor to upper left corner       ^[[;H *)
+BEGIN
+    WriteString(cursorhome1Str)
+END cursorhome1;
+
+PROCEDURE cursorpos(x,y : CARDINAL); (*OK*)
+    (* CUP Move cursor to screen location v,h     ^[[<v>;<h>H *)
+
+BEGIN
+    WriteString(cursorblplStr);
+END cursorpos;
+
+PROCEDURE clearscreen; (*OK*)
+(* ED2 Clear entire screen                    ^[[2J *)
+BEGIN
+    WriteString(clearscreenStr)
+END clearscreen;
+
+PROCEDURE screenMode(mode : screenModes);
+VAR
+    tmpString   : Array7;
+BEGIN
+    tmpString := "";
+    CASE mode OF
+        M40x25BW:       Assign(M40x25BWStr, tmpString);       |
+        M40x25C:        Assign(M40x25CStr, tmpString);        |
+        M80x25BW:       Assign(M80x25BWStr, tmpString);       |
+        M80x25C:        Assign(M80x25CStr, tmpString);        |
+        M320x200C4:     Assign(M320x200C4Str, tmpString);     |
+        M320x200BW:     Assign(M320x200BWStr, tmpString);     |
+        M640x200BW:     Assign(M640x200BWStr, tmpString);     |
+        M320x200C256:   Assign(M320x200C256Str, tmpString);   |
+        M640x200C:      Assign(M640x200CStr, tmpString);      |
+        M640x350BW:     Assign(M640x350BWStr, tmpString);     |
+        M640x350C:      Assign(M640x350CStr, tmpString);      |
+        M640x480BW:     Assign(M640x480BWStr, tmpString);     |
+        M640x480C:      Assign(M640x480CStr, tmpString);      |
+        M320x200C:      Assign(M320x200CStr, tmpString);
+    END;
+    WriteString(tmpString)
+END screenMode;
+
+PROCEDURE resetScreenMode(mode : screenModes);
+BEGIN
+   WriteString(resetScreenModeStr)
+END resetScreenMode;
+
+PROCEDURE lineWrapping;
+BEGIN
+   WriteString(lineWrappingStr)
+END lineWrapping;
+
+PROCEDURE resetLineWrapping;
+BEGIN
+   WriteString(resetLineWrappingStr)
+END resetLineWrapping;
+
+PROCEDURE makeCursorInvisible;
+BEGIN
+   WriteString(makeCursorInvisibleStr)
+END makeCursorInvisible;
+
+PROCEDURE makeCursorVisible;
+BEGIN
+   WriteString(makeCursorVisibleStr)
+END makeCursorVisible;
+
+PROCEDURE restoreScreen;
+BEGIN
+   WriteString(restoreScreenStr)
+END restoreScreen;
+
+PROCEDURE saveScreen;
+BEGIN
+   WriteString(saveScreenStr)
+END saveScreen;
+
+PROCEDURE enableAlternativeBuffer;
+BEGIN
+   WriteString(enableAlternativeBufferStr)
+END enableAlternativeBuffer;
+
+PROCEDURE disableAlternativeBuffer;
+BEGIN
+   WriteString(disableAlternativeBufferStr)
+END disableAlternativeBuffer;
+
+PROCEDURE setAttribut ( attribut : Attribut; front, back : Colors );
+    (* esc + [ + attribut + ; + front + ; back + m, written directly. *)
+BEGIN
+    WriteChar(ASCII.esc);
+    WriteChar("[");
+    (* attribute *)
+    CASE attribut OF
+      boldAt:           WriteString("1");   |
+      dimAt:            WriteString("2");   |
+      italicAt:         WriteString("3");   |
+      underlineAt:      WriteString("4");   |
+      blinkingAt:       WriteString("5");   |
+      inverseAt:        WriteString("7");   |
+      hiddenAt:         WriteString("8");   |
+      strikethroughAt:  WriteString("9");   |
+      doubleunderlineAt:WriteString("21");
+    END;
+    (* ; *)
+    WriteChar(";");
+    (* front *)
+    CASE front OF
+        Black:          WriteString("30"); |
+        Red:            WriteString("31"); |
+        Green:          WriteString("32"); |
+        Yellow:         WriteString("33"); |
+        Blue:           WriteString("34"); |
+        Magenta:        WriteString("35"); |
+        Cyan:           WriteString("36"); |
+        White:          WriteString("37"); |
+        Default:        WriteString("39"); |
+        BrightBlack:    WriteString("90"); |
+        BrightRed:      WriteString("91"); |
+        BrightGreen:    WriteString("92"); |
+        BrightYellow:   WriteString("93"); |
+        BrightBlue:     WriteString("94"); |
+        BrighMagenta:   WriteString("95"); |
+        BrightCyan:     WriteString("96"); |
+        BrightWhite:    WriteString("97");
+    END;
+    WriteChar(";");
+    (* back *)
+    CASE back OF
+        Black:          WriteString("40");  |
+        Red:            WriteString("41");  |
+        Green:          WriteString("42");  |
+        Yellow:         WriteString("43");  |
+        Blue:           WriteString("44");  |
+        Magenta:        WriteString("45");  |
+        Cyan:           WriteString("46");  |
+        White:          WriteString("47");  |
+        Default:        WriteString("49");  |
+        BrightBlack:    WriteString("100"); |
+        BrightRed:      WriteString("101"); |
+        BrightGreen:    WriteString("102"); |
+        BrightYellow:   WriteString("103"); |
+        BrightBlue:     WriteString("104"); |
+        BrighMagenta:   WriteString("105"); |
+        BrightCyan:     WriteString("106"); |
+        BrightWhite:    WriteString("107");
+    END;
+    (* m *)
+    WriteChar("m")
+END setAttribut;
+
+(* 
+#
+#  All codes below are for use in VT52 compatibility mode.
+# 
+*)
+
+PROCEDURE VT52setansi; (*OK*)
+    (* Enter/exit ANSI mode (VT52)            ^[< *)
+BEGIN
+    WriteString(setansiStr)
+END VT52setansi ;
+
+PROCEDURE VT52altkeypad;
+    (* Enter alternate keypad mode            ^[= *)
+BEGIN
+    WriteString(altkeypadStr)
+END VT52altkeypad;
+
+PROCEDURE VT52numkeypad ;
+    (* Exit alternate keypad mode             ^[> *)
+BEGIN
+    WriteString(numkeypadStr)
+END VT52numkeypad;
+
+PROCEDURE VT52setgr ;
+    (* Use special graphics character set     ^[F *)
+BEGIN
+    WriteString(setgrStr)
+END VT52setgr;
+
+PROCEDURE VT52resetgr;
+    (* Use normal US/UK character set         ^[G *)
+BEGIN
+    WriteString(resetgrStr)
+END VT52resetgr;
+
+PROCEDURE VT52cursorup; (*OK*)
+    (* Move cursor up one line                ^[A *)
+BEGIN
+    WriteString(cursorupStr)
+END VT52cursorup;
+
+PROCEDURE VT52cursordn; (*OK*)
+    (* Move cursor down one line              ^[B *)
+BEGIN
+    WriteString(cursordnStr)
+END VT52cursordn;
+
+PROCEDURE VT52cursorrt; (*OK*)
+    (* Move cursor right one char             ^[C *)
+BEGIN
+    WriteString(cursorrtStr)
+END VT52cursorrt;
+
+PROCEDURE VT52cursorlf; (*OK*)
+    (* Move cursor left one char              ^[D *)
+BEGIN
+    WriteString(cursorlfStr)
+END VT52cursorlf;
+
+PROCEDURE VT52cursorhome; (*OK*)
+    (* Move cursor to upper left corner       ^[H *)
+BEGIN
+    WriteString(cursorhomeStr)
+END VT52cursorhome;
+
+PROCEDURE VT52cursorpos(y ,x : CARDINAL);
+    (* Move cursor to v,h location            ^[<v><h> *)
+    VAR
+        xPos, yPos      : CARDINAL;
+
+BEGIN
+    WriteString(cursorposStr);
+    xPos := x  + 31;
+    yPos := y + 31;
+    (* don't forget to flip x and y *)
+    WriteChar(CHR(yPos));
+    WriteChar(CHR(xPos))
+END VT52cursorpos;
+
+PROCEDURE VT52revindex;
+    (* Generate a reverse line-feed           ^[I *)
+BEGIN
+    WriteString(revindexStr)
+END VT52revindex;
+
+PROCEDURE VT52cleareol; (*OK*)
+    (* Erase to end of current line           ^[K *)
+BEGIN
+    WriteString(cleareolStr)
+END VT52cleareol;
+
+PROCEDURE VT52cleareos; (*OK*)
+    (* Erase to end of screen                 ^[J *)
+BEGIN
+    WriteString(cleareosStr)
+END VT52cleareos;
+
+PROCEDURE VT52ident;
+    (* Identify what the terminal is          ^[Z *)
+BEGIN
+    WriteString(identStr)
+END VT52ident;
+
+PROCEDURE VT52identresp;
+    (* Correct response to ident              ^[/Z *)
+BEGIN
+    WriteString(identrespStr)
+END VT52identresp; 
+
+PROCEDURE CloseTerminal;
+    (* PROCEDURE tcsetattr (fd: INTEGER; option: INTEGER; t: TERMIOS) : INTEGER ; *)
+
+   VAR
+        theResult : INTEGER;
+BEGIN
+    theResult  := termios.tcsetattr(savedFd,termios.lflusho,theterminal);
+    IF theResult <> 0 THEN
+        WriteString(" Terminal state properly restored !")
+    ELSE
+        WriteString("Terminal not properly restored !")
+    END;
+END CloseTerminal;
+
+
+PROCEDURE InitTerminal;
+(* PROCEDURE tcgetattr (fd: INTEGER; t: TERMIOS) : INTEGER ; *)
+
+    VAR
+        theResult : INTEGER;
+BEGIN
+    theterminal := termios.InitTermios();
+    theResult  := termios.tcgetattr(savedFd, theterminal);
+    IF theResult <> -1 THEN
+        WriteString(" Terminal state properly saved !")
+    ELSE
+        WriteString("Terminal state not properly saved")
+    END;
+    termios.cfmakeraw (theterminal) ;
+END InitTerminal;
+
+BEGIN
+    (* VT 52 mode *)
+    Concat(ASCII.esc,"[<",setansiStr);
+
+    Concat(ASCII.esc,"[=",altkeypadStr);
+    Concat(ASCII.esc,"[>",numkeypadStr);
+
+    Concat(ASCII.esc,"[F",setgrStr);
+    Concat(ASCII.esc,"[G",resetgrStr);
+
+    Concat(ASCII.esc,"[A",cursorupStr);
+    Concat(ASCII.esc,"[B",cursordnStr);
+    Concat(ASCII.esc,"[C",cursorrtStr);
+    Concat(ASCII.esc,"[D",cursorlfStr);
+    Concat(ASCII.esc,"[H",cursorhomeStr);
+    Concat(ASCII.esc,"[Y",cursorposStr);
+    Concat(ASCII.esc,"[I",revindexStr);
+
+    Concat(ASCII.esc,"[K",cleareolStr);
+    Concat(ASCII.esc,"[J",cleareosStr);
+
+    Concat(ASCII.esc,"[Z",identStr);
+    Concat(ASCII.esc,"[/Z",identrespStr);
+
+    (* VT100 mode *)
+    Concat(ASCII.esc,"[",setnlStr);
+    Concat(ASCII.esc,"[",setapplStr);
+    Concat(ASCII.esc,"[",setansi1Str);
+    Concat(ASCII.esc,"[",setcolStr);
+    Concat(ASCII.esc,"[",setsmoothStr);
+    Concat(ASCII.esc,"[",setrevscrnStr);
+    Concat(ASCII.esc,"[",setorgrelStr);
+    Concat(ASCII.esc,"[",setwrapStr);
+    Concat(ASCII.esc,"[",setrepStr);
+    Concat(ASCII.esc,"[",setinterStr);
+
+    Concat(ASCII.esc,"[",setlfStr);
+    Concat(ASCII.esc,"[",setcursorStr);
+    Concat(ASCII.esc,"[",setvt52Str);
+    Concat(ASCII.esc,"[",resetcolStr);
+    Concat(ASCII.esc,"[",setjumpStr);
+    Concat(ASCII.esc,"[",setnormscrnStr);
+    Concat(ASCII.esc,"[",setorgabsStr);
+    Concat(ASCII.esc,"[",resetwrapStr);
+    Concat(ASCII.esc,"[",resetrepStr);
+    Concat(ASCII.esc,"[",resetinterStr);
+
+    Concat(ASCII.esc,"[",altkeypad1Str);
+    Concat(ASCII.esc,"[",numkeypad1Str);
+
+    Concat(ASCII.esc,"[",setukg0Str);
+    Concat(ASCII.esc,"[",setukg1Str);
+    Concat(ASCII.esc,"[",setusg0Str);
+    Concat(ASCII.esc,"[",setusg1Str);
+    Concat(ASCII.esc,"[",setspecg0Str);
+    Concat(ASCII.esc,"[",setspecg1Str);
+    Concat(ASCII.esc,"[",setaltg0Str);
+    Concat(ASCII.esc,"[",setaltg1Str);
+    Concat(ASCII.esc,"[",setaltspecg0Str);
+    Concat(ASCII.esc,"[",setaltspecg1Str);
+
+    Concat(ASCII.esc,"[",setss2Str);
+    Concat(ASCII.esc,"[",setss3Str);
+
+    Concat(ASCII.esc,"[m",modesoff0Str);
+    Concat(ASCII.esc,"[0m",modesoff1Str);
+    Concat(ASCII.esc,"[1m",boldStr);
+    Concat(ASCII.esc,"[2m",lowintStr);
+    Concat(ASCII.esc,"[3m",italicStr);
+    Concat(ASCII.esc,"[4m",underlineStr);
+    Concat(ASCII.esc,"[5m",blinkStr);
+    Concat(ASCII.esc,"[7m",reverseStr);
+    Concat(ASCII.esc,"[8m",invisibleStr);
+    Concat(ASCII.esc,"[9m",strikethroughStr);
+
+    Concat(ASCII.esc,"[22m",resetboldStr);
+    Concat(ASCII.esc,"[22m",resetlowintStr);
+    Concat(ASCII.esc,"[23m",resetitalicStr);
+    Concat(ASCII.esc,"[24m",resetunderlineStr);
+    Concat(ASCII.esc,"[25m",resetblinkStr);
+    Concat(ASCII.esc,"[27m",resetreverseStr);
+    Concat(ASCII.esc,"[28m",resetinvisibleStr);
+    Concat(ASCII.esc,"[29m",resetstrikethroughStr);
+
+(*)
+    Concat(ASCII.esc,"[",setwinStr);
+    Concat(ASCII.esc,"[",cursorhome0Str);
+    Concat(ASCII.esc,"[;H",cursorhome1Str);
+    Concat(ASCII.esc,"[6n",requestCursorPositionStr);
+    Concat(ASCII.esc,"[",hvhome0Str);
+    Concat(ASCII.esc,"[",hvhome1Str);
+    Concat(ASCII.esc,"[",cursorbnlStr);
+    Concat(ASCII.esc,"[",cursorblplStr);
+    Concat(ASCII.esc,"[",cursottocolStr);
+    Concat(ASCII.esc,"[",hvposStr);
+    Concat(ASCII.esc,"[",indexStr);
+    Concat(ASCII.esc,"[",revindex1Str);
+    Concat(ASCII.esc,"[",nextlineStr);
+    Concat(ASCII.esc,"[",savecursStr);
+    Concat(ASCII.esc,"[",restorecursorStr);
+
+    Concat(ASCII.esc,"[",tabsetStr);
+    Concat(ASCII.esc,"[",tabclr0Str);
+    Concat(ASCII.esc,"[",tabclr1Str);
+    Concat(ASCII.esc,"[",tabclrallStr);
+
+    Concat(ASCII.esc,"[",dhtopStr);
+    Concat(ASCII.esc,"[",dhbotStr);
+    Concat(ASCII.esc,"[",swshStr);
+    Concat(ASCII.esc,"[",dwshStr);
+
+    Concat(ASCII.esc,"[",cleareol0Str);
+    Concat(ASCII.esc,"[",cleareol1Str);
+    Concat(ASCII.esc,"[",clearbol2Str);
+    Concat(ASCII.esc,"[",clearlineStr);
+
+    Concat(ASCII.esc,"[",cleareos0Str);
+    Concat(ASCII.esc,"[",cleareos1Str);
+    Concat(ASCII.esc,"[",clearbos2Str);
+    Concat(ASCII.esc,"[2J",clearscreenStr);
+
+    Concat(ASCII.esc,"[",devstatStr);
+    Concat(ASCII.esc,"[",termokStr);
+    Concat(ASCII.esc,"[",termnokStr);
+
+    Concat(ASCII.esc,"[",getcursorStr);
+    Concat(ASCII.esc,"[",cursorpos2Str);
+
+    Concat(ASCII.esc,"[",ident1Str);
+    Concat(ASCII.esc,"[",ident2Str);
+    Concat(ASCII.esc,"[",gettypeStr);
+
+    Concat(ASCII.esc,"[",resetStr);
+
+    Concat(ASCII.esc,"[",alignStr);
+    Concat(ASCII.esc,"[",testpuStr);
+    Concat(ASCII.esc,"[",testlbStr);
+    Concat(ASCII.esc,"[",testpurepStr);
+    Concat(ASCII.esc,"[",testlbrepStr);
+
+    Concat(ASCII.esc,"[",ledsoffStr);
+    Concat(ASCII.esc,"[",led1Str);
+    Concat(ASCII.esc,"[",led2Str);
+    Concat(ASCII.esc,"[",led3Str);
+    Concat(ASCII.esc,"[",led4Str);
+*)
+
+    Concat(ASCII.esc,"[=0h",M40x25BWStr);    (*	40 x 25 monochrome (text)*)
+    Concat(ASCII.esc,"[=1h",M40x25CStr);     (* 	40 x 25 color (text)*)
+    Concat(ASCII.esc,"[=2h",M80x25BWStr);  (* 	80 x 25 monochrome (text)*)
+    Concat(ASCII.esc,"[=3h",M80x25CStr);     (* 	80 x 25 color (text)*)
+    Concat(ASCII.esc,"[=4h",M320x200C4Str);   (* 	320 x 200 4-color (graphics)*)
+    Concat(ASCII.esc,"[=5h",M320x200BWStr);  (* 	320 x 200 monochrome (graphics)*)
+    Concat(ASCII.esc,"[=6h",M640x200BWStr);  (* 	640 x 200 monochrome (graphics)*)
+    Concat(ASCII.esc,"[=7h",resetLineWrappingStr);              (* 	Enables line wrapping*)
+    (* [=13h "320x200 color" dropped: it overwrote M640x200BWStr and
+    matches no declared mode variable; see M320x200CStr ([=19h)). *)
+    Concat(ASCII.esc,"[=14h",M640x200CStr);  (* 	640 x 200 color (16-color graphics)*)
+    Concat(ASCII.esc,"[=15h",M640x350BWStr);(* 	640 x 350 monochrome (2-color graphics)*)
+    Concat(ASCII.esc,"[=16h",M640x350CStr);  (* 	640 x 350 color (16-color graphics)*)
+    Concat(ASCII.esc,"[=17h",M640x480BWStr); (*	640 x 480 monochrome (2-color graphics)*)
+    Concat(ASCII.esc,"[=18h",M640x480CStr);  (* 	640 x 480 color (16-color graphics)*)
+    Concat(ASCII.esc,"[=19h",M320x200CStr);  (* 	320 x 200 color (256-color graphics)*)
+    (* ESC[={value}l *)
+
+    Concat(ASCII.esc,"[?25l",makeCursorInvisibleStr); (* ESC[?25l 	make cursor invisible *)
+    Concat(ASCII.esc,"[?25h",makeCursorVisibleStr); (* ESC[?25h 	make cursor visible *)
+    Concat(ASCII.esc,"[?47l",restoreScreenStr); (* ESC[?47l 	restore screen *)
+    Concat(ASCII.esc,"[?47h",saveScreenStr); (* ESC[?47h 	save screen *)
+    Concat(ASCII.esc,"[?1049h",enableAlternativeBufferStr); (* ESC[?1049h 	enables the alternative buffer *)
+    Concat(ASCII.esc,"[?1049l",disableAlternativeBufferStr); (* ESC[?1049l 	disables the alternative buffer *)
+
+    Concat(ASCII.esc,"[28m",resetinvisibleStr);          (* ESC[28m. *)
+    Concat(ASCII.esc,"[21m",doubleUnderlineStr);             (* ESC[21m *)
+    Concat(ASCII.esc,"[24m",resetDoubleUnderlineStr);      (* ESC[24m. *)
+
+END VT100.
+
+   (*Debug*)
+    (* chaine := "toto"; *)
+    (* FOR i := 0 TO Length(tmpString) DO
+        WriteHex(ORD(tmpString[i]),2);
+        WriteChar(" ")
+    END; *)
+    (*End Debug*)

+ 21 - 0
Old/VT100.mod.firsttest

@@ -0,0 +1,21 @@
+IMPLEMENTATION MODULE VT100;
+
+FROM STextIO IMPORT WriteString;
+FROM ASCII IMPORT esc;
+FROM Strings IMPORT Concat;
+
+CONST
+    clearScreenCode = "[2J";
+
+VAR
+    clearScreen : ARRAY [0..5]  OF CHAR;
+
+    PROCEDURE cls;
+    BEGIN
+       WriteString(clearScreen) 
+    END cls;
+
+BEGIN
+    Concat(esc,"[2J",clearScreen);
+    Concat(esc,clearScreenCode,clearScreen);
+END VT100.

+ 74 - 0
Regis.def

@@ -0,0 +1,74 @@
+DEFINITION MODULE Regis;
+
+(*
+  ReGIS vector graphics (DEC VT125/VT240/VT340; xterm built with
+  --enable-regis-graphics; contour).
+  Grounding: VT330/VT340 Programmer Reference Manual Vol.2, via the
+  contour ReGIS reference. Canvas 800x480, origin top-left, Y down.
+  [x,y] absolute, signed [+-dx,+-dy] relative. Commands emitted
+  uppercase (ReGIS is case-insensitive). Wrap pictures in
+  Enter ... Exit (DCS ... ST).
+  L (Load charset) intentionally omitted: recognised but not
+  rendered by common emulators.
+*)
+
+PROCEDURE Enter;        (* DCS 1 p : reset graphics state + clear canvas *)
+PROCEDURE EnterResume;  (* DCS p   : resume, keep previous state *)
+PROCEDURE Exit;         (* ST : back to text mode *)
+
+PROCEDURE ScreenErase;  (* S(E) *)
+PROCEDURE AddressWindow(x0, y0, x1, y1 : CARDINAL); (* S(A[x0,y0][x1,y1]) *)
+
+PROCEDURE MoveTo(x, y : CARDINAL);   (* P[x,y] absolute, no drawing *)
+PROCEDURE MoveRel(dx, dy : INTEGER); (* P signed relative *)
+
+PROCEDURE LineTo(x, y : CARDINAL);   (* V[x,y] *)
+PROCEDURE LineRel(dx, dy : INTEGER); (* V signed relative *)
+PROCEDURE Dot;                       (* V[] plot one dot *)
+PROCEDURE Rect(x0, y0, x1, y1 : CARDINAL); (* outline via P+V *)
+
+PROCEDURE Circle(edgeX, edgeY : CARDINAL); (* C[x,y], centre = cursor *)
+PROCEDURE CircleCenter(cx, cy : CARDINAL); (* C(C)[cx,cy] *)
+PROCEDURE Arc(degrees : INTEGER; x, y : CARDINAL); (* C(A deg)[x,y] *)
+
+PROCEDURE FillTriangle(x1, y1, x2, y2 : CARDINAL);
+(* F(V[x1,y1][x2,y2]), cursor is the first vertex *)
+
+PROCEDURE TextOut(s : ARRAY OF CHAR); (* T'...' ; avoid quotes in s *)
+PROCEDURE TextSize(n : CARDINAL);     (* T(Sn), 0..16 *)
+PROCEDURE TextSizeWH(w, h : CARDINAL);(* T(S[w,h]) custom cell *)
+PROCEDURE TextDir(deg : CARDINAL);    (* T(D..), 45-degree steps *)
+PROCEDURE TextSlant(deg : CARDINAL);  (* T(I..) italic slant *)
+
+PROCEDURE UseColor(reg : CARDINAL); (* W(I reg), 0..15 *)
+PROCEDURE ColorName(c : CHAR);      (* W(I(c)), D R G B C Y M W *)
+PROCEDURE SetRGB(reg, r, g, b : CARDINAL); (* S(M reg(R..G..B..)), 0..100 *)
+PROCEDURE SetHLS(reg, h, l, s : CARDINAL); (* S(M reg(H..L..S..)) *)
+PROCEDURE BgRegister(reg : CARDINAL);      (* S(I reg) background *)
+
+PROCEDURE WriteOverlay;    (* W(V) default *)
+PROCEDURE WriteReplace;    (* W(R) *)
+PROCEDURE WriteComplement; (* W(C) *)
+PROCEDURE WriteErase;      (* W(E) *)
+
+PROCEDURE Pattern(n : CARDINAL);          (* W(P n), 0..9, 1 = solid *)
+PROCEDURE PatternBits(s : ARRAY OF CHAR); (* W(P bits), custom 0/1 string *)
+PROCEDURE LineWidth(n : CARDINAL);        (* W(L n) pixels *)
+PROCEDURE PVMult(n : CARDINAL);           (* W(M n) pixel-vector multiplier *)
+
+PROCEDURE ShadeOn;             (* W(S1) *)
+PROCEDURE ShadeOff;            (* W(S0) *)
+PROCEDURE ShadeRefY(y : CARDINAL); (* W(S[,y]) horizontal reference *)
+
+PROCEDURE MacroDef(name : CHAR); (* @:X ... *)
+PROCEDURE MacroEnd;              (* @; *)
+PROCEDURE MacroRun(name : CHAR); (* @X *)
+PROCEDURE MacroClearAll;         (* @. *)
+
+PROCEDURE ReportPosition; (* R(P) send-only; read reply unbuffered *)
+PROCEDURE ReportError;    (* R(E) send-only *)
+
+PROCEDURE Unbuffered;
+PROCEDURE Buffered;
+
+END Regis.

+ 211 - 0
Regis.mod

@@ -0,0 +1,211 @@
+IMPLEMENTATION MODULE Regis;
+
+IMPORT ASCII;
+FROM STextIO IMPORT WriteChar, WriteString;
+FROM NumberIO IMPORT WriteCard, WriteInt;
+IMPORT IO, termios, FIO;
+
+VAR
+  savedTerm : termios.TERMIOS;
+  flushFlag : INTEGER;
+  haveTerm : BOOLEAN;
+
+PROCEDURE Pair(x, y : CARDINAL); (* [x,y] *)
+BEGIN
+  WriteChar("["); WriteCard(x, 1);
+  WriteChar(","); WriteCard(y, 1);
+  WriteChar("]");
+END Pair;
+
+PROCEDURE Signed(n : INTEGER); (* +n / -n *)
+BEGIN
+  IF n < 0 THEN WriteInt(n, 1);
+  ELSE WriteChar("+"); WriteCard(VAL(CARDINAL, n), 1);
+  END;
+END Signed;
+
+PROCEDURE PairRel(dx, dy : INTEGER); (* [+dx,-dy] *)
+BEGIN
+  WriteChar("["); Signed(dx);
+  WriteChar(","); Signed(dy);
+  WriteChar("]");
+END PairRel;
+
+PROCEDURE Enter; (* DCS 1 p *)
+BEGIN
+  WriteChar(ASCII.esc); WriteChar("P"); WriteString("1p");
+END Enter;
+
+PROCEDURE EnterResume; (* DCS p *)
+BEGIN
+  WriteChar(ASCII.esc); WriteChar("P"); WriteChar("p");
+END EnterResume;
+
+PROCEDURE Exit; (* ST *)
+BEGIN
+  WriteChar(ASCII.esc); WriteChar("\");
+END Exit;
+
+PROCEDURE ScreenErase;
+BEGIN WriteChar("S"); WriteString("(E)"); END ScreenErase;
+
+PROCEDURE AddressWindow(x0, y0, x1, y1 : CARDINAL);
+BEGIN
+  WriteChar("S"); WriteString("(A");
+  Pair(x0, y0); Pair(x1, y1);
+  WriteChar(")");
+END AddressWindow;
+
+PROCEDURE MoveTo(x, y : CARDINAL);
+BEGIN WriteChar("P"); Pair(x, y); END MoveTo;
+
+PROCEDURE MoveRel(dx, dy : INTEGER);
+BEGIN WriteChar("P"); PairRel(dx, dy); END MoveRel;
+
+PROCEDURE LineTo(x, y : CARDINAL);
+BEGIN WriteChar("V"); Pair(x, y); END LineTo;
+
+PROCEDURE LineRel(dx, dy : INTEGER);
+BEGIN WriteChar("V"); PairRel(dx, dy); END LineRel;
+
+PROCEDURE Dot;
+BEGIN WriteChar("V"); WriteString("[]"); END Dot;
+
+PROCEDURE Rect(x0, y0, x1, y1 : CARDINAL);
+BEGIN
+  WriteChar("P"); Pair(x0, y0);
+  WriteChar("V"); Pair(x1, y0);
+  WriteChar("V"); Pair(x1, y1);
+  WriteChar("V"); Pair(x0, y1);
+  WriteChar("V"); Pair(x0, y0);
+END Rect;
+
+PROCEDURE Circle(edgeX, edgeY : CARDINAL);
+BEGIN WriteChar("C"); Pair(edgeX, edgeY); END Circle;
+
+PROCEDURE CircleCenter(cx, cy : CARDINAL);
+BEGIN WriteChar("C"); WriteString("(C)"); Pair(cx, cy); END CircleCenter;
+
+PROCEDURE Arc(degrees : INTEGER; x, y : CARDINAL);
+BEGIN
+  WriteChar("C"); WriteString("(A"); WriteInt(degrees, 1);
+  WriteChar(")"); Pair(x, y);
+END Arc;
+
+PROCEDURE FillTriangle(x1, y1, x2, y2 : CARDINAL);
+BEGIN
+  WriteChar("F"); WriteString("(V");
+  Pair(x1, y1); Pair(x2, y2);
+  WriteChar(")");
+END FillTriangle;
+
+PROCEDURE TextOut(s : ARRAY OF CHAR);
+BEGIN WriteChar("T"); WriteChar("'"); WriteString(s); WriteChar("'"); END TextOut;
+
+PROCEDURE TextSize(n : CARDINAL);
+BEGIN WriteChar("T"); WriteString("(S"); WriteCard(n, 1); WriteChar(")"); END TextSize;
+
+PROCEDURE TextSizeWH(w, h : CARDINAL);
+BEGIN
+  WriteChar("T"); WriteString("(S");
+  Pair(w, h); WriteChar(")");
+END TextSizeWH;
+
+PROCEDURE TextDir(deg : CARDINAL);
+BEGIN WriteChar("T"); WriteString("(D"); WriteCard(deg, 1); WriteChar(")"); END TextDir;
+
+PROCEDURE TextSlant(deg : CARDINAL);
+BEGIN WriteChar("T"); WriteString("(I"); WriteCard(deg, 1); WriteChar(")"); END TextSlant;
+
+PROCEDURE UseColor(reg : CARDINAL);
+BEGIN WriteChar("W"); WriteString("(I"); WriteCard(reg, 1); WriteChar(")"); END UseColor;
+
+PROCEDURE ColorName(c : CHAR);
+BEGIN
+  WriteChar("W"); WriteString("(I(");
+  WriteChar(c); WriteString("))");
+END ColorName;
+
+PROCEDURE SetRGB(reg, r, g, b : CARDINAL);
+BEGIN
+  WriteChar("S"); WriteString("(M"); WriteCard(reg, 1);
+  WriteString("(R"); WriteCard(r, 1);
+  WriteChar("G"); WriteCard(g, 1);
+  WriteChar("B"); WriteCard(b, 1);
+  WriteString("))");
+END SetRGB;
+
+PROCEDURE SetHLS(reg, h, l, s : CARDINAL);
+BEGIN
+  WriteChar("S"); WriteString("(M"); WriteCard(reg, 1);
+  WriteString("(H"); WriteCard(h, 1);
+  WriteChar("L"); WriteCard(l, 1);
+  WriteChar("S"); WriteCard(s, 1);
+  WriteString("))");
+END SetHLS;
+
+PROCEDURE BgRegister(reg : CARDINAL);
+BEGIN WriteChar("S"); WriteString("(I"); WriteCard(reg, 1); WriteChar(")"); END BgRegister;
+
+PROCEDURE WriteOverlay; BEGIN WriteChar("W"); WriteString("(V)"); END WriteOverlay;
+PROCEDURE WriteReplace; BEGIN WriteChar("W"); WriteString("(R)"); END WriteReplace;
+PROCEDURE WriteComplement; BEGIN WriteChar("W"); WriteString("(C)"); END WriteComplement;
+PROCEDURE WriteErase; BEGIN WriteChar("W"); WriteString("(E)"); END WriteErase;
+
+PROCEDURE Pattern(n : CARDINAL);
+BEGIN WriteChar("W"); WriteString("(P"); WriteCard(n, 1); WriteChar(")"); END Pattern;
+
+PROCEDURE PatternBits(s : ARRAY OF CHAR);
+BEGIN WriteChar("W"); WriteString("(P"); WriteString(s); WriteChar(")"); END PatternBits;
+
+PROCEDURE LineWidth(n : CARDINAL);
+BEGIN WriteChar("W"); WriteString("(L"); WriteCard(n, 1); WriteChar(")"); END LineWidth;
+
+PROCEDURE PVMult(n : CARDINAL);
+BEGIN WriteChar("W"); WriteString("(M"); WriteCard(n, 1); WriteChar(")"); END PVMult;
+
+PROCEDURE ShadeOn; BEGIN WriteChar("W"); WriteString("(S1)"); END ShadeOn;
+PROCEDURE ShadeOff; BEGIN WriteChar("W"); WriteString("(S0)"); END ShadeOff;
+
+PROCEDURE ShadeRefY(y : CARDINAL);
+BEGIN WriteChar("W"); WriteString("(S[,"); WriteCard(y, 1); WriteString("])"); END ShadeRefY;
+
+PROCEDURE MacroDef(name : CHAR);
+BEGIN WriteChar("@"); WriteChar(":"); WriteChar(name); END MacroDef;
+
+PROCEDURE MacroEnd;
+BEGIN WriteChar("@"); WriteChar(";"); END MacroEnd;
+
+PROCEDURE MacroRun(name : CHAR);
+BEGIN WriteChar("@"); WriteChar(name); END MacroRun;
+
+PROCEDURE MacroClearAll;
+BEGIN WriteChar("@"); WriteChar("."); END MacroClearAll;
+
+PROCEDURE ReportPosition;
+BEGIN WriteChar("R"); WriteString("(P)"); END ReportPosition;
+
+PROCEDURE ReportError;
+BEGIN WriteChar("R"); WriteString("(E)"); END ReportError;
+
+PROCEDURE Unbuffered;
+BEGIN
+  flushFlag := termios.tcsflush();
+  savedTerm := termios.InitTermios();
+  haveTerm := termios.tcgetattr(FIO.StdIn, savedTerm) # -1;
+  IO.UnBufferedMode(0, TRUE);
+  IO.UnBufferedMode(1, TRUE);
+END Unbuffered;
+
+PROCEDURE Buffered;
+VAR res : INTEGER;
+BEGIN
+  IO.BufferedMode(0, TRUE);
+  IO.BufferedMode(1, TRUE);
+  IF haveTerm THEN
+    haveTerm := FALSE;
+    res := termios.tcsetattr(FIO.StdIn, flushFlag, savedTerm);
+  END;
+END Buffered;
+
+END Regis.

+ 59 - 0
SUMMARY.md

@@ -0,0 +1,59 @@
+# Terminal escape libraries — summary (tag: `terminals-strict-v1`)
+
+Three strict, direct-emitter Modula-2 libraries (gm2 `-fiso`), no `Concat`
+tables. Each procedure writes its bytes via `STextIO` immediately.
+
+## Libraries
+
+* `VT100.def/mod` (`MODULE VT100`) — strict DEC VT100: SGR `0,1,4,5,7`,
+  cursor `H/CUP/HVP/CUU/CUD/CUF/CUB`, `IND/RI/NEL`, `DECSC/DECRC`,
+  erase `EL0/1/2 + ED0/1/2`, `DECSTBM`, tabs, double-size `ESC#3..#8`,
+  LNM + DEC private modes `?1..?9`, keypad `ESC=/ESC>`, charsets
+  `G0/G1 + SS2/SS3`, `DSR/DA/RIS`, LEDs, `DECTST`. No VT52, no DOS
+  screen modes, no xterm, no colors.
+* `VT52.def/mod` (`MODULE VT52`) — strict DEC VT52 (17 procs): `ESC </=/>`,
+  charsets `F/G`, cursor `A/B/C/D/H`, `ESC Y` direct address (+31 offset,
+  row first), `I/K/J/Z//Z`.
+* `Ansi.def/mod` (`MODULE Ansi`) — modern superset per `docs/VT100-3.txt`:
+  cursor incl. `E/F/G/s/u`, erase incl. `3J`, SGR `0-9` + resets,
+  `SetAttr`, 16 colors + `Default`, `38;5/48;5`, `38;2/48;2` RGB,
+  DOS `ESC[=`, private `?25/?47/?1049`, print `i/1i/4i/5i`, BEL..CR.
+* All three export `Unbuffered` / `Buffered` (termios save + 
+  `IO.UnBufferedMode`, restore + `BufferedMode`; pattern from
+  `../Editor/Tests/T17.mod`) so device replies (CPR `ESC[row;colR`)
+  can be read char-by-char with `IO.Read`, no RETURN needed.
+
+## Tests (`tests/`, all link clean)
+
+* `TestVT100*` (11): SGR, Cursor, Scroll, Erase, Tabs, Size,
+  Modes, Keypad, Charset, Reports, LedTest.
+* `TestVT52*` (4): Mode, Cursor, Erase, Ident.
+* `TestAnsi*` (7): Cursor, Erase, SGR, Color, Modes, Print,
+  RequestPosition (live CPR query, prints `Row=/Col=`).
+* `testSplit.mod` (SplitV1 helper, kept from original code).
+
+## Build
+
+`sh build.sh` — compiles `SplitV1 + VT100 + VT52 + Ansi`, links every
+test. Full suite exit 0. Byte-verified via `od`: `ESC[0m/1m`,
+`ESC[3;7H`, `ESC[2J`, `ESC[?3h`, `ESC(0`, `ESCc`, `ESC[38;5;200m`,
+`ESC[38;2;255;0;128m`, `ESC[?1049h`, `ESC[i`, `ESC Y $ )`, `ESC / Z`.
+
+## Archive
+
+`Old/` keeps the superseded originals untouched: firsttest files,
+pre-promotion `VT100.def/mod`, old-API tests (`TestVT100N13`, `T`).
+`docs/` holds the VT100/VT52 reference material plus `regis-cli.txt`.
+
+## ReGIS
+
+`Regis.def/mod` (`MODULE Regis`) — ReGIS vector graphics for xterm
+(built with `--enable-regis-graphics`) and contour, grounded in the
+VT330/VT340 PRM via the contour ReGIS reference: `Enter` (`DCS 1 p`)
+/ `EnterResume` (`DCS p`) / `Exit` (`ST`), `S(E)`, address window,
+`P/V` absolute + signed-relative, `Dot`, `Rect`, `C` circle variants +
+arcs, `F(V)` triangle fill, `T` text + size/dir/slant, `W` colors
+(index/named/RGB/HLS), modes, patterns, widths, shading, `@`
+macrographs, `R` reports (send-only), `Unbuffered/Buffered`.
+Tests: `TestRegisDemo/Color/Macro`. See `docs/regis-cli.txt` for
+shell one-liners and support detection (`CSI c` contains `;3`).

+ 28 - 0
SplitV1.def

@@ -0,0 +1,28 @@
+DEFINITION MODULE SplitV1;
+
+TYPE
+  Element = RECORD
+              pos : CARDINAL;
+              element : ARRAY[0..255] OF CHAR;
+            END;  
+  Structure = ARRAY[0..20] OF Element;    
+ 
+VAR 
+  trimMode    : BOOLEAN;
+  allTrimMode : BOOLEAN;
+  noDupMode   : BOOLEAN;
+  rtrim       : BOOLEAN;
+  ltrim       : BOOLEAN;
+  
+                  
+PROCEDURE Ltrim ( VAR src : ARRAY OF CHAR; separator : CHAR  );
+  
+PROCEDURE Rtrim ( VAR src : ARRAY OF CHAR ; separator : CHAR );
+    
+PROCEDURE removeDuplicate ( VAR src : ARRAY OF CHAR ; separator : CHAR );             
+                  
+PROCEDURE SplitStr(s : ARRAY OF CHAR; separator : CHAR; VAR out : Structure); 
+
+PROCEDURE InitStructure ( VAR out : Structure);
+
+END SplitV1.

+ 157 - 0
SplitV1.mod

@@ -0,0 +1,157 @@
+IMPLEMENTATION MODULE SplitV1;
+
+IMPORT Strings;
+FROM InOut IMPORT Write, WriteString, WriteCard, WriteLn;
+
+VAR
+  j : CARDINAL;
+  
+PROCEDURE Ltrim (VAR src : ARRAY OF CHAR; separator : CHAR  );
+
+VAR
+  longueur : CARDINAL;
+  
+  BEGIN
+    REPEAT
+      longueur := LENGTH(src);
+      IF src[0] = separator THEN
+      	(*PROCEDURE Delete (VAR stringVar: ARRAY OF CHAR; startIndex, numberToDelete:CARDINAL);*)
+        (* Deletes at most numberToDelete characters from stringVar, starting at position startIndex.*)
+        Strings.Delete(src,0,1);
+      END;  
+    UNTIL (src[0] # separator) OR (longueur = 0)
+  END Ltrim;     
+  
+PROCEDURE Rtrim ( VAR src : ARRAY OF CHAR ; separator : CHAR );
+
+VAR
+  longueur : CARDINAL;
+  
+  BEGIN
+    longueur := LENGTH(src);
+    REPEAT
+      longueur := LENGTH(src);
+      IF src[longueur - 1] = separator THEN
+      	(*PROCEDURE Delete (VAR stringVar: ARRAY OF CHAR; startIndex, numberToDelete:CARDINAL);*)
+        (* Deletes at most numberToDelete characters from stringVar, starting at position startIndex.*)
+        Strings.Delete(src,longueur - 1,1);
+      END;  
+      longueur := LENGTH(src);
+    UNTIL (src[longueur - 1] # separator) OR (longueur =0 ) 
+   END Rtrim;  
+  
+PROCEDURE removeDuplicate ( VAR src : ARRAY OF CHAR ; separator : CHAR );             
+
+VAR
+  longueur : CARDINAL;
+  pos      : CARDINAL;
+  
+  BEGIN
+    pos := 0;
+    longueur := LENGTH(src);
+    LOOP
+      IF (longueur = 0 ) OR (pos = longueur ) THEN
+        RETURN
+      END;
+      (*Write(src[pos]);Write(" ");*)
+      IF src[pos] = separator THEN 
+        pos := pos + 1;
+        WHILE src[pos] = separator DO 
+          Strings.Delete(src,pos,1);
+        END; 
+      ELSE 
+        INC(pos) 
+      END;  
+      longueur := LENGTH(src);
+    END; (* end loop*)
+  END removeDuplicate;   
+  
+PROCEDURE SplitStr(s : ARRAY OF CHAR; separator : CHAR; VAR out : Structure) ;
+
+(*
+  There are several cases to take account for :
+  - standard case : s begin with an element and end with an element
+  - s begins with a separator and end with an element
+  - s begins with a separator and ends with a separators
+  - there are consecutive separators inside s
+  - there are consecutive separators at the beginning
+  - there are consecutive separators at the end
+*)
+
+VAR 
+  i : CARDINAL;
+  indice : CARDINAL;
+  longueur : CARDINAL;
+  resultat : ARRAY[0..255] OF CHAR;
+  deja : BOOLEAN;
+  c : CHAR;
+  
+  BEGIN
+    indice := 0; 
+    (* modes de fonctionnement *)
+    (*  trimMode    : BOOLEAN;
+        allTrimMode : BOOLEAN;
+        noDupMode   : BOOLEAN;
+        rtrim       : BOOLEAN;
+        ltrim       : BOOLEAN;*)
+    IF trimMode THEN
+      Rtrim ( s, separator);
+      Ltrim ( s, separator);
+    END;
+    
+    IF ltrim THEN
+      Ltrim ( s, separator);
+    END;
+    
+    IF rtrim THEN
+      Rtrim ( s, separator);
+    END;    
+    
+    IF noDupMode THEN
+      removeDuplicate ( s, separator);
+    END;
+    
+    IF allTrimMode THEN
+      Rtrim ( s, separator);
+      Ltrim ( s, separator);
+      removeDuplicate ( s, separator);
+    END;  
+    
+    longueur := LENGTH(s);
+    resultat := "";
+    deja := FALSE;
+    FOR i := 0 TO longueur -1 DO
+      c := s[i]; 						(* the first character of the string s *)
+      IF c # separator THEN 					(* the character belongs to an element *)
+         Strings.Append(Strings.String1(c),resultat);
+      ELSE
+        out[indice].element := resultat;
+        resultat := ""; 
+        INC(indice);
+      END;
+      out[indice].element := resultat;
+    END;
+    FOR i := indice + 1 TO HIGH(out) DO 
+      out[i].pos := MAX(CARDINAL);
+    END;
+  END SplitStr;
+
+PROCEDURE InitStructure ( VAR out : Structure);
+
+VAR 
+  i : CARDINAL;
+  
+BEGIN 
+  FOR i := 0 TO HIGH(out)   DO
+    out[i].pos := i;
+    out[i].element := "";
+  END;
+END InitStructure;
+
+BEGIN 
+  trimMode    := FALSE;
+  allTrimMode := FALSE;
+  noDupMode   := FALSE;
+  ltrim       := FALSE;
+  rtrim       := FALSE; 
+END SplitV1. 

+ 123 - 0
VT100.def

@@ -0,0 +1,123 @@
+DEFINITION MODULE VT100;
+
+(*
+  Strict DEC VT100 escape sequences.
+  No VT52 compat, no DOS screen modes, no xterm extensions,
+  no colors. Pure CSI/ESC emitter, plus Unbuffered/Buffered
+  input-mode helpers (termios) for reading device replies.
+  Reference: DEC VT100 User Guide (EK-VT100-UG).
+*)
+
+(* SGR - character attributes (VT100: 0,1,4,5,7 only) *)
+PROCEDURE ResetAttributes;  (* SGR0  ESC[0m *)
+PROCEDURE Bold;             (* SGR1  ESC[1m *)
+PROCEDURE Underline;        (* SGR4  ESC[4m *)
+PROCEDURE Blink;            (* SGR5  ESC[5m *)
+PROCEDURE Reverse;          (* SGR7  ESC[7m *)
+
+(* Cursor movement *)
+PROCEDURE CursorHome;                          (* ESC[H *)
+PROCEDURE CursorPosition(line, col : CARDINAL); (* CUP ESC[line;colH *)
+PROCEDURE HVPosition(line, col : CARDINAL);     (* HVP ESC[line;colf *)
+PROCEDURE CursorUp(n : CARDINAL);               (* CUU ESC[nA *)
+PROCEDURE CursorDown(n : CARDINAL);             (* CUD ESC[nB *)
+PROCEDURE CursorRight(n : CARDINAL);            (* CUF ESC[nC *)
+PROCEDURE CursorLeft(n : CARDINAL);             (* CUB ESC[nD *)
+
+(* Scroll / line movement *)
+PROCEDURE Index;           (* IND ESC D *)
+PROCEDURE ReverseIndex;    (* RI  ESC M *)
+PROCEDURE NextLine;        (* NEL ESC E *)
+
+(* Cursor save / restore (DEC) *)
+PROCEDURE SaveCursor;      (* DECSC  ESC 7 *)
+PROCEDURE RestoreCursor;   (* DECRC  ESC 8 *)
+
+(* Erase in line / screen *)
+PROCEDURE ClearLineRight;  (* EL0 ESC[K  / ESC[0K *)
+PROCEDURE ClearLineLeft;   (* EL1 ESC[1K *)
+PROCEDURE ClearLine;       (* EL2 ESC[2K *)
+PROCEDURE ClearScreenDown; (* ED0 ESC[J  / ESC[0J *)
+PROCEDURE ClearScreenUp;   (* ED1 ESC[1J *)
+PROCEDURE ClearScreen;     (* ED2 ESC[2J *)
+
+(* Scrolling region *)
+PROCEDURE SetScrollRegion(top, bottom : CARDINAL); (* DECSTBM ESC[top;bottomr *)
+
+(* Tabs *)
+PROCEDURE TabSet;          (* HTS ESC H *)
+PROCEDURE TabClear;        (* TBC ESC[g  / ESC[0g *)
+PROCEDURE TabClearAll;     (* TBC ESC[3g *)
+
+(* Double-size / alignment *)
+PROCEDURE DoubleHeightTop;    (* DECDHL ESC#3 *)
+PROCEDURE DoubleHeightBottom; (* DECDHL ESC#4 *)
+PROCEDURE SingleWidth;        (* DECSWL ESC#5 *)
+PROCEDURE DoubleWidth;        (* DECDWL ESC#6 *)
+PROCEDURE ScreenAlign;        (* DECALN ESC#8 *)
+
+(* LNM / DEC private modes *)
+PROCEDURE SetNewLine;        (* LNM     ESC[20h *)
+PROCEDURE ResetNewLine;      (* LNM     ESC[20l *)
+PROCEDURE SetAppCursorKeys;  (* DECCKM  ESC[?1h *)
+PROCEDURE SetCursorKeys;     (* DECCKM  ESC[?1l *)
+PROCEDURE SetANSI;           (* DECANM  ESC[?2h *)
+PROCEDURE SetVT52;           (* DECANM  ESC[?2l *)
+PROCEDURE Set132Columns;     (* DECCOLM ESC[?3h *)
+PROCEDURE Set80Columns;      (* DECCOLM ESC[?3l *)
+PROCEDURE SetSmoothScroll;   (* DECSCLM ESC[?4h *)
+PROCEDURE SetJumpScroll;     (* DECSCLM ESC[?4l *)
+PROCEDURE SetReverseScreen;  (* DECSCNM ESC[?5h *)
+PROCEDURE SetNormalScreen;   (* DECSCNM ESC[?5l *)
+PROCEDURE SetRelativeOrigin; (* DECOM   ESC[?6h *)
+PROCEDURE SetAbsoluteOrigin; (* DECOM   ESC[?6l *)
+PROCEDURE SetAutoWrap;       (* DECAWM  ESC[?7h *)
+PROCEDURE ResetAutoWrap;     (* DECAWM  ESC[?7l *)
+PROCEDURE SetAutoRepeat;     (* DECARM  ESC[?8h *)
+PROCEDURE ResetAutoRepeat;   (* DECARM  ESC[?8l *)
+PROCEDURE SetInterlace;      (* DECINLM ESC[?9h *)
+PROCEDURE ResetInterlace;    (* DECINLM ESC[?9l *)
+
+(* Keypad *)
+PROCEDURE SetAltKeypad;  (* DECKPAM ESC= *)
+PROCEDURE SetNumKeypad;  (* DECKPNM ESC> *)
+
+(* Character sets *)
+PROCEDURE SetUK_G0;      (* ESC(A *)
+PROCEDURE SetUS_G0;      (* ESC(B *)
+PROCEDURE SetGraphics_G0;(* ESC(0 *)
+PROCEDURE SetAlt_G0;     (* ESC(1 *)
+PROCEDURE SetAltGraph_G0;(* ESC(2 *)
+PROCEDURE SetUK_G1;      (* ESC)A *)
+PROCEDURE SetUS_G1;      (* ESC)B *)
+PROCEDURE SetGraphics_G1;(* ESC)0 *)
+PROCEDURE SetAlt_G1;     (* ESC)1 *)
+PROCEDURE SetAltGraph_G1;(* ESC)2 *)
+PROCEDURE Shift2;        (* SS2 ESC N *)
+PROCEDURE Shift3;        (* SS3 ESC O *)
+
+(* Reports / identification / reset *)
+PROCEDURE RequestDeviceStatus;   (* DSR ESC[5n *)
+PROCEDURE RequestCursorPosition; (* DSR ESC[6n, response ESC[line;colR *)
+PROCEDURE Identify;              (* DA  ESC[c *)
+PROCEDURE Identify2;             (* DA  ESC[0c *)
+PROCEDURE ResetTerminal;         (* RIS ESC c *)
+
+(* LEDs / confidence tests *)
+PROCEDURE LedsOff;  (* DECLL ESC[0q *)
+PROCEDURE Led1;     (* DECLL ESC[1q *)
+PROCEDURE Led2;     (* DECLL ESC[2q *)
+PROCEDURE Led3;     (* DECLL ESC[3q *)
+PROCEDURE Led4;     (* DECLL ESC[4q *)
+PROCEDURE TestPowerUp;   (* DECTST ESC[2;1y *)
+PROCEDURE TestLoopback;  (* DECTST ESC[2;2y *)
+PROCEDURE TestPowerRepeat;  (* DECTST ESC[2;9y *)
+PROCEDURE TestLoopRepeat;   (* DECTST ESC[2;10y *)
+
+(* Terminal input mode: call Unbuffered before reading device
+   replies (e.g. CPR) so no RETURN key is needed; call
+   Buffered afterwards to restore the saved state. *)
+PROCEDURE Unbuffered;
+PROCEDURE Buffered;
+
+END VT100.

+ 228 - 0
VT100.mod

@@ -0,0 +1,228 @@
+IMPLEMENTATION MODULE VT100;
+
+IMPORT ASCII;
+FROM STextIO IMPORT WriteString, WriteChar;
+FROM NumberIO IMPORT WriteCard;
+IMPORT IO, termios, FIO;
+
+VAR
+  savedTerm : termios.TERMIOS;
+  flushFlag : INTEGER;
+  haveTerm : BOOLEAN;
+
+(* helper: ESC [ *)
+PROCEDURE CSI;
+BEGIN
+  WriteChar(ASCII.esc);
+  WriteChar("[");
+END CSI;
+
+PROCEDURE CSIPriv; (* ESC [ ? *)
+BEGIN
+  WriteChar(ASCII.esc);
+  WriteString("[?");
+END CSIPriv;
+
+(* SGR *)
+PROCEDURE ResetAttributes;
+BEGIN CSI; WriteString("0m"); END ResetAttributes;
+
+PROCEDURE Bold;
+BEGIN CSI; WriteString("1m"); END Bold;
+
+PROCEDURE Underline;
+BEGIN CSI; WriteString("4m"); END Underline;
+
+PROCEDURE Blink;
+BEGIN CSI; WriteString("5m"); END Blink;
+
+PROCEDURE Reverse;
+BEGIN CSI; WriteString("7m"); END Reverse;
+
+(* Cursor *)
+PROCEDURE CursorHome;
+BEGIN CSI; WriteChar("H"); END CursorHome;
+
+PROCEDURE CursorPosition(line, col : CARDINAL);
+BEGIN
+  CSI; WriteCard(line, 1); WriteChar(";"); WriteCard(col, 1); WriteChar("H");
+END CursorPosition;
+
+PROCEDURE HVPosition(line, col : CARDINAL);
+BEGIN
+  CSI; WriteCard(line, 1); WriteChar(";"); WriteCard(col, 1); WriteChar("f");
+END HVPosition;
+
+PROCEDURE CursorUp(n : CARDINAL);
+BEGIN CSI; WriteCard(n, 1); WriteChar("A"); END CursorUp;
+
+PROCEDURE CursorDown(n : CARDINAL);
+BEGIN CSI; WriteCard(n, 1); WriteChar("B"); END CursorDown;
+
+PROCEDURE CursorRight(n : CARDINAL);
+BEGIN CSI; WriteCard(n, 1); WriteChar("C"); END CursorRight;
+
+PROCEDURE CursorLeft(n : CARDINAL);
+BEGIN CSI; WriteCard(n, 1); WriteChar("D"); END CursorLeft;
+
+PROCEDURE Index;
+BEGIN WriteChar(ASCII.esc); WriteChar("D"); END Index;
+
+PROCEDURE ReverseIndex;
+BEGIN WriteChar(ASCII.esc); WriteChar("M"); END ReverseIndex;
+
+PROCEDURE NextLine;
+BEGIN WriteChar(ASCII.esc); WriteChar("E"); END NextLine;
+
+PROCEDURE SaveCursor;
+BEGIN WriteChar(ASCII.esc); WriteChar("7"); END SaveCursor;
+
+PROCEDURE RestoreCursor;
+BEGIN WriteChar(ASCII.esc); WriteChar("8"); END RestoreCursor;
+
+(* Erase *)
+PROCEDURE ClearLineRight;
+BEGIN CSI; WriteChar("K"); END ClearLineRight;
+
+PROCEDURE ClearLineLeft;
+BEGIN CSI; WriteString("1K"); END ClearLineLeft;
+
+PROCEDURE ClearLine;
+BEGIN CSI; WriteString("2K"); END ClearLine;
+
+PROCEDURE ClearScreenDown;
+BEGIN CSI; WriteChar("J"); END ClearScreenDown;
+
+PROCEDURE ClearScreenUp;
+BEGIN CSI; WriteString("1J"); END ClearScreenUp;
+
+PROCEDURE ClearScreen;
+BEGIN CSI; WriteString("2J"); END ClearScreen;
+
+PROCEDURE SetScrollRegion(top, bottom : CARDINAL);
+BEGIN
+  CSI; WriteCard(top, 1); WriteChar(";"); WriteCard(bottom, 1); WriteChar("r");
+END SetScrollRegion;
+
+(* Tabs *)
+PROCEDURE TabSet;
+BEGIN WriteChar(ASCII.esc); WriteChar("H"); END TabSet;
+
+PROCEDURE TabClear;
+BEGIN CSI; WriteChar("g"); END TabClear;
+
+PROCEDURE TabClearAll;
+BEGIN CSI; WriteString("3g"); END TabClearAll;
+
+(* Double-size / alignment *)
+PROCEDURE DoubleHeightTop;
+BEGIN WriteChar(ASCII.esc); WriteString("#3"); END DoubleHeightTop;
+
+PROCEDURE DoubleHeightBottom;
+BEGIN WriteChar(ASCII.esc); WriteString("#4"); END DoubleHeightBottom;
+
+PROCEDURE SingleWidth;
+BEGIN WriteChar(ASCII.esc); WriteString("#5"); END SingleWidth;
+
+PROCEDURE DoubleWidth;
+BEGIN WriteChar(ASCII.esc); WriteString("#6"); END DoubleWidth;
+
+PROCEDURE ScreenAlign;
+BEGIN WriteChar(ASCII.esc); WriteString("#8"); END ScreenAlign;
+
+(* Modes *)
+PROCEDURE SetNewLine; BEGIN CSI; WriteString("20h"); END SetNewLine;
+PROCEDURE ResetNewLine; BEGIN CSI; WriteString("20l"); END ResetNewLine;
+
+PROCEDURE SetAppCursorKeys; BEGIN CSIPriv; WriteString("1h"); END SetAppCursorKeys;
+PROCEDURE SetCursorKeys; BEGIN CSIPriv; WriteString("1l"); END SetCursorKeys;
+PROCEDURE SetANSI; BEGIN CSIPriv; WriteString("2h"); END SetANSI;
+PROCEDURE SetVT52; BEGIN CSIPriv; WriteString("2l"); END SetVT52;
+PROCEDURE Set132Columns; BEGIN CSIPriv; WriteString("3h"); END Set132Columns;
+PROCEDURE Set80Columns; BEGIN CSIPriv; WriteString("3l"); END Set80Columns;
+PROCEDURE SetSmoothScroll; BEGIN CSIPriv; WriteString("4h"); END SetSmoothScroll;
+PROCEDURE SetJumpScroll; BEGIN CSIPriv; WriteString("4l"); END SetJumpScroll;
+PROCEDURE SetReverseScreen; BEGIN CSIPriv; WriteString("5h"); END SetReverseScreen;
+PROCEDURE SetNormalScreen; BEGIN CSIPriv; WriteString("5l"); END SetNormalScreen;
+PROCEDURE SetRelativeOrigin; BEGIN CSIPriv; WriteString("6h"); END SetRelativeOrigin;
+PROCEDURE SetAbsoluteOrigin; BEGIN CSIPriv; WriteString("6l"); END SetAbsoluteOrigin;
+PROCEDURE SetAutoWrap; BEGIN CSIPriv; WriteString("7h"); END SetAutoWrap;
+PROCEDURE ResetAutoWrap; BEGIN CSIPriv; WriteString("7l"); END ResetAutoWrap;
+PROCEDURE SetAutoRepeat; BEGIN CSIPriv; WriteString("8h"); END SetAutoRepeat;
+PROCEDURE ResetAutoRepeat; BEGIN CSIPriv; WriteString("8l"); END ResetAutoRepeat;
+PROCEDURE SetInterlace; BEGIN CSIPriv; WriteString("9h"); END SetInterlace;
+PROCEDURE ResetInterlace; BEGIN CSIPriv; WriteString("9l"); END ResetInterlace;
+
+(* Keypad *)
+PROCEDURE SetAltKeypad;
+BEGIN WriteChar(ASCII.esc); WriteChar("="); END SetAltKeypad;
+
+PROCEDURE SetNumKeypad;
+BEGIN WriteChar(ASCII.esc); WriteChar(">"); END SetNumKeypad;
+
+(* Charsets *)
+PROCEDURE SetUK_G0; BEGIN WriteChar(ASCII.esc); WriteString("(A"); END SetUK_G0;
+PROCEDURE SetUS_G0; BEGIN WriteChar(ASCII.esc); WriteString("(B"); END SetUS_G0;
+PROCEDURE SetGraphics_G0; BEGIN WriteChar(ASCII.esc); WriteString("(0"); END SetGraphics_G0;
+PROCEDURE SetAlt_G0; BEGIN WriteChar(ASCII.esc); WriteString("(1"); END SetAlt_G0;
+PROCEDURE SetAltGraph_G0; BEGIN WriteChar(ASCII.esc); WriteString("(2"); END SetAltGraph_G0;
+PROCEDURE SetUK_G1; BEGIN WriteChar(ASCII.esc); WriteString(")A"); END SetUK_G1;
+PROCEDURE SetUS_G1; BEGIN WriteChar(ASCII.esc); WriteString(")B"); END SetUS_G1;
+PROCEDURE SetGraphics_G1; BEGIN WriteChar(ASCII.esc); WriteString(")0"); END SetGraphics_G1;
+PROCEDURE SetAlt_G1; BEGIN WriteChar(ASCII.esc); WriteString(")1"); END SetAlt_G1;
+PROCEDURE SetAltGraph_G1; BEGIN WriteChar(ASCII.esc); WriteString(")2"); END SetAltGraph_G1;
+PROCEDURE Shift2; BEGIN WriteChar(ASCII.esc); WriteChar("N"); END Shift2;
+PROCEDURE Shift3; BEGIN WriteChar(ASCII.esc); WriteChar("O"); END Shift3;
+
+(* Reports / reset *)
+PROCEDURE RequestDeviceStatus;
+BEGIN CSI; WriteString("5n"); END RequestDeviceStatus;
+
+PROCEDURE RequestCursorPosition;
+BEGIN CSI; WriteString("6n"); END RequestCursorPosition;
+
+PROCEDURE Identify;
+BEGIN CSI; WriteChar("c"); END Identify;
+
+PROCEDURE Identify2;
+BEGIN CSI; WriteString("0c"); END Identify2;
+
+PROCEDURE ResetTerminal;
+BEGIN WriteChar(ASCII.esc); WriteChar("c"); END ResetTerminal;
+
+(* LEDs / tests *)
+PROCEDURE LedsOff; BEGIN CSI; WriteString("0q"); END LedsOff;
+PROCEDURE Led1; BEGIN CSI; WriteString("1q"); END Led1;
+PROCEDURE Led2; BEGIN CSI; WriteString("2q"); END Led2;
+PROCEDURE Led3; BEGIN CSI; WriteString("3q"); END Led3;
+PROCEDURE Led4; BEGIN CSI; WriteString("4q"); END Led4;
+
+PROCEDURE TestPowerUp; BEGIN CSI; WriteString("2;1y"); END TestPowerUp;
+PROCEDURE TestLoopback; BEGIN CSI; WriteString("2;2y"); END TestLoopback;
+PROCEDURE TestPowerRepeat; BEGIN CSI; WriteString("2;9y"); END TestPowerRepeat;
+PROCEDURE TestLoopRepeat; BEGIN CSI; WriteString("2;10y"); END TestLoopRepeat;
+
+(* Terminal input mode (cf. Editor/Tests/T17.mod): Unbuffered
+   saves the termios state and disables line buffering so device
+   replies can be read char by char; Buffered restores it. *)
+PROCEDURE Unbuffered;
+BEGIN
+  flushFlag := termios.tcsflush();
+  savedTerm := termios.InitTermios();
+  haveTerm := termios.tcgetattr(FIO.StdIn, savedTerm) # -1;
+  IO.UnBufferedMode(0, TRUE);
+  IO.UnBufferedMode(1, TRUE);
+END Unbuffered;
+
+PROCEDURE Buffered;
+VAR res : INTEGER;
+BEGIN
+  IO.BufferedMode(0, TRUE);
+  IO.BufferedMode(1, TRUE);
+  IF haveTerm THEN
+    haveTerm := FALSE;
+    res := termios.tcsetattr(FIO.StdIn, flushFlag, savedTerm);
+  END;
+END Buffered;
+
+END VT100.

+ 36 - 0
VT52.def

@@ -0,0 +1,36 @@
+DEFINITION MODULE VT52;
+
+(*
+  Strict DEC VT52 escape sequences.
+  No VT100/ANSI CSI. Pure ESC emitter, plus Unbuffered/Buffered
+  input-mode helpers (termios) for reading device replies.
+  Direct cursor address is ESC Y row col with +31 offset.
+*)
+
+PROCEDURE EnterAnsi;        (* ESC < : enter ANSI mode *)
+PROCEDURE SetAltKeypad;     (* ESC = : alternate keypad *)
+PROCEDURE SetNumKeypad;     (* ESC > : numeric keypad *)
+PROCEDURE SetGraphics;      (* ESC F : special graphics charset *)
+PROCEDURE SetAscii;         (* ESC G : normal US/UK charset *)
+
+PROCEDURE CursorUp;         (* ESC A *)
+PROCEDURE CursorDown;       (* ESC B *)
+PROCEDURE CursorRight;      (* ESC C *)
+PROCEDURE CursorLeft;       (* ESC D *)
+PROCEDURE CursorHome;       (* ESC H *)
+PROCEDURE CursorPosition(row, col : CARDINAL); (* ESC Y r c, r=row+31, c=col+31 *)
+
+PROCEDURE ReverseFeed;      (* ESC I : reverse line feed *)
+PROCEDURE ClearToEndOfLine; (* ESC K *)
+PROCEDURE ClearToEndOfScreen; (* ESC J *)
+
+PROCEDURE Identify;         (* ESC Z *)
+PROCEDURE IdentifyResponse; (* ESC / Z *)
+
+(* Terminal input mode: call Unbuffered before reading device
+   replies so no RETURN key is needed; call Buffered
+   afterwards to restore the saved state. *)
+PROCEDURE Unbuffered;
+PROCEDURE Buffered;
+
+END VT52.

+ 74 - 0
VT52.mod

@@ -0,0 +1,74 @@
+IMPLEMENTATION MODULE VT52;
+
+IMPORT ASCII;
+FROM STextIO IMPORT WriteChar, WriteString;
+IMPORT IO, termios, FIO;
+
+VAR
+  savedTerm : termios.TERMIOS;
+  flushFlag : INTEGER;
+  haveTerm : BOOLEAN;
+
+PROCEDURE Esc(c : CHAR);
+BEGIN
+  WriteChar(ASCII.esc);
+  WriteChar(c);
+END Esc;
+
+PROCEDURE EnterAnsi; BEGIN Esc("<"); END EnterAnsi;
+PROCEDURE SetAltKeypad; BEGIN Esc("="); END SetAltKeypad;
+PROCEDURE SetNumKeypad; BEGIN Esc(">"); END SetNumKeypad;
+PROCEDURE SetGraphics; BEGIN Esc("F"); END SetGraphics;
+PROCEDURE SetAscii; BEGIN Esc("G"); END SetAscii;
+
+PROCEDURE CursorUp; BEGIN Esc("A"); END CursorUp;
+PROCEDURE CursorDown; BEGIN Esc("B"); END CursorDown;
+PROCEDURE CursorRight; BEGIN Esc("C"); END CursorRight;
+PROCEDURE CursorLeft; BEGIN Esc("D"); END CursorLeft;
+PROCEDURE CursorHome; BEGIN Esc("H"); END CursorHome;
+
+PROCEDURE CursorPosition(row, col : CARDINAL);
+BEGIN
+  WriteChar(ASCII.esc);
+  WriteChar("Y");
+  WriteChar(CHR(row + 31));
+  WriteChar(CHR(col + 31));
+END CursorPosition;
+
+PROCEDURE ReverseFeed; BEGIN Esc("I"); END ReverseFeed;
+PROCEDURE ClearToEndOfLine; BEGIN Esc("K"); END ClearToEndOfLine;
+PROCEDURE ClearToEndOfScreen; BEGIN Esc("J"); END ClearToEndOfScreen;
+
+PROCEDURE Identify; BEGIN Esc("Z"); END Identify;
+
+PROCEDURE IdentifyResponse;
+BEGIN
+  WriteChar(ASCII.esc);
+  WriteChar("/");
+  WriteChar("Z");
+END IdentifyResponse;
+
+(* Terminal input mode (cf. Editor/Tests/T17.mod): Unbuffered
+   saves the termios state and disables line buffering so device
+   replies can be read char by char; Buffered restores it. *)
+PROCEDURE Unbuffered;
+BEGIN
+  flushFlag := termios.tcsflush();
+  savedTerm := termios.InitTermios();
+  haveTerm := termios.tcgetattr(FIO.StdIn, savedTerm) # -1;
+  IO.UnBufferedMode(0, TRUE);
+  IO.UnBufferedMode(1, TRUE);
+END Unbuffered;
+
+PROCEDURE Buffered;
+VAR res : INTEGER;
+BEGIN
+  IO.BufferedMode(0, TRUE);
+  IO.BufferedMode(1, TRUE);
+  IF haveTerm THEN
+    haveTerm := FALSE;
+    res := termios.tcsetattr(FIO.StdIn, flushFlag, savedTerm);
+  END;
+END Buffered;
+
+END VT52.

+ 33 - 0
build.sh

@@ -0,0 +1,33 @@
+#
+############################################
+# Build libraries + tests (gm2 -fiso)
+############################################
+
+#
+rm -f ./*.o
+
+#
+
+for x in   \
+  SplitV1.mod \
+  VT100.mod \
+  VT52.mod \
+  Ansi.mod \
+  Regis.mod
+do
+  echo "+++++++++++++++++++++++++++++"
+  echo $x
+  gm2 -fiso -c  $x
+done
+
+echo "+++++++++++++++++++++++++++++"
+echo Compiling tests
+for t in tests/TestVT100*.mod tests/TestVT52*.mod tests/TestAnsi*.mod tests/TestRegis*.mod; do
+  base=$(basename $t .mod)
+  echo "---- $base"
+  gm2 -fiso -o tests/$base VT100.o VT52.o Ansi.o Regis.o SplitV1.o $t
+done
+
+echo "+++++++++++++++++++++++++++++"
+echo Split test
+gm2 -fiso -o tests/testSpliV1 SplitV1.o tests/testSplit.mod

BIN
docs/TerminalEscapeCodes.pdf


File diff suppressed because it is too large
+ 233 - 0
docs/VT100 commands.html


BIN
docs/VT100-2.odt


+ 321 - 0
docs/VT100-3.txt

@@ -0,0 +1,321 @@
+ANSI Escape Sequences
+
+Standard escape codes are prefixed with Escape:
+
+    Ctrl-Key: ^[
+    Octal: \033
+    Unicode: \u001b
+    Hexadecimal: \x1B
+    Decimal: 27
+
+Followed by the command, somtimes delimited by opening square bracket ([), known as a Control Sequence Introducer (CSI), optionally followed by arguments and the command itself.
+
+Arguments are delimeted by semi colon (;).
+
+For example:
+
+\x1b[1;31m  # Set style to bold, red foreground.
+
+Sequences
+
+    ESC - sequence starting with ESC (\x1B)
+    CSI - Control Sequence Introducer: sequence starting with ESC [ or CSI (\x9B)
+    DCS - Device Control String: sequence starting with ESC P or DCS (\x90)
+    OSC - Operating System Command: sequence starting with ESC ] or OSC (\x9D)
+
+Any whitespaces between sequences and arguments should be ignored. They are present for improved readability.
+General ASCII Codes
+Name 	decimal 	octal 	hex 	C-escape 	Ctrl-Key 	Description
+BEL 	7 	007 	0x07 	\a 	^G 	Terminal bell
+BS 	8 	010 	0x08 	\b 	^H 	Backspace
+HT 	9 	011 	0x09 	\t 	^I 	Horizontal TAB
+LF 	10 	012 	0x0A 	\n 	^J 	Linefeed (newline)
+VT 	11 	013 	0x0B 	\v 	^K 	Vertical TAB
+FF 	12 	014 	0x0C 	\f 	^L 	Formfeed (also: New page NP)
+CR 	13 	015 	0x0D 	\r 	^M 	Carriage return
+ESC 	27 	033 	0x1B 	\e* 	^[ 	Escape character
+DEL 	127 	177 	0x7F 	<none> 	<none> 	Delete character
+
+    Note: Some control escape sequences, like \e for ESC, are not guaranteed to work in all languages and compilers. It is recommended to use the decimal, octal or hex representation as escape code.
+
+    Note: The Ctrl-Key representation is simply associating the non-printable characters from ASCII code 1 with the printable (letter) characters from ASCII code 65 ("A"). ASCII code 1 would be ^A (Ctrl-A), while ASCII code 7 (BEL) would be ^G (Ctrl-G). This is a common representation (and input method) and historically comes from one of the VT series of terminals.
+
+Cursor Controls
+
+    Hide cursor for 5 seconds
+
+echo -e "\e[?25l" ; sleep 5 ; echo -e "\e[?25h"
+
+ESC Code Sequence 	Description
+ESC[H 	moves cursor to home position (0, 0)
+ESC[{line};{column}H
+ESC[{line};{column}f 	moves cursor to line #, column #
+ESC[#A 	moves cursor up # lines
+ESC[#B 	moves cursor down # lines
+ESC[#C 	moves cursor right # columns
+ESC[#D 	moves cursor left # columns
+ESC[#E 	moves cursor to beginning of next line, # lines down
+ESC[#F 	moves cursor to beginning of previous line, # lines up
+ESC[#G 	moves cursor to column #
+ESC[6n 	request cursor position (reports as ESC[#;#R)
+ESC M 	moves cursor one line up, scrolling if needed
+ESC 7 	save cursor position (DEC)
+ESC 8 	restores the cursor to the last saved position (DEC)
+ESC[s 	save cursor position (SCO)
+ESC[u 	restores the cursor to the last saved position (SCO)
+
+    Note: Some sequences, like saving and restoring cursors, are private sequences and are not standardized. While some terminal emulators (i.e. xterm and derived) support both SCO and DEC sequences, they are likely to have different functionality. It is therefore recommended to use DEC sequences.
+
+Erase Functions
+ESC Code Sequence 	Description
+ESC[J 	erase in display (same as ESC[0J)
+ESC[0J 	erase from cursor until end of screen
+ESC[1J 	erase from cursor to beginning of screen
+ESC[2J 	erase entire screen
+ESC[3J 	erase saved lines
+ESC[K 	erase in line (same as ESC[0K)
+ESC[0K 	erase from cursor to end of line
+ESC[1K 	erase start of line to the cursor
+ESC[2K 	erase the entire line
+
+    Note: Erasing the line won't move the cursor, meaning that the cursor will stay at the last position it was at before the line was erased. You can use \r after erasing the line, to return the cursor to the start of the current line.
+
+Colors / Graphics Mode
+ESC Code Sequence 	Reset Sequence 	Description
+ESC[1;34;{...}m 		Set graphics modes for cell, separated by semicolon (;).
+ESC[0m 		reset all modes (styles and colors)
+ESC[1m 	ESC[22m 	set bold mode.
+ESC[2m 	ESC[22m 	set dim/faint mode.
+ESC[3m 	ESC[23m 	set italic mode.
+ESC[4m 	ESC[24m 	set underline mode.
+ESC[5m 	ESC[25m 	set blinking mode
+ESC[7m 	ESC[27m 	set inverse/reverse mode
+ESC[8m 	ESC[28m 	set hidden/invisible mode
+ESC[9m 	ESC[29m 	set strikethrough mode.
+
+    Note: Some terminals may not support some of the graphic mode sequences listed above.
+
+    Note: Both dim and bold modes are reset with the ESC[22m sequence. The ESC[21m sequence is a non-specified sequence for double underline mode and only work in some terminals and is reset with ESC[24m.
+
+Color codes
+
+Most terminals support 8 and 16 colors, as well as 256 (8-bit) colors. These colors are set by the user, but have commonly defined meanings.
+8-16 Colors
+Color Name 	Foreground Color Code 	Background Color Code
+Black 	30 	40
+Red 	31 	41
+Green 	32 	42
+Yellow 	33 	43
+Blue 	34 	44
+Magenta 	35 	45
+Cyan 	36 	46
+White 	37 	47
+Default 	39 	49
+Reset 	0 	0
+
+    Note: the Reset color is the reset code that resets all colors and text effects, Use Default color to reset colors only.
+
+Most terminals, apart from the basic set of 8 colors, also support the "bright" or "bold" colors. These have their own set of codes, mirroring the normal colors, but with an additional ;1 in their codes:
+
+# Set style to bold, red foreground.
+\x1b[1;31mHello
+# Set style to dimmed white foreground with red background.
+\x1b[2;37;41mWorld
+
+Terminals that support the aixterm specification provides bright versions of the ISO colors, without the need to use the bold modifier:
+Color Name 	Foreground Color Code 	Background Color Code
+Bright Black 	90 	100
+Bright Red 	91 	101
+Bright Green 	92 	102
+Bright Yellow 	93 	103
+Bright Blue 	94 	104
+Bright Magenta 	95 	105
+Bright Cyan 	96 	106
+Bright White 	97 	107
+256 Colors
+
+The following escape codes tells the terminal to use the given color ID:
+ESC Code Sequence 	Description
+ESC[38;5;{ID}m 	Set foreground color.
+ESC[48;5;{ID}m 	Set background color.
+
+Where {ID} should be replaced with the color index from 0 to 255 of the following color table:
+
+256 Color table
+
+The table starts with the original 16 colors (0-15).
+
+The proceeding 216 colors (16-231) or formed by a 3bpc RGB value offset by 16, packed into a single value.
+
+The final 24 colors (232-255) are grayscale starting from a shade slighly lighter than black, ranging up to shade slightly darker than white.
+
+Some emulators interpret these steps as linear increments (256 / 24) on all three channels, although some emulators may explicitly define these values.
+RGB Colors
+
+More modern terminals supports Truecolor (24-bit RGB), which allows you to set foreground and background colors using RGB.
+
+These escape sequences are usually not well documented.
+ESC Code Sequence 	Description
+ESC[38;2;{r};{g};{b}m 	Set foreground color as RGB.
+ESC[48;2;{r};{g};{b}m 	Set background color as RGB.
+
+    Note that ;38 and ;48 corresponds to the 16 color sequence and is interpreted by the terminal to set the foreground and background color respectively. Where as ;2 and ;5 sets the color format.
+
+Screen Modes
+Set Mode
+ESC Code Sequence 	Description
+ESC[={value}h 	Changes the screen width or type to the mode specified by value.
+ESC[=0h 	40 x 25 monochrome (text)
+ESC[=1h 	40 x 25 color (text)
+ESC[=2h 	80 x 25 monochrome (text)
+ESC[=3h 	80 x 25 color (text)
+ESC[=4h 	320 x 200 4-color (graphics)
+ESC[=5h 	320 x 200 monochrome (graphics)
+ESC[=6h 	640 x 200 monochrome (graphics)
+ESC[=7h 	Enables line wrapping
+ESC[=13h 	320 x 200 color (graphics)
+ESC[=14h 	640 x 200 color (16-color graphics)
+ESC[=15h 	640 x 350 monochrome (2-color graphics)
+ESC[=16h 	640 x 350 color (16-color graphics)
+ESC[=17h 	640 x 480 monochrome (2-color graphics)
+ESC[=18h 	640 x 480 color (16-color graphics)
+ESC[=19h 	320 x 200 color (256-color graphics)
+ESC[={value}l 	Resets the mode by using the same values that Set Mode uses, except for 7, which disables line wrapping. The last character in this escape sequence is a lowercase L.
+Common Private Modes
+
+These are some examples of private modes, which are not defined by the specification, but are implemented in most terminals.
+ESC Code Sequence 	Description
+ESC[?25l 	make cursor invisible
+ESC[?25h 	make cursor visible
+ESC[?47l 	restore screen
+ESC[?47h 	save screen
+ESC[?1049h 	enables the alternative buffer
+ESC[?1049l 	disables the alternative buffer
+
+Refer to the XTerm Control Sequences for a more in-depth list of private modes defined by XTerm.
+
+    Note: While these modes may be supported by the most terminals, some may not work in multiplexers like tmux.
+
+Keyboard Strings
+
+ESC[{code};{string};{...}p
+
+Redefines a keyboard key to a specified string.
+
+The parameters for this escape sequence are defined as follows:
+
+    code is one or more of the values listed in the following table. These values represent keyboard keys and key combinations. When using these values in a command, you must type the semicolons shown in this table in addition to the semicolons required by the escape sequence. The codes in parentheses are not available on some keyboards. ANSI.SYS will not interpret the codes in parentheses for those keyboards unless you specify the /X switch in the DEVICE command for ANSI.SYS.
+
+    string is either the ASCII code for a single character or a string contained in quotation marks. For example, both 65 and "A" can be used to represent an uppercase A.
+
+    IMPORTANT: Some of the values in the following table are not valid for all computers. Check your computer's documentation for values that are different.
+
+List of keyboard strings
+Key 	Code 	SHIFT+code 	CTRL+code 	ALT+code
+F1 	0;59 	0;84 	0;94 	0;104
+F2 	0;60 	0;85 	0;95 	0;105
+F3 	0;61 	0;86 	0;96 	0;106
+F4 	0;62 	0;87 	0;97 	0;107
+F5 	0;63 	0;88 	0;98 	0;108
+F6 	0;64 	0;89 	0;99 	0;109
+F7 	0;65 	0;90 	0;100 	0;110
+F8 	0;66 	0;91 	0;101 	0;111
+F9 	0;67 	0;92 	0;102 	0;112
+F10 	0;68 	0;93 	0;103 	0;113
+F11 	0;133 	0;135 	0;137 	0;139
+F12 	0;134 	0;136 	0;138 	0;140
+HOME (num keypad) 	0;71 	55 	0;119 	--
+UP ARROW (num keypad) 	0;72 	56 	(0;141) 	--
+PAGE UP (num keypad) 	0;73 	57 	0;132 	--
+LEFT ARROW (num keypad) 	0;75 	52 	0;115 	--
+RIGHT ARROW (num keypad) 	0;77 	54 	0;116 	--
+END (num keypad) 	0;79 	49 	0;117 	--
+DOWN ARROW (num keypad) 	0;80 	50 	(0;145) 	--
+PAGE DOWN (num keypad) 	0;81 	51 	0;118 	--
+INSERT (num keypad) 	0;82 	48 	(0;146) 	--
+DELETE (num keypad) 	0;83 	46 	(0;147) 	--
+HOME 	(224;71) 	(224;71) 	(224;119) 	(224;151)
+UP ARROW 	(224;72) 	(224;72) 	(224;141) 	(224;152)
+PAGE UP 	(224;73) 	(224;73) 	(224;132) 	(224;153)
+LEFT ARROW 	(224;75) 	(224;75) 	(224;115) 	(224;155)
+RIGHT ARROW 	(224;77) 	(224;77) 	(224;116) 	(224;157)
+END 	(224;79) 	(224;79) 	(224;117) 	(224;159)
+DOWN ARROW 	(224;80) 	(224;80) 	(224;145) 	(224;154)
+PAGE DOWN 	(224;81) 	(224;81) 	(224;118) 	(224;161)
+INSERT 	(224;82) 	(224;82) 	(224;146) 	(224;162)
+DELETE 	(224;83) 	(224;83) 	(224;147) 	(224;163)
+PRINT SCREEN 	-- 	-- 	0;114 	--
+PAUSE/BREAK 	-- 	-- 	0;0 	--
+BACKSPACE 	8 	8 	127 	(0)
+ENTER 	13 	-- 	10 	(0
+TAB 	9 	0;15 	(0;148) 	(0;165)
+NULL 	0;3 	-- 	-- 	--
+A 	97 	65 	1 	0;30
+B 	98 	66 	2 	0;48
+C 	99 	66 	3 	0;46
+D 	100 	68 	4 	0;32
+E 	101 	69 	5 	0;18
+F 	102 	70 	6 	0;33
+G 	103 	71 	7 	0;34
+H 	104 	72 	8 	0;35
+I 	105 	73 	9 	0;23
+J 	106 	74 	10 	0;36
+K 	107 	75 	11 	0;37
+L 	108 	76 	12 	0;38
+M 	109 	77 	13 	0;50
+N 	110 	78 	14 	0;49
+O 	111 	79 	15 	0;24
+P 	112 	80 	16 	0;25
+Q 	113 	81 	17 	0;16
+R 	114 	82 	18 	0;19
+S 	115 	83 	19 	0;31
+T 	116 	84 	20 	0;20
+U 	117 	85 	21 	0;22
+V 	118 	86 	22 	0;47
+W 	119 	87 	23 	0;17
+X 	120 	88 	24 	0;45
+Y 	121 	89 	25 	0;21
+Z 	122 	90 	26 	0;44
+1 	49 	33 	-- 	0;120
+2 	50 	64 	0 	0;121
+3 	51 	35 	-- 	0;122
+4 	52 	36 	-- 	0;123
+5 	53 	37 	-- 	0;124
+6 	54 	94 	30 	0;125
+7 	55 	38 	-- 	0;126
+8 	56 	42 	-- 	0;126
+9 	57 	40 	-- 	0;127
+0 	48 	41 	-- 	0;129
+- 	45 	95 	31 	0;130
+= 	61 	43 	--- 	0;131
+[ 	91 	123 	27 	0;26
+] 	93 	125 	29 	0;27
+	92 	124 	28 	0;43
+; 	59 	58 	-- 	0;39
+' 	39 	34 	-- 	0;40
+, 	44 	60 	-- 	0;51
+. 	46 	62 	-- 	0;52
+/ 	47 	63 	-- 	0;53
+` 	96 	126 	-- 	(0;41)
+ENTER (keypad) 	13 	-- 	10 	(0;166)
+/ (keypad) 	47 	47 	(0;142) 	(0;74)
+* (keypad) 	42 	(0;144) 	(0;78) 	--
+- (keypad) 	45 	45 	(0;149) 	(0;164)
++ (keypad) 	43 	43 	(0;150) 	(0;55)
+5 (keypad) 	(0;76) 	53 	(0;143) 	--
+Resources
+
+    Wikipedia: ANSI escape code
+    Build your own Command Line with ANSI escape codes
+    ascii-table: ANSI Escape sequences
+    bluesock: ansi codes
+    bash-hackers: Terminal Codes (ANSI/VT100) introduction
+    XTerm Control Sequences
+    VT100 – Various terminal manuals
+    xterm.js – Supported Terminal Sequences
+
+click to expand⣿⣿⣷⣶⣦⣤⣄⣀⡀ Control Characters - VT100 User Guide
+
+【𝐄𝐍𝐃】
+
+

+ 209 - 0
docs/VT100-escape codes.txt

@@ -0,0 +1,209 @@
+
+VT100 escape codes
+
+This document describes how to control a VT100 terminal. The entries are of the form "name, description, escape code".
+
+The name isn't important, and the description is just to help you find what you're looking for. What you have to do is send the "escape code" to the screen. These codes are often several characters long, but they all begin with ^[. This isn't the two characters ^ and [, but rather a representation of the ASCII code ESC (which is why these are called escape codes).
+
+ESC has the decimal value 27 and should be sent before the rest of the code, which is simply an ASCII string.
+
+As an example of how to use this information, here's how to clear the screen in C, using the VT100 escape codes:
+
+    #define ASCII_ESC 27
+    printf( "%c[2J", ASCII_ESC );
+
+   or
+
+    puts( "\033[2J" );
+
+Name                  Description                            Esc Code
+
+setnl LMN             Set new line mode                      ^[[20h
+setappl DECCKM        Set cursor key to application          ^[[?1h
+setansi DECANM        Set ANSI (versus VT52)                 none
+setcol DECCOLM        Set number of columns to 132           ^[[?3h
+setsmooth DECSCLM     Set smooth scrolling                   ^[[?4h
+setrevscrn DECSCNM    Set reverse video on screen            ^[[?5h
+setorgrel DECOM       Set origin to relative                 ^[[?6h
+setwrap DECAWM        Set auto-wrap mode                     ^[[?7h
+setrep DECARM         Set auto-repeat mode                   ^[[?8h
+setinter DECINLM      Set interlacing mode                   ^[[?9h
+
+setlf LMN             Set line feed mode                     ^[[20l
+setcursor DECCKM      Set cursor key to cursor               ^[[?1l
+setvt52 DECANM        Set VT52 (versus ANSI)                 ^[[?2l
+resetcol DECCOLM      Set number of columns to 80            ^[[?3l
+setjump DECSCLM       Set jump scrolling                     ^[[?4l
+setnormscrn DECSCNM   Set normal video on screen             ^[[?5l
+setorgabs DECOM       Set origin to absolute                 ^[[?6l
+resetwrap DECAWM      Reset auto-wrap mode                   ^[[?7l
+resetrep DECARM       Reset auto-repeat mode                 ^[[?8l
+resetinter DECINLM    Reset interlacing mode                 ^[[?9l
+
+altkeypad DECKPAM     Set alternate keypad mode              ^[=
+numkeypad DECKPNM     Set numeric keypad mode                ^[>
+
+setukg0               Set United Kingdom G0 character set    ^[(A
+setukg1               Set United Kingdom G1 character set    ^[)A
+setusg0               Set United States G0 character set     ^[(B
+setusg1               Set United States G1 character set     ^[)B
+setspecg0             Set G0 special chars. & line set       ^[(0
+setspecg1             Set G1 special chars. & line set       ^[)0
+setaltg0              Set G0 alternate character ROM         ^[(1
+setaltg1              Set G1 alternate character ROM         ^[)1
+setaltspecg0          Set G0 alt char ROM and spec. graphics ^[(2
+setaltspecg1          Set G1 alt char ROM and spec. graphics ^[)2
+
+setss2 SS2            Set single shift 2                     ^[N
+setss3 SS3            Set single shift 3                     ^[O
+
+modesoff SGR0         Turn off character attributes          ^[[m
+modesoff SGR0         Turn off character attributes          ^[[0m
+bold SGR1             Turn bold mode on                      ^[[1m
+lowint SGR2           Turn low intensity mode on             ^[[2m
+underline SGR4        Turn underline mode on                 ^[[4m
+blink SGR5            Turn blinking mode on                  ^[[5m
+reverse SGR7          Turn reverse video on                  ^[[7m
+invisible SGR8        Turn invisible text mode on            ^[[8m
+
+setwin DECSTBM        Set top and bottom line#s of a window  ^[[<v>;<v>r
+
+cursorup(n) CUU       Move cursor up n lines                 ^[[<n>A
+cursordn(n) CUD       Move cursor down n lines               ^[[<n>B
+cursorrt(n) CUF       Move cursor right n lines              ^[[<n>C
+cursorlf(n) CUB       Move cursor left n lines               ^[[<n>D
+cursorhome            Move cursor to upper left corner       ^[[H
+cursorhome            Move cursor to upper left corner       ^[[;H
+cursorpos(v,h) CUP    Move cursor to screen location v,h     ^[[<v>;<h>H
+hvhome                Move cursor to upper left corner       ^[[f
+hvhome                Move cursor to upper left corner       ^[[;f
+hvpos(v,h) CUP        Move cursor to screen location v,h     ^[[<v>;<h>f
+index IND             Move/scroll window up one line         ^[D
+revindex RI           Move/scroll window down one line       ^[M
+nextline NEL          Move to next line                      ^[E
+savecursor DECSC      Save cursor position and attributes    ^[7
+restorecursor DECSC   Restore cursor position and attributes ^[8
+
+tabset HTS            Set a tab at the current column        ^[H
+tabclr TBC            Clear a tab at the current column      ^[[g
+tabclr TBC            Clear a tab at the current column      ^[[0g
+tabclrall TBC         Clear all tabs                         ^[[3g
+
+dhtop DECDHL          Double-height letters, top half        ^[#3
+dhbot DECDHL          Double-height letters, bottom half     ^[#4
+swsh DECSWL           Single width, single height letters    ^[#5
+dwsh DECDWL           Double width, single height letters    ^[#6
+
+cleareol EL0          Clear line from cursor right           ^[[K
+cleareol EL0          Clear line from cursor right           ^[[0K
+clearbol EL1          Clear line from cursor left            ^[[1K
+clearline EL2         Clear entire line                      ^[[2K
+
+cleareos ED0          Clear screen from cursor down          ^[[J
+cleareos ED0          Clear screen from cursor down          ^[[0J
+clearbos ED1          Clear screen from cursor up            ^[[1J
+clearscreen ED2       Clear entire screen                    ^[[2J
+
+devstat DSR           Device status report                   ^[5n
+termok DSR               Response: terminal is OK            ^[0n
+termnok DSR              Response: terminal is not OK        ^[3n
+
+getcursor DSR         Get cursor position                    ^[6n
+cursorpos CPR            Response: cursor is at v,h          ^[<v>;<h>R
+
+ident DA              Identify what terminal type            ^[[c
+ident DA              Identify what terminal type (another)  ^[[0c
+gettype DA               Response: terminal type code n      ^[[?1;<n>0c
+
+reset RIS             Reset terminal to initial state        ^[c
+
+align DECALN          Screen alignment display               ^[#8
+testpu DECTST         Confidence power up test               ^[[2;1y
+testlb DECTST         Confidence loopback test               ^[[2;2y
+testpurep DECTST      Repeat power up test                   ^[[2;9y
+testlbrep DECTST      Repeat loopback test                   ^[[2;10y
+
+ledsoff DECLL0        Turn off all four leds                 ^[[0q
+led1 DECLL1           Turn on LED #1                         ^[[1q
+led2 DECLL2           Turn on LED #2                         ^[[2q
+led3 DECLL3           Turn on LED #3                         ^[[3q
+led4 DECLL4           Turn on LED #4                         ^[[4q
+
+#
+#  All codes below are for use in VT52 compatibility mode.
+#
+
+setansi               Enter/exit ANSI mode (VT52)            ^[<
+
+altkeypad             Enter alternate keypad mode            ^[=
+numkeypad             Exit alternate keypad mode             ^[>
+
+setgr                 Use special graphics character set     ^[F
+resetgr               Use normal US/UK character set         ^[G
+
+cursorup              Move cursor up one line                ^[A
+cursordn              Move cursor down one line              ^[B
+cursorrt              Move cursor right one char             ^[C
+cursorlf              Move cursor left one char              ^[D
+cursorhome            Move cursor to upper left corner       ^[H
+cursorpos(v,h)        Move cursor to v,h location            ^[<v><h>
+revindex              Generate a reverse line-feed           ^[I
+
+cleareol              Erase to end of current line           ^[K
+cleareos              Erase to end of screen                 ^[J
+
+ident                 Identify what the terminal is          ^[Z
+identresp             Correct response to ident              ^[/Z
+
+<hr>
+
+#
+# VT100 Special Key Codes
+#
+# These are sent from the terminal back to the computer when the
+# particular key is pressed.  Note that the numeric keypad keys
+# send different codes in numeric mode than in alternate mode.
+# See escape codes above to change keypad mode.
+#
+
+# Function Keys:
+
+PF1     ^[OP
+PF2     ^[OQ
+PF3     ^[OR
+PF4     ^[OS
+
+
+# Arrow Keys:
+        Reset    Set
+        -----    ---
+up      ^[A ^[OA
+down        ^[B ^[OB
+right       ^[C ^[OC
+left        ^[D ^[OD
+
+
+# Numeric Keypad Keys:
+
+        Keypad Mode
+        -----------------
+Keypad Key  Numeric Alternate
+----------  ------- ---------
+0       0   ^[Op
+1       1   ^[Oq
+2       2   ^[Or
+3       3   ^[Os
+4       4   ^[Ot
+5       5   ^[Ou
+6       6   ^[Ov
+7       7   ^[Ow
+8       8   ^[Ox
+9       9   ^[Oy
+- (minus)   -   ^[Om
+, (comma)   ,   ^[Ol
+. (period)  .   ^[On
+ENTER       ^M  ^[OM
+
+C 	27, 033, 0x1b
+English 	27 decimal, 33 octal, 1b hexadecimal
+

+ 232 - 0
docs/VT100.txt

@@ -0,0 +1,232 @@
+
+ANSI/VT100 Terminal Control Escape Sequences
+[ Status | Setup | Fonts | Cursor | Scrolling | Tabs | Erasing | Printing | Keyboard | Colours ]
+
+Many computer terminals and terminal emulators support colour and cursor control through a system of escape sequences. One such standard is commonly referred to as ANSI Colour. Several terminal specifications are based on the ANSI colour standard, including VT100.
+
+The following is a partial listing of the VT100 control set.
+
+<ESC> represents the ASCII "escape" character, 0x1B. Bracketed tags represent modifiable decimal parameters; eg. {ROW} would be replaced by a row number.
+
+Device Status
+The following codes are used for reporting terminal/display settings, and vary depending on the implementation:
+
+Query Device Code	<ESC>[c
+
+    Requests a Report Device Code response from the device.
+
+Report Device Code	<ESC>[{code}0c
+
+    Generated by the device in response to Query Device Code request.
+
+Query Device Status	<ESC>[5n
+
+    Requests a Report Device Status response from the device.
+
+Report Device OK	<ESC>[0n
+
+    Generated by the device in response to a Query Device Status request; indicates that device is functioning correctly.
+
+Report Device Failure	<ESC>[3n
+
+    Generated by the device in response to a Query Device Status request; indicates that device is functioning improperly.
+
+Query Cursor Position	<ESC>[6n
+
+    Requests a Report Cursor Position response from the device.
+
+Report Cursor Position	<ESC>[{ROW};{COLUMN}R
+
+    Generated by the device in response to a Query Cursor Position request; reports current cursor position.
+
+Terminal Setup
+The h and l codes are used for setting terminal/display mode, and vary depending on the implementation. Line Wrap is one of the few setup codes that tend to be used consistently:
+
+Reset Device		<ESC>c
+
+    Reset all terminal settings to default.
+
+Enable Line Wrap	<ESC>[7h
+
+    Text wraps to next line if longer than the length of the display area.
+
+Disable Line Wrap	<ESC>[7l
+
+    Disables line wrapping.
+
+Fonts
+Some terminals support multiple fonts: normal/bold, swiss/italic, etc. There are a variety of special codes for certain terminals; the following are fairly standard:
+
+Font Set G0		<ESC>(
+
+    Set default font.
+
+Font Set G1		<ESC>)
+
+    Set alternate font.
+
+Cursor Control
+
+Cursor Home 		<ESC>[{ROW};{COLUMN}H
+
+    Sets the cursor position where subsequent text will begin. If no row/column parameters are provided (ie. <ESC>[H), the cursor will move to the home position, at the upper left of the screen.
+
+Cursor Up		<ESC>[{COUNT}A
+
+    Moves the cursor up by COUNT rows; the default count is 1.
+
+Cursor Down		<ESC>[{COUNT}B
+
+    Moves the cursor down by COUNT rows; the default count is 1.
+
+Cursor Forward		<ESC>[{COUNT}C
+
+    Moves the cursor forward by COUNT columns; the default count is 1.
+
+Cursor Backward		<ESC>[{COUNT}D
+
+    Moves the cursor backward by COUNT columns; the default count is 1.
+
+Force Cursor Position	<ESC>[{ROW};{COLUMN}f
+
+    Identical to Cursor Home.
+
+Save Cursor		<ESC>[s
+
+    Save current cursor position.
+
+Unsave Cursor		<ESC>[u
+
+    Restores cursor position after a Save Cursor.
+
+Save Cursor & Attrs	<ESC>7
+
+    Save current cursor position.
+
+Restore Cursor & Attrs	<ESC>8
+
+    Restores cursor position after a Save Cursor.
+
+Scrolling
+
+Scroll Screen		<ESC>[r
+
+    Enable scrolling for entire display.
+
+Scroll Screen		<ESC>[{start};{end}r
+
+    Enable scrolling from row {start} to row {end}.
+
+Scroll Down		<ESC>D
+
+    Scroll display down one line.
+
+Scroll Up		<ESC>M
+
+    Scroll display up one line.
+
+Tab Control
+
+Set Tab 		<ESC>H
+
+    Sets a tab at the current position.
+
+Clear Tab 		<ESC>[g
+
+    Clears tab at the current position.
+
+Clear All Tabs 		<ESC>[3g
+
+    Clears all tabs.
+
+Erasing Text
+
+Erase End of Line	<ESC>[K
+
+    Erases from the current cursor position to the end of the current line.
+
+Erase Start of Line	<ESC>[1K
+
+    Erases from the current cursor position to the start of the current line.
+
+Erase Line		<ESC>[2K
+
+    Erases the entire current line.
+
+Erase Down		<ESC>[J
+
+    Erases the screen from the current line down to the bottom of the screen.
+
+Erase Up		<ESC>[1J
+
+    Erases the screen from the current line up to the top of the screen.
+
+Erase Screen		<ESC>[2J
+
+    Erases the screen with the background colour and moves the cursor to home.
+
+Printing
+Some terminals support local printing:
+
+Print Screen		<ESC>[i
+
+    Print the current screen.
+
+Print Line		<ESC>[1i
+
+    Print the current line.
+
+Stop Print Log		<ESC>[4i
+
+    Disable log.
+
+Start Print Log		<ESC>[5i
+
+    Start log; all received text is echoed to a printer.
+
+Define Key
+
+Set Key Definition	<ESC>[{key};"{string}"p
+
+    Associates a string of text to a keyboard key. {key} indicates the key by its ASCII value in decimal.
+
+Set Display Attributes
+
+Set Attribute Mode	<ESC>[{attr1};...;{attrn}m
+
+    Sets multiple display attribute settings. The following lists standard attributes:
+
+    0	Reset all attributes
+    1	Bright
+    2	Dim
+    4	Underscore	
+    5	Blink
+    7	Reverse
+    8	Hidden
+
+    	Foreground Colours
+    30	Black
+    31	Red
+    32	Green
+    33	Yellow
+    34	Blue
+    35	Magenta
+    36	Cyan
+    37	White
+
+    	Background Colours
+    40	Black
+    41	Red
+    42	Green
+    43	Yellow
+    44	Blue
+    45	Magenta
+    46	Cyan
+    47	White
+
+[ Top | Status | Setup | Fonts | Cursor | Scrolling | Tabs | Erasing | Printing | Keyboard | Colours ]
+	
+
+    
+
+

BIN
docs/VT52 - Wikipedia.pdf


+ 60 - 0
docs/regis-cli.txt

@@ -0,0 +1,60 @@
+ReGIS on the command line (xterm / contour)
+==============================================
+
+ReGIS travels inside a DCS string. Sending the introducer IS the
+switch: no xterm flag starts you in graphics mode, the application
+(or printf) enters it, ST (ESC \) leaves it.
+
+  Enter fresh (reset state + clear canvas):
+    printf '\033P1pS(E)\033\\'
+
+  Enter keeping previous state (resume):
+    printf '\033Pp'
+
+  Leave graphics mode:
+    printf '\033\\'
+
+One-liners (each is a complete DCS ... ST picture):
+
+  # diagonal line
+  printf '\033PpP[100,100]V[400,300]\033\\'
+
+  # rectangle
+  printf '\033PpP[100,100]V[400,100]V[400,300]V[100,300]V[100,100]\033\\'
+
+  # circle, radius 100, centred at cursor
+  printf '\033PpP[400,240]C[500,240]\033\\'
+
+  # text, double-size cell
+  printf "\033PpP[100,100]T(S2)'Hello, ReGIS'\033\\"
+
+  # clear + reset coordinate window
+  printf '\033PpS(E)S(A[0,0][799,479])\033\\'
+
+Canvas: 800x480, origin top-left, Y down. [x,y] absolute,
+[+dx,-dy] relative, [x] X-only, [,y] Y-only, [] current pos.
+
+Detecting support: ask Device Attributes and look for ";3"
+(3 = ReGIS, 4 = Sixel):
+
+  printf '\033[c'     # e.g. ESC [ ? 65 ; ... ; 3 ; 4 ; ... c
+
+xterm caveat: ReGIS exists only in xterm built with
+--enable-regis-graphics; stock distro builds often omit it.
+Check yours with:
+
+  strings $(which xterm) | grep -i regis
+  appres XTerm | grep -i regis     # regisScreenSize ...
+
+No match (as on this machine's xterm 398) means no ReGIS:
+use contour, or rebuild xterm with the flag. Related resource:
+regisScreenSize (default 800x480 window), privateColorRegisters.
+
+Programmatically (this repo, Modula-2): see Regis.def +
+tests/TestRegisDemo.mod, TestRegisColor.mod, TestRegisMacro.mod:
+
+  Regis.Enter;
+  Regis.Rect(50, 50, 750, 430);
+  Regis.MoveTo(300, 445);
+  Regis.TextOut("hi");
+  Regis.Exit;

+ 44 - 0
docs/regis.txt

@@ -0,0 +1,44 @@
+ReGIS
+
+ReGIS is a vector graphics markup language made by DEC for it's VT125, VT230, VT240/241 and above terminals. commands can be sent to it by serial or any other text/tty connexion.
+
+    official manual "VT330/VT340 Programmer Reference Manual - Volume 2: Graphics Programming" by Digital, is available online in HTML format here: https://vt100.net/docs/vt3xx-gp/ and pdf https://raw.githubusercontent.com/hackerb9/vt340test/main/docs/EK-VT3XX-HR-002_VT330_VT340_Programmer_Pocket_Guide_May88.pdf
+
+Overview of the features
+
+Depending on terminal resolution and features changes
+
+    VT125 768×240 pixels, 2 bitplans
+    VT230 800×480 pixels, 2 bitplans
+    VT240/VT241 768×480 pixels, 4 bitplans
+
+There is "shading" management allowing to mix simple patterns for fill or border,
+
+It supports curves with polynomial interpolation, by default with only one point + a value, it builds a circle.
+
+
+Use it on Linux distros
+
+Xterm supports it. Arch Linux and derivative support it from scratch. It must be recompiled on Debian and derivatives, with the --enable-regis-graphics option. Display will change depending on used VT emulation.
+
+Launch xterm like this to have more capabilities:
+
+xterm +u8 -geometry 132x50 -ti vt340 -tn vt340 /bin/bash
+
+On some recent distribution, +u8 could fail and the command just return with return code 0. In this case, just start with:
+
+xterm -geometry 132x50 -ti vt340 -tn vt340 /bin/bash
+
+then launch the script or connect by one of the available serial tools (screen, minicom, etc...) to the hw producing the markup.
+
+The markup is send to terminal prefixed, after the documentation by 0x1b 0x50 0x32 x70 (ESC + 'P2p', but on xterm implementation at least, any single digit decimal number instead of 2 works). It is also suffixed by 0x1b 0x5c (ESC + '\', standard VT endline sequence).
+
+Implementation in Bash:
+
+echo -e "\x1bP2p${command}\x1b\\"
+
+in Lua:
+
+io.stream(string.char(0x1b).."P2p"..command..string.char(0x1b,0x5c))
+
+Don't forget to flush the stream in tests with system based languages, to avoid a buffer filling few seconds wait :). 

+ 36 - 0
tests/Test1.mod

@@ -0,0 +1,36 @@
+MODULE Test1;
+
+IMPORT Strings, STextIO, NumberIO;
+
+VAR
+    str : ARRAY [0..9] OF CHAR;
+    str1 : ARRAY[1..10] OF CHAR;
+    str2 : ARRAY[0..10] OF CHAR;
+
+BEGIN
+    str := "123456789";
+    STextIO.WriteString(str);
+    STextIO.WriteLn;
+    Strings.Delete(str,0,1);
+    STextIO.WriteString(str);
+    STextIO.WriteLn;
+
+    str1 := "123456789";
+    STextIO.WriteString(str1);
+    STextIO.WriteLn;
+    Strings.Delete(str1,0,1);
+    STextIO.WriteString(str1);
+    STextIO.WriteLn;
+
+    str2 := "e[#;#R";
+    Strings.Delete(str2,0,2);
+    STextIO.WriteString(str2);
+    STextIO.WriteLn;
+    NumberIO.WriteCard(Strings.Length(str2),5);
+    STextIO.WriteLn;
+    Strings.Delete(str2,Strings.Length(str2) -1 ,1);
+    STextIO.WriteString(str2);
+    STextIO.WriteLn;
+
+
+END Test1.

BIN
tests/TestAnsiColor


+ 35 - 0
tests/TestAnsiColor.mod

@@ -0,0 +1,35 @@
+MODULE TestAnsiColor;
+
+IMPORT Ansi;
+FROM STextIO IMPORT WriteString, WriteLn;
+FROM Delay IMPORT Delay;
+
+BEGIN
+  Ansi.EraseScreen;
+  Ansi.Home;
+  WriteString("--- ANSI Color test ---"); WriteLn;
+
+  Ansi.FG(Ansi.Red); WriteString("Red FG"); WriteLn;
+  Ansi.FG(Ansi.Default);
+  Ansi.BG(Ansi.Blue); WriteString("Blue BG"); WriteLn;
+  Ansi.BG(Ansi.Default);
+
+  Ansi.FG(Ansi.BrightGreen); WriteString("BrightGreen"); WriteLn;
+  Ansi.FG(Ansi.Default);
+  Ansi.BG(Ansi.BrightMagenta); WriteString("BrightMagenta BG"); WriteLn;
+  Ansi.BG(Ansi.Default);
+
+  Ansi.FG256(200); WriteString("FG256 200"); WriteLn;
+  Ansi.FG(Ansi.Default);
+  Ansi.BG256(100); WriteString("BG256 100"); WriteLn;
+  Ansi.BG(Ansi.Default);
+
+  Ansi.FGRGB(255, 0, 128); WriteString("RGB FG 255,0,128"); WriteLn;
+  Ansi.FG(Ansi.Default);
+  Ansi.BGRGB(0, 255, 64); WriteString("RGB BG 0,255,64"); WriteLn;
+  Ansi.BG(Ansi.Default);
+
+  Ansi.SGRReset;
+  WriteString("--- end Color ---"); WriteLn;
+  Delay(500);
+END TestAnsiColor.

BIN
tests/TestAnsiCursor


+ 50 - 0
tests/TestAnsiCursor.mod

@@ -0,0 +1,50 @@
+MODULE TestAnsiCursor;
+
+IMPORT Ansi;
+FROM STextIO IMPORT WriteString, WriteLn;
+FROM Delay IMPORT Delay;
+
+BEGIN
+  Ansi.EraseScreen;
+  Ansi.Home;
+  WriteString("--- ANSI Cursor test ---"); WriteLn;
+
+  Ansi.Position(5, 10);
+  WriteString("at (5,10)");
+  Ansi.HVPosition(7, 10);
+  WriteString(" HV(7,10)");
+  WriteLn;
+
+  Ansi.Home;
+  WriteString("H+");
+  Ansi.Right(5); WriteString("R5+");
+  Ansi.Down(2); WriteString("D2+");
+  Ansi.Left(2); WriteString("L2+");
+  Ansi.Up(1); WriteString("U1");
+  WriteLn;
+
+  Ansi.NextLine(2); WriteString("E2");
+  WriteLn;
+  Ansi.PrevLine(1); WriteString("F1");
+  WriteLn;
+  Ansi.ToColumn(20); WriteString("G20");
+  WriteLn;
+
+  Ansi.SaveDEC;
+  Ansi.Position(15, 1); WriteString("moved");
+  Ansi.RestoreDEC; WriteString(" DEC restored");
+  WriteLn;
+
+  Ansi.SaveSCO;
+  Ansi.Position(16, 1); WriteString("moved2");
+  Ansi.RestoreSCO; WriteString(" SCO restored");
+  WriteLn;
+
+  Ansi.RequestPosition;
+  WriteLn; WriteString("6n sent"); WriteLn;
+
+  Ansi.CursorUpScroll; WriteString(" ESC M"); WriteLn;
+
+  WriteString("--- end Cursor ---"); WriteLn;
+  Delay(500);
+END TestAnsiCursor.

BIN
tests/TestAnsiErase


+ 46 - 0
tests/TestAnsiErase.mod

@@ -0,0 +1,46 @@
+MODULE TestAnsiErase;
+
+IMPORT Ansi;
+FROM STextIO IMPORT WriteString, WriteLn;
+FROM Delay IMPORT Delay;
+
+BEGIN
+  Ansi.EraseScreen;
+  Ansi.Home;
+  WriteString("--- ANSI Erase test ---"); WriteLn;
+
+  WriteString("garbage garbage");
+  Ansi.Position(2, 20);
+  Ansi.EraseLineRight;
+  WriteLn; WriteString("EraseLineRight done"); WriteLn;
+
+  WriteString("garbage garbage");
+  Ansi.Position(3, 20);
+  Ansi.EraseLineLeft;
+  WriteLn; WriteString("EraseLineLeft done"); WriteLn;
+
+  WriteString("to be cleared");
+  Ansi.Position(4, 1);
+  Ansi.EraseLine;
+  Ansi.Position(4, 1);
+  WriteString("EraseLine done"); WriteLn;
+
+  Ansi.Position(10, 1); WriteString("below filler");
+  Ansi.Position(8, 1);
+  Ansi.EraseDown;
+  Ansi.Position(8, 1); WriteString("EraseDown done"); WriteLn;
+
+  Ansi.Position(12, 1); WriteString("filler");
+  Ansi.Position(12, 1);
+  Ansi.EraseUp;
+  Ansi.Position(12, 1); WriteString("EraseUp done"); WriteLn;
+
+  Ansi.EraseSavedLines;
+  WriteString("EraseSavedLines sent"); WriteLn;
+  Delay(300);
+
+  Ansi.EraseScreen;
+  Ansi.Home;
+  WriteString("EraseScreen done"); WriteLn;
+  WriteString("--- end Erase ---"); WriteLn;
+END TestAnsiErase.

BIN
tests/TestAnsiModes


+ 31 - 0
tests/TestAnsiModes.mod

@@ -0,0 +1,31 @@
+MODULE TestAnsiModes;
+
+IMPORT Ansi;
+FROM STextIO IMPORT WriteString, WriteLn;
+FROM Delay IMPORT Delay;
+
+BEGIN
+  Ansi.EraseScreen;
+  Ansi.Home;
+  WriteString("--- ANSI Modes test ---"); WriteLn;
+
+  Ansi.DosMode(3); WriteString("DosMode 3"); WriteLn;
+  Delay(300);
+  Ansi.DosModeReset(3); WriteString("DosModeReset 3"); WriteLn;
+  Ansi.WrapOn; WriteString("WrapOn"); WriteLn;
+  Ansi.WrapOff; WriteString("WrapOff"); WriteLn;
+  Ansi.WrapOn;
+
+  Ansi.CursorInvisible; WriteString("CursorInvisible"); WriteLn;
+  Delay(300);
+  Ansi.CursorVisible; WriteString("CursorVisible"); WriteLn;
+
+  Ansi.ScreenSave; WriteString("ScreenSave"); WriteLn;
+  Ansi.ScreenRestore; WriteString("ScreenRestore"); WriteLn;
+
+  Ansi.AltBufferOn; WriteString("AltBufferOn"); WriteLn;
+  Delay(300);
+  Ansi.AltBufferOff; WriteString("AltBufferOff"); WriteLn;
+
+  WriteString("--- end Modes ---"); WriteLn;
+END TestAnsiModes.

BIN
tests/TestAnsiPrint


+ 25 - 0
tests/TestAnsiPrint.mod

@@ -0,0 +1,25 @@
+MODULE TestAnsiPrint;
+
+IMPORT Ansi;
+FROM STextIO IMPORT WriteString, WriteLn;
+
+BEGIN
+  Ansi.EraseScreen;
+  Ansi.Home;
+  WriteString("--- ANSI Print/Ctrl test ---"); WriteLn;
+
+  Ansi.PrintScreen; WriteLn; WriteString("PrintScreen sent"); WriteLn;
+  Ansi.PrintLine; WriteLn; WriteString("PrintLine sent"); WriteLn;
+  Ansi.StartLog; WriteLn; WriteString("StartLog sent"); WriteLn;
+  Ansi.StopLog; WriteLn; WriteString("StopLog sent"); WriteLn;
+
+  Ansi.Bell; WriteString("Bell sent"); WriteLn;
+  Ansi.Backspace; WriteString("Backspace sent"); WriteLn;
+  Ansi.HTab; WriteString("HTab sent"); WriteLn;
+  Ansi.LineFeed; WriteString("LineFeed sent"); WriteLn;
+  Ansi.VTab; WriteString("VTab sent"); WriteLn;
+  Ansi.FormFeed; WriteString("FormFeed sent"); WriteLn;
+  Ansi.CarriageReturn; WriteString("CR sent"); WriteLn;
+
+  WriteString("--- end Print/Ctrl ---"); WriteLn;
+END TestAnsiPrint.

BIN
tests/TestAnsiRequestPosition


+ 51 - 0
tests/TestAnsiRequestPosition.mod

@@ -0,0 +1,51 @@
+MODULE TestAnsiRequestPosition;
+
+(* Query cursor position with our ansi library (ESC[6n),
+   read CPR reply ESC[row;colR with no RETURN needed,
+   parse and print Row/Col. *)
+
+IMPORT Ansi, IO, Strings, NumberIO, SplitV1, STextIO;
+
+VAR
+  str : ARRAY[0..31] OF CHAR;
+  cc : Strings.String1;
+  c : CHAR;
+  x, y : CARDINAL;
+  theStructure : SplitV1.Structure;
+
+BEGIN
+  STextIO.WriteString("--- ANSI RequestPosition test ---");
+  STextIO.WriteLn;
+
+  Ansi.Unbuffered;
+
+  (* place cursor at a known spot, then ask where it is *)
+  Ansi.Position(10, 20);
+  Ansi.RequestPosition;
+
+  (* read reply char by char, no RETURN needed *)
+  str := "";
+  REPEAT
+    IO.Read(c);
+    cc[0] := c;
+    Strings.Concat(str, cc, str);
+  UNTIL c = "R";
+
+  Ansi.Buffered;
+
+  (* str = ESC [ row ; col R : strip ESC [ and trailing R *)
+  Strings.Delete(str, 0, 2);
+  Strings.Delete(str, Strings.Length(str) - 1, 1);
+  SplitV1.SplitStr(str, ";", theStructure);
+  NumberIO.StrToCard(theStructure[0].element, x);
+  NumberIO.StrToCard(theStructure[1].element, y);
+
+  STextIO.WriteString("Row=");
+  NumberIO.WriteCard(x, 1);
+  STextIO.WriteString(" Col=");
+  NumberIO.WriteCard(y, 1);
+  STextIO.WriteLn;
+
+  STextIO.WriteString("--- end RequestPosition ---");
+  STextIO.WriteLn;
+END TestAnsiRequestPosition.

BIN
tests/TestAnsiSGR


+ 36 - 0
tests/TestAnsiSGR.mod

@@ -0,0 +1,36 @@
+MODULE TestAnsiSGR;
+
+IMPORT Ansi;
+FROM STextIO IMPORT WriteString, WriteLn;
+FROM Delay IMPORT Delay;
+
+BEGIN
+  Ansi.EraseScreen;
+  Ansi.Home;
+  WriteString("--- ANSI SGR test ---"); WriteLn;
+
+  Ansi.SGR(Ansi.ResetA); WriteString("Reset "); WriteLn;
+  Ansi.SGR(Ansi.BoldA); WriteString("Bold"); WriteLn;
+  Ansi.SGRResetBoldDim;
+  Ansi.SGR(Ansi.DimA); WriteString("Dim"); WriteLn;
+  Ansi.SGRResetBoldDim;
+  Ansi.SGR(Ansi.ItalicA); WriteString("Italic"); WriteLn;
+  Ansi.SGRResetItalic;
+  Ansi.SGR(Ansi.UnderlineA); WriteString("Underline"); WriteLn;
+  Ansi.SGRResetUnderline;
+  Ansi.SGR(Ansi.BlinkA); WriteString("Blink"); WriteLn;
+  Ansi.SGRResetBlink;
+  Ansi.SGR(Ansi.InverseA); WriteString("Inverse"); WriteLn;
+  Ansi.SGRResetInverse;
+  Ansi.SGR(Ansi.HiddenA); WriteString("Hidden"); WriteLn;
+  Ansi.SGRResetHidden;
+  Ansi.SGR(Ansi.StrikeA); WriteString("Strike"); WriteLn;
+  Ansi.SGRResetStrike;
+
+  Ansi.SetAttr(Ansi.BoldA, Ansi.Red, Ansi.Blue);
+  WriteString("SetAttr bold red/blue"); WriteLn;
+  Ansi.SGRReset;
+
+  WriteString("--- end SGR ---"); WriteLn;
+  Delay(500);
+END TestAnsiSGR.

BIN
tests/TestRegisColor


+ 36 - 0
tests/TestRegisColor.mod

@@ -0,0 +1,36 @@
+MODULE TestRegisColor;
+
+(* ReGIS color/pattern/fill demo: registers, arcs, filled triangle. *)
+
+IMPORT Regis;
+
+BEGIN
+  Regis.Enter;
+
+  Regis.SetRGB(1, 100, 0, 0);
+  Regis.SetHLS(2, 120, 50, 100);
+  Regis.BgRegister(0);
+
+  Regis.UseColor(1);
+  Regis.LineWidth(3);
+  Regis.MoveTo(100, 240);
+  Regis.Circle(200, 240);
+
+  Regis.UseColor(2);
+  Regis.Pattern(2);
+  Regis.MoveTo(400, 240);
+  Regis.Arc(180, 500, 240);
+
+  Regis.ColorName("G");
+  Regis.MoveTo(150, 350);
+  Regis.FillTriangle(300, 350, 225, 200);
+
+  Regis.UseColor(0);
+  Regis.Pattern(1);
+  Regis.LineWidth(1);
+  Regis.MoveTo(500, 350);
+  Regis.TextDir(0);
+  Regis.TextOut("color + pattern + fill");
+
+  Regis.Exit;
+END TestRegisColor.

BIN
tests/TestRegisDemo


+ 31 - 0
tests/TestRegisDemo.mod

@@ -0,0 +1,31 @@
+MODULE TestRegisDemo;
+
+(* ReGIS demo scene: frame, house, sun, label. View on a ReGIS-capable
+   terminal (xterm built with --enable-regis-graphics, or contour).
+   Pipe through od to inspect bytes headlessly. *)
+
+IMPORT Regis;
+
+BEGIN
+  Regis.Enter;
+
+  Regis.Rect(50, 50, 750, 430);
+
+  (* house body + roof + door *)
+  Regis.Rect(300, 250, 500, 400);
+  Regis.MoveTo(280, 250);
+  Regis.LineTo(400, 150);
+  Regis.LineTo(520, 250);
+  Regis.Rect(380, 320, 420, 400);
+
+  (* sun *)
+  Regis.MoveTo(650, 120);
+  Regis.Circle(700, 120);
+
+  (* label *)
+  Regis.MoveTo(300, 445);
+  Regis.TextSize(2);
+  Regis.TextOut("ReGIS house");
+
+  Regis.Exit;
+END TestRegisDemo.

BIN
tests/TestRegisMacro


+ 27 - 0
tests/TestRegisMacro.mod

@@ -0,0 +1,27 @@
+MODULE TestRegisMacro;
+
+(* ReGIS macrograph demo: define a relative box once, stamp it twice. *)
+
+IMPORT Regis;
+
+BEGIN
+  Regis.Enter;
+  Regis.ScreenErase;
+
+  Regis.MacroDef("B");
+  Regis.LineRel(100, 0);
+  Regis.LineRel(0, 100);
+  Regis.LineRel(-100, 0);
+  Regis.LineRel(0, -100);
+  Regis.MacroEnd;
+
+  Regis.MoveTo(100, 100);
+  Regis.MacroRun("B");
+  Regis.MoveTo(400, 250);
+  Regis.MacroRun("B");
+
+  Regis.MoveTo(100, 400);
+  Regis.TextOut("macros stamped twice");
+
+  Regis.Exit;
+END TestRegisMacro.

BIN
tests/TestVT100Charset


+ 35 - 0
tests/TestVT100Charset.mod

@@ -0,0 +1,35 @@
+MODULE TestVT100Charset;
+
+(* Character sets G0/G1 + shifts *)
+
+IMPORT VT100;
+FROM STextIO IMPORT WriteString, WriteLn;
+FROM Delay IMPORT Delay;
+
+BEGIN
+  VT100.ClearScreen;
+  VT100.CursorHome;
+  WriteString("--- VT100 Charset test ---"); WriteLn;
+
+  VT100.SetUK_G0; WriteString("SetUK_G0"); WriteLn;
+  VT100.SetUS_G0; WriteString("SetUS_G0"); WriteLn;
+  VT100.SetGraphics_G0; WriteString("SetGraphics_G0"); WriteLn;
+  VT100.SetAlt_G0; WriteString("SetAlt_G0"); WriteLn;
+  VT100.SetAltGraph_G0; WriteString("SetAltGraph_G0"); WriteLn;
+
+  VT100.SetUK_G1; WriteString("SetUK_G1"); WriteLn;
+  VT100.SetUS_G1; WriteString("SetUS_G1"); WriteLn;
+  VT100.SetGraphics_G1; WriteString("SetGraphics_G1"); WriteLn;
+  VT100.SetAlt_G1; WriteString("SetAlt_G1"); WriteLn;
+  VT100.SetAltGraph_G1; WriteString("SetAltGraph_G1"); WriteLn;
+
+  VT100.Shift2; WriteString("Shift2 (SS2)"); WriteLn;
+  VT100.Shift3; WriteString("Shift3 (SS3)"); WriteLn;
+
+  VT100.SetUS_G0;
+  VT100.SetUS_G1;
+  WriteString("back to US ASCII"); WriteLn;
+
+  WriteString("--- end Charset ---"); WriteLn;
+  Delay(500);
+END TestVT100Charset.

BIN
tests/TestVT100Cursor


+ 34 - 0
tests/TestVT100Cursor.mod

@@ -0,0 +1,34 @@
+MODULE TestVT100Cursor;
+
+(* Cursor: Home, Position, HVPosition, Up, Down, Right, Left *)
+
+IMPORT VT100;
+FROM STextIO IMPORT WriteString, WriteLn;
+FROM Delay IMPORT Delay;
+
+BEGIN
+  VT100.ClearScreen;
+  VT100.CursorHome;
+  WriteString("--- VT100 Cursor test ---"); WriteLn;
+  Delay(500);
+
+  VT100.CursorPosition(5, 10);
+  WriteString("at (5,10)");
+
+  VT100.HVPosition(7, 10);
+  WriteString("at HV (7,10)");
+
+  VT100.CursorHome;
+  WriteString("Home+");
+  VT100.CursorRight(5);
+  WriteString("R5+");
+  VT100.CursorDown(2);
+  WriteString("D2+");
+  VT100.CursorLeft(2);
+  WriteString("L2+");
+  VT100.CursorUp(1);
+  WriteString("U1");
+  WriteLn;
+
+  WriteString("--- end Cursor ---"); WriteLn;
+END TestVT100Cursor.

BIN
tests/TestVT100Erase


+ 54 - 0
tests/TestVT100Erase.mod

@@ -0,0 +1,54 @@
+MODULE TestVT100Erase;
+
+(* Erase: line right/left/all, screen down/up/all *)
+
+IMPORT VT100;
+FROM STextIO IMPORT WriteString, WriteLn;
+FROM Delay IMPORT Delay;
+
+BEGIN
+  VT100.ClearScreen;
+  VT100.CursorHome;
+  WriteString("--- VT100 Erase test ---"); WriteLn;
+
+  WriteString("Line with ClearLineRight -> garbage garbage");
+  VT100.CursorPosition(2, 20);
+  VT100.ClearLineRight;
+  WriteLn;
+
+  WriteString("garbage garbage <- ClearLineLeft");
+  VT100.CursorPosition(3, 20);
+  VT100.ClearLineLeft;
+  WriteLn;
+
+  WriteString("This line will be cleared");
+  VT100.CursorPosition(4, 1);
+  VT100.ClearLine;
+  VT100.CursorPosition(4, 1);
+  WriteString("ClearLine done");
+  WriteLn;
+  Delay(500);
+
+  VT100.CursorPosition(10, 1);
+  WriteString("filler below");
+  VT100.CursorPosition(8, 1);
+  VT100.ClearScreenDown;
+  VT100.CursorPosition(8, 1);
+  WriteString("ClearScreenDown done");
+  WriteLn;
+
+  VT100.CursorPosition(12, 1);
+  WriteString("filler");
+  VT100.CursorPosition(12, 1);
+  VT100.ClearScreenUp;
+  VT100.CursorPosition(12, 1);
+  WriteString("ClearScreenUp done");
+  WriteLn;
+  Delay(500);
+
+  VT100.ClearScreen;
+  VT100.CursorHome;
+  WriteString("ClearScreen done"); WriteLn;
+
+  WriteString("--- end Erase ---"); WriteLn;
+END TestVT100Erase.

BIN
tests/TestVT100Keypad


+ 21 - 0
tests/TestVT100Keypad.mod

@@ -0,0 +1,21 @@
+MODULE TestVT100Keypad;
+
+(* Keypad modes *)
+
+IMPORT VT100;
+FROM STextIO IMPORT WriteString, WriteLn;
+FROM Delay IMPORT Delay;
+
+BEGIN
+  VT100.ClearScreen;
+  VT100.CursorHome;
+  WriteString("--- VT100 Keypad test ---"); WriteLn;
+
+  VT100.SetAltKeypad;
+  WriteString("SetAltKeypad (ESC=)"); WriteLn;
+  Delay(500);
+  VT100.SetNumKeypad;
+  WriteString("SetNumKeypad (ESC>)"); WriteLn;
+
+  WriteString("--- end Keypad ---"); WriteLn;
+END TestVT100Keypad.

BIN
tests/TestVT100LedTest


+ 34 - 0
tests/TestVT100LedTest.mod

@@ -0,0 +1,34 @@
+MODULE TestVT100LedTest;
+
+(* LEDs + confidence tests. ResetTerminal isolated here. *)
+
+IMPORT VT100;
+FROM STextIO IMPORT WriteString, WriteLn;
+FROM Delay IMPORT Delay;
+
+BEGIN
+  VT100.ClearScreen;
+  VT100.CursorHome;
+  WriteString("--- VT100 LED/Test ---"); WriteLn;
+
+  VT100.LedsOff; WriteString("LedsOff"); WriteLn;
+  VT100.Led1; WriteString("Led1"); WriteLn;
+  VT100.Led2; WriteString("Led2"); WriteLn;
+  VT100.Led3; WriteString("Led3"); WriteLn;
+  VT100.Led4; WriteString("Led4"); WriteLn;
+  VT100.LedsOff;
+  Delay(500);
+
+  (* Confidence tests are destructive on real hardware;
+     emit only on explicit confirmation via TestPowerUp etc.
+     Left commented by default. *)
+  (*
+  VT100.TestPowerUp;
+  VT100.TestLoopback;
+  VT100.TestPowerRepeat;
+  VT100.TestLoopRepeat;
+  *)
+  WriteString("DECTST calls present but commented out."); WriteLn;
+
+  WriteString("--- end LED/Test ---"); WriteLn;
+END TestVT100LedTest.

BIN
tests/TestVT100Modes


+ 49 - 0
tests/TestVT100Modes.mod

@@ -0,0 +1,49 @@
+MODULE TestVT100Modes;
+
+(* LNM + DEC private modes ?1..?9 *)
+
+IMPORT VT100;
+FROM STextIO IMPORT WriteString, WriteLn;
+FROM Delay IMPORT Delay;
+
+BEGIN
+  VT100.ClearScreen;
+  VT100.CursorHome;
+  WriteString("--- VT100 Modes test ---"); WriteLn;
+
+  VT100.SetNewLine; WriteString("SetNewLine "); WriteLn;
+  VT100.ResetNewLine; WriteString("ResetNewLine"); WriteLn;
+
+  VT100.SetAppCursorKeys; WriteString("SetAppCursorKeys"); WriteLn;
+  VT100.SetCursorKeys; WriteString("SetCursorKeys"); WriteLn;
+
+  VT100.SetANSI; WriteString("SetANSI"); WriteLn;
+  VT100.SetVT52; WriteString("SetVT52 (careful: terminal may switch!)"); WriteLn;
+  VT100.SetANSI; (* back to ANSI *)
+
+  VT100.Set132Columns; WriteString("Set132Columns"); WriteLn;
+  Delay(300);
+  VT100.Set80Columns; WriteString("Set80Columns"); WriteLn;
+
+  VT100.SetSmoothScroll; WriteString("SetSmoothScroll"); WriteLn;
+  VT100.SetJumpScroll; WriteString("SetJumpScroll"); WriteLn;
+
+  VT100.SetReverseScreen; WriteString("SetReverseScreen"); WriteLn;
+  Delay(300);
+  VT100.SetNormalScreen; WriteString("SetNormalScreen"); WriteLn;
+
+  VT100.SetRelativeOrigin; WriteString("SetRelativeOrigin"); WriteLn;
+  VT100.SetAbsoluteOrigin; WriteString("SetAbsoluteOrigin"); WriteLn;
+
+  VT100.SetAutoWrap; WriteString("SetAutoWrap"); WriteLn;
+  VT100.ResetAutoWrap; WriteString("ResetAutoWrap"); WriteLn;
+  VT100.SetAutoWrap; (* leave wrap on *)
+
+  VT100.SetAutoRepeat; WriteString("SetAutoRepeat"); WriteLn;
+  VT100.ResetAutoRepeat; WriteString("ResetAutoRepeat"); WriteLn;
+
+  VT100.SetInterlace; WriteString("SetInterlace"); WriteLn;
+  VT100.ResetInterlace; WriteString("ResetInterlace"); WriteLn;
+
+  WriteString("--- end Modes ---"); WriteLn;
+END TestVT100Modes.

BIN
tests/TestVT100Reports


+ 37 - 0
tests/TestVT100Reports.mod

@@ -0,0 +1,37 @@
+MODULE TestVT100Reports;
+
+(* DSR / DA / RIS. Sends requests only, no blocking read. *)
+
+IMPORT VT100;
+FROM STextIO IMPORT WriteString, WriteLn;
+FROM Delay IMPORT Delay;
+
+BEGIN
+  VT100.ClearScreen;
+  VT100.CursorHome;
+  WriteString("--- VT100 Reports test ---"); WriteLn;
+
+  VT100.RequestDeviceStatus;
+  WriteLn;
+  WriteString("RequestDeviceStatus sent (ESC[5n)"); WriteLn;
+  Delay(300);
+
+  VT100.RequestCursorPosition;
+  WriteLn;
+  WriteString("RequestCursorPosition sent (ESC[6n)"); WriteLn;
+  Delay(300);
+
+  VT100.Identify;
+  WriteLn;
+  WriteString("Identify sent (ESC[c)"); WriteLn;
+  Delay(300);
+
+  VT100.Identify2;
+  WriteLn;
+  WriteString("Identify2 sent (ESC[0c)"); WriteLn;
+  Delay(300);
+
+  WriteString("ResetTerminal NOT executed here (would reset)."); WriteLn;
+
+  WriteString("--- end Reports ---"); WriteLn;
+END TestVT100Reports.

BIN
tests/TestVT100SGR


+ 36 - 0
tests/TestVT100SGR.mod

@@ -0,0 +1,36 @@
+MODULE TestVT100SGR;
+
+(* SGR attributes: Reset, Bold, Underline, Blink, Reverse *)
+
+IMPORT VT100;
+FROM STextIO IMPORT WriteString, WriteLn;
+FROM Delay IMPORT Delay;
+
+BEGIN
+  VT100.ClearScreen;
+  VT100.CursorHome;
+
+  WriteString("--- VT100 SGR test ---"); WriteLn;
+  Delay(500);
+
+  VT100.ResetAttributes;
+  WriteString("Normal"); WriteLn;
+
+  VT100.Bold;
+  WriteString("Bold"); WriteLn;
+  VT100.ResetAttributes;
+
+  VT100.Underline;
+  WriteString("Underline"); WriteLn;
+  VT100.ResetAttributes;
+
+  VT100.Blink;
+  WriteString("Blink"); WriteLn;
+  VT100.ResetAttributes;
+
+  VT100.Reverse;
+  WriteString("Reverse"); WriteLn;
+  VT100.ResetAttributes;
+
+  WriteString("--- end SGR ---"); WriteLn;
+END TestVT100SGR.

BIN
tests/TestVT100Scroll


+ 39 - 0
tests/TestVT100Scroll.mod

@@ -0,0 +1,39 @@
+MODULE TestVT100Scroll;
+
+(* Scroll/line: Index, ReverseIndex, NextLine, Save/Restore, ScrollRegion *)
+
+IMPORT VT100;
+FROM STextIO IMPORT WriteString, WriteLn;
+FROM Delay IMPORT Delay;
+
+BEGIN
+  VT100.ClearScreen;
+  VT100.CursorHome;
+  WriteString("--- VT100 Scroll test ---"); WriteLn;
+
+  VT100.SaveCursor;
+  VT100.CursorPosition(10, 1);
+  WriteString("saved here");
+  VT100.CursorPosition(12, 1);
+  WriteString("moved");
+  Delay(500);
+  VT100.RestoreCursor;
+  WriteString(" <- restored");
+  WriteLn;
+  Delay(500);
+
+  VT100.Index;
+  WriteString("Index (ESC D)"); WriteLn;
+  VT100.ReverseIndex;
+  WriteString("ReverseIndex (ESC M)"); WriteLn;
+  VT100.NextLine;
+  WriteString("NextLine (ESC E)"); WriteLn;
+
+  VT100.SetScrollRegion(5, 15);
+  WriteString("ScrollRegion 5..15 set"); WriteLn;
+  Delay(500);
+  VT100.SetScrollRegion(1, 24);
+  WriteString("ScrollRegion reset 1..24"); WriteLn;
+
+  WriteString("--- end Scroll ---"); WriteLn;
+END TestVT100Scroll.

BIN
tests/TestVT100Size


+ 37 - 0
tests/TestVT100Size.mod

@@ -0,0 +1,37 @@
+MODULE TestVT100Size;
+
+(* Double-size lines + alignment *)
+
+IMPORT VT100;
+FROM STextIO IMPORT WriteString, WriteLn;
+FROM Delay IMPORT Delay;
+
+BEGIN
+  VT100.ClearScreen;
+  VT100.CursorHome;
+  WriteString("--- VT100 Size test ---"); WriteLn;
+
+  VT100.DoubleHeightTop;
+  WriteString("DoubleHeightTop"); WriteLn;
+  VT100.DoubleHeightBottom;
+  WriteString("DoubleHeightBottom"); WriteLn;
+  VT100.SingleWidth;
+  WriteString("SingleWidth"); WriteLn;
+  VT100.DoubleWidth;
+  WriteString("DoubleWidth"); WriteLn;
+  Delay(1000);
+
+  VT100.ClearScreen;
+  VT100.CursorHome;
+  VT100.SingleWidth;
+  WriteString("back to single width"); WriteLn;
+
+  (* ScreenAlign fills screen with E - destructive, keep last *)
+  VT100.ScreenAlign;
+  Delay(1000);
+  VT100.ClearScreen;
+  VT100.CursorHome;
+  WriteString("ScreenAlign done + cleared"); WriteLn;
+
+  WriteString("--- end Size ---"); WriteLn;
+END TestVT100Size.

BIN
tests/TestVT100Tabs


+ 30 - 0
tests/TestVT100Tabs.mod

@@ -0,0 +1,30 @@
+MODULE TestVT100Tabs;
+
+(* Tabs: Set, Clear, ClearAll *)
+
+IMPORT VT100;
+FROM STextIO IMPORT WriteString, WriteLn;
+FROM Delay IMPORT Delay;
+
+BEGIN
+  VT100.ClearScreen;
+  VT100.CursorHome;
+  WriteString("--- VT100 Tabs test ---"); WriteLn;
+
+  VT100.CursorPosition(5, 10);
+  VT100.TabSet;
+  VT100.CursorPosition(5, 20);
+  VT100.TabSet;
+  WriteString("tabs set at col 10,20");
+
+  VT100.CursorPosition(6, 1);
+  VT100.TabClear;
+  WriteString("TabClear at current col done");
+  WriteLn;
+
+  VT100.TabClearAll;
+  WriteString("TabClearAll done"); WriteLn;
+
+  WriteString("--- end Tabs ---"); WriteLn;
+  Delay(500);
+END TestVT100Tabs.

BIN
tests/TestVT52Cursor


+ 34 - 0
tests/TestVT52Cursor.mod

@@ -0,0 +1,34 @@
+MODULE TestVT52Cursor;
+
+(* VT52 cursor: Up/Down/Right/Left/Home/Position *)
+
+IMPORT VT52;
+FROM STextIO IMPORT WriteString, WriteLn;
+FROM Delay IMPORT Delay;
+
+BEGIN
+  VT52.CursorHome;
+  WriteString("--- VT52 Cursor test ---"); WriteLn;
+  Delay(300);
+
+  VT52.CursorPosition(5, 10);
+  WriteString("at (5,10)");
+
+  VT52.CursorHome;
+  WriteString("Home+");
+  VT52.CursorRight;
+  WriteString("R+");
+  VT52.CursorDown;
+  WriteString("D+");
+  VT52.CursorLeft;
+  WriteString("L+");
+  VT52.CursorUp;
+  WriteString("U");
+  WriteLn;
+
+  VT52.CursorPosition(12, 30);
+  WriteString("at (12,30)");
+  WriteLn;
+
+  WriteString("--- end Cursor ---"); WriteLn;
+END TestVT52Cursor.

BIN
tests/TestVT52Erase


+ 38 - 0
tests/TestVT52Erase.mod

@@ -0,0 +1,38 @@
+MODULE TestVT52Erase;
+
+(* VT52 erase + reverse feed *)
+
+IMPORT VT52;
+FROM STextIO IMPORT WriteString, WriteLn;
+FROM Delay IMPORT Delay;
+
+BEGIN
+  VT52.CursorHome;
+  WriteString("--- VT52 Erase test ---"); WriteLn;
+
+  WriteString("line + garbage garbage");
+  VT52.CursorHome;
+  VT52.CursorDown;
+  VT52.CursorRight;
+  VT52.CursorRight;
+  VT52.CursorRight;
+  VT52.CursorRight;
+  VT52.ClearToEndOfLine;
+  WriteLn;
+  WriteString("ClearToEndOfLine done (ESC K)"); WriteLn;
+  Delay(300);
+
+  VT52.CursorPosition(10, 1);
+  WriteString("filler below");
+  VT52.CursorPosition(8, 1);
+  VT52.ClearToEndOfScreen;
+  VT52.CursorPosition(8, 1);
+  WriteString("ClearToEndOfScreen done (ESC J)");
+  WriteLn;
+  Delay(300);
+
+  VT52.ReverseFeed;
+  WriteString("ReverseFeed (ESC I)"); WriteLn;
+
+  WriteString("--- end Erase ---"); WriteLn;
+END TestVT52Erase.

BIN
tests/TestVT52Ident


+ 22 - 0
tests/TestVT52Ident.mod

@@ -0,0 +1,22 @@
+MODULE TestVT52Ident;
+
+(* VT52 identify: send only, no blocking read *)
+
+IMPORT VT52;
+FROM STextIO IMPORT WriteString, WriteLn;
+FROM Delay IMPORT Delay;
+
+BEGIN
+  WriteString("--- VT52 Ident test ---"); WriteLn;
+
+  VT52.Identify;
+  WriteLn;
+  WriteString("Identify sent (ESC Z)"); WriteLn;
+  Delay(300);
+
+  VT52.IdentifyResponse;
+  WriteLn;
+  WriteString("IdentifyResponse sent (ESC / Z)"); WriteLn;
+
+  WriteString("--- end Ident ---"); WriteLn;
+END TestVT52Ident.

BIN
tests/TestVT52Mode


+ 29 - 0
tests/TestVT52Mode.mod

@@ -0,0 +1,29 @@
+MODULE TestVT52Mode;
+
+(* VT52 modes + charsets: EnterAnsi, keypads, graphics/ascii *)
+
+IMPORT VT52;
+FROM STextIO IMPORT WriteString, WriteLn;
+FROM Delay IMPORT Delay;
+
+BEGIN
+  WriteString("--- VT52 Mode test ---"); WriteLn;
+
+  VT52.SetAltKeypad;
+  WriteString("SetAltKeypad (ESC=)"); WriteLn;
+  Delay(300);
+  VT52.SetNumKeypad;
+  WriteString("SetNumKeypad (ESC>)"); WriteLn;
+
+  VT52.SetGraphics;
+  WriteString("SetGraphics (ESC F)"); WriteLn;
+  Delay(300);
+  VT52.SetAscii;
+  WriteString("SetAscii (ESC G)"); WriteLn;
+
+  (* EnterAnsi switches terminal out of VT52 - keep last *)
+  VT52.EnterAnsi;
+  WriteString("EnterAnsi (ESC <)"); WriteLn;
+
+  WriteString("--- end Mode ---"); WriteLn;
+END TestVT52Mode.

BIN
tests/testSpliV1


+ 200 - 0
tests/testSplit.mod

@@ -0,0 +1,200 @@
+MODULE testSplit;
+
+IMPORT SplitV1;
+FROM InOut IMPORT Write, WriteLn, WriteString, WriteCard;
+
+
+VAR 
+  chaine1 : ARRAY[0..255] OF CHAR;
+  chaine2 : ARRAY[0..255] OF CHAR;
+  maStructure : SplitV1.Structure;
+  i : CARDINAL;
+
+BEGIN
+  SplitV1.InitStructure(maStructure);
+
+(*  WriteString (" Test de Ltrim ");
+  WriteLn;
+  chaine1 := "=====Encore=un=test==";
+  WriteString(chaine1);
+  WriteLn;
+  Write("*");
+  SplitV1.Ltrim(chaine1, "=");
+  WriteString(chaine1);
+  Write("*");
+  WriteLn;
+*)
+(*  
+  WriteString (" Test de Rtrim ");
+  WriteLn;
+  chaine1 := "!!Encore!un=test!!!!!";
+  WriteString(chaine1);
+  WriteLn;
+  Write("*");
+  SplitV1.Rtrim(chaine1, "!");
+  WriteString(chaine1);
+  Write("*");
+  WriteLn;
+*)  
+
+(*  WriteString (" Test de RemoveDuplicate ");
+  WriteLn;
+  chaine1 := "!!Encore!!un!!test!!!!!";
+  WriteString(chaine1);
+  WriteLn;
+  Write("*");
+  SplitV1.removeDuplicate(chaine1, "!");
+  WriteString(chaine1);
+  Write("*");
+  WriteLn; 
+*)
+
+(******************* test de Split dans les # cas *************)
+(*  ça fonctionne !
+  WriteString (" Test de Split version 1 sans separateurs en début ou à la fin et sans duplicats");
+  WriteLn;
+  Write("*");
+  chaine1 := "Encore de beaux jours devant nous";
+  WriteString(chaine1);
+  Write("*");
+  WriteLn;  
+
+  SplitV1.SplitStr(chaine1, " ", maStructure);
+  FOR i := 0 TO HIGH(maStructure) DO
+    WriteCard(maStructure[i].pos,5);
+    Write("-");
+    WriteString(maStructure[i].element);
+    WriteLn;
+  END;
+  WriteLn;
+  WriteLn;  
+*)
+  
+(* ça fonctionne !
+  WriteString (" Test de Split version avec separateurs au début ou à la fin et duplicata");
+  WriteLn;
+  Write("*");
+  chaine1 := " Encore   de beaux jours   devant nous ";
+  Write("*");
+  WriteString(chaine1);
+  WriteLn;
+  WriteString (" Test de Split ");
+  WriteLn;  
+
+  SplitV1.SplitStr(chaine1, " ", maStructure);
+  FOR i := 0 TO HIGH(maStructure) DO
+    WriteCard(maStructure[i].pos,5);
+    Write("-");
+    WriteString(maStructure[i].element);
+    WriteLn;
+  END;
+  WriteLn;
+  WriteLn;    
+*)
+(* ça marche ! 
+  WriteString (" Test de Split version avec separateurs au début ou à la fin et duplicata, mais en mode suppression duplicata");
+  WriteLn;
+  Write("*");
+  chaine1 := "###Encore####de#beaux##jours#####devant nous####";
+  WriteString(chaine1);
+  Write("*");
+  WriteLn;
+  WriteString (" Test de Split ");
+  WriteLn;  
+  SplitV1.noDupMode := TRUE ;
+  SplitV1.SplitStr(chaine1, "#", maStructure);
+  FOR i := 0 TO HIGH(maStructure) DO
+    WriteCard(maStructure[i].pos,5);
+    Write("-");
+    WriteString(maStructure[i].element);
+    WriteLn;
+  END;
+  WriteLn;
+  WriteLn;
+*)  
+(* ça marche !  
+  WriteString (" Test de Split version avec separateurs au début ou à la fin et duplicata, mais en mode ltrim");
+  WriteLn;
+  Write("*");
+  chaine1 := "###Encore####de#beaux##jours#####devant nous####";
+  WriteString(chaine1);
+  Write("*");
+  WriteLn;
+  WriteString (" Test de Split ");
+  WriteLn;  
+  SplitV1.ltrim := TRUE ;
+  SplitV1.SplitStr(chaine1, "#", maStructure);
+  FOR i := 0 TO HIGH(maStructure) DO
+    WriteCard(maStructure[i].pos,5);
+    Write("-");
+    WriteString(maStructure[i].element);
+    WriteLn;
+  END;
+  WriteLn;
+  WriteLn;  
+  *)
+
+(*
+  WriteString (" Test de Split version avec separateurs au début ou à la fin et duplicata, mais en mode rtrim");
+  WriteLn;
+  Write("*");
+  chaine1 := "###Encore####de#beaux##jours#####devant nous####";
+  WriteString(chaine1);
+  Write("*");
+  WriteLn;
+  WriteString (" Test de Split ");
+  WriteLn;  
+  SplitV1.rtrim := TRUE ;
+  SplitV1.SplitStr(chaine1, "#", maStructure);
+  FOR i := 0 TO HIGH(maStructure) DO
+    WriteCard(maStructure[i].pos,5);
+    Write("-");
+    WriteString(maStructure[i].element);
+    WriteLn;
+  END;
+  WriteLn;
+  WriteLn;
+ *)
+ 
+  (* WriteString (" Test de Split version avec separateurs au début ou à la fin et duplicata, mais en mode rtrim");
+  WriteLn;
+  Write("*");
+  chaine1 := "###Encore####de#beaux##jours#####devant nous####";
+  WriteString(chaine1);
+  Write("*");
+  WriteLn;
+  WriteString (" Test de Split ");
+  WriteLn;  
+  SplitV1.allTrimMode := TRUE ;
+  SplitV1.SplitStr(chaine1, "#", maStructure);
+  FOR i := 0 TO HIGH(maStructure) DO
+    WriteCard(maStructure[i].pos,5);
+    Write("-");
+    WriteString(maStructure[i].element);
+    WriteLn;
+  END;
+  WriteLn;
+  WriteLn;  *)
+
+  WriteString (" Test de Split version avec separateurs au début ou à la fin et duplicata, mais en mode rtrim");
+  WriteLn;
+  Write("*");
+  chaine1 := "24;1";
+  WriteString(chaine1);
+  Write("*");
+  WriteLn;
+  WriteString (" Test de Split ");
+  WriteLn;  
+  SplitV1.allTrimMode := TRUE ;
+  SplitV1.SplitStr(chaine1, ";", maStructure);
+  FOR i := 0 TO HIGH(maStructure) DO
+    WriteCard(maStructure[i].pos,5);
+    Write("-");
+    WriteString(maStructure[i].element);
+    WriteLn;
+  END;
+  WriteLn;
+  WriteLn; 
+  
+  WriteString (" Fin du test V1 ");
+END testSplit.

Some files were not shown because too many files changed in this diff