On Mon, May 29, 2006 at 04:30:19AM +0200, Michael Kerrisk wrote:
> 
> If you have some fixes to suggest, send me a patch.  If
> there are several distinct areas to fix, send me a separate
> patch for each are, please.

attached

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
--- testing-console_codes.4     2005-11-18 01:37:20.000000000 -0500
+++ fixed-testing-console_codes.4       2006-05-29 09:48:43.000000000 -0400
@@ -15,9 +15,12 @@
 .\" by Eric S. Raymond <[EMAIL PROTECTED]>.
 .\"
 .\" Tiny correction, aeb, 961107.
+.\"
 .\" Modified Thu Dec 13 23:23:41 2001 by Martin Schulze <[EMAIL PROTECTED]>
 .\"
-.TH CONSOLE_CODES 4 1996-10-31 "Linux" "Linux Programmer's Manual"
+.\" Several corrections - Thomas E. Dickey 2006/5/29.
+.\"
+.TH CONSOLE_CODES 4 2006-05-29 "Linux" "Linux Programmer's Manual"
 .SH NAME
 console_codes \- Linux console escape and control sequences
 .SH DESCRIPTION
@@ -36,8 +39,8 @@
 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 CHARACTER SETS
-section below for discussion.
+(which translates it to a Unicode value).
+See the \fBCHARACTER SETS\fP section below for discussion.
 .LP
 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
@@ -49,7 +52,7 @@
 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 LINUX CONSOLE CONTROLS section below for discussion.
+See the \fBLINUX CONSOLE CONTROLS\fP section below for discussion.
 .LP
 It is generally not good practice to hard-wire terminal controls into
 programs.  Linux supports a 
@@ -76,7 +79,7 @@
 On the other hand, in UTF-8 mode all codes 00-1f are regarded
 as control characters, regardless of any `display control characters'
 mode.
-
+.PP
 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.
@@ -117,11 +120,15 @@
 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 pointed at by G0, G1).
+ESC Z  DECID   T{
+DEC private identification. The kernel
+returns the string  ESC [ ? 6 c, claiming
+that it is a VT102.
+T}
+ESC 7  DECSC   T{
+Save current state (cursor coordinates,
+attributes, character sets pointed at by G0, G1).
+T}
 ESC 8  DECRC   Restore state most recently saved by ESC 7.
 ESC [  CSI     Control sequence introducer
 ESC %          Start sequence selecting character set
@@ -131,7 +138,7 @@
 ESC # 8        DECALN  DEC screen alignment test \- fill screen with E's.
 ESC (          Start sequence defining G0 character set
 ESC ( B                \0\0\0Select default (ISO 8859-1 mapping)
-ESC ( 0                \0\0\0Select vt100 graphics mapping
+ESC ( 0                \0\0\0Select VT100 graphics mapping
 ESC ( U                \0\0\0Select null mapping \- straight to character ROM
 ESC ( K                \0\0\0Select user mapping \- the map that is loaded by
                \0\0\0the utility \fBmapscrn\fP(8).
@@ -139,25 +146,27 @@
                (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 \fInrrggbb\fP: set palette, with parameter
-               given in 7 hexadecimal digits after the final P :-(.
-               Here \fIn\fP is the color (0-15), and \fIrrggbb\fP indicates
-               the red/green/blue values (0-255). 
-               ESC ] R: reset palette
+ESC ]  OSC     T{
+(Should be: Operating system command)
+ESC ] P \fInrrggbb\fP: set palette, with parameter
+given in 7 hexadecimal digits after the final P :-(.
+Here \fIn\fP is the color (0-15), and \fIrrggbb\fP indicates
+the red/green/blue values (0-255). 
+ESC ] R: reset palette
+T}
 .TE
 .SS "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.
-
+.PP
 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.)
-
+.PP
 The action of a CSI sequence is determined by its final character.
-
+.PP
 .TS
 l l l.
 @      ICH     Insert the indicated # of blank characters.
@@ -201,29 +210,40 @@
 `      HPA     Move cursor to indicated column in current row.
 .TE
 .SS ECMA-48 Set Graphics Rendition
-The ECMA-48 SGR sequence ESC [ <parameters> m sets display attributes.
-Several attributes can be set in the same sequence.
+The ECMA-48 SGR sequence ESC [ \fIparameters\fP 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.
 .LP
 .TS
 l l.
-par    result
+param  result
 0      reset all attributes to their defaults
 1      set bold
 2      set half-bright (simulated with color on a color display)
-4      set underscore (simulated with color on a color display)
-       (the colors used to simulate dim or underline are set
-       using ESC ] ...)
+4      T{
+set underscore (simulated with color on a color display)
+(the colors used to simulate dim or underline are set
+using ESC ] ...)
+T}
 5      set blink
 7      set reverse video
