MakeVT100:
PROC
RETURNS [t: Term] = {
cursor ← NEW[CurrentCursorRec];
t ← NEW [TermRep ← [cp: NewControlProgram[]]];
AddInstruction[t.cp, LIST["\000"], [Naught]];
AddInstruction[t.cp, LIST["\007"], [Beep]];
AddInstruction[t.cp, LIST["\010"], [SkipCursor, $left]];
AddInstruction[t.cp, LIST["\011"], [Tab, $dontTouch]];
AddInstruction[t.cp, LIST["\012"], [SkipCursor, $down]];
AddInstruction[t.cp, LIST["\015"], [CarriageReturn]];
AddInstruction[t.cp, LIST["\033[H"], [Home]];
AddInstruction[t.cp, LIST["\033f"], [Home]];
AddInstruction[t.cp, LIST["\033[f"], [Home]];
AddInstruction[t.cp, LIST["\033[A"], [SkipCursor, $up]];
AddInstruction[t.cp, LIST["\033A"], [Vt52CU]];
AddInstruction[t.cp, LIST["\033[B"], [SkipCursor, $down]];
AddInstruction[t.cp, LIST["\033B"], [Vt52CD]];
AddInstruction[t.cp, LIST["\033[C"], [SkipCursor, $right]];
AddInstruction[t.cp, LIST["\033C"], [Vt52CR]];
AddInstruction[t.cp, LIST["\033[D"], [SkipCursor, $left]];
AddInstruction[t.cp, LIST["\033D"], [Vt52CL]];
AddInstruction[t.cp, LIST["\033H"], [Vt52CH]];
AddInstruction[t.cp, LIST["\033I"], [Vt52RLF]];
AddInstruction[t.cp, LIST["\033[J"], [ClrTo, $eos]];
AddInstruction[t.cp, LIST["\033J"], [Vt52EOS]];
AddInstruction[t.cp, LIST["\033[K"], [ClrTo, $eol]];
AddInstruction[t.cp, LIST["\033K"], [Vt52EOL]];
AddInstruction[t.cp, LIST["\0337"], [SaveAll]];
AddInstruction[t.cp, LIST["\0338"], [RestoreAll]];
AddInstruction[t.cp, LIST["\033[m"], [AttsOff]];
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line]], "J"], [JDecode]];
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line]], "K"], [KDecode]];
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line]], "m"], [Att1Decode]];
AddInstruction[t.cp,
LIST["\033[",
NEW [DecodeRep ← [reg: line]], ";",
NEW [DecodeRep ← [reg: col]],
"m"], [Att2Decode]];
AddInstruction[t.cp,
LIST["\033[",
NEW [DecodeRep ← [reg: line]], ";",
NEW [DecodeRep ← [reg: col]], ";",
NEW [DecodeRep ← [reg: aux1]], ";",
"m"], [Att3Decode]];
AddInstruction[t.cp,
LIST["\033[",
NEW [DecodeRep ← [reg: line]], ";",
NEW [DecodeRep ← [reg: col]], ";",
NEW [DecodeRep ← [reg: aux1]], ";",
NEW [DecodeRep ← [reg: aux2]], ";",
"m"], [Att4Decode]];
AddInstruction[t.cp,
LIST["\033[",
NEW [DecodeRep ← [reg: line]], ";",
NEW [DecodeRep ← [reg: col]], ";",
NEW [DecodeRep ← [reg: aux1]], ";",
NEW [DecodeRep ← [reg: aux2]], ";",
NEW [DecodeRep ← [reg: aux3]], ";",
"m"], [Att5Decode]];
AddInstruction[t.cp,
LIST["\033[",
NEW [DecodeRep ← [reg: line]], ";",
NEW [DecodeRep ← [reg: col]], "H"], [NormCursor]];
AddInstruction[t.cp,
LIST["\033Y",
NEW [DecodeRep ← [reg: line, base: NumChars, org: ' , len: 1]],
NEW [DecodeRep ← [reg: col, base: NumChars, org: ' , len: 1]]],
[Vt52CA]];
AddInstruction[t.cp,
LIST["\033[",
NEW [DecodeRep ← [reg: line]], ";",
NEW [DecodeRep ← [reg: col]], "f"], [NormCursor]];
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line]], "A"], [JumpCursor, $v]];
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line]], "B"], [JumpCursor, $v]];
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line]], "C"], [CursorHn]];
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line]], "D"], [CursorHn]];
-- *** NoOp Traps *** --
-- Programmable LEDs
AddInstruction[t.cp, LIST["\033[q"], [Naught]];
-- Line Size
AddInstruction[t.cp, LIST["\033#", NEW [DecodeRep ← [reg: line, len: 1]]], [Naught]];
-- Indexing
AddInstruction[t.cp, LIST["\033D"], [Naught]];
AddInstruction[t.cp, LIST["\033E"], [Naught]];
AddInstruction[t.cp, LIST["\033M"], [Naught]];
-- Alternate Characters/Keys
AddInstruction[t.cp, LIST["\033F"], [Naught]];
AddInstruction[t.cp, LIST["\033G"], [Naught]];
AddInstruction[t.cp, LIST["\033>"], [Naught]];
AddInstruction[t.cp, LIST["\033<"], [Naught]];
AddInstruction[t.cp, LIST["\033="], [Naught]];
AddInstruction[t.cp, LIST["\033(A"], [Naught]];
AddInstruction[t.cp, LIST["\033(B"], [Naught]];
AddInstruction[t.cp, LIST["\033(", NEW [DecodeRep ← [reg: line, len: 1]]], [Naught]];
AddInstruction[t.cp, LIST["\033)A"], [Naught]];
AddInstruction[t.cp, LIST["\033)B"], [Naught]];
AddInstruction[t.cp, LIST["\033)", NEW [DecodeRep ← [reg: line, len: 1]]], [Naught]];
-- Scrolling Region
AddInstruction[t.cp,
LIST["\033[",
NEW [DecodeRep ← [reg: line]], ";",
NEW [DecodeRep ← [reg: col]],
"r"], [Naught]];
-- Tabbing
AddInstruction[t.cp, LIST["\033H"], [Naught]];
AddInstruction[t.cp, LIST["\033[g"], [Naught]];
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line, len: 1]], "g"], [Naught]];
-- Status Report
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line, len: 1]], "n"], [Naught]];
-- Interrogation
AddInstruction[t.cp, LIST["\033c"], [Naught]];
AddInstruction[t.cp, LIST["\033Z"], [Naught]];
AddInstruction[t.cp, LIST["\033[c"], [Naught]];
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line, len: 1]], "c"], [Naught]];
AddInstruction[t.cp, LIST["\033[?l", NEW [DecodeRep ← [reg: line, len: 1]], "c"], [Naught]];
-- Tests
AddInstruction[t.cp, LIST["\033[2", NEW [DecodeRep ← [reg: line, len: 1]], "y"], [Naught]];
-- Modes
AddInstruction[t.cp, LIST["\033[?", NEW [DecodeRep ← [reg: line, len: 1]], "h"], [hDecode]];
AddInstruction[t.cp, LIST["\033[?", NEW [DecodeRep ← [reg: line, len: 1]], "l"], [lDecode]];
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line, len: 2]], "h"], [Naught]];
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line, len: 2]], "l"], [Naught]];
};