ANSI/DEC VT Terminal Character Control Sequences ================================================ I have found that documentation for various VT/ANSI terminal sequences is contradictory and misleading. After extensive testing, the following sequences are what I use to obtain these listed effects. +--------+--------+---------------------+--------------------+----------------------------+ | Char : Action | VT100 and later | VT52 : UKNC/VT52 | +--------+--------+---------------------+--------------------+----------------------------+ | 07 : Bell | 07 | 07 : 07 | +--------+--------+---------------------+--------------------+----------------------------+ | 08 : Left | 08 | D : D | | 09 : Right | [C | C : C | | 10 : Down | D | 11 : 10 | | 11 : Up | M | I : I | | 12 : CLS | [2J[1;1H | HJ : HJ | | 13 : CR | 13 | 13 : 13 | | 30 : Home | [1;1H | Y : Y | | 31,x,y : TAB | [1+y;1+xH | Y<32+y><32+x> : Y<32+y><32+x> | | 127 : Delete | 0808 | 0808 : 0808 | +--------+--------+---------------------+--------------------+----------------------------+ | 17,n : COLOUR | [...m | : &00+n: ,160,'0'-'7' | | : | | : &40+n: ,167,'0'-'7' | | : | | : &80+n: ,161,'0'-'7', | | : | | : ,162,'0'-'7' | | 20 : Reset | [0m | :,191,163,,191,164,| | : | | :,160,'7',,167,'7',| | : | | :,161,'0',,162,'0' | | 22,n : MODE | as VDU 20,12 | :,166,'1'-'4' | | : | | : then VDU 20,12 | +--------+--------+---------------------+--------------------+----------------------------+ | 16 : CLG | | : | | 18,a,n : GCOL | | : | | 19... : Palette| | : | | 23... : | | : | | 24... : | | : | | 25... : PLOT | | : | | 26... : | | : | | 28... : | | : | | 29... : | | : | +--------+--------+---------------------+--------------------+----------------------------+ Notes ----- 08 and 13 appear to be the only universal control characters. Everything else appears to be interpreted differently by different systems. In particular, the VT100 appears to implement 10 as NEWLINE instead of DOWN, necessitating using D - which is different to D on the VT52! Documentation and testing shows that A/B/C/D move the cursor, but fail to scroll when at the edge of the screen, resulting in text being overwritten. This neccessitates using using D and M on the VT100 and 10 or 11 and I on the VT52. Even character 08 can't be relied on. The VT52 can be switched to a different mode where 08 is Home not Left, so D has to be used. ANSI colour selection builds an [0;7;4;5;30;1;40;100m sequence as follows: Initialise with: fgd=7:bgd=0:PRINT CHR$27;"[0,"; :REM White on black Select colour with: IF (C >= 192):border=C AND 15:ENDPROC :REM Set border colour IF (C AND 128):bgd=C AND 15 ELSE fgd=C AND 15 :REM Set new colour PRINT CHR$27;"[0"; IF (C AND 16):PRINT ";5"; :REM Flash IF (C AND 32):PRINT ";4"; :REM Underline IF (C AND 64):PRINT ";7"; :REM Inverse PRINT ";";30+(fgd AND 7); :REM Foreground colour IF (fgd AND 8):PRINT ";1"; :REM Bright foreground PRINT ";";40+(bgd AND 7); :REM Background colour IF (bgd AND 8):PRINT ";";100+(bgd AND 7); :REM Bright background PRINT "m"; On some platforms [21m is not the opposite of [1m, so they cannot be used as a pair, so a reset sequence has to be sent instead. On the UKNC the RGB colour number 0,1,2,3,4,5,6,7 is mapped to 0,4,2,6,1,5,3,7. RT11Em's VT52 implementation appears to have bugs in it. CHR$10 does NEWLINE instead of DOWN, but CHR$11 does DOWN. A VT100 [...m colour sequence appears to crash either RT11 or the emulator.