-10     reset selected mapping, display control flag,
-       and toggle meta flag.
-11     select null mapping, set display control flag,
-       reset toggle meta flag.
-12     select null mapping, set display control flag,
-       set toggle meta flag. (The toggle meta flag
-       causes the high bit of a byte to be toggled
-       before the mapping table translation is done.)
-21     set normal intensity (this is not compatible with ECMA-48)
+10     T{
+reset selected mapping, display control flag,
+and toggle meta flag (ECMA-48 says "primary font").
+T}
+11     T{
+select null mapping, set display control flag,
+reset toggle meta flag (ECMA-48 says "first alternate font").
+T}
+12     T{
+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.
+T}
+21     set normal intensity (ECMA-48 says "doubly underlined")
 22     set normal intensity
 24     underline off
 25     blink off
@@ -306,7 +326,7 @@
 0) \(em see below.
 .TP
 ESC [ ? 25 h
-DECCM (default on): Make cursor visible.
+DECTECM (default on): Make cursor visible.
 .TP
 ESC [ ? 1000 h
 X11 Mouse Reporting (default off): Set reporting mode to 2 (or reset
@@ -318,7 +338,6 @@
 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.
-
 .TS
 l l.
 ESC [ 1 ; \fIn\fP ]    Set color \fIn\fP as the underline color
@@ -335,18 +354,18 @@
 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.
-
+.PP
 There are two character sets, called G0 and G1, and one of them
 is the current character set. (Initially G0.)
 Typing ^N causes G1 to become current, ^O causes G0 to become current.
-
+.PP
 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.
-
+.PP
 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 only make G0 current,
 but there is no guarantee that G0 points at table a).
@@ -355,7 +374,7 @@
 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.
-
+.PP
 The user-defined mapping table can be set using
 .BR mapscrn (8).
 The result of the mapping is that if a symbol c is printed, the symbol
@@ -369,12 +388,12 @@
 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 \fBgpm(8)\fR daemon.
-
-Parameters for all mouse tracking escape sequences generated by
+.PP
+The mouse tracking escape sequences generated by
 \fIxterm\fP encode numeric parameters in a single character as
 \fIvalue\fP+040.  For example, `!' is 1.  The screen
 coordinate system is 1-based.
-
+.PP
 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.
@@ -383,7 +402,7 @@
 and \fIx\fP and \fIy\fP are the x and y coordinates of the mouse
 when the button was pressed.
 This is the same code the kernel also produces.
-
+.PP
 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
@@ -396,12 +415,13 @@
 left corner is (1,1).
 .SH "COMPARISONS WITH OTHER TERMINALS"
 Many different terminal types are described, like the Linux console,
-as being `VT100-compatible'.  Here we discuss differences vbetween the
-Linux console an the two most important others, the DEC VT102 and
+as being `VT100-compatible'.
+Here we discuss differences between the
+Linux console and the two most important others, the DEC VT102 and
 .BR xterm (1).
 .\"
 .SS Control-character handling
-The vt102 also recognized the following control characters:
+The VT102 also recognized the following control characters:
 .HP
 NUL (0x00) was ignored;
 .HP
@@ -409,19 +429,18 @@
 .HP
 DC1 (0x11, ^Q, XON) resumed transmission;
 .HP
-DC3 (0x13, ^S, XOFF) caused vt100 to ignore (and stop transmitting)
+DC3 (0x13, ^S, XOFF) caused VT100 to ignore (and stop transmitting)
 all codes except XOFF and XON.
 .LP
 VT100-like DC1/DC3 processing may be enabled by the tty driver.
 .LP
 The 
 .I xterm
-program (in vt100 mode) recognizes the control characters 
+program (in VT100 mode) recognizes the control characters 
 BEL, BS, HT, LF, VT, FF, CR, SO, SI, ESC.
 .\"
 .SS Escape sequences
 VT100 console sequences not implemented on the Linux console:
-.LP
 .TS
 l l l.
 ESC N  SS2     Single shift 2. (Select G2 character set for the next
@@ -435,81 +454,138 @@
 ESC * ...              Designate G2 character set
 ESC + ...              Designate G3 character set
 .TE
-
+.PP
 The program
 .I xterm
-(in vt100 mode) recognizes ESC c, ESC # 8, ESC >, ESC =,
+(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')
+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 USASCII,
+the DEC special character and line drawing set, UK, and US-ASCII,
 respectively.
-It accepts ESC ] for the setting of certain resources:
-.LP
+.PP
+The user can configure \fIxterm\fP 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.
+.PP
+It accepts ESC ] (OSC) for the setting of certain resources.
+In addition to the ECMA-48 string terminator (ST),
+\fIxterm\fP accepts a BEL to terminate an OSC string.
+These are a few of the OSC control sequences recognized by \fIxterm\fP:
 .TS
 l l.
-ESC ] 0 ; txt BEL      Set icon name and window title to txt.
-ESC ] 1 ; txt BEL      Set icon name to txt.
-ESC ] 2 ; txt BEL      Set window title to txt.
-ESC ] 4 6 ; name BEL   Change log file to name (normally disabled
+ESC ] 0 ; \fItxt\fP ST Set icon name and window title to \fItxt\fP.
+ESC ] 1 ; \fItxt\fP ST Set icon name to \fItxt\fP.
+ESC ] 2 ; \fItxt\fP ST Set window title to \fItxt\fP.
+ESC ] 4 ; \fInum\fP; \fItxt\fP ST      Set ANSI color \fInum\fP to \fItxt\fP.
+ESC ] 10 ; \fItxt\fP ST        Set dynamic text color to \fItxt\fP.
+ESC ] 4 6 ; \fIname\fP ST      Change log file to \fIname\fP (normally disabled
        by a compile-time option)
-ESC ] 5 0 ; fn BEL     Set font to fn.
+ESC ] 5 0 ; \fIfn\fP ST        Set font to \fIfn\fP.
 .TE
-
-It recognizes the following with slightly modified meaning:
-.LP
+.PP
+It recognizes the following with slightly modified meaning
+(saving more state, behaving closer to VT100/VT220):
 .TS
 l l l.
 ESC 7  DECSC   Save cursor
 ESC 8  DECRC   Restore cursor
 .TE
-
+.PP
 It also recognizes
-.LP
 .TS
 l l l.
 ESC F          Cursor to lower left corner of screen (if enabled by
-               the hpLowerleftBugCompat resource)
+               \fIxterm\fP's \fBhpLowerleftBugCompat\fP resource)
 ESC l          Memory lock (per HP terminals).
                Locks memory above the cursor.
 ESC m          Memory unlock (per HP terminals).
 ESC n  LS2     Invoke the G2 character set.
 ESC o  LS3     Invoke the G3 character set.
 ESC |  LS3R    Invoke the G3 character set as GR.
-               Has no visible effect in xterm.
 ESC }  LS2R    Invoke the G2 character set as GR.
-               Has no visible effect in xterm.
 ESC ~  LS1R    Invoke the G1 character set as GR.
-               Has no visible effect in xterm.
 .TE
-
-It does not recognize ESC % ...
+.PP
+It also recognizes ESC % and provides a more complete UTF-8 implementation
+than Linux console.
 .\"
 .SS CSI Sequences
-The 
-.I xterm
-program (as of XFree86 3.1.2G) does not recognize the blink or invisible-mode 
-SGRs. Stock X11R6 versions do not recognize the color-setting SGRs.
-All other ECMA-48 CSI sequences recognized by Linux are also recognized by
+Old versions of \fIxterm\fP, e.g., from X11R5,
+interpret the blink SGR as a bold SGR.
+Later versions which implemented ANSI colors, e.g., 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
 .IR xterm ,
-and vice-versa.
-
-The 
-.I xterm
-program will recognize all of the DEC Private Mode sequences listed
-above, but none of the Linux private-mode sequences.  For discussion
-of 
-.IR xterm 's
+however \fIxterm\fP implements several ECMA-48 and DEC control sequences
+not recognized by Linux.
+.PP
+The \fIxterm\fP
+program recognizes all of the DEC Private Mode sequences listed
+above, but none of the Linux private-mode sequences.
+For discussion of \fIxterm\fP's
 own private-mode sequences, refer to the
-.I Xterm Control Sequences
-document by Edward Moy and Stephen Gildea, available with the X 
-distribution.
+\fIXterm Control Sequences\fP
+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,
+.PP
+.RS
+http://invisible-island.net/xterm/xterm.log.html
+.RE
+.PP
+details changes to xterm.
+.PP
+The \fIvttest\fP program 
+.PP
+.RS
+http://invisible-island.net/vttest/
+.RE
+.PP
+demonstrates many of these control sequences.
+The \fIxterm\fP source distribution also contains sample
+scripts which exercise other features.
 .SH NOTE
 ESC 8 (DECRC) is not able to restore the character set changed with
 ESC %.
 .SH BUGS
 In 2.0.23, CSI is broken, and NUL is not ignored inside escape sequences.
+.PP
+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.
+.PP
+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 \fIxterm\fP may interpret this as a control sequence
+which requires a string terminator (ST).
+Unlike the \fIsetterm\fP sequences which will be ignored (since
+they are invalid control sequences), the palette sequence will make
+\fIxterm\fP 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 \fIxterm\fP resource \fBbrokenLinuxOSC\fP to true.
+.PP
+An older version of this document implied that Linux recognizes the
+ECMA-48 control sequence for invisible text.
+It is ignored.
 .SH "SEE ALSO"
 .BR console (4),
 .BR console_ioctl (4),

Attachment: pgpx3jLg8YVRH.pgp
Description: PGP signature

Reply via email to