MakeSunConsole:
PROC
RETURNS [t: Term] = {
t ←
NEW [TermRep ← [cp: NewControlProgram[], tipTableName: tipName]];
Control Characters
t.det.lines ← 34; -- set to 34-line window
AddInstruction[t.cp, LIST["\000"], [Naught]]; -- control-@ (null)
AddInstruction[t.cp, LIST["\007"], [Beep]]; -- control-G (bell)
AddInstruction[t.cp, LIST["\010"], [SkipCursor, $left]]; -- control-H (backspace)
AddInstruction[t.cp, LIST["\011"], [Tab, $dontTouch]]; -- control-I (tab)
AddInstruction[t.cp, LIST["\012"], [SkipCursor, $down]]; -- control-J (linefeed)
AddInstruction[t.cp, LIST["\013"], [SkipCursor, $up]]; -- control-K (un-linefeed)
AddInstruction[t.cp, LIST["\014"], [FormFeed]]; -- control-L (formfeed)
AddInstruction[t.cp,
LIST["\015"], [CarriageReturn]];
-- control-M (return)
Escape Sequences
AddInstruction[t.cp, LIST["\033[@"], [InsertSpace]]; -- insert character
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line]], "@"], [InsertSpaces, $v]];
AddInstruction[t.cp, LIST["\033[A"], [SkipCursor, $up]]; -- move cursor
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line]], "A"], [CursorMove, $up]];
AddInstruction[t.cp, LIST["\033[B"], [SkipCursor, $down]];
AddInstruction[
t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line]], "B"], [CursorMove, $down]];
AddInstruction[t.cp, LIST["\033[C"], [SkipCursor, $right]];
AddInstruction[
t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line]], "C"], [CursorMove, $right]];
AddInstruction[t.cp, LIST["\033[D"], [SkipCursor, $left]];
AddInstruction[
t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line]], "D"], [CursorMove, $left]];
AddInstruction[t.cp, LIST["\033[E"], [NextLine]]; -- next line (CRLF)
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line]], "E"], [SkipLines]];
AddInstruction[t.cp, LIST["\033[f"], [Home]]; -- position cursor
AddInstruction[t.cp, LIST["\033[H"], [Home]]; -- home
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line]], "f"], [StartOfLine]];
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line]], "H"], [StartOfLine]];
AddInstruction[t.cp, -- position using "f"
LIST["\033[", NEW [DecodeRep ← [reg: line]], ";", NEW [DecodeRep ← [reg: col]], "f"],
[NormCursor]
];
AddInstruction[t.cp, -- position using "H"
LIST["\033[", NEW [DecodeRep ← [reg: line]], ";", NEW [DecodeRep ← [reg: col]], "H"],
[NormCursor]
];
AddInstruction[t.cp, LIST["\033[J"], [ClrTo, $eos]]; -- erase rest of display
AddInstruction[t.cp, LIST["\033[K"], [ClrTo, $eol]]; -- erase rest of line
AddInstruction[t.cp, LIST["\033[L"], [Line, $ins]]; -- insert line
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line]], "L"], [Lines, $ins]];
AddInstruction[t.cp, LIST["\033[M"], [Line, $del]]; -- delete line
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line]], "M"], [Lines, $del]];
AddInstruction[t.cp, LIST["\033[P"], [DeleteChar]]; -- delete character
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line]], "P"], [DeleteChars]];
AddInstruction[t.cp, LIST["\033[m"], [SetEmph, $inverseOff]]; -- select graphic rendition
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line]], "m"], [InvertChars]];
AddInstruction[t.cp, LIST["\033[p"], [Naught]]; -- set screen Black on White
AddInstruction[t.cp, LIST["\033[q"], [Naught]]; -- set screen White on Black
AddInstruction[t.cp, LIST["\033[r"], [Naught]]; -- set scrolling
AddInstruction[t.cp, LIST["\033[", NEW [DecodeRep ← [reg: line]], "r"], [Naught]];
AddInstruction[t.cp, LIST["\033[s"], [Reset]]; -- reset modes to default
AddInstruction[t.cp, LIST["\033[",
NEW [DecodeRep ← [reg: line]], ";",
NEW [DecodeRep ← [reg: col]], ";",
NEW [DecodeRep ← [reg: col]], "t"], [Naught]]; -- Meiko junk
};