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