GEMDOS ASCII text control codes.
********************************

Jason J Railton, 19 April 1997


   The following information is taken from COMPUTE's
Technical Reference Guide, Volume 3, TOS, by Sheldon Leemon,
ISBN 0-87455-149-8.  I really can't plug this book enough.

   This is a list of VT-52 terminal control codes.  They work with any
output to the ST's console device (the screen) using system calls, since
it emulates the VT-52 standard.  Each code consists of the 'Escape' code
27 ($1b in hex, or use chr$(27) in Basic) followed by a character and
then sometimes more byte codes, as listed below.


   Esc A                Move the cursor up
   Esc B                Move the cursor down
   Esc C                Move the cursor right
   Esc D                Move the cursor left
   Esc E                Clear the screen and home the cursor
   Esc H                Just home the cursor (reset to top-left of screen)
   Esc I                Move the cursor up, and scroll the screen down if
                           at the top of the screen. 
   Esc J                Clear to the end of the screen
   Esc K                Clear to the end of the current line
   Esc L                Insert a line (shifts subsequent lines down?)
   Esc M                Delete the current line (shifts subs. lines up?)
   Esc Y,[y+32],[x+32]  Position cursor at row y, column x 
   Esc b,[i]            Select ink (foreground) colour i   
   Esc c,[p]            Select paper (background) colour p
   Esc d                Clear to beginning of screen
   Esc e                Cursor on
   Esc f                Cursor off
   Esc j                Save cursor position
   Esc k                Move cursor back to saved position
   Esc l                Clear line (not the same as delete line)
   Esc o                Clear from beginning of line
   Esc p                Inverse video on
   Esc q                Inverse video off
   Esc v                Line wrapping on (lines wider than the screen wrap
                          round to the next line)
   Esc w                Line wrapping off (lines wider than the screen are
                          cut off)

   Note that the Escape code 27 is always followed by a printable
character, and the case of this character is important.  'Esc Y' is the
code to relocate the cursor, as used in the code JNO supplied.  It is
followed by row/col co-ordinates.  These codes start at the value 32 for
position 0.  This makes the codes 32 or greater, so they are actually 
printable characters.  Strangely though, the colour codes 'Esc b' and
'ESC c' are followed by the actual code 0-15, so these aren't printable.

   The colours in medium-res are  0=white (background), 1=red, 2=green,
3=black (normal text colour).  In low-res, the black text colour is 15.
Since there's no way of knowing if the ST is in low- or medium-res when
the file is read, it makes it hard to know what to set the ink to for
normal text.  In low-res, colour 3 is normally yellow, which is nearly
invisible on white.  The best thing to do if you're using colour is to
assume medium-res.  Most text files are in 80-column text anyway, so it's
rare that anyone would read your text file in low-res.


   GEMDOS also accepts the following codes:

   [8]                  Backspace
   [9]                  Tab
   [10]-[12]            Line feed
   [13]                 Carriage return

   A line ends with code 10, then code 13.  This would instruct a printer
to move down a line (line feed) then return the print head to the start of
the line (carriage return).


   Now, a couple of things to remember when using these codes.  Firstly,
if you do use the colour codes, inverse video or whatever, you must change
them back at the end of the file.  If you don't, then the next file you
read will appear in the changed colours, or inverse video, or whatever.
So, set the screen back with inverse video off, background colour 0,
foreground colour 3 (for medium-res; see above), cursor on, line wrapping
on.

  Secondly, the GEMDOS file viewing routine keeps a count of how many
lines have been displayed for giving you the '-MORE-' prompt.  It does
this by counting the line feeds and carriage returns at the end of each
normal line of text.  So, if you don't want the '-MORE-' prompt to
appear during an animation, write out your codes and text to the text
file with a semi-colon at the end of the 'PRINT #' statement, so that
all the codes bunch up and make one long line.  I'm not sure what happens
if you then switch line wrapping off, but I wouldn't recommend it.

   If you do want the '-MORE-' prompt to appear and you are moving the
cursor around the screen, you'll have to insert enough carriage returns
(22 of them) yourself, and make sure you don't reach the bottom of the
screen and make it scroll in the meantime.

   You could, for instance, put the 'Esc E' code (clears the screen and
homes the cursor) after every 22 lines in your text file.  Then every
22 lines of text would be displayed on a clean screen, and not actually
scroll.  Have fun...

