Previous Topic | Table of Contents | Next Topic

ANSI Escape Sequences

The C shell and all the utilities that come with it generate the following ANSI escape sequences when writing to a file or pipe. When writing to the console, they interpret these sequences. In this table, Esc refers to the 0x1b escape character.

Escape Sequence
Meaning
Esc [ row; col H Set cursor position, counting from (1, 1) in upper left-hand corner.
Esc [ row; col f Set cursor position, counting from (1, 1) in upper left-hand corner.
Esc [ n A Cursor up n rows.
Esc [ n B Cursor down n rows.
Esc [ n C Cursor forward n rows.
Esc [ n D Cursor backward n rows.
Esc [ s Save cursor position.
Esc [ u Restore cursor position.
Esc [ 2 J Erase display and move cursor to upper left-hand corner.
Esc [ K Erase to end of line.
Esc [ g m

Set graphics rendition (color, etc.). More than one change can be specified by using semicolons between each g value:

Basic attributes:

0 Normal
1 Bright
2 Dim
5 Bright background
7 Reverse video
8 Hidden

Foreground colors:

30 Black
31 Red
32 Green
33 Yellow
34 Blue
35 Magenta
36 Cyan
37 White

Background colors:

40 Black
41 Red
42 Green
43 Yellow
44 Blue
45 Magenta
46 Cyan
47 White



Previous Topic | Table of Contents | Next Topic

Copyright © 1988-2003 by Hamilton Laboratories. All rights reserved.