Debian Codegraph @

upstream/debian-trixie/man4/console_codes.4

raw
1 '\" t
2 .\" Copyright (c) 1996 Andries Brouwer <[email protected]>, Mon Oct 31 22:13:04 1996
3 .\"
4 .\" SPDX-License-Identifier: GPL-2.0-or-later
5 .\"
6 .\" This is combined from many sources.
7 .\" For Linux, the definitive source is of course console.c.
8 .\" About vt100-like escape sequences in general there are
9 .\" the ISO/IEC 6429 and ISO/IEC 2022 norms, the descriptions of
10 .\" an actual vt100, and the xterm docs (ctlseqs.ms).
11 .\" Substantial portions of this text are derived from a write-up
12 .\" by Eric S. Raymond <[email protected]>.
13 .\"
14 .\" Tiny correction, aeb, 961107.
15 .\"
16 .\" 2006-05-27, Several corrections - Thomas E. Dickey
17 .\" Modified Thu Dec 13 23:23:41 2001 by Martin Schulze <[email protected]>
18 .\"
19 .TH console_codes 4 2024-06-15 "Linux man-pages 6.9.1"
20 .SH NAME
21 console_codes \- Linux console escape and control sequences
22 .SH DESCRIPTION
23 The Linux console implements a large subset of
24 the VT102 and ECMA-48 / ISO/IEC\~6429 / ANSI X3.64 terminal controls,
25 plus certain private-mode sequences
26 for changing the color palette, character-set mapping, and so on.
27 In the tabular descriptions below, the second column gives ECMA-48 or DEC
28 mnemonics (the latter if prefixed with DEC) for the given function.
29 Sequences without a mnemonic are neither ECMA-48 nor VT102.
30 .P
31 After all the normal output processing has been done, and a
32 stream of characters arrives at the console driver for actual
33 printing, the first thing that happens is a translation from
34 the code used for processing to the code used for printing.
35 .P
36 If the console is in UTF-8 mode, then the incoming bytes are
37 first assembled into 16-bit Unicode codes.
38 Otherwise, each byte is transformed according to the current mapping table
39 (which translates it to a Unicode value).
40 See the \fBCharacter Sets\fP section below for discussion.
41 .P
42 In the normal case, the Unicode value is converted to a font index,
43 and this is stored in video memory, so that the corresponding glyph
44 (as found in video ROM) appears on the screen.
45 Note that the use of Unicode (and the design of the PC hardware)
46 allows us to use 512 different glyphs simultaneously.
47 .P
48 If the current Unicode value is a control character, or we are
49 currently processing an escape sequence, the value will treated
50 specially.
51 Instead of being turned into a font index and rendered as
52 a glyph, it may trigger cursor movement or other control functions.
53 See the \fBLinux Console Controls\fP section below for discussion.
54 .P
55 It is generally not good practice to hard-wire terminal controls into
56 programs.
57 Linux supports a
58 .BR terminfo (5)
59 database of terminal capabilities.
60 Rather than emitting console escape sequences by hand, you will almost
61 always want to use a terminfo-aware screen library or utility such as
62 .BR ncurses (3),
63 .BR tput (1),
64 or
65 .BR reset (1).
66 .SS Linux console controls
67 This section describes all the control characters and escape sequences
68 that invoke special functions (i.e., anything other than writing a
69 glyph at the current cursor location) on the Linux console.
70 .P
71 .B "Control characters"
72 .P
73 A character is a control character if (before transformation
74 according to the mapping table) it has one of the 14 codes
75 00 (NUL), 07 (BEL), 08 (BS), 09 (HT), 0a (LF), 0b (VT),
76 0c (FF), 0d (CR), 0e (SO), 0f (SI), 18 (CAN), 1a (SUB),
77 1b (ESC), 7f (DEL).
78 One can set a "display control characters" mode (see below),
79 and allow 07, 09, 0b, 18, 1a, 7f to be displayed as glyphs.
80 On the other hand, in UTF-8 mode all codes 00\[en]1f are regarded
81 as control characters, regardless of any "display control characters"
82 mode.
83 .P
84 If we have a control character, it is acted upon immediately
85 and then discarded (even in the middle of an escape sequence)
86 and the escape sequence continues with the next character.
87 (However, ESC starts a new escape sequence, possibly aborting a previous
88 unfinished one, and CAN and SUB abort any escape sequence.)
89 The recognized control characters are BEL, BS, HT, LF, VT, FF,
90 CR, SO, SI, CAN, SUB, ESC, DEL, CSI.
91 They do what one would expect:
92 .TP
93 BEL (0x07, \fB\[ha]G\fP)
94 beeps;
95 .TP
96 BS (0x08, \fB\[ha]H\fP)
97 backspaces one column
98 (but not past the beginning of the line);
99 .TP
100 HT (0x09, \fB\[ha]I\fP)
101 goes to the next tab stop or to the end of the line
102 if there is no earlier tab stop;
103 .TP
104 LF (0x0A, \fB\[ha]J\fP)
105 .TQ
106 VT (0x0B, \fB\[ha]K\fP)
107 .TQ
108 FF (0x0C, \fB\[ha]L\fP)
109 all give a linefeed,
110 and if LF/NL (new-line mode) is set also a carriage return;
111 .TP
112 CR (0x0D, \fB\[ha]M\fP)
113 gives a carriage return;
114 .TP
115 SO (0x0E, \fB\[ha]N\fP)
116 activates the G1 character set;
117 .TP
118 SI (0x0F, \fB\[ha]O\fP)
119 activates the G0 character set;
120 .TP
121 CAN (0x18, \fB\[ha]X\fP)
122 .TQ
123 SUB (0x1A, \fB\[ha]Z\fP)
124 abort escape sequences;
125 .TP
126 ESC (0x1B, \fB\[ha][\fP)
127 starts an escape sequence;
128 .TP
129 DEL (0x7F)
130 is ignored;
131 .TP
132 CSI (0x9B)
133 is equivalent to ESC [.
134 .P
135 .B "ESC- but not CSI-sequences"
136 .ad l
137 .TS
138 l l lx.
139 ESC c RIS Reset.
140 ESC D IND Linefeed.
141 ESC E NEL Newline.
142 ESC H HTS Set tab stop at current column.
143 ESC M RI Reverse linefeed.
144 ESC Z DECID T{
145 DEC private identification. The kernel
146 returns the string ESC [ ? 6 c, claiming
147 that it is a VT102.
148 T}
149 ESC 7 DECSC T{
150 Save current state (cursor coordinates,
151 attributes, character sets pointed at by G0, G1).
152 T}
153 ESC 8 DECRC T{
154 Restore state most recently saved by ESC 7.
155 T}
156 ESC % Start sequence selecting character set
157 ESC % @ \0\0\0Select default (ISO/IEC\~646 / ISO/IEC\~8859-1)
158 ESC % G \0\0\0Select UTF-8
159 ESC % 8 \0\0\0Select UTF-8 (obsolete)
160 ESC # 8 DECALN T{
161 DEC screen alignment test \- fill screen with E's.
162 T}
163 ESC ( T{
164 Start sequence defining G0 character set
165 (followed by one of B, 0, U, K, as below)
166 T}
167 ESC ( B T{
168 Select default (ISO/IEC\~8859-1 mapping).
169 T}
170 ESC ( 0 T{
171 Select VT100 graphics mapping.
172 T}
173 ESC ( U T{
174 Select null mapping \- straight to character ROM.
175 T}
176 ESC ( K T{
177 Select user mapping \- the map that is loaded by the utility \fBmapscrn\fP(8).
178 T}
179 ESC ) T{
180 Start sequence defining G1 (followed by one of B, 0, U, K, as above).
181 T}
182 ESC > DECPNM Set numeric keypad mode
183 ESC = DECPAM Set application keypad mode
184 ESC ] OSC T{
185 Operating System Command prefix.
186 T}
187 ESC ] R Reset palette.
188 ESC ] P T{
189 Set palette, with parameter given in 7 hexadecimal digits \fInrrggbb\fP after
190 the final P. Here \fIn\fP is the color (0\[en]15), and \fIrrggbb\fP indicates
191 the red/green/blue values (0\[en]255).
192 T}
193 .TE
194 .ad
195 .P
196 .B "ECMA-48 CSI sequences"
197 .P
198 CSI (or ESC [) is followed by a sequence of parameters,
199 at most NPAR (16), that are decimal numbers separated by
200 semicolons.
201 An empty or absent parameter is taken to be 0.
202 The sequence of parameters may be preceded by a single question mark.
203 .P
204 However, after CSI [ (or ESC [ [) a single character is read
205 and this entire sequence is ignored.
206 (The idea is to ignore an echoed function key.)
207 .P
208 The action of a CSI sequence is determined by its final character.
209 .ad l
210 .TS
211 l l lx.
212 @ ICH T{
213 Insert the indicated # of blank characters.
214 T}
215 A CUU T{
216 Move cursor up the indicated # of rows.
217 T}
218 B CUD T{
219 Move cursor down the indicated # of rows.
220 T}
221 C CUF T{
222 Move cursor right the indicated # of columns.
223 T}
224 D CUB T{
225 Move cursor left the indicated # of columns.
226 T}
227 E CNL T{
228 Move cursor down the indicated # of rows, to column 1.
229 T}
230 F CPL T{
231 Move cursor up the indicated # of rows, to column 1.
232 T}
233 G CHA T{
234 Move cursor to indicated column in current row.
235 T}
236 H CUP T{
237 Move cursor to the indicated row, column (origin at 1,1).
238 T}
239 J ED T{
240 Erase display (default: from cursor to end of display).
241 T}
242 T{
243 ESC [ 1 J: erase from start to cursor.
244 T}
245 T{
246 ESC [ 2 J: erase whole display.
247 T}
248 T{
249 ESC [ 3 J: erase whole display including scroll-back
250 buffer (since Linux 3.0).
251 T}
252 .\" ESC [ 3 J: commit f8df13e0a901fe55631fed66562369b4dba40f8b
253 K EL T{
254 Erase line (default: from cursor to end of line).
255 T}
256 T{
257 ESC [ 1 K: erase from start of line to cursor.
258 T}
259 T{
260 ESC [ 2 K: erase whole line.
261 T}
262 L IL T{
263 Insert the indicated # of blank lines.
264 T}
265 M DL T{
266 Delete the indicated # of lines.
267 T}
268 P DCH T{
269 Delete the indicated # of characters on current line.
270 T}
271 X ECH T{
272 Erase the indicated # of characters on current line.
273 T}
274 a HPR T{
275 Move cursor right the indicated # of columns.
276 T}
277 c DA T{
278 Answer ESC [ ? 6 c: "I am a VT102".
279 T}
280 d VPA T{
281 Move cursor to the indicated row, current column.
282 T}
283 e VPR T{
284 Move cursor down the indicated # of rows.
285 T}
286 f HVP T{
287 Move cursor to the indicated row, column.
288 T}
289 g TBC T{
290 Without parameter: clear tab stop at current position.
291 T}
292 T{
293 ESC [ 3 g: delete all tab stops.
294 T}
295 h SM Set Mode (see below).
296 l RM Reset Mode (see below).
297 m SGR Set attributes (see below).
298 n DSR Status report (see below).
299 q DECLL Set keyboard LEDs.
300 ESC [ 0 q: clear all LEDs
301 ESC [ 1 q: set Scroll Lock LED
302 ESC [ 2 q: set Num Lock LED
303 ESC [ 3 q: set Caps Lock LED
304 r DECSTBM T{
305 Set scrolling region; parameters are top and bottom row.
306 T}
307 s ? Save cursor location.
308 u ? Restore cursor location.
309 \` HPA T{
310 Move cursor to indicated column in current row.
311 T}
312 .TE
313 .ad
314 .P
315 .B ECMA-48 Select Graphic Rendition
316 .P
317 The ECMA-48 SGR sequence ESC [ \fIparameters\fP m sets display
318 attributes.
319 Several attributes can be set in the same sequence, separated by
320 semicolons.
321 An empty parameter (between semicolons or string initiator or
322 terminator) is interpreted as a zero.
323 .ad l
324 .TS
325 l lx.
326 param result
327 0 T{
328 reset all attributes to their defaults
329 T}
330 1 set bold
331 2 T{
332 set half-bright (simulated with color on a color display)
333 T}
334 3 set italic (since Linux 2.6.22; simulated with color on a color display)
335 4 T{
336 set underscore (simulated with color on a color display)
337 (the colors used to simulate dim or underline are set
338 using ESC ] ...)
339 T}
340 5 set blink
341 7 set reverse video
342 10 T{
343 reset selected mapping, display control flag,
344 and toggle meta flag (ECMA-48 says "primary font").
345 T}
346 11 T{
347 select null mapping, set display control flag,
348 reset toggle meta flag (ECMA-48 says "first alternate font").
349 T}
350 12 T{
351 select null mapping, set display control flag,
352 set toggle meta flag (ECMA-48 says "second alternate font").
353 The toggle meta flag
354 causes the high bit of a byte to be toggled
355 before the mapping table translation is done.
356 T}
357 21 T{
358 set underline; before Linux 4.17, this value
359 set normal intensity (as is done in many other terminals)
360 T}
361 22 set normal intensity
362 23 italic off (since Linux 2.6.22)
363 24 underline off
364 25 blink off
365 27 reverse video off
366 30 set black foreground
367 31 set red foreground
368 32 set green foreground
369 33 set brown foreground
370 34 set blue foreground
371 35 set magenta foreground
372 36 set cyan foreground
373 37 set white foreground
374 38 T{
375 256/24-bit foreground color follows, shoehorned into 16 basic colors
376 (before Linux 3.16: set underscore on, set default foreground color)
377 T}
378 39 T{
379 set default foreground color
380 (before Linux 3.16: set underscore off, set default foreground color)
381 T}
382 40 set black background
383 41 set red background
384 42 set green background
385 43 set brown background
386 44 set blue background
387 45 set magenta background
388 46 set cyan background
389 47 set white background
390 48 T{
391 256/24-bit background color follows, shoehorned into 8 basic colors
392 T}
393 49 set default background color
394 90..97 T{
395 set foreground to bright versions of 30..37
396 T}
397 100..107 T{
398 set background, same as 40..47 (bright not supported)
399 T}
400 .TE
401 .ad
402 .P
403 Commands 38 and 48 require further arguments:
404 .TS
405 l lx.
406 ;5;x T{
407 256 color: values 0..15 are IBGR (black, red, green, ... white),
408 16..231 a 6x6x6 color cube, 232..255 a grayscale ramp
409 T}
410 ;2;r;g;b T{
411 24-bit color, r/g/b components are in the range 0..255
412 T}
413 .TE
414 .P
415 .B ECMA-48 Mode Switches
416 .TP
417 ESC [ 3 h
418 DECCRM (default off): Display control chars.
419 .TP
420 ESC [ 4 h
421 DECIM (default off): Set insert mode.
422 .TP
423 ESC [ 20 h
424 LF/NL (default off): Automatically follow echo of LF, VT, or FF with CR.
425 .\"
426 .P
427 .B ECMA-48 Status Report Commands
428 .\"
429 .TP
430 ESC [ 5 n
431 Device status report (DSR): Answer is ESC [ 0 n (Terminal OK).
432 .TP
433 ESC [ 6 n
434 Cursor position report (CPR): Answer is ESC [ \fIy\fP ; \fIx\fP R,
435 where \fIx,y\fP is the cursor location.
436 .\"
437 .P
438 .B DEC Private Mode (DECSET/DECRST) sequences
439 .P
440 .\"
441 These are not described in ECMA-48.
442 We list the Set Mode sequences;
443 the Reset Mode sequences are obtained by replacing the final \[aq]h\[aq]
444 by \[aq]l\[aq].
445 .TP
446 ESC [ ? 1 h
447 DECCKM (default off): When set, the cursor keys send an ESC O prefix,
448 rather than ESC [.
449 .TP
450 ESC [ ? 3 h
451 DECCOLM (default off = 80 columns): 80/132 col mode switch.
452 The driver sources note that this alone does not suffice; some user-mode
453 utility such as
454 .BR resizecons (8)
455 has to change the hardware registers on the console video card.
456 .TP
457 ESC [ ? 5 h
458 DECSCNM (default off): Set reverse-video mode.
459 .TP
460 ESC [ ? 6 h
461 DECOM (default off): When set, cursor addressing is relative to
462 the upper left corner of the scrolling region.
463 .TP
464 ESC [ ? 7 h
465 DECAWM (default on): Set autowrap on.
466 In this mode, a graphic
467 character emitted after column 80 (or column 132 of DECCOLM is on)
468 forces a wrap to the beginning of the following line first.
469 .TP
470 ESC [ ? 8 h
471 DECARM (default on): Set keyboard autorepeat on.
472 .TP
473 ESC [ ? 9 h
474 X10 Mouse Reporting (default off): Set reporting mode to 1 (or reset to
475 0)\[em]see below.
476 .TP
477 ESC [ ? 25 h
478 DECTECM (default on): Make cursor visible.
479 .TP
480 ESC [ ? 1000 h
481 X11 Mouse Reporting (default off): Set reporting mode to 2 (or reset
482 to 0)\[em]see below.
483 .\"
484 .P
485 .B Linux Console Private CSI Sequences
486 .P
487 .\"
488 The following sequences are neither ECMA-48 nor native VT102.
489 They are native to the Linux console driver.
490 Colors are in SGR parameters:
491 0 = black, 1 = red, 2 = green, 3 = brown, 4 = blue, 5 = magenta, 6 =
492 cyan, 7 = white; 8\[en]15 = bright versions of 0\[en]7.
493 .TS
494 l lx.
495 ESC [ 1 ; \fIn\fP ] T{
496 Set color \fIn\fP as the underline color.
497 T}
498 ESC [ 2 ; \fIn\fP ] T{
499 Set color \fIn\fP as the dim color.
500 T}
501 ESC [ 8 ] T{
502 Make the current color pair the default attributes.
503 T}
504 ESC [ 9 ; \fIn\fP ] T{
505 Set screen blank timeout to \fIn\fP minutes.
506 T}
507 ESC [ 10 ; \fIn\fP ] T{
508 Set bell frequency in Hz.
509 T}
510 ESC [ 11 ; \fIn\fP ] T{
511 Set bell duration in msec.
512 T}
513 ESC [ 12 ; \fIn\fP ] T{
514 Bring specified console to the front.
515 T}
516 ESC [ 13 ] T{
517 Unblank the screen.
518 T}
519 ESC [ 14 ; \fIn\fP ] T{
520 Set the VESA powerdown interval in minutes.
521 T}
522 ESC [ 15 ] T{
523 Bring the previous console to the front
524 (since Linux 2.6.0).
525 T}
526 ESC [ 16 ; \fIn\fP ] T{
527 Set the cursor blink interval in milliseconds
528 (since Linux 4.2).
529 T}
530 .\" commit bd63364caa8df38bad2b25b11b2a1b849475cce5
531 .TE
532 .SS Character sets
533 The kernel knows about 4 translations of bytes into console-screen
534 symbols.
535 The four tables are: a) Latin1 \-> PC,
536 b) VT100 graphics \-> PC, c) PC \-> PC, d) user-defined.
537 .P
538 There are two character sets, called G0 and G1, and one of them
539 is the current character set.
540 (Initially G0.)
541 Typing \fB\[ha]N\fP causes G1 to become current,
542 \fB\[ha]O\fP causes G0 to become current.
543 .P
544 These variables G0 and G1 point at a translation table, and can be
545 changed by the user.
546 Initially they point at tables a) and b), respectively.
547 The sequences ESC ( B and ESC ( 0 and ESC ( U and ESC ( K cause G0 to
548 point at translation table a), b), c), and d), respectively.
549 The sequences ESC ) B and ESC ) 0 and ESC ) U and ESC ) K cause G1 to
550 point at translation table a), b), c), and d), respectively.
551 .P
552 The sequence ESC c causes a terminal reset, which is what you want if the
553 screen is all garbled.
554 The oft-advised "echo \[ha]V\[ha]O" will make only G0 current,
555 but there is no guarantee that G0 points at table a).
556 In some distributions there is a program
557 .BR reset (1)
558 that just does "echo \[ha][c".
559 If your terminfo entry for the console is correct
560 (and has an entry rs1=\[rs]Ec), then "tput reset" will also work.
561 .P
562 The user-defined mapping table can be set using
563 .BR mapscrn (8).
564 The result of the mapping is that if a symbol c is printed, the symbol
565 s = map[c] is sent to the video memory.
566 The bitmap that corresponds to
567 s is found in the character ROM, and can be changed using
568 .BR setfont (8).
569 .SS Mouse tracking
570 The mouse tracking facility is intended to return
571 .BR xterm (1)-compatible
572 mouse status reports.
573 Because the console driver has no way to know
574 the device or type of the mouse, these reports are returned in the
575 console input stream only when the virtual terminal driver receives
576 a mouse update ioctl.
577 These ioctls must be generated by a mouse-aware
578 user-mode application such as the
579 .BR gpm (8)
580 daemon.
581 .P
582 The mouse tracking escape sequences generated by
583 \fBxterm\fP(1) encode numeric parameters in a single character as
584 \fIvalue\fP+040.
585 For example, \[aq]!\[aq] is 1.
586 The screen coordinate system is 1-based.
587 .P
588 The X10 compatibility mode sends an escape sequence on button press
589 encoding the location and the mouse button pressed.
590 It is enabled by sending ESC [ ? 9 h and disabled with ESC [ ? 9 l.
591 On button press, \fBxterm\fP(1) sends
592 ESC [ M \fIbxy\fP (6 characters).
593 Here \fIb\fP is button\-1,
594 and \fIx\fP and \fIy\fP are the x and y coordinates of the mouse
595 when the button was pressed.
596 This is the same code the kernel also produces.
597 .P
598 Normal tracking mode (not implemented in Linux 2.0.24) sends an escape
599 sequence on both button press and release.
600 Modifier information is also sent.
601 It is enabled by sending ESC [ ? 1000 h and disabled with
602 ESC [ ? 1000 l.
603 On button press or release, \fBxterm\fP(1) sends ESC [ M
604 \fIbxy\fP.
605 The low two bits of \fIb\fP encode button information:
606 0=MB1 pressed, 1=MB2 pressed, 2=MB3 pressed, 3=release.
607 The upper bits encode what modifiers were down when the button was
608 pressed and are added together: 4=Shift, 8=Meta, 16=Control.
609 Again \fIx\fP and
610 \fIy\fP are the x and y coordinates of the mouse event.
611 The upper left corner is (1,1).
612 .SS Comparisons with other terminals
613 Many different terminal types are described, like the Linux console,
614 as being "VT100-compatible".
615 Here we discuss differences between the
616 Linux console and the two most important others, the DEC VT102 and
617 .BR xterm (1).
618 .\"
619 .P
620 .B Control-character handling
621 .P
622 The VT102 also recognized the following control characters:
623 .TP
624 NUL (0x00)
625 was ignored;
626 .TP
627 ENQ (0x05)
628 triggered an answerback message;
629 .TP
630 DC1 (0x11, \fB\[ha]Q\fP, XON)
631 resumed transmission;
632 .TP
633 DC3 (0x13, \fB\[ha]S\fP, XOFF)
634 caused VT100 to ignore (and stop transmitting)
635 all codes except XOFF and XON.
636 .P
637 VT100-like DC1/DC3 processing may be enabled by the terminal driver.
638 .P
639 The
640 .BR xterm (1)
641 program (in VT100 mode) recognizes the control characters
642 BEL, BS, HT, LF, VT, FF, CR, SO, SI, ESC.
643 .\"
644 .P
645 .B Escape sequences
646 .P
647 VT100 console sequences not implemented on the Linux console:
648 .TS
649 l l l.
650 ESC N SS2 T{
651 Single shift 2. (Select G2 character set for the next character only.)
652 T}
653 ESC O SS3 T{
654 Single shift 3. (Select G3 character set for the next character only.)
655 T}
656 ESC P DCS T{
657 Device control string (ended by ESC \[rs])
658 T}
659 ESC X SOS Start of string.
660 ESC \[ha] PM Privacy message (ended by ESC \[rs])
661 ESC \[rs] ST String terminator
662 ESC * ... Designate G2 character set
663 ESC + ... Designate G3 character set
664 .TE
665 .P
666 The program
667 .BR xterm (1)
668 (in VT100 mode) recognizes ESC c, ESC # 8, ESC >, ESC =,
669 ESC D, ESC E, ESC H, ESC M, ESC N, ESC O, ESC P ... ESC \[rs],
670 ESC Z (it answers ESC [ ? 1 ; 2 c, "I am a VT100 with
671 advanced video option")
672 and ESC \[ha] ... ESC \[rs] with the same meanings as indicated above.
673 It accepts ESC (, ESC ), ESC *, ESC + followed by 0, A, B for
674 the DEC special character and line drawing set, UK, and US-ASCII,
675 respectively.
676 .P
677 The user can configure \fBxterm\fP(1) to respond to VT220-specific
678 control sequences, and it will identify itself as a VT52, VT100, and
679 up depending on the way it is configured and initialized.
680 .P
681 It accepts ESC ] (OSC) for the setting of certain resources.
682 In addition to the ECMA-48 string terminator (ST),
683 \fBxterm\fP(1) accepts a BEL to terminate an OSC string.
684 These are a few of the OSC control sequences recognized by \fBxterm\fP(1):
685 .TS
686 l l.
687 ESC ] 0 ; \fItxt\fP ST T{
688 Set icon name and window title to \fItxt\fP.
689 T}
690 ESC ] 1 ; \fItxt\fP ST Set icon name to \fItxt\fP.
691 ESC ] 2 ; \fItxt\fP ST Set window title to \fItxt\fP.
692 ESC ] 4 ; \fInum\fP; \fItxt\fP ST Set ANSI color \fInum\fP to \fItxt\fP.
693 ESC ] 10 ; \fItxt\fP ST Set dynamic text color to \fItxt\fP.
694 ESC ] 4 6 ; \fIname\fP ST T{
695 Change log file to \fIname\fP (normally disabled by a compile-time option).
696 T}
697 ESC ] 5 0 ; \fIfn\fP ST Set font to \fIfn\fP.
698 .TE
699 .P
700 It recognizes the following with slightly modified meaning
701 (saving more state, behaving closer to VT100/VT220):
702 .TS
703 l l l.
704 ESC 7 DECSC Save cursor
705 ESC 8 DECRC Restore cursor
706 .TE
707 .P
708 It also recognizes
709 .TS
710 l l lx.
711 ESC F T{
712 Cursor to lower left corner of screen (if enabled
713 by \fBxterm\fP(1)'s \fBhpLowerleftBugCompat\fP resource).
714 T}
715 ESC l Memory lock (per HP terminals).
716 Locks memory above the cursor.
717 ESC m Memory unlock (per HP terminals).
718 ESC n LS2 Invoke the G2 character set.
719 ESC o LS3 Invoke the G3 character set.
720 ESC | LS3R Invoke the G3 character set as GR.
721 Has no visible effect in xterm.
722 ESC } LS2R Invoke the G2 character set as GR.
723 Has no visible effect in xterm.
724 ESC \[ti] LS1R Invoke the G1 character set as GR.
725 .TE
726 .P
727 It also recognizes ESC % and provides a more complete UTF-8
728 implementation than Linux console.
729 .\"
730 .P
731 .B CSI Sequences
732 .P
733 Old versions of \fBxterm\fP(1), for example, from X11R5,
734 interpret the blink SGR as a bold SGR.
735 Later versions which implemented ANSI colors, for example,
736 XFree86 3.1.2A in 1995, improved this by allowing
737 the blink attribute to be displayed as a color.
738 Modern versions of xterm implement blink SGR as blinking text
739 and still allow colored text as an alternate rendering of SGRs.
740 Stock X11R6 versions did not recognize the color-setting SGRs until
741 the X11R6.8 release, which incorporated XFree86 xterm.
742 All ECMA-48 CSI sequences recognized by Linux are also recognized by
743 .IR xterm ,
744 however \fBxterm\fP(1) implements several ECMA-48 and DEC control sequences
745 not recognized by Linux.
746 .P
747 The \fBxterm\fP(1)
748 program recognizes all of the DEC Private Mode sequences listed
749 above, but none of the Linux private-mode sequences.
750 For discussion of \fBxterm\fP(1)'s
751 own private-mode sequences, refer to the
752 \fIXterm Control Sequences\fP
753 document by
754 Edward Moy,
755 Stephen Gildea,
756 and Thomas E.\& Dickey
757 available with the X distribution.
758 That document, though terse, is much longer than this manual page.
759 For a chronological overview,
760 .P
761 .RS
762 .UR http://invisible\-island.net\:/xterm\:/xterm.log.html
763 .UE
764 .RE
765 .P
766 details changes to xterm.
767 .P
768 The \fIvttest\fP program
769 .P
770 .RS
771 .UR http://invisible\-island.net\:/vttest/
772 .UE
773 .RE
774 .P
775 demonstrates many of these control sequences.
776 The \fBxterm\fP(1) source distribution also contains sample
777 scripts which exercise other features.
778 .SH NOTES
779 ESC 8 (DECRC) is not able to restore the character set changed with
780 ESC %.
781 .SH BUGS
782 In Linux 2.0.23, CSI is broken, and NUL is not ignored inside
783 escape sequences.
784 .P
785 Some older kernel versions (after Linux 2.0) interpret 8-bit control
786 sequences.
787 These "C1 controls" use codes between 128 and 159 to replace
788 ESC [, ESC ] and similar two-byte control sequence initiators.
789 There are fragments of that in modern kernels (either overlooked or
790 broken by changes to support UTF-8),
791 but the implementation is incomplete and should be regarded
792 as unreliable.
793 .P
794 Linux "private mode" sequences do not follow the rules in ECMA-48
795 for private mode control sequences.
796 In particular, those ending with ] do not use a standard terminating
797 character.
798 The OSC (set palette) sequence is a greater problem,
799 since \fBxterm\fP(1) may interpret this as a control sequence
800 which requires a string terminator (ST).
801 Unlike the \fBsetterm\fP(1) sequences which will be ignored (since
802 they are invalid control sequences), the palette sequence will make
803 \fBxterm\fP(1) appear to hang (though pressing the return-key
804 will fix that).
805 To accommodate applications which have been hardcoded to use Linux
806 control sequences,
807 set the \fBxterm\fP(1) resource \fBbrokenLinuxOSC\fP to true.
808 .P
809 An older version of this document implied that Linux recognizes the
810 ECMA-48 control sequence for invisible text.
811 It is ignored.
812 .SH SEE ALSO
813 .BR ioctl_console (2),
814 .BR charsets (7)