-->

Previous | Table of Contents | Next

Page 1068

LINUX CONSOLE CONTROLS

This section describes all the control characters and escape sequences that invoke special functions (that is, anything other than writing a glyph at the current cursor location) on the Linux console.

CONTROL CHARACTERS

A character is a control character if (before transformation according to the mapping table) it has one of the 14 codes 00 (NUL), 07 (BEL), 08 (BS), 09 (HT), 0a (LF), 0b (VT), 0c (FF), 0d (CR), 0e (SO), 0f (SI), 18 (CAN), 1a (SUB), 1b (ESC), 7f (DEL). One can set a display control characters mode (see below), and allow 07, 09, 0b, 18, 1a, 7f to be displayed as glyphs. On the other hand, in UTF-8 mode all codes 00_1f are regarded as control characters, regardless of any display control characters mode.

If you have a control character, it is acted upon immediately and then discarded (even in the middle of an escape sequence) and the escape sequence continues with the next character. (However, ESC starts a new escape sequence, possibly aborting a previous unfinished one, and CAN and SUB abort any escape sequence.) The recognized control characters are BEL, BS, HT, LF, VT, FF, CR, SO, SI, CAN, SUB, ESC, DEL, CSI. They do what one would expect:

BEL (0x07, ^G) beeps.
BS (0x08, ^H) backspaces one column (but not past the beginning of the line).
HT (0x09, ^I) goes to the next tab stop or to the end of the line if there is no earlier tab stop.
LF (0x0A, ^J), VT (0x0B, ^K) and FF (0x0C, ^L) all give a linefeed.
CR (0x0D, ^M) gives a carriage return.
SO (0x0E, ^N) activates the G1 character set, and if LF/NL (new line mode) is set, also a carriage return.
SI (0x0F, ^O) activates the G0 character set.
CAN (0x18, ^X) and SUB (0x1A, ^Z) interrupt escape sequences.
ESC (0x1B, ^[) starts an escape sequence.
DEL (0x7F) is ignored.
CSI (0x9B) is equivalent to ESC [.

ESC SEQUENCES, NOT CSI SEQUENCES

ESC c RIS Reset.
ESC D IND Linefeed.
ESC E NEL Newline.
ESC H HTS Set tab stop at current column.
ESC M RI Reverse linefeed.
ESC Z DECID DEC private identification. The kernel returns the string ESC [ ? 6 c, claiming that it is a VT102.
ESC 7 DECSC Save current state (cursor coordinates, attributes, character sets).
ESC 8 DECRC Restore most recently saved state.
ESC [ CSI Control sequence introducer.
ESC % Start sequence selecting character set.
ESC % @ Select default (ISO 646 / ISO 8859-1).
ESC % G Select UTF-8.
ESC % 8 Select UTF-8 (obsolete).
ESC # 8 DECALN DEC screen alignment test: fill screen with Es.
ESC ( Start sequence defining G0 character set.
ESC ( B Select default (ISO 8859-1 mapping).
ESC ( 0 Select vt100 graphics mapping.

Page 1069

ESC ( U Select null mapping—straight to character ROM.
ESC ( K Select user mapping, the map that is loaded by the utility mapscrn(8).
ESC ) Start sequence defining G1 (followed by one of B, 0, U, K, as above).
ESC > DECPNM Set numeric keypad mode.
ESC = DECPAM Set application keypad mode.
ESC ] OSC (Should be: Operating system command) ESC ] P nrrggbb: set palette, with parameter given in 7 hexadecimal digits after the final P :-(. Here n is the color (0_16), and rrggbb indicates the red/green/blue values (0_255). ESC ] R: reset palette.

ECMA-48 CSI SEQUENCES

CSI (or ESC [) is followed by a sequence of parameters, at most NPAR(16), that are decimal numbers separated by semicolons. An empty or absent parameter is taken to be 0. The sequence of parameters may be preceded by a single question mark.

However, after CSI [ (or ESC [ [) a single character is read and this entire sequence is ignored. (The idea is to ignore an echoed function key.)

The action of a CSI sequence is determined by its final character.

Character Function Description
@ ICH Insert the indicated # of blank characters.
A CUU Move cursor up the indicated # of rows.
B CUD Move cursor down the indicated # of rows.
C CUF Move cursor right the indicated # of columns.
D CUB Move cursor left the indicated # of columns.
E CNL Move cursor down the indicated # of rows, to column 1.
F CPL Move cursor up the indicated # of rows, to column 1.
G CHA Move cursor to indicated column in current row.
H CUP Move cursor to the indicated row, column (origin at 1,1).
J ED Erase display (default: from cursor to end of display).
ESC [ 1 J: erase from start to cursor.
ESC [ 2 J: erase whole display.
K EL Erase line (default: from cursor to end of line).
ESC [ 1 K: erase from start of line to cursor.
ESC [ 2 K: erase whole line.
L IL Insert the indicated # of blank lines.
M DL Delete the indicated # of lines.
P DCH Delete the indicated # of characters on the current line.
X ECH Erase the indicated # of characters on the current line.
a HPR Move cursor right the indicated # of columns.
c DA Answer ESC [ ? 6 c: `I am a VT102'.
d VPA Move cursor to the indicated row, current column.
e VPR Move cursor down the indicated # of rows.
f HVP Move cursor to the indicated row, column.

                                                 continues

Previous | Table of Contents | Next