

For a simple example, here's some Python code from the Blender build scripts: class bcolors: The most common way to do this is by printing ANSI escape sequences. This page is for INFORMATIONAL PURPOSES ONLY.This somewhat depends on what platform you are on. This batch file demonstrates some of the Display Attribute commands. Where is the path name of the directory where ANSI.SYS is stored. Place a line in CONFIG.SYS similar to this one:
BATCH ANSI ESCAPE SEQUENCES WINDOWS 10 DRIVER
To use ANSI escape sequences, the file ANSI.SYS must be on your system disk and named as a device driver in the CONFIG.SYS file. In Windows: Hold down the while typing 0027 on the keypad. In DOS: Hold down the key while typing 27 on the keyboard keypad. Redefine as a Directory command piped to a Sort command, followed by a Carriage Return. Restore the tilde key to its original meaning. To restore a key to its original meaning, enter a Define Key command that sets equal to.


It can be specified as an ASCII code, an ANSI key code, a string enclosed in quotation marks, or any combination of codes and strings separated by semicolons. is the character or characters to be produced when a key is pressed. If the key is a function key, keypad key, or a combination of the, , or key and some other key, is two numbers separated by a semicolon, found in ANSI Key Code table.

If the key is one of the standard ASCII characters, is a number from 1 through 127. Truncate lines longer than 80 characters.Īssigns one or more characters to be produced when you press a key. It can be one of the following:Ĭontinued lines longer than 80 characters, don't truncate them.Ĭauses lines longer than 80 characters to be truncated at the 80th character, rather than continued to the next line. It can be turned off with the Turn Off Line Wrap command. This command can also be used to cause lines longer than 80 characters to be broken at the 80th character and continued on the next line, rather than truncated at the 80th column this is called line wrap. Sets the width and color capability of the display (generally equivalent to the DOS MODE command). Turn off all attributes, then turn on high-intensity cyan foreground. If you omit, all attributes are turned off (equivalent to specifying as 0). More than one attribute can be specified by using a semicolon to separate the attribute numbers. specifies the display attribute to be turned on. Turns on a characteristic or attribute of the display, such as high intensity, blink, or foreground and background color. Move the cursor the row and column last saved with a Save Cursor Position command.Įrases the entire display (equivalent to the DOS Clear Screen or cls command).Įrases from the current cursor position through the end of the line that contains the cursor.Įrase from the cursor to the end of the line. Moves the cursor to the row and column position most recently saved with a Save Cursor Position command. is a number from 1 through 80 that specifies the column where the cursor is located. is a number from 1 through 25 that specifies the row where the cursor is located. Returns the current row and column position of the cursor in the form [ R. You can move the cursor to this location with a Restore Cursor Position command. Stores the current row and column position of the cursor. If you omit both and, DOS moves the cursor to the home position (row 1, column 1-the upper left corner of the screen). If you omit, DOS moves the cursor to column 1. is a number from 1 through 80 that specifies the column to which the cursor is to be moved. To omit but specify, enter the semicolon to show the is omitted. If you omit, DOS moves the cursor to row 1. is a number from 1 through 25 that specifies the row to which the cursor is to be moved. Moves the cursor to the specified row and column. If you omit, DOS moves the cursor left one column. is a number from 1 through 79 that specifies how many columns the cursor is to be moved left. Moves the cursor left the specified number of columns without changing the row. If you omit, DOS moves the cursor right one column. is a number from 1 through 79 that specifies how many columns that cursor is to be moved right. Moves the cursor right the specified number of columns without changing the row. If you omit, DOS moves the cursor down one row. is a number from 1 through 24 that specifies how many rows the cursor is to be moved down. Moves the cursor down the specified number of rows without changing the column. If you omit, DOS moves the cursor up one row. is a number from 1 through 24 that specifies how many rows the cursor is to be moved up. Moves the cursor up the specified number of rows without changing the column. Programming Notes - ANSI Escape Sequences Programming
