796 lines
32 KiB
HTML
796 lines
32 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of CONSOLE_CODES</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>CONSOLE_CODES</H1>
|
|
Section: Linux Programmer's Manual (4)<BR>Updated: 2020-02-09<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
console_codes - Linux console escape and control sequences
|
|
<A NAME="lbAC"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
The Linux console implements a large subset of the VT102 and ECMA-48/ISO
|
|
6429/ANSI X3.64 terminal controls, plus certain private-mode sequences
|
|
for changing the color palette, character-set mapping, and so on.
|
|
In the tabular descriptions below, the second column gives ECMA-48 or DEC
|
|
mnemonics (the latter if prefixed with DEC) for the given function.
|
|
Sequences without a mnemonic are neither ECMA-48 nor VT102.
|
|
<P>
|
|
|
|
After all the normal output processing has been done, and a
|
|
stream of characters arrives at the console driver for actual
|
|
printing, the first thing that happens is a translation from
|
|
the code used for processing to the code used for printing.
|
|
<P>
|
|
|
|
If the console is in UTF-8 mode, then the incoming bytes are
|
|
first assembled into 16-bit Unicode codes.
|
|
Otherwise, each byte is transformed according to the current mapping table
|
|
(which translates it to a Unicode value).
|
|
See the <B>Character Sets</B> section below for discussion.
|
|
<P>
|
|
|
|
In the normal case, the Unicode value is converted to a font index,
|
|
and this is stored in video memory, so that the corresponding glyph
|
|
(as found in video ROM) appears on the screen.
|
|
Note that the use of Unicode (and the design of the PC hardware)
|
|
allows us to use 512 different glyphs simultaneously.
|
|
<P>
|
|
|
|
If the current Unicode value is a control character, or we are
|
|
currently processing an escape sequence, the value will treated
|
|
specially.
|
|
Instead of being turned into a font index and rendered as
|
|
a glyph, it may trigger cursor movement or other control functions.
|
|
See the <B>Linux Console Controls</B> section below for discussion.
|
|
<P>
|
|
|
|
It is generally not good practice to hard-wire terminal controls into
|
|
programs.
|
|
Linux supports a
|
|
<B><A HREF="/cgi-bin/man/man2html?5+terminfo">terminfo</A></B>(5)
|
|
|
|
database of terminal capabilities.
|
|
Rather than emitting console escape sequences by hand, you will almost
|
|
always want to use a terminfo-aware screen library or utility such as
|
|
<B><A HREF="/cgi-bin/man/man2html?3+ncurses">ncurses</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+tput">tput</A></B>(1),
|
|
|
|
or
|
|
<B><A HREF="/cgi-bin/man/man2html?1+reset">reset</A></B>(1).
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H3>Linux console controls</H3>
|
|
|
|
This section describes all the control characters and escape sequences
|
|
that invoke special functions (i.e., anything other than writing a
|
|
glyph at the current cursor location) on the Linux console.
|
|
<P>
|
|
|
|
<B>Control characters</B>
|
|
|
|
<P>
|
|
|
|
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.
|
|
<P>
|
|
|
|
If we 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:
|
|
<DL COMPACT>
|
|
<DT id="1">
|
|
<DD>BEL (0x07, <B>^G</B>) beeps;
|
|
<DT id="2">
|
|
<DD>BS (0x08, <B>^H</B>) backspaces one column
|
|
(but not past the beginning of the line);
|
|
<DT id="3">
|
|
<DD>HT (0x09, <B>^I</B>) goes to the next tab stop or to the end of the line
|
|
if there is no earlier tab stop;
|
|
<DT id="4">
|
|
<DD>LF (0x0A, <B>^J</B>), VT (0x0B, <B>^K</B>) and
|
|
FF (0x0C, <B>^L</B>) all give a linefeed,
|
|
and if LF/NL (new-line mode) is set also a carriage return;
|
|
<DT id="5">
|
|
<DD>CR (0x0D, <B>^M</B>) gives a carriage return;
|
|
<DT id="6">
|
|
<DD>SO (0x0E, <B>^N</B>) activates the G1 character set;
|
|
<DT id="7">
|
|
<DD>SI (0x0F, <B>^O</B>) activates the G0 character set;
|
|
<DT id="8">
|
|
<DD>CAN (0x18, <B>^X</B>) and SUB (0x1A, <B>^Z</B>) interrupt escape sequences;
|
|
<DT id="9">
|
|
<DD>ESC (0x1B, <B>^[</B>) starts an escape sequence;
|
|
<DT id="10">
|
|
<DD>DEL (0x7F) is ignored;
|
|
<DT id="11">
|
|
<DD>CSI (0x9B) is equivalent to ESC [.
|
|
</DL>
|
|
<P>
|
|
|
|
<B>ESC- but not CSI-sequences</B>
|
|
|
|
<TABLE>
|
|
<TR VALIGN=top><TD>ESC c</TD><TD>RIS</TD><TD>Reset.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC D</TD><TD>IND</TD><TD>Linefeed.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC E</TD><TD>NEL</TD><TD>Newline.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC H</TD><TD>HTS</TD><TD>Set tab stop at current column.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC M</TD><TD>RI</TD><TD>Reverse linefeed.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC Z</TD><TD>DECID</TD><TD>
|
|
DEC private identification. The kernel
|
|
returns the string ESC [ ? 6 c, claiming
|
|
that it is a VT102.
|
|
<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC 7</TD><TD>DECSC</TD><TD>
|
|
Save current state (cursor coordinates,
|
|
attributes, character sets pointed at by G0, G1).
|
|
<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC 8</TD><TD>DECRC</TD><TD>Restore state most recently saved by ESC 7.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC [</TD><TD>CSI</TD><TD>Control sequence introducer<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC %</TD><TD></TD><TD>Start sequence selecting character set<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC % @</TD><TD></TD><TD> Select default (ISO 646 / ISO 8859-1)<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC % G</TD><TD></TD><TD> Select UTF-8<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC % 8</TD><TD></TD><TD> Select UTF-8 (obsolete)<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC # 8</TD><TD>DECALN</TD><TD>DEC screen alignment test - fill screen with E's.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC (</TD><TD></TD><TD>Start sequence defining G0 character set<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC ( B</TD><TD></TD><TD> Select default (ISO 8859-1 mapping)<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC ( 0</TD><TD></TD><TD> Select VT100 graphics mapping<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC ( U</TD><TD></TD><TD> Select null mapping - straight to character ROM<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC ( K</TD><TD></TD><TD> Select user mapping - the map that is loaded by<BR></TD></TR>
|
|
<TR VALIGN=top><TD></TD><TD></TD><TD> the utility <B><A HREF="/cgi-bin/man/man2html?8+mapscrn">mapscrn</A></B>(8).<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC )</TD><TD></TD><TD>Start sequence defining G1<BR></TD></TR>
|
|
<TR VALIGN=top><TD></TD><TD></TD><TD>(followed by one of B, 0, U, K, as above).<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC ></TD><TD>DECPNM</TD><TD>Set numeric keypad mode<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC =</TD><TD>DECPAM</TD><TD>Set application keypad mode<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC ]</TD><TD>OSC</TD><TD>
|
|
(Should be: Operating system command)
|
|
ESC ] P <I>nrrggbb</I>: set palette, with parameter
|
|
given in 7 hexadecimal digits after the final P :-(.
|
|
Here <I>n</I> is the color (0-15), and <I>rrggbb</I> indicates
|
|
the red/green/blue values (0-255).
|
|
ESC ] R: reset palette
|
|
<BR></TD></TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
|
|
<B>ECMA-48 CSI sequences</B>
|
|
|
|
<P>
|
|
|
|
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.
|
|
<P>
|
|
|
|
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.)
|
|
<P>
|
|
|
|
The action of a CSI sequence is determined by its final character.
|
|
<TABLE>
|
|
<TR VALIGN=top><TD>@</TD><TD>ICH</TD><TD>Insert the indicated # of blank characters.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>A</TD><TD>CUU</TD><TD>Move cursor up the indicated # of rows.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>B</TD><TD>CUD</TD><TD>Move cursor down the indicated # of rows.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>C</TD><TD>CUF</TD><TD>Move cursor right the indicated # of columns.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>D</TD><TD>CUB</TD><TD>Move cursor left the indicated # of columns.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>E</TD><TD>CNL</TD><TD>Move cursor down the indicated # of rows, to column 1.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>F</TD><TD>CPL</TD><TD>Move cursor up the indicated # of rows, to column 1.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>G</TD><TD>CHA</TD><TD>Move cursor to indicated column in current row.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>H</TD><TD>CUP</TD><TD>Move cursor to the indicated row, column (origin at 1,1).<BR></TD></TR>
|
|
<TR VALIGN=top><TD>J</TD><TD>ED</TD><TD>Erase display (default: from cursor to end of display).<BR></TD></TR>
|
|
<TR VALIGN=top><TD></TD><TD></TD><TD>ESC [ 1 J: erase from start to cursor.<BR></TD></TR>
|
|
<TR VALIGN=top><TD></TD><TD></TD><TD>ESC [ 2 J: erase whole display.<BR></TD></TR>
|
|
<TR VALIGN=top><TD></TD><TD></TD><TD>ESC [ 3 J: erase whole display including scroll-back<BR></TD></TR>
|
|
<TR VALIGN=top><TD></TD><TD></TD><TD> buffer (since Linux 3.0).<BR></TD></TR>
|
|
<TR VALIGN=top><TD>K</TD><TD>EL</TD><TD>Erase line (default: from cursor to end of line).<BR></TD></TR>
|
|
<TR VALIGN=top><TD></TD><TD></TD><TD>ESC [ 1 K: erase from start of line to cursor.<BR></TD></TR>
|
|
<TR VALIGN=top><TD></TD><TD></TD><TD>ESC [ 2 K: erase whole line.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>L</TD><TD>IL</TD><TD>Insert the indicated # of blank lines.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>M</TD><TD>DL</TD><TD>Delete the indicated # of lines.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>P</TD><TD>DCH</TD><TD>Delete the indicated # of characters on current line.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>X</TD><TD>ECH</TD><TD>Erase the indicated # of characters on current line.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>a</TD><TD>HPR</TD><TD>Move cursor right the indicated # of columns.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>c</TD><TD>DA</TD><TD>Answer ESC [ ? 6 c: "I am a VT102".<BR></TD></TR>
|
|
<TR VALIGN=top><TD>d</TD><TD>VPA</TD><TD>Move cursor to the indicated row, current column.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>e</TD><TD>VPR</TD><TD>Move cursor down the indicated # of rows.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>f</TD><TD>HVP</TD><TD>Move cursor to the indicated row, column.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>g</TD><TD>TBC</TD><TD>Without parameter: clear tab stop at current position.<BR></TD></TR>
|
|
<TR VALIGN=top><TD></TD><TD></TD><TD>ESC [ 3 g: delete all tab stops.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>h</TD><TD>SM</TD><TD>Set Mode (see below).<BR></TD></TR>
|
|
<TR VALIGN=top><TD>l</TD><TD>RM</TD><TD>Reset Mode (see below).<BR></TD></TR>
|
|
<TR VALIGN=top><TD>m</TD><TD>SGR</TD><TD>Set attributes (see below).<BR></TD></TR>
|
|
<TR VALIGN=top><TD>n</TD><TD>DSR</TD><TD>Status report (see below).<BR></TD></TR>
|
|
<TR VALIGN=top><TD>q</TD><TD>DECLL</TD><TD>Set keyboard LEDs.<BR></TD></TR>
|
|
<TR VALIGN=top><TD></TD><TD></TD><TD>ESC [ 0 q: clear all LEDs<BR></TD></TR>
|
|
<TR VALIGN=top><TD></TD><TD></TD><TD>ESC [ 1 q: set Scroll Lock LED<BR></TD></TR>
|
|
<TR VALIGN=top><TD></TD><TD></TD><TD>ESC [ 2 q: set Num Lock LED<BR></TD></TR>
|
|
<TR VALIGN=top><TD></TD><TD></TD><TD>ESC [ 3 q: set Caps Lock LED<BR></TD></TR>
|
|
<TR VALIGN=top><TD>r</TD><TD>DECSTBM</TD><TD>Set scrolling region; parameters are top and bottom row.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>s</TD><TD>?</TD><TD>Save cursor location.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>u</TD><TD>?</TD><TD>Restore cursor location.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>`</TD><TD>HPA</TD><TD>Move cursor to indicated column in current row.<BR></TD></TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
|
|
<B>ECMA-48 Set Graphics Rendition</B>
|
|
|
|
<P>
|
|
|
|
The ECMA-48 SGR sequence ESC [ <I>parameters</I> m sets display
|
|
attributes.
|
|
Several attributes can be set in the same sequence, separated by
|
|
semicolons.
|
|
An empty parameter (between semicolons or string initiator or
|
|
terminator) is interpreted as a zero.
|
|
<TABLE>
|
|
<TR VALIGN=top><TD>param</TD><TD>result<BR></TD></TR>
|
|
<TR VALIGN=top><TD>0</TD><TD>reset all attributes to their defaults<BR></TD></TR>
|
|
<TR VALIGN=top><TD>1</TD><TD>set bold<BR></TD></TR>
|
|
<TR VALIGN=top><TD>2</TD><TD>set half-bright (simulated with color on a color display)<BR></TD></TR>
|
|
<TR VALIGN=top><TD>4</TD><TD>
|
|
set underscore (simulated with color on a color display)
|
|
(the colors used to simulate dim or underline are set
|
|
using ESC ] ...)
|
|
<BR></TD></TR>
|
|
<TR VALIGN=top><TD>5</TD><TD>set blink<BR></TD></TR>
|
|
<TR VALIGN=top><TD>7</TD><TD>set reverse video<BR></TD></TR>
|
|
<TR VALIGN=top><TD>10</TD><TD>
|
|
reset selected mapping, display control flag,
|
|
and toggle meta flag (ECMA-48 says "primary font").
|
|
<BR></TD></TR>
|
|
<TR VALIGN=top><TD>11</TD><TD>
|
|
select null mapping, set display control flag,
|
|
reset toggle meta flag (ECMA-48 says "first alternate font").
|
|
<BR></TD></TR>
|
|
<TR VALIGN=top><TD>12</TD><TD>
|
|
select null mapping, set display control flag,
|
|
set toggle meta flag (ECMA-48 says "second alternate font").
|
|
The toggle meta flag
|
|
causes the high bit of a byte to be toggled
|
|
before the mapping table translation is done.
|
|
<BR></TD></TR>
|
|
<TR VALIGN=top><TD>21</TD><TD>
|
|
set underline; before Linux 4.17, this value
|
|
set normal intensity (as is done in many other terminals)
|
|
<BR></TD></TR>
|
|
<TR VALIGN=top><TD>22</TD><TD>set normal intensity<BR></TD></TR>
|
|
<TR VALIGN=top><TD>24</TD><TD>underline off<BR></TD></TR>
|
|
<TR VALIGN=top><TD>25</TD><TD>blink off<BR></TD></TR>
|
|
<TR VALIGN=top><TD>27</TD><TD>reverse video off<BR></TD></TR>
|
|
<TR VALIGN=top><TD>30</TD><TD>set black foreground<BR></TD></TR>
|
|
<TR VALIGN=top><TD>31</TD><TD>set red foreground<BR></TD></TR>
|
|
<TR VALIGN=top><TD>32</TD><TD>set green foreground<BR></TD></TR>
|
|
<TR VALIGN=top><TD>33</TD><TD>set brown foreground<BR></TD></TR>
|
|
<TR VALIGN=top><TD>34</TD><TD>set blue foreground<BR></TD></TR>
|
|
<TR VALIGN=top><TD>35</TD><TD>set magenta foreground<BR></TD></TR>
|
|
<TR VALIGN=top><TD>36</TD><TD>set cyan foreground<BR></TD></TR>
|
|
<TR VALIGN=top><TD>37</TD><TD>set white foreground<BR></TD></TR>
|
|
<TR VALIGN=top><TD>38</TD><TD>
|
|
256/24-bit foreground color follows, shoehorned into 16 basic colors
|
|
(before Linux 3.16: set underscore on, set default foreground color)
|
|
<BR></TD></TR>
|
|
<TR VALIGN=top><TD>39</TD><TD>
|
|
set default foreground color
|
|
(before Linux 3.16: set underscore off, set default foreground color)
|
|
<BR></TD></TR>
|
|
<TR VALIGN=top><TD>40</TD><TD>set black background<BR></TD></TR>
|
|
<TR VALIGN=top><TD>41</TD><TD>set red background<BR></TD></TR>
|
|
<TR VALIGN=top><TD>42</TD><TD>set green background<BR></TD></TR>
|
|
<TR VALIGN=top><TD>43</TD><TD>set brown background<BR></TD></TR>
|
|
<TR VALIGN=top><TD>44</TD><TD>set blue background<BR></TD></TR>
|
|
<TR VALIGN=top><TD>45</TD><TD>set magenta background<BR></TD></TR>
|
|
<TR VALIGN=top><TD>46</TD><TD>set cyan background<BR></TD></TR>
|
|
<TR VALIGN=top><TD>47</TD><TD>set white background<BR></TD></TR>
|
|
<TR VALIGN=top><TD>48</TD><TD>
|
|
256/24-bit background color follows, shoehorned into 8 basic colors
|
|
<BR></TD></TR>
|
|
<TR VALIGN=top><TD>49</TD><TD>set default background color<BR></TD></TR>
|
|
<TR VALIGN=top><TD>90..97</TD><TD>set foreground to bright versions of 30..37<BR></TD></TR>
|
|
<TR VALIGN=top><TD>100.107</TD><TD>set background, same as 40..47 (bright not supported)<BR></TD></TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
|
|
Commands 38 and 48 require further arguments:
|
|
<TABLE>
|
|
<TR VALIGN=top><TD>;5;x</TD><TD>
|
|
256 color: values 0..15 are IBGR (black, red, green, ... white),
|
|
16..231 a 6x6x6 color cube, 232..255 a grayscale ramp
|
|
<BR></TD></TR>
|
|
<TR VALIGN=top><TD>;2;r;g;b</TD><TD>24-bit color, r/g/b components are in the range 0..255<BR></TD></TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
|
|
<B>ECMA-48 Mode Switches</B>
|
|
|
|
<DL COMPACT>
|
|
<DT id="12">ESC [ 3 h<DD>
|
|
DECCRM (default off): Display control chars.
|
|
<DT id="13">ESC [ 4 h<DD>
|
|
DECIM (default off): Set insert mode.
|
|
<DT id="14">ESC [ 20 h<DD>
|
|
LF/NL (default off): Automatically follow echo of LF, VT or FF with CR.
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<B>ECMA-48 Status Report Commands</B>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="15">ESC [ 5 n<DD>
|
|
Device status report (DSR): Answer is ESC [ 0 n (Terminal OK).
|
|
<DT id="16">ESC [ 6 n<DD>
|
|
Cursor position report (CPR): Answer is ESC [ <I>y</I> ; <I>x</I> R,
|
|
where <I>x,y</I> is the cursor location.
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<B>DEC Private Mode (DECSET/DECRST) sequences</B>
|
|
|
|
<P>
|
|
|
|
|
|
These are not described in ECMA-48.
|
|
We list the Set Mode sequences;
|
|
the Reset Mode sequences are obtained by replacing the final 'h'
|
|
by 'l'.
|
|
<DL COMPACT>
|
|
<DT id="17">ESC [ ? 1 h<DD>
|
|
DECCKM (default off): When set, the cursor keys send an ESC O prefix,
|
|
rather than ESC [.
|
|
<DT id="18">ESC [ ? 3 h<DD>
|
|
DECCOLM (default off = 80 columns): 80/132 col mode switch.
|
|
The driver sources note that this alone does not suffice; some user-mode
|
|
utility such as
|
|
<B><A HREF="/cgi-bin/man/man2html?8+resizecons">resizecons</A></B>(8)
|
|
|
|
has to change the hardware registers on the console video card.
|
|
<DT id="19">ESC [ ? 5 h<DD>
|
|
DECSCNM (default off): Set reverse-video mode.
|
|
<DT id="20">ESC [ ? 6 h<DD>
|
|
DECOM (default off): When set, cursor addressing is relative to
|
|
the upper left corner of the scrolling region.
|
|
<DT id="21">ESC [ ? 7 h<DD>
|
|
DECAWM (default on): Set autowrap on.
|
|
In this mode, a graphic
|
|
character emitted after column 80 (or column 132 of DECCOLM is on)
|
|
forces a wrap to the beginning of the following line first.
|
|
<DT id="22">ESC [ ? 8 h<DD>
|
|
DECARM (default on): Set keyboard autorepeat on.
|
|
<DT id="23">ESC [ ? 9 h<DD>
|
|
X10 Mouse Reporting (default off): Set reporting mode to 1 (or reset to
|
|
0)---see below.
|
|
<DT id="24">ESC [ ? 25 h<DD>
|
|
DECTECM (default on): Make cursor visible.
|
|
<DT id="25">ESC [ ? 1000 h<DD>
|
|
X11 Mouse Reporting (default off): Set reporting mode to 2 (or reset
|
|
to 0)---see below.
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<B>Linux Console Private CSI Sequences</B>
|
|
|
|
<P>
|
|
|
|
|
|
The following sequences are neither ECMA-48 nor native VT102.
|
|
They are native to the Linux console driver.
|
|
Colors are in SGR parameters:
|
|
0 = black, 1 = red, 2 = green, 3 = brown, 4 = blue, 5 = magenta, 6 =
|
|
cyan, 7 = white; 8-15 = bright versions of 0-7.
|
|
<TABLE>
|
|
<TR VALIGN=top><TD>ESC [ 1 ; <I>n</I> ]</TD><TD>Set color <I>n</I> as the underline color.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC [ 2 ; <I>n</I> ]</TD><TD>Set color <I>n</I> as the dim color.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC [ 8 ] </TD><TD>Make the current color pair the default attributes.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC [ 9 ; <I>n</I> ]</TD><TD>Set screen blank timeout to <I>n</I> minutes.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC [ 10 ; <I>n</I> ]</TD><TD>Set bell frequency in Hz.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC [ 11 ; <I>n</I> ]</TD><TD>Set bell duration in msec.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC [ 12 ; <I>n</I> ]</TD><TD>Bring specified console to the front.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC [ 13 ] </TD><TD>Unblank the screen.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC [ 14 ; <I>n</I> ] </TD><TD>Set the VESA powerdown interval in minutes.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC [ 15 ] </TD><TD>
|
|
Bring the previous console to the front
|
|
(since Linux 2.6.0).
|
|
<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC [ 16 ; <I>n</I> ] </TD><TD>
|
|
Set the cursor blink interval in milliseconds
|
|
(since Linux 4.2).
|
|
<BR></TD></TR>
|
|
</TABLE>
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H3>Character sets</H3>
|
|
|
|
The kernel knows about 4 translations of bytes into console-screen
|
|
symbols.
|
|
The four tables are: a) Latin1 -> PC,
|
|
b) VT100 graphics -> PC, c) PC -> PC, d) user-defined.
|
|
<P>
|
|
|
|
There are two character sets, called G0 and G1, and one of them
|
|
is the current character set.
|
|
(Initially G0.)
|
|
Typing <B>^N</B> causes G1 to become current,
|
|
<B>^O</B> causes G0 to become current.
|
|
<P>
|
|
|
|
These variables G0 and G1 point at a translation table, and can be
|
|
changed by the user.
|
|
Initially they point at tables a) and b), respectively.
|
|
The sequences ESC ( B and ESC ( 0 and ESC ( U and ESC ( K cause G0 to
|
|
point at translation table a), b), c) and d), respectively.
|
|
The sequences ESC ) B and ESC ) 0 and ESC ) U and ESC ) K cause G1 to
|
|
point at translation table a), b), c) and d), respectively.
|
|
<P>
|
|
|
|
The sequence ESC c causes a terminal reset, which is what you want if the
|
|
screen is all garbled.
|
|
The oft-advised "echo ^V^O" will make only G0 current,
|
|
but there is no guarantee that G0 points at table a).
|
|
In some distributions there is a program
|
|
<B><A HREF="/cgi-bin/man/man2html?1+reset">reset</A></B>(1)
|
|
|
|
that just does "echo ^[c".
|
|
If your terminfo entry for the console is correct
|
|
(and has an entry rs1=\Ec), then "tput reset" will also work.
|
|
<P>
|
|
|
|
The user-defined mapping table can be set using
|
|
<B><A HREF="/cgi-bin/man/man2html?8+mapscrn">mapscrn</A></B>(8).
|
|
|
|
The result of the mapping is that if a symbol c is printed, the symbol
|
|
s = map[c] is sent to the video memory.
|
|
The bitmap that corresponds to
|
|
s is found in the character ROM, and can be changed using
|
|
<B><A HREF="/cgi-bin/man/man2html?8+setfont">setfont</A></B>(8).
|
|
|
|
<A NAME="lbAF"> </A>
|
|
<H3>Mouse tracking</H3>
|
|
|
|
The mouse tracking facility is intended to return
|
|
<B><A HREF="/cgi-bin/man/man2html?1+xterm">xterm</A></B>(1)-compatible
|
|
|
|
mouse status reports.
|
|
Because the console driver has no way to know
|
|
the device or type of the mouse, these reports are returned in the
|
|
console input stream only when the virtual terminal driver receives
|
|
a mouse update ioctl.
|
|
These ioctls must be generated by a mouse-aware
|
|
user-mode application such as the
|
|
<B><A HREF="/cgi-bin/man/man2html?8+gpm">gpm</A></B>(8)
|
|
|
|
daemon.
|
|
<P>
|
|
|
|
The mouse tracking escape sequences generated by
|
|
<B><A HREF="/cgi-bin/man/man2html?1+xterm">xterm</A></B>(1) encode numeric parameters in a single character as
|
|
<I>value</I>+040.
|
|
For example, '!' is 1.
|
|
The screen coordinate system is 1-based.
|
|
<P>
|
|
|
|
The X10 compatibility mode sends an escape sequence on button press
|
|
encoding the location and the mouse button pressed.
|
|
It is enabled by sending ESC [ ? 9 h and disabled with ESC [ ? 9 l.
|
|
On button press, <B><A HREF="/cgi-bin/man/man2html?1+xterm">xterm</A></B>(1) sends
|
|
ESC [ M <I>bxy</I> (6 characters).
|
|
Here <I>b</I> is button-1,
|
|
and <I>x</I> and <I>y</I> are the x and y coordinates of the mouse
|
|
when the button was pressed.
|
|
This is the same code the kernel also produces.
|
|
<P>
|
|
|
|
Normal tracking mode (not implemented in Linux 2.0.24) sends an escape
|
|
sequence on both button press and release.
|
|
Modifier information is also sent.
|
|
It is enabled by sending ESC [ ? 1000 h and disabled with
|
|
ESC [ ? 1000 l.
|
|
On button press or release, <B><A HREF="/cgi-bin/man/man2html?1+xterm">xterm</A></B>(1) sends ESC [ M
|
|
<I>bxy</I>.
|
|
The low two bits of <I>b</I> encode button information:
|
|
0=MB1 pressed, 1=MB2 pressed, 2=MB3 pressed, 3=release.
|
|
The upper bits encode what modifiers were down when the button was
|
|
pressed and are added together: 4=Shift, 8=Meta, 16=Control.
|
|
Again <I>x</I> and
|
|
<I>y</I> are the x and y coordinates of the mouse event.
|
|
The upper left corner is (1,1).
|
|
<A NAME="lbAG"> </A>
|
|
<H3>Comparisons with other terminals</H3>
|
|
|
|
Many different terminal types are described, like the Linux console,
|
|
as being "VT100-compatible".
|
|
Here we discuss differences between the
|
|
Linux console and the two most important others, the DEC VT102 and
|
|
<B><A HREF="/cgi-bin/man/man2html?1+xterm">xterm</A></B>(1).
|
|
|
|
|
|
<P>
|
|
|
|
<B>Control-character handling</B>
|
|
|
|
<P>
|
|
|
|
The VT102 also recognized the following control characters:
|
|
<DL COMPACT>
|
|
<DT id="26">
|
|
<DD>NUL (0x00) was ignored;
|
|
<DT id="27">
|
|
<DD>ENQ (0x05) triggered an answerback message;
|
|
<DT id="28">
|
|
<DD>DC1 (0x11, <B>^Q</B>, XON) resumed transmission;
|
|
<DT id="29">
|
|
<DD>DC3 (0x13, <B>^S</B>, XOFF) caused VT100 to ignore (and stop transmitting)
|
|
all codes except XOFF and XON.
|
|
</DL>
|
|
<P>
|
|
|
|
VT100-like DC1/DC3 processing may be enabled by the terminal driver.
|
|
<P>
|
|
|
|
The
|
|
<B><A HREF="/cgi-bin/man/man2html?1+xterm">xterm</A></B>(1)
|
|
|
|
program (in VT100 mode) recognizes the control characters
|
|
BEL, BS, HT, LF, VT, FF, CR, SO, SI, ESC.
|
|
|
|
<P>
|
|
|
|
<B>Escape sequences</B>
|
|
|
|
<P>
|
|
|
|
VT100 console sequences not implemented on the Linux console:
|
|
<TABLE>
|
|
<TR VALIGN=top><TD>ESC N</TD><TD>SS2</TD><TD>Single shift 2. (Select G2 character set for the next<BR></TD></TR>
|
|
<TR VALIGN=top><TD></TD><TD></TD><TD>character only.)<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC O</TD><TD>SS3</TD><TD>Single shift 3. (Select G3 character set for the next<BR></TD></TR>
|
|
<TR VALIGN=top><TD></TD><TD></TD><TD>character only.)<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC P</TD><TD>DCS</TD><TD>Device control string (ended by ESC \)<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC X</TD><TD>SOS</TD><TD>Start of string.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC ^</TD><TD>PM</TD><TD>Privacy message (ended by ESC \)<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC \</TD><TD>ST</TD><TD>String terminator<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC * ...</TD><TD></TD><TD>Designate G2 character set<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC + ...</TD><TD></TD><TD>Designate G3 character set<BR></TD></TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
|
|
The program
|
|
<B><A HREF="/cgi-bin/man/man2html?1+xterm">xterm</A></B>(1)
|
|
|
|
(in VT100 mode) recognizes ESC c, ESC # 8, ESC >, ESC =,
|
|
ESC D, ESC E, ESC H, ESC M, ESC N, ESC O, ESC P ... ESC \,
|
|
ESC Z (it answers ESC [ ? 1 ; 2 c, "I am a VT100 with
|
|
advanced video option")
|
|
and ESC ^ ... ESC \ with the same meanings as indicated above.
|
|
It accepts ESC (, ESC ), ESC *, ESC + followed by 0, A, B for
|
|
the DEC special character and line drawing set, UK, and US-ASCII,
|
|
respectively.
|
|
<P>
|
|
|
|
The user can configure <B><A HREF="/cgi-bin/man/man2html?1+xterm">xterm</A></B>(1) to respond to VT220-specific
|
|
control sequences, and it will identify itself as a VT52, VT100, and
|
|
up depending on the way it is configured and initialized.
|
|
<P>
|
|
|
|
It accepts ESC ] (OSC) for the setting of certain resources.
|
|
In addition to the ECMA-48 string terminator (ST),
|
|
<B><A HREF="/cgi-bin/man/man2html?1+xterm">xterm</A></B>(1) accepts a BEL to terminate an OSC string.
|
|
These are a few of the OSC control sequences recognized by <B><A HREF="/cgi-bin/man/man2html?1+xterm">xterm</A></B>(1):
|
|
<TABLE>
|
|
<TR VALIGN=top><TD>ESC ] 0 ; <I>txt</I> ST</TD><TD>Set icon name and window title to <I>txt</I>.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC ] 1 ; <I>txt</I> ST</TD><TD>Set icon name to <I>txt</I>.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC ] 2 ; <I>txt</I> ST</TD><TD>Set window title to <I>txt</I>.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC ] 4 ; <I>num</I>; <I>txt</I> ST</TD><TD>Set ANSI color <I>num</I> to <I>txt</I>.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC ] 10 ; <I>txt</I> ST</TD><TD>Set dynamic text color to <I>txt</I>.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC ] 4 6 ; <I>name</I> ST</TD><TD>Change log file to <I>name</I> (normally disabled<BR></TD></TR>
|
|
<TR VALIGN=top><TD></TD><TD>by a compile-time option)<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC ] 5 0 ; <I>fn</I> ST</TD><TD>Set font to <I>fn</I>.<BR></TD></TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
|
|
It recognizes the following with slightly modified meaning
|
|
(saving more state, behaving closer to VT100/VT220):
|
|
<TABLE>
|
|
<TR VALIGN=top><TD>ESC 7 DECSC</TD><TD>Save cursor</TD><TD><BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC 8 DECRC</TD><TD>Restore cursor</TD><TD><BR></TD></TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
|
|
It also recognizes
|
|
<TABLE>
|
|
<TR VALIGN=top><TD>ESC F</TD><TD></TD><TD>Cursor to lower left corner of screen (if enabled by<BR></TD></TR>
|
|
<TR VALIGN=top><TD></TD><TD></TD><TD><B><A HREF="/cgi-bin/man/man2html?1+xterm">xterm</A></B>(1)'s <B>hpLowerleftBugCompat</B> resource)<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC l</TD><TD></TD><TD>Memory lock (per HP terminals).<BR></TD></TR>
|
|
<TR VALIGN=top><TD></TD><TD></TD><TD>Locks memory above the cursor.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC m</TD><TD></TD><TD>Memory unlock (per HP terminals).<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC n</TD><TD>LS2</TD><TD>Invoke the G2 character set.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC o</TD><TD>LS3</TD><TD>Invoke the G3 character set.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC |</TD><TD>LS3R</TD><TD>Invoke the G3 character set as GR.<BR></TD></TR>
|
|
<TR VALIGN=top><TD></TD><TD></TD><TD>Has no visible effect in xterm.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC }</TD><TD>LS2R</TD><TD>Invoke the G2 character set as GR.<BR></TD></TR>
|
|
<TR VALIGN=top><TD></TD><TD></TD><TD>Has no visible effect in xterm.<BR></TD></TR>
|
|
<TR VALIGN=top><TD>ESC ~</TD><TD>LS1R</TD><TD>Invoke the G1 character set as GR.<BR></TD></TR>
|
|
<TR VALIGN=top><TD></TD><TD></TD><TD>Has no visible effect in xterm.<BR></TD></TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
|
|
It also recognizes ESC % and provides a more complete UTF-8
|
|
implementation than Linux console.
|
|
|
|
<P>
|
|
|
|
<B>CSI Sequences</B>
|
|
|
|
<P>
|
|
|
|
Old versions of <B><A HREF="/cgi-bin/man/man2html?1+xterm">xterm</A></B>(1), for example, from X11R5,
|
|
interpret the blink SGR as a bold SGR.
|
|
Later versions which implemented ANSI colors, for example,
|
|
XFree86 3.1.2A in 1995, improved this by allowing
|
|
the blink attribute to be displayed as a color.
|
|
Modern versions of xterm implement blink SGR as blinking text
|
|
and still allow colored text as an alternate rendering of SGRs.
|
|
Stock X11R6 versions did not recognize the color-setting SGRs until
|
|
the X11R6.8 release, which incorporated XFree86 xterm.
|
|
All ECMA-48 CSI sequences recognized by Linux are also recognized by
|
|
<I>xterm</I>,
|
|
|
|
however <B><A HREF="/cgi-bin/man/man2html?1+xterm">xterm</A></B>(1) implements several ECMA-48 and DEC control sequences
|
|
not recognized by Linux.
|
|
<P>
|
|
|
|
The <B><A HREF="/cgi-bin/man/man2html?1+xterm">xterm</A></B>(1)
|
|
program recognizes all of the DEC Private Mode sequences listed
|
|
above, but none of the Linux private-mode sequences.
|
|
For discussion of <B><A HREF="/cgi-bin/man/man2html?1+xterm">xterm</A></B>(1)'s
|
|
own private-mode sequences, refer to the
|
|
<I>Xterm Control Sequences</I>
|
|
document by
|
|
Edward Moy,
|
|
Stephen Gildea,
|
|
and Thomas E. Dickey
|
|
available with the X distribution.
|
|
That document, though terse, is much longer than this manual page.
|
|
For a chronological overview,
|
|
<P>
|
|
|
|
<DL COMPACT><DT id="30"><DD>
|
|
|
|
|
|
</DL>
|
|
|
|
<P>
|
|
|
|
details changes to xterm.
|
|
<P>
|
|
|
|
The <I>vttest</I> program
|
|
<P>
|
|
|
|
<DL COMPACT><DT id="31"><DD>
|
|
|
|
|
|
</DL>
|
|
|
|
<P>
|
|
|
|
demonstrates many of these control sequences.
|
|
The <B><A HREF="/cgi-bin/man/man2html?1+xterm">xterm</A></B>(1) source distribution also contains sample
|
|
scripts which exercise other features.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
ESC 8 (DECRC) is not able to restore the character set changed with
|
|
ESC %.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>BUGS</H2>
|
|
|
|
In 2.0.23, CSI is broken, and NUL is not ignored inside
|
|
escape sequences.
|
|
<P>
|
|
|
|
Some older kernel versions (after 2.0) interpret 8-bit control
|
|
sequences.
|
|
These "C1 controls" use codes between 128 and 159 to replace
|
|
ESC [, ESC ] and similar two-byte control sequence initiators.
|
|
There are fragments of that in modern kernels (either overlooked or
|
|
broken by changes to support UTF-8),
|
|
but the implementation is incomplete and should be regarded
|
|
as unreliable.
|
|
<P>
|
|
|
|
Linux "private mode" sequences do not follow the rules in ECMA-48
|
|
for private mode control sequences.
|
|
In particular, those ending with ] do not use a standard terminating
|
|
character.
|
|
The OSC (set palette) sequence is a greater problem,
|
|
since <B><A HREF="/cgi-bin/man/man2html?1+xterm">xterm</A></B>(1) may interpret this as a control sequence
|
|
which requires a string terminator (ST).
|
|
Unlike the <B><A HREF="/cgi-bin/man/man2html?1+setterm">setterm</A></B>(1) sequences which will be ignored (since
|
|
they are invalid control sequences), the palette sequence will make
|
|
<B><A HREF="/cgi-bin/man/man2html?1+xterm">xterm</A></B>(1) appear to hang (though pressing the return-key
|
|
will fix that).
|
|
To accommodate applications which have been hardcoded to use Linux
|
|
control sequences,
|
|
set the <B><A HREF="/cgi-bin/man/man2html?1+xterm">xterm</A></B>(1) resource <B>brokenLinuxOSC</B> to true.
|
|
<P>
|
|
|
|
An older version of this document implied that Linux recognizes the
|
|
ECMA-48 control sequence for invisible text.
|
|
It is ignored.
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+ioctl_console">ioctl_console</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+charsets">charsets</A></B>(7)
|
|
|
|
<A NAME="lbAK"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="32"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="33"><A HREF="#lbAC">DESCRIPTION</A><DD>
|
|
<DL>
|
|
<DT id="34"><A HREF="#lbAD">Linux console controls</A><DD>
|
|
<DT id="35"><A HREF="#lbAE">Character sets</A><DD>
|
|
<DT id="36"><A HREF="#lbAF">Mouse tracking</A><DD>
|
|
<DT id="37"><A HREF="#lbAG">Comparisons with other terminals</A><DD>
|
|
</DL>
|
|
<DT id="38"><A HREF="#lbAH">NOTES</A><DD>
|
|
<DT id="39"><A HREF="#lbAI">BUGS</A><DD>
|
|
<DT id="40"><A HREF="#lbAJ">SEE ALSO</A><DD>
|
|
<DT id="41"><A HREF="#lbAK">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:06:01 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|