home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / bbs / qansi / qansi.doc next >
Text File  |  1989-11-06  |  14KB  |  316 lines

  1. --------------------------------------------------------------------------
  2. ---                      The QuickBBS ST Ansi Emulator                 ---
  3. ---                            (and related topics)                    ---
  4. --------------------------------------------------------------------------
  5.  
  6. [1]  What is Ansi?
  7.  
  8.      ANSI  is short for American National Standards  Institute.  The  ANSI 
  9.      organisation develops and documents standards, especially in the area  
  10.      data communications.  One of those standars is Ansi X3.64, which is a 
  11.      terminal emulation protocol.  It helps a host computer,  or a program 
  12.      running locally,  use the intelligent console,  with features such as 
  13.      cursor movement, advanced text attributes etc.
  14.  
  15.      ANSI  is also the name of the screen and keyboard driver used on  MS-
  16.      Dos  machines (ANSI.SYS).  The choice of name is not rather  idiotic, 
  17.      because ANSI.SYS is neither a complete implementation of  X3.64,  nor 
  18.      a subset of X3.64.  Anyway,  when I refer to ANSI in this document, I 
  19.      mean  the  MicroSoft version.  Some communication programs  (such  as 
  20.      ProComm and Telix) call it Ansi-BBS.
  21.  
  22. [2]  What has Ansi got to do with QuickBBS ST?
  23.  
  24.      A hell of a lot of PC communications packages have an Ansi mode. It's 
  25.      fairly easy for 'them',  because they can just re-route the  incoming 
  26.      characters straight to the console driver. To make it possible for PC 
  27.      users  with  such  packages  to have 'fancy'  screens  and  menus  in 
  28.      QuickBBS ST,  a graphics mode called 'Ansi-BBS' is available.  Due to 
  29.      the fact that I have to do my own screen driving, it is *much* slower 
  30.      than the VT-52 modes when used locally, but on-line it shouldn't make 
  31.      too much difference. When operating in Ansi mode QuickBBS will use an 
  32.      MS-Dos style font, so you can create box graphic text files.
  33.  
  34. [3]  Ansi compared to VT-52.
  35.  
  36.      Both  Ansi and VT-52 use things called Escape  Sequences.  An  Escape 
  37.      Sequence is a string of characters which starts with an ESC character 
  38.      (27),  followed  by  one or more parameters.  An example of  an  Ansi 
  39.      escape sequence is
  40.  
  41.           <ESC> [ 10; 20 H
  42.  
  43.      Where <ESC> is the an escape, and the spaces are only for clarity (as 
  44.      in the rest of this document).  This particular escape sequence makes 
  45.      the cursor move to line 10,  column 20,  and is defined by the 'H' at 
  46.      the end.
  47.  
  48.      The VT-52 version of this escape sequence is
  49.  
  50.           <ESC> Y * 4
  51.  
  52.      The  '<ESC>  Y' indicates that the cursor has to  be  moved,  and  is 
  53.      followed  by  two characters whose ASCII codes are Y and  X  plus  32 
  54.      (10+32 = 42 = "*", 20+32 = 52 = "4").
  55.  
  56.      Note that the VT-52 sequence is much more efficient for two reasons:
  57.  
  58.      1)   The code is 4 bytes instead of 8.
  59.      2)   The command is followed by the parameters, instead of parameters 
  60.           followed by command.  For practical reasons this is much  easier 
  61.           to implement.
  62.  
  63.      So, if possible, use one of the VT-52 modes of QuickBBS ST instead of 
  64.      Ansi.
  65.  
  66. [4]  Limitations and differences.
  67.  
  68.      Due to the structural differences between the screen of a PC and that 
  69.      of an ST, the Ansi driver in QuickBBS ST has some 'differences'...
  70.  
  71.      1)   A PC with CGA monitor can display 8 colours for foreground  and 
  72.           8  colours  for background,  whereas the ST can only  display  4 
  73.           each  on a colour monitor.  See the 'change  attributes'  escape 
  74.           sequence to see how Quick handles colours.
  75.  
  76.      2)   A PC can underline,  highlight,  blink and reverse text.  An  ST 
  77.           using  BIOS/GEMDOS  for output can only  use  reverse.  See  the 
  78.           'change attributes' escape sequence.
  79.  
  80.      3)   I  have not found any way of changing the scroll  region  X,  Y, 
  81.           and Width for TOS output.
  82.  
  83.      4)   All  escape  sequences  that QuickBBS ST doesn't  know  will  be 
  84.           ignored. They WILL however be sent to the user on-line.
  85.  
  86.      The implementation in QuickBBS ST also has some escape sequences  not 
  87.      found in ANSI.SYS, but which are part of X3.64, or frequently used by 
  88.      Unix machines. 
  89.  
  90. [5]  Recognised Escape Sequences.
  91.  
  92.      QuickBBS   ST   recognises  and  reacts  to  the   following   escape 
  93.      sequences.  All  characters  in <brackets> should  be  replaced,  and 
  94.      spaces should be removed...
  95.  
  96.      Name      : CUU - Cursor Up
  97.      Escape    : <ESC> [ <n> A
  98.      Example   : <ESC> [  5  A
  99.  
  100.      This  sequence  moves the cursor up <n> lines.  If parameter  <n>  is 
  101.      ommited,  the cursor moves up one line.  The cursor will not move off 
  102.      the screen,  nor will the screen scroll down.  The cursor remains  on 
  103.      the same column.
  104.  
  105.      Name      : CUD - Cursor Down
  106.      Escape    : <ESC> [ <n> B
  107.      Example   : <ESC> [  3  B
  108.  
  109.      CUD  is  the same as CUU (cursor up),  but the cursor is  moved  down 
  110.      instead.
  111.  
  112.      Name      : CUF - Cursor Forward (right)
  113.      Escape    : <ESC> [ <n> C
  114.      Example   : <ESC> [  8  B
  115.  
  116.      This moves the cursor <n> columns to the right. If the cursor reaches 
  117.      column 80,  it will stay there.  The cursor remains on the same line. 
  118.      If <n> is ommited, the cursor moves one column.
  119.  
  120.      Name      : CUB - Cursor Backward (left)
  121.      Escape    : <ESC> [ <n> D
  122.      Example   : <ESC> [  7  D
  123.  
  124.      Is identical to CUF (cursor forward),  exept that the cursor is moved 
  125.      to the left, as far as the left hand side of the screen.
  126.  
  127.      Name      : CUP - Cursor Position
  128.      Escape    : <ESC> [ <y> ; <x> H
  129.      Example   : <ESC> [ 10  ; 20  H
  130.  
  131.      This escape moves the cursor to location (x,y),  where X is between 1 
  132.      and  80,  and Y between 1 and 24.  If <y> and <x>  are  ommited,  the 
  133.      cursor is moved to the top left-hand corner (1,1). The sequences
  134.  
  135.           <ESC> [ <y> ; <x> H
  136.           <ESC> [ <y> ; <x> f
  137.           <ESC> [ <y> ; <x> j
  138.  
  139.      are identical, but the first is recommended.
  140.  
  141.      Name      : SCP - Save Cursor Position
  142.      Escape    : <ESC> [ s
  143.      
  144.      SCP  tells the Ansi driver to note down the current  cursor  position 
  145.      for future use.  If an RCP is received the cursor will be returned to 
  146.      this position. The SCP and RCP escapes are not nestable.
  147.  
  148.      Name      : RCP - Restore Cursor Position
  149.      Escape    : <ESC> [ u
  150.  
  151.      RCP places the cursor at the location noted down by SCP.
  152.  
  153.      Name      : ED - Erase Display
  154.      Escape    : <ESC> [ <n> J
  155.      Example   : <ESC> [  2  J
  156.  
  157.      ED  erases all or part of the screen depending on the parameter  <n>. 
  158.      If this parameter is ommited, it is assumed to be '0'...
  159.  
  160.           <n> = 0 : The  screen  is  erased  between  the  current  cursor 
  161.                     location  and  the lower right corner of  the  screen, 
  162.                     inclusive. The cursor doesn't move.
  163.           <n> = 1 : The screen is erased between the upper left corner  of 
  164.                     the screen and the current cursor location, inclusive. 
  165.                     The cursor doesn't move.
  166.           <n> = 2 : The whole screen is erased and the cursor is moved  to 
  167.                     the upper left corner.
  168.  
  169.      The screen is cleared using the current background colour.
  170.  
  171.      Name      : EL - Erase Line
  172.      Escape    : <ESC> [ <n> K
  173.      Example   : <ESC> [  0  K
  174.  
  175.      All  or part of the current line is erased,  depending  on  parameter 
  176.      <n>.  The cursor is never moved by this escape. If <n> is ommited, it 
  177.      is assumed to be '0'...
  178.  
  179.           <n> = 0 : All characters to the right of the cursor are erased.
  180.           <n> = 1 : All characters to the left  of the cursor are erased.
  181.           <n> = 2 : All characters on the current line are erased.
  182.  
  183.      The line is cleared using the current background colour.
  184.  
  185.      Name      : IL - Insert Lines
  186.      Escape    : <ESC> [ <n> L
  187.      Example   : <ESC> [  3  L
  188.  
  189.      IL inserts <n> lines at the current cursor location. The current line
  190.      and  all lines below it are moved down.  Lines at the bottom  of  the
  191.      screen will be lost.  If <n> is omitted,  one line is  inserted.  The
  192.      cursor  doesn't move.  The new line will be displayed in the  current 
  193.      background colour.
  194.  
  195.      Name      : DL - Delete Lines
  196.      Escape    : <ESC> [ <n> M
  197.      Example   : <ESC> [  9  M
  198.  
  199.      DL  deletes <n> lines,  starting with the current  cursor  line.  All 
  200.      lines  underneath  the line(s) to be deleted will be  moved  up.  New 
  201.      lines, in the current background colour, will appear at the bottom of 
  202.      the screen. The cursor doesn't move.
  203.  
  204.      Name      : DECSC - DEC Private, Save Cursor Parameters
  205.      Escape    : <ESC> 7
  206.  
  207.      This  is supposed to be a DEC Private escape,  but is used  on  other 
  208.      systems as well. It saves the current cursor position (like SCP), but 
  209.      also stores the current text attributes and colours. With DECRC these 
  210.      parameters can be restored. THIS IS NOT IMPLEMENTED IN ANSI.SYS!!!
  211.  
  212.      Name      : DECRC - DEC Private, Restore Cursor Parameters
  213.      Escape    : <ESC> 8
  214.  
  215.      DECRC  is  the  opposite of DECSC,  and  restores  the  saved  cursor 
  216.      parameters. THIS IS NOT IMPLEMENTED IN ANSI.SYS!!!
  217.  
  218.      Name      : RIS - Reset to Initial State
  219.      Escape    : <ESC> c
  220.  
  221.      This 'resets' the Ansi driver: the colours are set to default values, 
  222.      all text attributes are switched off and the screen is cleared. It is 
  223.      the same as doing an SGR 0 followed by ED 2.  THIS IS NOT IMPLEMENTED 
  224.      IN ANSI.SYS!!!
  225.  
  226.      Name      : NEL - Next Line
  227.      Escape    : <ESC> E
  228.  
  229.      This  moves  the  cursor  to the first position  on  the  next  line, 
  230.      scrolling the screen up if neccesary.  It is effectively the same  as 
  231.      Carriage  Return  followed by Line Feed,  and is NOT  IMPLEMENTED  IN 
  232.      ANSI.SYS.
  233.  
  234.      Name      : SGR - Set Graphics Rendition
  235.      Escape    : <ESC> [ <n> ; <n> ; ... ; <n> m
  236.      Example   : <ESC> [  1  ; 37  m
  237.  
  238.      Now this is the good stuff...  With this escape you can control three 
  239.      things:
  240.  
  241.           - The text foreground colour,
  242.           - The text background colour,
  243.           - The text attributes.
  244.  
  245.      There can be any number of parameters,  separated by ';'  characters. 
  246.      The  effect  is  cumulative.  If no parameters  are  passed,  '0'  is 
  247.      assumed. The following parameters are available:
  248.  
  249.           0         - Reset colours and attributes
  250.           1         - Bold (*)
  251.           4         - Underlined (*)
  252.           5         - Blink (*)
  253.           7         - Reverse Video
  254.  
  255.           30        - Foreground Black
  256.           31        - Foreground Red
  257.           32        - Foreground Green
  258.           33        - Foreground Yellow
  259.           34        - Foreground Blue
  260.           35        - Foreground Magenta
  261.           36        - Foreground Cyan
  262.           37        - Foreground White
  263.  
  264.           40 to 47  - Background Colours
  265.  
  266.      Attributes  marked  by (*) are ignored by Quick.  When running  on  a 
  267.      monochrome monitor the colours are also ignored.  On a colour monitor 
  268.      colour 30 is black (register 0), colour 37 is white (register 3), and
  269.      all  colours  inbetween  are alternated Blue  (register  1)  and  Red
  270.      (register 2). Of course this depends on your screen settings, but the 
  271.      above  are the QuickBBS defaults.  If foreground and background  turn 
  272.      out to be the same, Quick will adjust the background colour.
  273.  
  274.      Some examples...
  275.  
  276.           Bold, White on Blue     : <ESC>[0;1;37;44m
  277.           Blink, Red on Yellow    : <ESC>[0;5;31;43m
  278.           Normal, White on Black  : <ESC>[m or <ESC>[0m
  279.           Bold, Underlined, Green : <ESC>[0;1;4;32m
  280.  
  281.      Note  that  setting  - say - Bold does not effect any  of  the  other 
  282.      attributes,  nor the colours. To make sure you've got the right mode, 
  283.      you  could  add  a '0' at the beginning,  but  that  depends  on  how 
  284.      intelligent your Ansi editor is, which brings us to...
  285.  
  286. [6]  How to create your Ansi screens.
  287.  
  288.      Well, there are basically three options. You can do it all by hand in 
  289.      a  text  editor  like Tempus,  you can buy a PC and  use  TheDraw  or 
  290.      AnsiPaint,  or  you  can use a little VT-52 to  Ansi  converter  I've 
  291.      written called...  QANSI. The convertor can only handle a screen at a 
  292.      time,  but  then most VT-52 editors can only create one screen  at  a 
  293.      time.  Operation is simple,  you just specify input and output files, 
  294.      and QANSI does the rest.
  295.  
  296. [7]  Box Graphics
  297.  
  298.      The MS-Dos character set has a number of BOX GRAPHICS which are  very 
  299.      nice for making logo screens,  boxes around texts and such. Here is a 
  300.      list of some often-used characters.
  301.  
  302.      « = 174     » = 175     ã = 176     õ = 177     Ø = 178     ø = 179
  303.      œ = 180     Œ = 181     À = 182     Ã = 183     Õ = 184     ¨ = 185
  304.      ´ = 186     † = 187     ¶ = 188     © = 189     ® = 190     ™ = 191
  305.      ij = 192     IJ = 193     א = 194     ב = 195     ג = 196     ד = 197
  306.      ה = 198     ו = 199     ז = 200     ח = 201     ט = 202     י = 203
  307.      כ = 204     ל = 205     מ = 206     נ = 207     ס = 208     ע = 209
  308.      פ = 210     צ = 211     ק = 212     ר = 213     ש = 214     ת = 215
  309.      ן = 216     ך = 217     ם = 218     ף = 219
  310.      ץ = 220     § = 221     ∧ = 222     ∞ = 223
  311.  
  312.      To print this out on a printer without MS-Dos character set:  display 
  313.      the file in QuickBBS with Ansi Graphics,  and just do a screen  dump. 
  314.      Perhaps someone has time to write a proper VT-52 and ANSI editor???
  315.  
  316.