ansi.spcs

  1. Directory
  2. Apple II Textfiles
  3. ansi.spcs
_O

 Number       : 17 of 21                             [ ACOS/MACOS Programming ]
 Subject      : ANSI/VT-100 CODES
 Addressed to : ALL
 Author       : Nuke at The Space Bar  (#198@#4)
 Date Posted  : Thursday, January 13th, 1994  20:57:51 PST
 Size         : 24632 bytes
-O
Somebody was asking for the VT-100 codes, well here is a listing of boith
ANSI/VT-100 codes from the Supertac docs I have.....hope this helps you out??




-----------------------------------------------------------------------------
SuperTac Tech note #2 - ANSI & DEC VT100 CODES...
                        Oct 30, 1990 - Larry Hawkins

v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v

                         ANSI & DEC VT100 Codes

^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^


   The following text will describe the various escape codes that allow
computers to transmit color text over communication lines.  Using ANSI
escape codes, any computer can receive and transmit color text as long as
the communication program can interpret the escape sequences.
   The escape sequences can be thought of the same as ones sent to a printer
to change the appearance of the output.  All ANSI codes begin with the one
byte character ESC (decimal 27), and are followed by the left bracket "[".
Additional parameters, which follow the bracket are seperated with a semi-
colon.All codes are ended with a single alphabetic character which determines
the function of the escape sequence.
   Since the characters come in one at a time, as soon as the ESC character
is received start building the sequence until an alphabetic character is
input.The case of the alphabetic character is very important since they
mean different things.   For example,"H" (which means set cursor position)
is different than "h" ,(which means set the display width and type).


   Notes:
       1) The default value is used when no explicit
          value is given, or a value of zero, is
          specified.

       2) The default value is 1 unless otherwise
          specified below.

       3) # - Numeric Parameter.  A decimal number
          specified with ASCII characters.

       4) In the control sequences described below,
          ESC is the 1 byte code for ESC (decimal 27),
          and not the three characters "ESC".



