Table of Contents

Cursor controll in PHP cli scripts

Controll cursor in CLI scripts by echoing ANSI characters

echo "\033[100D";

Many computer terminals and terminal emulators support colour and cursor control through a system of escape sequences. One such standard is commonly referred to as ANSI Colour. Several terminal specifications are based on the ANSI colour standard, including VT100.

The following is a partial listing of the VT100 control set.

<ESC> represents the ASCII “escape” character, 0x1B. Bracketed tags represent modifiable decimal parameters; eg. {ROW} would be replaced by a row number.

Device Status

The following codes are used for reporting terminal/display settings, and vary depending on the implementation:

Terminal Setup

The h and l codes are used for setting terminal/display mode, and vary depending on the implementation. Line Wrap is one of the few setup codes that tend to be used consistently:

Fonts

Some terminals support multiple fonts: normal/bold, swiss/italic, etc. There are a variety of special codes for certain terminals; the following are fairly standard:

Cursor Control

Scrolling

Tab Control

Erasing Text

Printing

Some terminals support local printing:

Define Key

Set Display Attributes

  0	Reset all attributes
  1	Bright
  2	Dim
  4	Underscore	
  5	Blink
  7	Reverse
  8	Hidden
  	Foreground Colours
  30	Black
  31	Red
  32	Green
  33	Yellow
  34	Blue
  35	Magenta
  36	Cyan
  37	White
  	Background Colours
  40	Black
  41	Red
  42	Green
  43	Yellow
  44	Blue
  45	Magenta
  46	Cyan
  47	White