platform_agnostic:vt100_escape_sequences
VT100 Escape Sequences
Links to various web pages
VT100 Escape Sequences
VT100 library for the Micromite console
'These are MMBasic library routines for TeraTerm VT100 terminal video. 'Comments are NOT recoverable from the Micromite as they are stripped out on 'inclusion into the library. It is worth keeping a copy of this file. :) ' Vhelp show help info ' Vcls clear screen ' Vch cursor home to top left ' Vcdn n move cursor down n lines ' Vcr n move cursor rignt n characters ' Vcl n move cursor left n characters ' Vcup n move cursor up n lines ' Vat row col move cursor to row,column ' Vsc save current cursor position ' Vrc restore cursor position saved by Vsc ' Vbox y,x,w,h,t draw a box ' Vl y,x,l,t draw a vertical or horixontal line to divide a box ' Vatt n$ set text attributes to n$ (none,bold,inverse,underlined) ' Vfc n$ set text/foreground colour by name or str$(number) 0-15 ' Vbc n$ set background colour by name or str$(number) 0-16 (16 is light grey) ' ch print Chr$(27)+"[" (the Escape sequence) - used internally Sub Vcls 'clear the screen ch Print "2J"; End Sub Sub Vch 'cursor home to top left corner ch Print "H"; End Sub Sub Vcdn(n) 'move cursor down n lines Local vz$ vz$=Str$(n)+";B" ch Print vz$; End Sub Sub Vcup(n) 'move cursor up n lines Local vz$ vz$=Str$(n)+";A" ch Print vz$; End Sub Sub Vcr(n) 'move cursor right n characters Local vz$ vz$=Str$(n)+";C" ch Print vz$; End Sub Sub Vcl(n) 'move cursor left n characters Local vz$ vz$=Str$(n)+";D" ch Print vz$; End Sub Sub Vat(row,col) 'locate cursor to row,col Local vz$ vz$=Str$(row)+";"+Str$(col)+"H" ch Print vz$; End Sub Sub Vsc 'save current cursor position Print Chr$(27);"7"; End Sub Sub Vrc 'restore cursor position saved with Vsc Print Chr$(27);"8"; End Sub Sub Vbox(row,col,w,h,t) 'daw a box in "Terminal" font box chars Vat row,col If t=0 Then Print Chr$(218);String$(w-2,196);Chr$(191); Vat row+h,col Print Chr$(192);String$(w-2,196);Chr$(217); For i=1 To h-1 Vat row+i,col:Print Chr$(179); Vat row+i,col+w-1:Print Chr$(179); Next Else Print Chr$(201);String$(w-2,205);Chr$(187); Vat row+h,col Print Chr$(200);String$(w-2,205);Chr$(188); For i=1 To h-1 Vat row+i,col:Print Chr$(186); Vat row+i,col+w-1:Print Chr$(186); Next End If End Sub Sub Vl(row,col,l,t) 'draw a vertical or horizontal line to divide a box Local i,m m=t:t=Abs(t) If m>0 Then 'vertical line vat row,col: If t=0 Then Print Chr$(194); Else Print Chr$(203); vat row+l,col: If t=0 Then Print Chr$(193); Else Print Chr$(202); vat row+1,col For i=1 To l-1 vat row+i,col If t=0 Then Print Chr$(179); Else Print Chr$(186); Next Else 'horizontal line vat row,col If t=0 Then Print Chr$(195)String$(w-2,196)Chr$(180) Else Print Chr$(204)String$(w-2,205)Chr$(185) End If End If End Sub Sub Vatt(tatt$) 'set text attributes ch Select Case LCase$(tatt$) Case "none" Print "0m"; Case "b" Print "1m"; Case "/b" Print "22m"; Case "in" Print "7m"; Case "/in" Print "27m"; Case "u" Print "4m"; Case "/u" Print "24m"; End Select End Sub Sub Vfc(color$) 'set text foreground colour Local vz$ 'if we have a colour number 0-15 then use it If Len(color$)<3 And Val(color$)<16 Then vz$="38;5;"+color$+"m" ch Print vz$ Else ch Select Case LCase$(color$) 'otherwise use the colour name Case "black" Print "30m"; Case "red" Print "31m"; Case "green" Print "32m"; Case "yellow" Print "33m"; Case "blue" Print "34m"; Case "magenta" Print "35m"; Case "cyan" Print "36m"; Case "white" Print "37m"; Case "grey","gray" Print "90m"; End Select End If End Sub Sub Vbc(color$) 'set text background colour Local vz$ 'if we have a colour number 0-15 then use it If Len(color$)<3 And Val(color$)<16 Then vz$="48;5;"+color$+"m" ch Print vz$ Else If Val(color$)=16 Then vz$="48:2:115:115:115m" ch Print vz$ Else ch Select Case LCase$(color$) 'otherwise use the colour name Case "black" Print "40m"; Case "red" Print "41m"; Case "green" Print "42m"; Case "yellow" Print "43m"; Case "blue" Print "44m"; Case "magenta" Print "45m"; Case "cyan" Print "46m"; Case "white" Print "47m"; Case "grey","gray" Print "100m"; Case Else Print "39m"; 'default background End Select End If End Sub Sub Vhelp Print Print " The V VT100 library" Print Print "Vcls clear screen" Print "Vch cursor home to top left" Print "Vcdn n move cursor down n lines" Print "Vcup n move cursor up n lines" Print "Vcr n move cursor rignt n characters" Print "Vcl n move cursor left n characters" Print "Vat row col move cursor to row,column" Print "Vsc save current cursor position" Print "Vrc restore cursor position saved by Vsc" Print "Vbox x,y,w,h,t draw a box width w height h at x,y using 'Terminal' font box characters." Print " t=0 for single line, 1 for double" Print "Vl y,x,l,t draw a horizotal or vertical line to divide a box." Print " l is length, t=0 for single line, 1 for double, negative for horizontal" Print "Vatt n$ set text attributes to n$ - none b /b in /in low u /u" Print " (none,bold,inverse,low_intensity,underlined)" Print "Vfc n$ set text/foreground colour by name or str$(number) 0-15" Print "Vbc n$ set background colour by name or str$(number) 0-16 (16 is light grey)" Print " Colours names are black, red, green, yellow, blue, magenta, cyan, white, grey" Print "ch print the Escape sequence 'Chr$27 [' - used internally" Print End Sub Sub ch Print Chr$(27);"["; End Sub
platform_agnostic/vt100_escape_sequences.txt · Last modified: 2024/11/16 22:31 by gerry