| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- 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.
|