CURSOR CONTROL

   Cursor Position (CUP)
     ESC[#;#H           Moves the cursor to the position
                   specified by the parameter.  The first
                   parameter specifies the line number and
                   the second parameter specifies the column
                   number.  If no parameter is given, the
                   cursor is moved to the home position
                   (Row 1, Column 1).
                     Example: ESC[10;20H  - moves the cursor to
                                 row 10, column 20.

   Cursor Up (CUU)
     ESC[#A             Moves the cursor up # lines without
                   changing columns.  The value of #
                   determines the number of lines to move up.
                   This sequence is ignored if the cursor is
                   already on the top line.
                     Example: ESC[5A       - moves the cursor up
                                 5 lines without changing
                                 columns.

   Cursor Down (CUD)
     ESC[#B             Moves the cursor down # lines without changing
                   columns.  The value of # determines the number
                   of lines to move down.
                   This sequence is ignored if the cursor is
                   already on the bottom line.
                     Example: ESC[5B       - moves the cursor down
                                 5 lines without changing
                                 columns.

   Cursor Forward (CUF)
     ESC[#C             Moves the cursor forward # columns without
                   changing lines.  The value of # determines
                   the number of columns moved forward.
                   This sequence is ignored if the cursor is already
                   in the rightmost column.
                     Example: ESC[25C      - moves the cursor forward
                                 25 columns.

   Cursor Backward (CUB)
     ESC[#n             Moves the cursor back # columns without changing
                   lines.  The value # determines the number of
                   columns moved backwards.
                   This sequence is ignored if the cursor is already
                   in the leftmost column.
                     Example: ESC[1n       - moves the cursor backwards
                                 1 column.

   Horizontal and Vertical Position (HVP)
     ESC[#;#f           This control sequence is the same as CUP.
                     Example: ESC[10;20f  - moves the cursor to
                                 row 10, column 20.

   Device Status Report (DSR)
     ESC[6n             Upon receipt of this command, the console
                   driver will output a CPR sequence as described
                   below.

   Cursor Position Report (CPR)
     ESC[#;#R           The CPR sequence reports the current cursor
                   position through the standard input device.  The
                   first parameter specifies the current line and
                   the second parameter specifies the current column.

   Save Cursor Position (SCP)
     ESC[s              The current cursor position is saved.  This
                   cursor position can be restored with the RCP
                   sequence.

   Restore Cursor Position (RCP)
     ESC[u              Restores the cursor to the value it had when
                   the control sequence SCP was received.

   Erase in Display (ED)
     ESC[2J             Erases all of the screen and the cursor goes
                   to the home position (row 1, column 1).

   Erase in Line (EL)
     ESC[k              Erases from the cursor to the end of the line
                   and includes the cursor position.

   Set Graphics Rendition (SGR)
     ESC[#;...;#m       Set the character attribute specified by then
                   parameter(s). All following characters will
                   have the attribute according to the parameter(s)
                   until the next occurrence of SGR.
                     Note:  attribute means the foreground color, the
                         background color, blink, high intensity,
                         underscore, reverse video, and invisible.

                  Parameter    Meaning
                     0    All Attributes Off (white on black)
                     1    Bold On (high intensity)
                     4    Underscore On (Some monitors only)
                     5    Blink On
                     7    Reverse Video
                     8    Cancelled On (invisible)
                     30   Black Foreground
                     31   Red Foreground
                     32   Green Foreground
                     33   Yellow Foreground
                     34   Blue Foreground
                     35   Magenta Foreground
                     36   Cyan Foreground
                     37   White Foreground
                     40   Black Background
                     41   Red Background
                     42   Green Background
                     43   Yellow Background
                     44   Blue Background
                     45   Magenta Background
                     46   Cyan Background
                     47   White Background

                     Example: ESC[33;40;1m    - all following
                                     characters will have
                                     a Yellow foreground,
                                     a Black background,
                                     and be in high intensity
                                     until receipt of another
                                     SGR control sequence.

                           ESC[0m         - all following
                                     characters will have
                                     a white foreground, on
                                     a black background, in
                                     normal intensity.


                     Note:  Several parameters can be stacked.  For
                         example, ESC[0;1;5;7;31;44m
                               the above example will reset the
                               attributes, set high intensity,
                               set blink on, set reversed video,
                               set foreground color to red, and
                               set background color to blue.
                               Note that since reverse video
                               is on the foreground will
                               actually be blue and the
                               background will be red.



Here is the requested list of ANSI control sequences. I picked it
up off of the Usenet a while back.

 ANSI Standard (X3.64) Control Sequences for Video Terminals and Peripherals
                       in alphabetic order by mnemonic

     (Inspired by the article "Toward Standardized Video Terminals: ANSI
      X3.64 Device Control" by Mark L. Siegel, April 1984 BYTE, page 365)

        Note: This describes the VT-100 standard.

               (Ps and Pn are parameters expressed in ASCII.)
               (Numeric parameters are given in decimal radix.)
               (Abbreviations are explained in detail at end.)
               (Spaces used in this table for clarity are not
                used in the actual codes.)

                                                           Default    Type
Sequence     Sequence                                      Parameter   or
Mnemonic     Name              Sequence                    Value      Mode
 ---------------------------------------------------------------------------
APC  Applicatn Program Command Esc Fe                                 Delim
CBT  Cursor Backward Tab       Esc [ Pn Z                   1         EdF
CCH  Cancel Previous Character Esc T
CHA  Cursor Horzntal Absolute  Esc [ Pn G                   1         EdF
CHT  Cursor Horizontal Tab     Esc [ Pn I                   1         EdF
CNL  Cursor Next Line          Esc [ Pn E                   1         EdF
CPL  Cursor Preceding Line     Esc [ Pn F                   1         EdF
CPR  Cursor Position Report    Esc [ Pn ; Pn R              1, 1
CSI  Control Sequence Intro    Esc [                                  Intro
CTC  Cursor Tab Control        Esc [ Ps W                   0         EdF
CUB  Cursor Backward           Esc [ Pn D                   1         EdF
CUD  Cursor Down               Esc [ Pn B                   1         EdF
CUF  Cursor Forward            Esc [ Pn C                   1         EdF
CUP  Cursor Position           Esc [ Pn ; Pn H              1, 1      EdF
CUU  Cursor Up                 Esc [ Pn A                   1         EdF
CVT  Cursor Vertical Tab       Esc [ Pn Y                             EdF
DA   Device Attributes         Esc [ Pn c                   0
DAQ  Define Area Qualification Esc [ Ps o                   0
DCH  Delete Character          Esc [ Pn P                   1         EdF
DCS  Device Control String     Esc P                                  Delim
DL   Delete Line               Esc [ Pn M                   1         EdF
DMI  Disable Manual Input      Esc \                                  Fs
DSR  Device Status Report      Esc [ Ps n                   0
EA   Erase in Area             Esc [ Ps O                   0         EdF
ECH  Erase Character           Esc [ Pn X                   1         EdF
ED   Erase in Display          Esc [ Ps J                   0         EdF
EF   Erase in Field            Esc [ Ps N                   0         EdF
EL   Erase in Line             Esc [ Ps K                   0         EdF
EMI  Enable Manual Input       Esc b                                  Fs
EPA  End of Protected Area     Esc W
ESA  End of Selected Area      Esc G
FNT  Font Selection            Esc [ Pn ; Pn Space D        0, 0      FE
GSM  Graphic Size Modify       Esc [ Pn ; Pn Space B        100, 100  FE
GSS  Graphic Size Selection    Esc [ Pn Space C             none      FE
HPA  Horz Position Absolute    Esc [ Pn `                   1         FE
HPR  Horz Position Relative    Esc [ Pn a                   1         FE
HTJ  Horz Tab w/Justification  Esc I                                  FE
HTS  Horizontal Tab Set        Esc H                                  FE
HVP  Horz & Vertical Position  Esc [ Pn ; Pn f              1, 1      FE
ICH  Insert Character          Esc [ Pn @                   1         EdF
IL   Insert Line               Esc [ Pn L                   1         EdF
IND  Index                     Esc D                                  FE
INT  Interrupt                 Esc a                                  Fs
JFY  Justify                   Esc [ Ps ; ... ; Ps Space F  0         FE
MC   Media Copy                Esc [ Ps i                   0
MW   Message Waiting           Esc U
NEL  Next Line                 Esc E                                  FE
NP   Next Page                 Esc [ Pn U                   1         EdF
OSC  Operating System Command  Esc ]                                  Delim
PLD  Partial Line Down         Esc K                                  FE
PLU  Partial Line Up           Esc L                                  FE
PM   Privacy Message           Esc ^                                  Delim
PP   Preceding Page            Esc [ Pn V                   1         EdF
PU1  Private Use 1             Esc Q
PU2  Private Use 2             Esc R
QUAD Typographic Quadding      Esc [ Ps Space H             0         FE
REP  Repeat Char or Control    Esc [ Pn b                   1
RI   Reverse Index             Esc M                                  FE
RIS  Reset to Initial State    Esc c                                  Fs
RM   Reset Mode                Esc [ Ps l                   none
SD   Scroll Down               Esc [ Pn T                   1         EdF
SEM  Select Edit Extent Mode   Esc [ Ps Q                   0
SGR  Select Graphic Rendition  Esc [ Ps m                   0         FE
SL   Scroll Left               Esc [ Pn Space @             1         EdF
SM   Select Mode               Esc [ Ps h                   none
SPA  Start of Protected Area   Esc V
SPI  Spacing Increment         Esc [ Pn ; Pn Space G        none      FE
SR   Scroll Right              Esc [ Pn Space A             1         EdF
SS2  Single Shift 2 (G2 set)   Esc N                                  Intro
SS3  Single Shift 3 (G3 set)   Esc O                                  Intro
SSA  Start of Selected Area    Esc F
ST   String Terminator         Esc \                                  Delim
STS  Set Transmit State        Esc S
SU   Scroll Up                 Esc [ Pn S                   1         EdF
TBC  Tab Clear                 Esc [ Ps g                   0         FE
TSS  Thin Space Specification  Esc [ Pn Space E             none      FE
VPA  Vert Position Absolute    Esc [ Pn d                   1         FE
VPR  Vert Position Relative    Esc [ Pn e                   1         FE
VTS  Vertical Tabulation Set   Esc J                                  FE

 ---------------------------------------------------------------------------

Abbreviations:

Intro  an Introducer of some kind of defined sequence; the normal 7-bit
       X3.64 Control Sequence Introducer is the two characters "Escape ["

Delim  a Delimiter

x/y    identifies a character by position in the ASCII table (column/row)

EdF    editor function (see explanation)

FE     format effector (see explanation)

F      is a Final character in
            an Escape sequence (F from 3/0 to 7/14 in the ASCII table)
            a control sequence (F from 4/0 to 7/14)

Gs     is a graphic character appearing in strings (Gs ranges from
       2/0 to 7/14) in the ASCII table

Ce     is a control represented as a single bit combination in the C1 set
       of controls in an 8-bit character set

C0     the familiar set of 7-bit ASCII control characters

C1     roughly, the set of control characters available only in 8-bit systems.
       This is too complicated to explain fully here, so read Jim Fleming's
       article in the February 1983 BYTE, especially pages 214 through 224.

Fe     is a Final character of a 2-character Escape sequence that has an
       equivalent representation in an 8-bit environment as a Ce-type
       (Fe ranges from 4/0 to 5/15)

Fs     is a Final character of a 2-character Escape sequence that is
       standardized internationally with identical representation in 7-bit
       and 8-bit environments and is independent of the currently
       designated C0 and C1 control sets (Fs ranges from 6/0 to 7/14)

I      is an Intermediate character from 2/0 to 2/15 (inclusive) in the
       ASCII table

P      is a parameter character from 3/0 to 3/15 (inclusive) in the ASCII
       table

Pn     is a numeric parameter in a control sequence, a string of zero or
       more characters ranging from 3/0 to 3/9 in the ASCII table

Ps     is a variable number of selective parameters in a control sequence
       with each selective parameter separated from the other by the code
       3/11 (which usually represents a semicolon); Ps ranges from
       3/0 to 3/9 and includes 3/11

v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v
v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v

Format Effectors versus Editor Functions

A format effector specifies how the final output is to be created.
An editor function allows you to modify the specification.

For instance, a format effector that moves the "active position" (the
cursor or equivalent) one space to the left would be useful when you want to
create an over strike, a compound character made of two standard characters
overlaid. Control-H, the Backspace character, is actually supposed to be a
format effector, so you can do this. But many systems use it in a
nonstandard fashion, as an editor function, deleting the character to the
left of the cursor and moving the cursor left. When Control-H is assumed to
be an editor function, you cannot predict whether its use will create an
over strike unless you also know whether the output device is in an "insert
mode" or an "overwrite mode". When Control-H is used as a format effector,
its effect can always be predicted. The familiar characters carriage
return, linefeed, formfeed, etc., are defined as format effectors.

v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v
^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^

ANSI X3.64 Mode-Changing Parameters for use with the
           Select Mode (SM) and Reset Mode (RM) functions

    Parameter           Mode          Mode Function
    Characters          Mnemonic
 column/    graphic
  row       repres.
 ----------------------------------------------------------------------------
3/0           0                       an error condition
3/1           1          GATM         guarded-area transfer mode
3/2           2          KAM          keyboard action mode
3/3           3          CRM          control representation mode
3/4           4          IRM          insertion/replacement mode
3/5           5          SRTM         status-reporting transfer mode
3/6           6          ERM          erasure mode
3/7           7          VEM          vertical editing mode
3/8           8                       reserved for future standardization
3/9           9                       reserved for future standardization
3/10          :                       reserved separator for parameters
3/11          ;                       Standard separator for parameters
3/12          <                       reserved for private (experimental) use
3/13          =                       reserved for private (experimental) use
3/14          >                       reserved for private (experimental) use
3/15          ?                       reserved for private (experimental) use
3/1  3/0      10         HEM          horizontal editing mode
3/1  3/1      11         PUM          positioning unit mode
3/1  3/2      12         SRM          send/receive mode
3/1  3/3      13         FEAM         format effector action mode
3/1  3/4      14         FETM         format effector transfer mode
3/1  3/5      15         MATM         multiple area transfer mode
3/1  3/6      16         TTM          transfer termination mode
3/1  3/7      17         SATM         selected area transfer mode
3/1  3/8      18         TSM          tabulation stop mode
3/1  3/9      19         EBM          editing boundary mode
3/1  3/10     1:                      reserved separator for parameters
3/1  3/11     1;                      Standard separator for parameters
3/1  3/12     1<                      error condition--unspecified recovery
3/1  3/13     1=                      error condition--unspecified recovery
3/1  3/14     1>                      error condition--unspecified recovery
3/1  3/15     1?                      error condition--unspecified recovery
3/2  3/0      20         LNM          linefeed/newline mode (not in ISO 6429)
3/2  3/1      21
 .            .
 .            .                       reserved for future standardization
 .            .
3/9  3/9      99

3/12 3/0      <0
 .            .
 .            .                       reserved for private (experimental) use
 .            .
3/15 3/15     ??

v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v
^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^

NOTES ON THE DEC VT100 IMPLEMENTATION

In the case of the popular DEC VT100 video-terminal implementation,
the only mode that may be altered is the linefeed/newline (LNM) mode.
Other modes are considered permanently set, reset, or not applicable
as follows:

     Set:   ERM
     Reset: CRM, EBM, FEAM, FETM, IRM, KAM, PUM, SRTM, TSM
     N/A:   GATM, HEM, MATM, SATM, TTM, VEM

Control sequences implemented in the VT100 are as follows:

     CPR, CUB, CUD, CUF, CUP, CUU, DA, DSR, ED, EL, HTS, HVP, IND,
     LNM, NEL, RI, RIS, RM, SGR, SM, TBC

plus several private DEC commands.

Erasing parts of the display (EL and ED) in the VT100 is performed thus:

     Erase from cursor to end of line           Esc [ 0 K    or Esc [ K
     Erase from beginning of line to cursor     Esc [ 1 K
     Erase line containing cursor               Esc [ 2 K
     Erase from cursor to end of screen         Esc [ 0 J    or Esc [ J
     Erase from beginning of screen to cursor   Esc [ 1 J
     Erase entire screen                        Esc [ 2 J

The VT100 responds to receiving the DA (Device Attributes) control

     Esc [ c    (or Esc [ 0 c)

by transmitting the sequence

     Esc [ ? l ; Ps c

where Ps is a character that describes installed options.

The VT100's cursor location can be read with the DSR (Device Status
Report) control

     Esc [ 6 n

The VT100 reports by transmitting the CPR sequence

     Esc [ Pl ; Pc R

where Pl is the line number and Pc is the column number (in decimal).

v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v
^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^

The complete document describing the standard,  "ANSI X3.64-1979:
Additional Controls for Use with the American National Standard
Code for Information Interchange," can be ordered for $13.50 (plus
$4 postage) from

     Standards Sales Department
     American National Standards Institute
     1430 Broadway
     New York, NY 10018
     212/354-3300

It's best to read the full standard before using it. It also helps
to have copies of the related standards "X3.4-1977: American
National Standard Code for Information Interchange" (the ASCII
standard) and "X3.41.1974: Code-Extension Techniques for Use with
the 7-Bit Coded Character Set of American National Standard for
Information Interchange."

See also the chapter "Using Extended Screens and Keyboard Control"
in the IBM PC-DOS manuals (versions 2.0, 2.1, and 3.0), especially
for the coding for character attributes.

The specification for the DEC VT100 is document EK-VT100-UG-003,
available for $13.00 prepaid from:

     Digital Equipment Corporation
     Accessories and Supplies Group
     POB CS-2008
     Nashua, NH 03061

(Copyright 1984 BYTE Publications, subsidiary of McGraw-Hill Inc.)
(Permission granted to reproduce for noncommercial uses.)


-----------------------------------------------------------------------------

---------------------------------------------------------------------------

_O

DOWNLOAD FILE
MD5
74d87407ec3d8d91743b123ff2f73ea5

AAAAH! MY EYES! Click here if you prefer a black and white color scheme.