ANSI Codes Reference

From The Bottomless Abyss BBS Wiki
Jump to navigation Jump to search

          ANSI CODES REFERENCE

                                                                             

     Below is a reference listing ANSI CODES.  For more information

     how to use the ansi codes, consult your DOS user's manual.

         >>>----- Screen Attribute Command Sequences -----<<<                

                                                                             

                                                                             

   Name/                         Default   Function                          

   Command        Parameter       Value    Operation                         

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

  SET SCREEN       see below        none    Sets the default character display

  ATTRIBUTE:                                mode.  Command line may contain   

  ESC [px;px;...;pxm                        several codes which are separated 

                                           by semicolons.                    

                                                                             

  Wherein p is a number specified below:           Wherein x is:              

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

  0   Normal (white on black)                      0 = Black                  

  1   High intensity                               1 = Red                    

  4   Underscore (monochrome display only)         2 = Green                  

  5   Blink                                        3 = Yellow                 

  7   Reverse video (black on white)               4 = Blue                   

  8   Invisible                                    5 = Magenta                

  3x  Set foreground color to x (wherein x is:)    6 = Cyan                   

  4x  Set backgroung color to x (wherein x is:)    7 = White                  

                                                                             

                                                                             

          >>>----- Cursor Control Command Sequences -----<<<                 

                                                                             

  Values for parameters are specified in ASCII decimal (that is, row 10 is   

  indicated by the characters  10 ).  Letters following the parameters       

  are case-sensitive.                                                        

                                                                             

   Name/                         Default   Function                          

   Command        Parameter       Value    Operation                         

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

  SET POSITION:    r = row #          1     Move the cursor to the specified  

  ESC [r;cH        c = column #       1     screen position.                  

  --or--                                   Both rows and columns are numbered

  ESC [r;cf                                 starting at 1.                    

                                                                             

  MOVE UP:         l # of lines       1     Move cursor up specified number of

  ESC [lA                                   lines or until top of screen is   

                                           reached.  Column position is not  

                                           changed.                          

                                                                             

  MOVE DOWN:       l # of lines       1     Move cursor down specified number 

  ESC [lB                                   of lines or until bottom of screen

                                           is reached.  Column position is   

                                           not changed.                      

                                                                             

  MOVE RIGHT:      c # of columns     1     Move cursor right specified number

  ESC [cC                                   of columns or until right edge of 

                                           screen is reached.  Row position  

                                           is not changed.                   

                                                      (continued on page 2)

                                                                             

                                                                     page 2

  MOVE LEFT:       c # of columns     1     Move cursor left specified number 

  ESC [cD                                   of columns or until left edge of  

                                           screen is reached.  Row position  

                                           is not changed.                   

  SAVE CURSOR      none                     The current cursor position is    

  POSITION:                                 saved (in memory).  Only the last 

  ESC [s                                    saved position is remembered.     

                                                                             

  RESTORE CURSOR   none                     Move cursor to the location set   

  POSITION:                                 with last SAVE CURSOR POSITION    

  ESC [u                                    command.                          

                                                                             

  REPORT CURSOR    6                        Will return the current cursor    

  POSITION:                                 position in the format of:        

  ESC [6n                                   ESC [r;cR                         

                                           wherein r is the current cursor row

                                           and c is the current cursor column

                                                                             

            >>>----- Screen Erase Command Sequences -----<<<                 

                                                                             

   Name/                         Default   Function                          

   Command        Parameter       Value    Operation                         

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

  ERASE SCREEN:    2                  2     Erase entire display and move     

  ESC [2J                                   cursor to home position.          

                                                                             

  ERASE LINE:      0                  0     Erase line from cursor position to

  ESC [0K                                   the right margin, inclusive.      

                                           Cursor position is not changed.   

                                                                             

            >>>----- Display Mode Command Sequences -----<<<

                                                                             

  SET MODE:        (wherein # is:)          Sets display mode according

  ESC [=#h                                  to the parameter (#) specified.

                                           Command sequence must end with

                                           a lowercase "h".

  RESET MODE:      (wherein # is:)          Resets display mode according

  ESC [=#l                                  to the parameter (#) specified.

                                           Equivalent to set mode except

                                           for parameter 7, which turns

                                           end-of-line wrap off.  Command

                                           sequence must end with a lower-

  wherein # is:                             case "l".

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

  0     40 x 25 black and white.        Remember that if these codes are

  1     40 x 25 color.                  used, they may not display correctly

  2     80 x 25 black and white.        on all monitors due to hardware

  3     80 x 25 color.                  variations.

  4     320 x 200 color.

  5     320 x 200 black and white.

  6     640 x 200 black and white.

  7     End-of-line wrap turned on.

  * Note: keyboard reassignment commands are not listed in this

         reference.  For more details, consult your DOS user's manual.

 

   Name/                         Default   Function                           

   Command        Parameter       Value    Operation                          

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

  SET SCREEN       see below        none    Sets the default character display

  ATTRIBUTE:                                mode.  Command line may contain    

  ESC [px;px;...;pxm                        several codes which are separated  

                                           by semicolons.                     

                                                                              

  Wherein p is a number specified below:           Wherein x is:               

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

  0   Normal (white on black)                      0 = Black                   

  1   High intensity                               1 = Red                     

  4   Underscore (monochrome display only)         2 = Green                   

  5   Blink                                        3 = Yellow                  

  7   Reverse video (black on white)               4 = Blue                    

  8   Invisible                                    5 = Magenta                 

  3x  Set foreground color to x (wherein x is:)    6 = Cyan                    

  4x  Set backgroung color to x (wherein x is:)    7 = White                   

                                                                              

                                                                              

          >>>----- Cursor Control Command Sequences -----<<<                  

                                                                              

  Values for parameters are specified in ASCII decimal (that is, row 10 is    

  indicated by the characters  10 ).  Letters following the parameters        

  are case-sensitive.                                                         

                                                                              

   Name/                         Default   Function                           

   Command        Parameter       Value    Operation                          

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

  SET POSITION:    r = row #          1     Move the cursor to the specified   

  ESC [r;cH        c = column #       1     screen position.                   

  --or--                                   Both rows and columns are numbered

  ESC [r;cf                                 starting at 1.                     

                                                                              

  MOVE UP:         l # of lines       1     Move cursor up specified number of

  ESC [lA                                   lines or until top of screen is    

                                           reached.  Column position is not   

                                           changed.                           

                                                                              

  MOVE DOWN:       l # of lines       1     Move cursor down specified number  

  ESC [lB                                   of lines or until bottom of screen

                                           is reached.  Column position is    

                                           not changed.                       

                                                                              

  MOVE RIGHT:      c # of columns     1     Move cursor right specified number

  ESC [cC                                   of columns or until right edge of  

                                           screen is reached.  Row position   

                                           is not changed.                    

                                                      (continued on page 2)

                                                                              

                                                                     page 2

  MOVE LEFT:       c # of columns     1     Move cursor left specified number  

  ESC [cD                                   of columns or until left edge of   

                                           screen is reached.  Row position   

                                           is not changed.                    

  SAVE CURSOR      none                     The current cursor position is     

  POSITION:                                 saved (in memory).  Only the last  

  ESC [s                                    saved position is remembered.      

                                                                              

  RESTORE CURSOR   none                     Move cursor to the location set    

  POSITION:                                 with last SAVE CURSOR POSITION     

  ESC [u                                    command.                           

                                                                              

  REPORT CURSOR    6                        Will return the current cursor     

  POSITION:                                 position in the format of:         

  ESC [6n                                   ESC [r;cR                          

                                           wherein r is the current cursor row

                                           and c is the current cursor column

                                                                              

            >>>----- Screen Erase Command Sequences -----<<<                  

                                                                              

   Name/                         Default   Function                           

   Command        Parameter       Value    Operation                          

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

  ERASE SCREEN:    2                  2     Erase entire display and move      

  ESC [2J                                   cursor to home position.           

                                                                              

  ERASE LINE:      0                  0     Erase line from cursor position to

  ESC [0K                                   the right margin, inclusive.       

                                           Cursor position is not changed.    

                                                                              

            >>>----- Display Mode Command Sequences -----<<<

                                                                              

  SET MODE:        (wherein # is:)          Sets display mode according

  ESC [=#h                                  to the parameter (#) specified.

                                           Command sequence must end with

                                           a lowercase "h".

  RESET MODE:      (wherein # is:)          Resets display mode according

  ESC [=#l                                  to the parameter (#) specified.

                                           Equivalent to set mode except

                                           for parameter 7, which turns

                                           end-of-line wrap off.  Command

                                           sequence must end with a lower-

  wherein # is:                             case "l".

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

  0     40 x 25 black and white.        Remember that if these codes are

  1     40 x 25 color.                  used, they may not display correctly

  2     80 x 25 black and white.        on all monitors due to hardware

  3     80 x 25 color.                  variations.

  4     320 x 200 color.

  5     320 x 200 black and white.

  6     640 x 200 black and white.

  7     End-of-line wrap turned on.

  * Note: keyboard reassignment commands are not listed in this

         reference.  For more details, consult your DOS user's manual.