ctlseqs.txt revision 04b94745
1
2
3
4
5
6
7
8
9
10                        XTerm Control Sequences
11
12
13                               Edward Moy
14                   University of California, Berkeley
15
16                               Revised by
17
18                             Stephen Gildea
19                          X Consortium (1994)
20
21                             Thomas Dickey
22                      XFree86 Project (1996-2006)
23                    invisible-island.net (2006-2024)
24               updated for XTerm Patch #392 (2024/05/22)
25
26
27
28
29Definitions
30
31Many controls use parameters, shown in italics.  If a control uses a
32single parameter, only one parameter name is listed.  Some parameters
33(along with separating ;  characters) may be optional.  Other characters
34in the control are required.
35
36C    A single (required) character.
37
38Ps   A single (usually optional) numeric parameter, composed of one or
39     more digits.
40
41Pm   Any number of single numeric parameters, separated by ;
42     character(s).  Individual values for the parameters are listed with
43     Ps .
44
45Pt   A text parameter composed of printable characters.
46
47
48Control Bytes, Characters, and Sequences
49
50ECMA-48 (aka "ISO 6429") documents C1 (8-bit) and C0 (7-bit) codes.
51Those are respectively codes 128 to 159 and 0 to 31.  ECMA-48 avoids
52referring to these codes as characters, because that term is associated
53with graphic characters.  Instead, it uses "bytes" and "codes", with
54occasional lapses to "characters" where the meaning cannot be mistaken.
55
56Controls (including the escape code 27) are processed once:
57
58o   This means that a C1 control can be mistaken for badly-formed UTF-8
59    when the terminal runs in UTF-8 mode because C1 controls are valid
60    continuation bytes of a UTF-8 encoded (multibyte) value.
61
62o   It is not possible to use a C1 control obtained from decoding the
63    UTF-8 text, because that would require reprocessing the data.
64    Consequently there is no ambiguity in the way this document uses the
65    term "character" to refer to bytes in a control sequence.
66
67The order of processing is a necessary consequence of the way ECMA-48 is
68designed:
69
70o   Each byte sent to the terminal can be unambiguously determined to
71    fall into one of a few categories (C0, C1 and graphic characters).
72
73o   ECMA-48 is modal; once it starts processing a control sequence, the
74    terminal continues until the sequence is complete, or some byte is
75    found which is not allowed in the sequence.
76
77o   Intermediate, parameter and final bytes may use the same codes as
78    graphic characters, but they are processed as part of a control
79    sequence and are not actually graphic characters.
80
81o   Eight-bit controls can have intermediate, etc., bytes in the range
82    160 to 255.  Those can be treated as their counterparts in the range
83    32 to 127.
84
85o   Single-byte controls can be handled separately from multi-byte
86    control sequences because ECMA-48's rules are unambiguous.
87
88    As a special case, ECMA-48 (section 9) mentions that the control
89    functions shift-in and shift-out are allowed to occur within a 7-bit
90    multibyte control sequence because those cannot alter the meaning of
91    the control sequence.
92
93o   Some controls (such as OSC ) introduce a string mode, which is ended
94    on a ST  (string terminator).
95
96    ECMA-48 describes only correct behavior, telling what types of
97    characters are expected at each stage of the control sequences.  It
98    says that the action taken in error recovery is implementation-
99    dependent.  XTerm decodes control sequences using a state machine.
100    It handles errors in decoding i.e., unexpected characters, by
101    resetting to the initial (ground) state.  That is different from the
102    treatment of unimplemented (but correctly formatted) features.
103
104    If an application does not send the string terminator, that is also
105    an error from the standpoint of a user.  To accommodate users of
106    those applications, xterm has resource settings which allow
107    workarounds:
108
109    o   The Linux console's palette sequences do not use a string
110        terminator.  The brokenLinuxOSC resource setting tells xterm to
111        ignore those particular sequences.
112
113    o   The terminal should accept single-byte controls within the
114        string.  But some applications omit a string terminator, like
115        the Linux console.  The brokenStringTerm resource setting tells
116        xterm to exit string mode if it decodes a common control
117        character such as carriage return before the string terminator.
118
119
120C1 (8-Bit) Control Characters
121
122The xterm program recognizes both 8-bit and 7-bit control characters.
123It generates 7-bit controls (by default) or 8-bit if S8C1T is enabled.
124The following pairs of 7-bit and 8-bit control characters are
125equivalent:
126
127ESC D
128     Index (IND  is 0x84).
129
130ESC E
131     Next Line (NEL  is 0x85).
132
133ESC H
134     Tab Set (HTS  is 0x88).
135
136ESC M
137     Reverse Index (RI  is 0x8d).
138
139ESC N
140     Single Shift Select of G2 Character Set (SS2  is 0x8e), VT220.
141     This affects next character only.
142
143ESC O
144     Single Shift Select of G3 Character Set (SS3  is 0x8f), VT220.
145     This affects next character only.
146
147ESC P
148     Device Control String (DCS  is 0x90).
149
150ESC V
151     Start of Guarded Area (SPA  is 0x96).
152
153ESC W
154     End of Guarded Area (EPA  is 0x97).
155
156ESC X
157     Start of String (SOS  is 0x98).
158
159ESC Z
160     Return Terminal ID (DECID is 0x9a).  Obsolete form of CSI c  (DA).
161
162ESC [
163     Control Sequence Introducer (CSI  is 0x9b).
164
165ESC \
166     String Terminator (ST  is 0x9c).
167
168ESC ]
169     Operating System Command (OSC  is 0x9d).
170
171ESC ^
172     Privacy Message (PM  is 0x9e).
173
174ESC _
175     Application Program Command (APC  is 0x9f).
176
177
178These control characters are used in the vtXXX emulation.
179
180
181VT100-related terminals
182
183In this document, "VT100" refers not only to VT100/VT102, but also to
184the succession of upward-compatible terminals produced by DEC (Digital
185Equipment Corporation) from the mid-1970s for about twenty years.  For
186brevity, the document refers to the related models:
187  "VT200" as VT220/VT240,
188  "VT300" as VT320/VT340,
189  "VT400" as VT420, and
190  "VT500" as VT510/VT520/VT525.
191
192Most of these control sequences are standard VT102 control sequences,
193but there is support for later DEC VT terminals (i.e., VT220, VT320,
194VT420, VT510), as well as ECMA-48 and aixterm color controls.  The only
195VT102 feature not supported is auto-repeat, since the only way X
196provides for this will affect all windows.
197
198There are additional control sequences to provide xterm-dependent
199functions, such as the scrollbar or window size.  Where the function is
200specified by DEC or ECMA-48, the mnemonic assigned to it is given in
201parentheses.
202
203The escape codes to designate and invoke character sets are specified by
204ISO 2022 (see that document for a discussion of character sets).
205
206Many of the features are optional; xterm can be configured and built
207without support for them.
208
209
210VT100 Mode
211
212
213Single-character functions
214
215BEL       Bell (BEL  is Ctrl-G).
216
217BS        Backspace (BS  is Ctrl-H).
218
219CR        Carriage Return (CR  is Ctrl-M).
220
221ENQ       Return Terminal Status (ENQ  is Ctrl-E).  Default response is
222          an empty string, but may be overridden by a resource
223          answerbackString.
224
225FF        Form Feed or New Page (NP ).  (FF  is Ctrl-L).  FF  is treated
226          the same as LF .
227
228LF        Line Feed or New Line (NL).  (LF  is Ctrl-J).
229
230SI        Switch to Standard Character Set (Ctrl-O is Shift In or LS0).
231          This invokes the G0 character set (the default) as GL.
232          VT200 and up implement LS0.
233
234SO        Switch to Alternate Character Set (Ctrl-N is Shift Out or
235          LS1).  This invokes the G1 character set as GL.
236          VT200 and up implement LS1.
237
238SP        Space.
239
240TAB       Horizontal Tab (HTS  is Ctrl-I).
241
242VT        Vertical Tab (VT  is Ctrl-K).  This is treated the same as LF.
243
244
245Controls beginning with ESC
246
247This excludes controls where ESC  is part of a 7-bit equivalent to 8-bit
248C1 controls, ordered by the final character(s).
249
250ESC SP F  7-bit controls (S7C1T), VT220.  This tells the terminal to
251          send C1 control characters as 7-bit sequences, e.g., its
252          responses to queries.  DEC VT200 and up always accept 8-bit
253          control sequences except when configured for VT100 mode.
254
255ESC SP G  8-bit controls (S8C1T), VT220.  This tells the terminal to
256          send C1 control characters as 8-bit sequences, e.g., its
257          responses to queries.  DEC VT200 and up always accept 8-bit
258          control sequences except when configured for VT100 mode.
259
260ESC SP L  Set ANSI conformance level 1, ECMA-43.
261
262ESC SP M  Set ANSI conformance level 2, ECMA-43.
263
264ESC SP N  Set ANSI conformance level 3, ECMA-43.
265
266ESC # 3   DEC double-height line, top half (DECDHL), VT100.
267
268ESC # 4   DEC double-height line, bottom half (DECDHL), VT100.
269
270ESC # 5   DEC single-width line (DECSWL), VT100.
271
272ESC # 6   DEC double-width line (DECDWL), VT100.
273
274ESC # 8   DEC Screen Alignment Test (DECALN), VT100.
275
276ESC % @   Select default character set.  That is ISO 8859-1 (ISO 2022).
277
278ESC % G   Select UTF-8 character set, ISO 2022.
279
280ESC ( C   Designate G0 Character Set, VT100, ISO 2022.
281          Final character C for designating 94-character sets.  In this
282          list,
283          o   0 , A  and B  were introduced in the VT100,
284          o   most were introduced in the VT200 series,
285          o   a few were introduced in the VT300 series, and
286          o   a few more were introduced in the VT500 series.
287          The VT220 character sets, together with a few others (such as
288          Portuguese) are activated by the National Replacement
289          Character Set (NRCS) controls.  The term "replacement" says
290          that the character set is formed by replacing some of the
291          characters in a set (termed the Multinational Character Set)
292          with more useful ones for a given language.  The ASCII and DEC
293          Supplemental character sets make up the two halves of the
294          Multinational Character set, initially mapped to GL and GR.
295          The valid final characters C for this control are:
296            C = A  -> United Kingdom (UK), VT100.
297            C = B  -> United States (USASCII), VT100.
298            C = C  or 5  -> Finnish, VT200.
299            C = H  or 7  -> Swedish, VT200.
300            C = K  -> German, VT200.
301            C = Q  or 9  -> French Canadian, VT200.
302            C = R  or f  -> French, VT200.
303            C = Y  -> Italian, VT200.
304            C = Z  -> Spanish, VT200.
305            C = 4  -> Dutch, VT200.
306            C = " >  -> Greek, VT500.
307            C = % 2  -> Turkish, VT500.
308            C = % 6  -> Portuguese, VT300.
309            C = % =  -> Hebrew, VT500.
310            C = =  -> Swiss, VT200.
311            C = ` , E  or 6  -> Norwegian/Danish, VT200.
312          The final character A  is a special case, since the same final
313          character is used by the VT300-control for the 96-character
314          British Latin-1.
315          There are a few other 94-character sets:
316            C = 0  -> DEC Special Character and Line Drawing Set, VT100.
317            C = <  -> DEC Supplemental, VT200.
318            C = <  -> User Preferred Selection Set, VT300.
319            C = >  -> DEC Technical, VT300.
320          These are documented as 94-character sets (like USASCII)
321          without NRCS:
322            C = " 4  -> DEC Hebrew, VT500.
323            C = " ?  -> DEC Greek, VT500.
324            C = % 0  -> DEC Turkish, VT500.
325            C = % 5  -> DEC Supplemental Graphics, VT300.
326            C = & 4  -> DEC Cyrillic, VT500.
327          The VT520 reference manual lists a few more, but no
328          documentation has been found for the mappings:
329            C = % 3  -> SCS NRCS, VT500.
330            C = & 5  -> DEC Russian, VT500.
331
332ESC ) C   Designate G1 Character Set, ISO 2022, VT100.
333          The same character sets apply as for ESC ( C.
334
335ESC * C   Designate G2 Character Set, ISO 2022, VT220.
336          The same character sets apply as for ESC ( C.
337
338ESC + C   Designate G3 Character Set, ISO 2022, VT220.
339          The same character sets apply as for ESC ( C.
340
341ESC - C   Designate G1 Character Set, VT300.
342          These controls apply only to 96-character sets.  Unlike the
343          94-character sets, these can have different values than ASCII
344          space and DEL for the mapping of 0x20 and 0x7f.  The valid
345          final characters C for this control are:
346            C = A  -> ISO Latin-1 Supplemental, VT300.
347            C = B  -> ISO Latin-2 Supplemental, VT500.
348            C = F  -> ISO Greek Supplemental, VT500.
349            C = H  -> ISO Hebrew Supplemental, VT500.
350            C = L  -> ISO Latin-Cyrillic, VT500.
351            C = M  -> ISO Latin-5 Supplemental, VT500.
352
353ESC . C   Designate G2 Character Set, VT300.
354          The same character sets apply as for ESC - C.
355
356ESC / C   Designate G3 Character Set, VT300.
357          The same character sets apply as for ESC - C.
358
359ESC 6     Back Index (DECBI), VT420 and up.
360
361ESC 7     Save Cursor (DECSC), VT100.
362
363ESC 8     Restore Cursor (DECRC), VT100.
364
365ESC 9     Forward Index (DECFI), VT420 and up.
366
367ESC =     Application Keypad (DECKPAM).
368
369ESC >     Normal Keypad (DECKPNM), VT100.
370
371ESC F     Cursor to lower left corner of screen.  This is enabled by the
372          hpLowerleftBugCompat resource.
373
374ESC c     Full Reset (RIS), VT100.
375
376ESC l     Memory Lock (per HP terminals).  Locks memory above the
377          cursor.
378
379ESC m     Memory Unlock (per HP terminals).
380
381ESC n     Invoke the G2 Character Set as GL (LS2).
382
383ESC o     Invoke the G3 Character Set as GL (LS3).
384
385ESC |     Invoke the G3 Character Set as GR (LS3R).
386
387ESC }     Invoke the G2 Character Set as GR (LS2R).
388
389ESC ~     Invoke the G1 Character Set as GR (LS1R), VT100.
390
391
392Application Program-Command functions
393
394APC Pt ST None.  xterm implements no APC  functions; Pt is ignored.  Pt
395          need not be printable characters.
396
397
398Device-Control functions
399
400DCS Ps ; Ps | Pt ST
401          User-Defined Keys (DECUDK), VT220 and up.
402
403          The first parameter:
404            Ps = 0  -> Clear all UDK definitions before starting
405          (default).
406            Ps = 1  -> Erase Below (default).
407
408          The second parameter:
409            Ps = 0  <- Lock the keys (default).
410            Ps = 1  <- Do not lock.
411
412          The third parameter is a ";"-separated list of strings
413          denoting the key-code separated by a "/" from the hex-encoded
414          key value.  The key codes correspond to the DEC function-key
415          codes (e.g., F6=17).
416
417DCS Ps! u Pt ST
418          Assigning User-Preferred Supplemental Sets (DECAUPSS), VT320,
419          VT510.  XTerm ignores this in UTF-8 mode, and uses the
420          preferLatin1 resource to choose the default setting.
421          VT320 provides these:
422            DCS 0 ! u % 5 ST  -> DEC Supplemental Graphic
423            DCS 1 ! u A ST    -> ISO Latin-1 supplemental
424          VT510 adds these:
425            DCS 0 ! u " ? ST  -> DEC Greek
426            DCS 0 ! u " 4 ST  -> DEC Hebrew
427            DCS 0 ! u % 0 ST  -> DEC Turkish
428            DCS 0 ! u & 4 ST  -> DEC Cyrillic
429            DCS 1 ! u B ST    -> ISO Latin-2 Supplemental
430            DCS 1 ! u F ST    -> ISO Greek Supplemental
431            DCS 1 ! u H ST    -> ISO Hebrew Supplemental
432            DCS 1 ! u M ST    -> ISO Latin-5 Supplemental
433            DCS 1 ! u L ST    -> ISO Latin-Cyrillic
434          VT520 accepts a few others (undocumented); xterm adds these:
435            DCS 0 ! u B ST    -> United States (USASCII).
436            DCS 0 ! u 0 ST    -> DEC Special Character and Line Drawing
437          Set.
438            DCS 0 ! u > ST    -> DEC Technical.
439
440DCS $ q Pt ST
441          Request Status String (DECRQSS), VT420 and up.
442          The string following the "q" is one of the following:
443            m       -> SGR
444            " p     -> DECSCL
445            SP q    -> DECSCUSR
446            " q     -> DECSCA
447            r       -> DECSTBM
448            s       -> DECSLRM
449            t       -> DECSLPP
450            $ |     -> DECSCPP
451            $ }     -> DECSASD
452            $ ~     -> DECSSDT
453            * x     -> DECSACE
454            * |     -> DECSNLS
455            , |     -> DECAC (VT525 only)
456            , }     -> DECATC (VT525 only)
457            > Pm m  -> XTQMODKEYS (xterm)
458          xterm responds with DCS 1 $ r Pt ST for valid requests,
459          replacing the Pt with the corresponding CSI string, or DCS 0 $
460          r  ST for invalid requests.
461
462DCS Ps $ t Pt ST
463          Restore presentation status (DECRSPS), VT320 and up.  The
464          control can be converted from a response from DECCIR or
465          DECTABSR by changing the first "u" to a "t"
466            Ps = 1  -> DECCIR
467            Ps = 2  -> DECTABSR
468
469DCS + Q Pt ST
470          Request resource values (XTGETXRES), xterm.  The string
471          following the "Q" is a list of names encoded in hexadecimal (2
472          digits per character) separated by ; which correspond to xterm
473          resource names.
474
475          xterm responds with
476          DCS 1 + R Pt ST for valid requests, adding to Pt an = , and
477          the value of the corresponding xterm resource, or
478          DCS 0 + R Pt ST for invalid requests.
479          The strings are encoded in hexadecimal (2 digits per
480          character).
481
482          Only boolean, numeric and string resources for the VT100
483          widget are supported by this query.  XTerm evaluates resources
484          at startup time.  Several of xterm's state variables use
485          resources to determine their initial value.  Because the
486          resource variable may not reflect the current state, xterm
487          provides control sequences for querying the state directly:
488
489          o   XTQALLOWED
490          o   XTQMODKEYS
491
492
493DCS + p Pt ST
494          Set Termcap/Terminfo Data (XTSETTCAP), xterm.  The string
495          following the "p" is encoded in hexadecimal.  After decoding
496          it, xterm will use the name to retrieve data from the terminal
497          database.  If successful, that overrides the termName resource
498          when handling the "tcap" keyboard configuration's function-
499          and special-keys, as well as by the Request Termcap/Terminfo
500          String control.
501
502
503DCS + q Pt ST
504          Request Termcap/Terminfo String (XTGETTCAP), xterm.  The
505          string following the "q" is a list of names encoded in
506          hexadecimal (2 digits per character) separated by ; which
507          correspond to termcap or terminfo key names.
508          A few special features are also recognized, which are not key
509          names:
510
511          o   Co for termcap colors (or colors for terminfo colors), and
512
513          o   TN for termcap name (or name for terminfo name).
514
515          o   RGB for the ncurses direct-color extension.
516              Only a terminfo name is provided, since termcap
517              applications cannot use this information.
518
519          xterm responds with
520          DCS 1 + r Pt ST for valid requests, adding to Pt an = , and
521          the value of the corresponding string that xterm would send,
522          or
523          DCS 0 + r ST for invalid requests.
524          The strings are encoded in hexadecimal (2 digits per
525          character).  If more than one name is given, xterm replies
526          with each name/value pair in the same response.  An invalid
527          name (one not found in xterm's tables) ends processing of the
528          list of names.
529
530
531Functions using CSI , ordered by the final character(s)
532
533CSI Ps @  Insert Ps (Blank) Character(s) (default = 1) (ICH).
534
535CSI Ps SP @
536          Shift left Ps columns(s) (default = 1) (SL), ECMA-48.
537
538CSI Ps A  Cursor Up Ps Times (default = 1) (CUU).
539
540CSI Ps SP A
541          Shift right Ps columns(s) (default = 1) (SR), ECMA-48.
542
543CSI Ps B  Cursor Down Ps Times (default = 1) (CUD).
544
545CSI Ps C  Cursor Forward Ps Times (default = 1) (CUF).
546
547CSI Ps D  Cursor Backward Ps Times (default = 1) (CUB).
548
549CSI Ps E  Cursor Next Line Ps Times (default = 1) (CNL).
550
551CSI Ps F  Cursor Preceding Line Ps Times (default = 1) (CPL).
552
553CSI Ps G  Cursor Character Absolute  [column] (default = [row,1]) (CHA).
554
555CSI Ps ; Ps H
556          Cursor Position [row;column] (default = [1,1]) (CUP).
557
558CSI Ps I  Cursor Forward Tabulation Ps tab stops (default = 1) (CHT).
559
560CSI Ps J  Erase in Display (ED), VT100.
561            Ps = 0  -> Erase Below (default).
562            Ps = 1  -> Erase Above.
563            Ps = 2  -> Erase All.
564            Ps = 3  -> Erase Saved Lines, xterm.
565
566CSI ? Ps J
567          Erase in Display (DECSED), VT220.
568            Ps = 0  -> Selective Erase Below (default).
569            Ps = 1  -> Selective Erase Above.
570            Ps = 2  -> Selective Erase All.
571            Ps = 3  -> Selective Erase Saved Lines, xterm.
572
573CSI Ps K  Erase in Line (EL), VT100.
574            Ps = 0  -> Erase to Right (default).
575            Ps = 1  -> Erase to Left.
576            Ps = 2  -> Erase All.
577
578CSI ? Ps K
579          Erase in Line (DECSEL), VT220.
580            Ps = 0  -> Selective Erase to Right (default).
581            Ps = 1  -> Selective Erase to Left.
582            Ps = 2  -> Selective Erase All.
583
584CSI Ps L  Insert Ps Line(s) (default = 1) (IL).
585
586CSI Ps M  Delete Ps Line(s) (default = 1) (DL).
587
588CSI Ps P  Delete Ps Character(s) (default = 1) (DCH).
589
590CSI # P
591CSI Pm # P
592          Push current dynamic- and ANSI-palette colors onto stack
593          (XTPUSHCOLORS), xterm.  Parameters (integers in the range 1
594          through 10, since the default 0 will push) may be used to
595          store the palette into the stack without pushing.
596
597CSI # Q
598CSI Pm # Q
599          Pop stack to set dynamic- and ANSI-palette colors
600          (XTPOPCOLORS), xterm.  Parameters (integers in the range 1
601          through 10, since the default 0 will pop) may be used to
602          restore the palette from the stack without popping.
603
604CSI # R   Report the current entry on the palette stack, and the number
605          of palettes stored on the stack, using the same form as
606          XTPOPCOLOR (default = 0) (XTREPORTCOLORS), xterm.
607
608CSI Ps S  Scroll up Ps lines (default = 1) (SU), VT420, ECMA-48.
609
610CSI ? Pi ; Pa ; Pv S
611          Set or request graphics attribute (XTSMGRAPHICS), xterm.  If
612          configured to support either Sixel Graphics or ReGIS Graphics,
613          xterm accepts a three-parameter control sequence, where Pi, Pa
614          and Pv are the item, action and value:
615
616            Pi = 1  -> item is number of color registers.
617            Pi = 2  -> item is Sixel graphics geometry (in pixels).
618            Pi = 3  -> item is ReGIS graphics geometry (in pixels).
619
620            Pa = 1  -> read attribute.
621            Pa = 2  -> reset to default.
622            Pa = 3  -> set to value in Pv.
623            Pa = 4  -> read the maximum allowed value.
624
625            Pv is ignored by xterm except when setting (Pa == 3 ).
626            Pv = n <- A single integer is used for color registers.
627            Pv = width ; height <- Two integers for graphics geometry.
628
629          xterm replies with a control sequence of the same form:
630
631               CSI ? Pi ; Ps ; Pv S
632
633          where Ps is the status:
634            Ps = 0  <- success.
635            Ps = 1  <- error in Pi.
636            Ps = 2  <- error in Pa.
637            Ps = 3  <- failure.
638
639          On success, Pv represents the value read or set.
640
641          Notes:
642          o   The current implementation allows reading the graphics
643              sizes, but disallows modifying those sizes because that is
644              done once, using resource-values.
645          o   Graphics geometry is not necessarily the same as "window
646              size" (see the XTWINOPS window manipulation extensions).
647              XTerm limits the maximum graphics geometry according to
648              the maxGraphicSize resource.
649              The maxGraphicSize resource can be either an explicit
650              heightxwidth (default: 1000x1000 as of version 328) or the
651              word "auto" (telling XTerm to use limits the decGraphicsID
652              or decTerminalID resource to determine the limits).
653          o   XTerm uses the minimum of the window size and the graphic
654              size to obtain the maximum geometry.
655          o   While resizing a window will always change the current
656              graphics geometry, the reverse is not true.  Setting
657              graphics geometry does not affect the window size.
658          o   If xterm is able to support graphics (compile-time), but
659              is not configured (runtime) for graphics, these responses
660              will indicate a failure.  Other implementations which do
661              not use the maximum graphics dimensions but are configured
662              for graphics should report zeroes for the maximum geometry
663              rather than a failure.
664
665CSI Ps T  Scroll down Ps lines (default = 1) (SD), VT420.
666
667CSI Ps ; Ps ; Ps ; Ps ; Ps T
668          Initiate highlight mouse tracking (XTHIMOUSE), xterm.
669          Parameters are [func;startx;starty;firstrow;lastrow].  See the
670          section Mouse Tracking.
671
672CSI > Pm T
673          Reset title mode features to default value (XTRMTITLE), xterm.
674          Normally, "reset" disables the feature.  It is possible to
675          disable the ability to reset features by compiling a different
676          default for the title modes into xterm.
677
678            Ps = 0  -> Do not set window/icon labels using hexadecimal.
679            Ps = 1  -> Do not query window/icon labels using
680          hexadecimal.
681            Ps = 2  -> Do not set window/icon labels using UTF-8.
682            Ps = 3  -> Do not query window/icon labels using UTF-8.
683
684          (See discussion of Title Modes).
685
686CSI ? 5 W Reset tab stops to start with column 9, every 8 columns
687          (DECST8C), VT510.
688
689CSI Ps X  Erase Ps Character(s) (default = 1) (ECH).
690
691CSI Ps Z  Cursor Backward Tabulation Ps tab stops (default = 1) (CBT).
692
693CSI Ps ^  Scroll down Ps lines (default = 1) (SD), ECMA-48.
694          This was a publication error in the original ECMA-48 5th
695          edition (1991) corrected in 2003.
696
697CSI Ps `  Character Position Absolute  [column] (default = [row,1])
698          (HPA).
699
700CSI Ps a  Character Position Relative  [columns] (default = [row,col+1])
701          (HPR).
702
703CSI Ps b  Repeat the preceding graphic character Ps times (REP).
704
705CSI Ps c  Send Device Attributes (Primary DA).
706            Ps = 0  or omitted -> request attributes from terminal.  The
707          response depends on the decTerminalID resource setting.
708            -> CSI ? 1 ; 2 c  ("VT100 with Advanced Video Option")
709            -> CSI ? 1 ; 0 c  ("VT101 with No Options")
710            -> CSI ? 4 ; 6 c  ("VT132 with Advanced Video and Graphics")
711            -> CSI ? 6 c  ("VT102")
712            -> CSI ? 7 c  ("VT131")
713            -> CSI ? 1 2 ; Ps c  ("VT125")
714            -> CSI ? 6 2 ; Ps c  ("VT220")
715            -> CSI ? 6 3 ; Ps c  ("VT320")
716            -> CSI ? 6 4 ; Ps c  ("VT420")
717            -> CSI ? 6 5 ; Ps c  ("VT510" to ("VT525")
718
719          The VT100-style response parameters do not mean anything by
720          themselves.  VT220 (and higher) parameters do, telling the
721          host what features the terminal supports:
722            Ps = 1  -> 132-columns.
723            Ps = 2  -> Printer.
724            Ps = 3  -> ReGIS graphics.
725            Ps = 4  -> Sixel graphics.
726            Ps = 6  -> Selective erase.
727            Ps = 8  -> User-defined keys.
728            Ps = 9  -> National Replacement Character sets.
729            Ps = 1 5  -> Technical characters.
730            Ps = 1 6  -> Locator port.
731            Ps = 1 7  -> Terminal state interrogation.
732            Ps = 1 8  -> User windows.
733            Ps = 2 1  -> Horizontal scrolling.
734            Ps = 2 2  -> ANSI color, e.g., VT525.
735            Ps = 2 8  -> Rectangular editing.
736            Ps = 2 9  -> ANSI text locator (i.e., DEC Locator mode).
737
738          XTerm supports part of the User windows feature, providing a
739          single page (which corresponds to its visible window).  Rather
740          than resizing the font to change the number of lines/columns
741          in a fixed-size display, xterm uses the window extension
742          controls (DECSNLS, DECSCPP, DECSLPP) to adjust its visible
743          window's size.  The "cursor coupling" controls (DECHCCM,
744          DECPCCM, DECVCCM) are ignored.
745
746CSI = Ps c
747          Send Device Attributes (Tertiary DA).
748            Ps = 0  -> report Terminal Unit ID (default), VT400.  XTerm
749          uses zeros for the site code and serial number in its DECRPTUI
750          response.
751
752CSI > Ps c
753          Send Device Attributes (Secondary DA).
754            Ps = 0  or omitted -> request the terminal's identification
755          code.  The response depends on the decTerminalID resource
756          setting.  It should apply only to VT220 and up, but xterm
757          extends this to VT100.
758            -> CSI  > Pp ; Pv ; Pc c
759          where Pp denotes the terminal type
760            Pp = 0  -> "VT100".
761            Pp = 1  -> "VT220".
762            Pp = 2  -> "VT240" or "VT241".
763            Pp = 1 8  -> "VT330".
764            Pp = 1 9  -> "VT340".
765            Pp = 2 4  -> "VT320".
766            Pp = 3 2  -> "VT382".
767            Pp = 4 1  -> "VT420".
768            Pp = 6 1  -> "VT510".
769            Pp = 6 4  -> "VT520".
770            Pp = 6 5  -> "VT525".
771
772          and Pv is the firmware version (for xterm, this was originally
773          the XFree86 patch number, starting with 95).  In a DEC
774          terminal, Pc indicates the ROM cartridge registration number
775          and is always zero.
776
777CSI Ps d  Line Position Absolute  [row] (default = [1,column]) (VPA).
778
779CSI Ps e  Line Position Relative  [rows] (default = [row+1,column])
780          (VPR).
781
782CSI Ps ; Ps f
783          Horizontal and Vertical Position [row;column] (default =
784          [1,1]) (HVP).
785
786CSI Ps g  Tab Clear (TBC).  ECMA-48 defines additional codes, but the
787          VT100 user manual notes that it ignores other codes.  DEC's
788          later terminals (and xterm) do the same, for compatibility.
789            Ps = 0  -> Clear Current Column (default).
790            Ps = 3  -> Clear All.
791
792CSI Pm h  Set Mode (SM).
793            Ps = 2  -> Keyboard Action Mode (KAM).
794            Ps = 4  -> Insert Mode (IRM).
795            Ps = 1 2  -> Send/receive (SRM).
796            Ps = 2 0  -> Automatic Newline (LNM).
797
798CSI ? Pm h
799          DEC Private Mode Set (DECSET).
800            Ps = 1  -> Application Cursor Keys (DECCKM), VT100.
801            Ps = 2  -> Designate USASCII for character sets G0-G3
802          (DECANM), VT100, and set VT100 mode.
803            Ps = 3  -> 132 Column Mode (DECCOLM), VT100.
804            Ps = 4  -> Smooth (Slow) Scroll (DECSCLM), VT100.
805            Ps = 5  -> Reverse Video (DECSCNM), VT100.
806            Ps = 6  -> Origin Mode (DECOM), VT100.
807            Ps = 7  -> Auto-Wrap Mode (DECAWM), VT100.
808            Ps = 8  -> Auto-Repeat Keys (DECARM), VT100.
809            Ps = 9  -> Send Mouse X & Y on button press.  See the
810          section Mouse Tracking.  This is the X10 xterm mouse protocol.
811            Ps = 1 0  -> Show toolbar (rxvt).
812            Ps = 1 2  -> Start blinking cursor (AT&T 610).
813            Ps = 1 3  -> Start blinking cursor (set only via resource or
814          menu).
815            Ps = 1 4  -> Enable XOR of blinking cursor control sequence
816          and menu.
817            Ps = 1 8  -> Print Form Feed (DECPFF), VT220.
818            Ps = 1 9  -> Set print extent to full screen (DECPEX),
819          VT220.
820            Ps = 2 5  -> Show cursor (DECTCEM), VT220.
821            Ps = 3 0  -> Show scrollbar (rxvt).
822            Ps = 3 5  -> Enable font-shifting functions (rxvt).
823            Ps = 3 8  -> Enter Tektronix mode (DECTEK), VT240, xterm.
824            Ps = 4 0  -> Allow 80 -> 132 mode, xterm.
825            Ps = 4 1  -> more(1) fix (see curses resource).
826            Ps = 4 2  -> Enable National Replacement Character sets
827          (DECNRCM), VT220.
828            Ps = 4 3  -> Enable Graphic Expanded Print Mode (DECGEPM),
829          VT340.
830            Ps = 4 4  -> Turn on margin bell, xterm.
831            Ps = 4 4  -> Enable Graphic Print Color Mode (DECGPCM),
832          VT340.
833            Ps = 4 5  -> Reverse-wraparound mode (XTREVWRAP), xterm.
834            Ps = 4 5  -> Enable Graphic Print Color Syntax (DECGPCS),
835          VT340.
836            Ps = 4 6  -> Start logging (XTLOGGING), xterm.  This is
837          normally disabled by a compile-time option.
838            Ps = 4 6  -> Graphic Print Background Mode, VT340.
839            Ps = 4 7  -> Use Alternate Screen Buffer, xterm.  This may
840          be disabled by the titeInhibit resource.
841            Ps = 4 7  -> Enable Graphic Rotated Print Mode (DECGRPM),
842          VT340.
843            Ps = 6 6  -> Application keypad mode (DECNKM), VT320.
844            Ps = 6 7  -> Backarrow key sends backspace (DECBKM), VT340,
845          VT420.  This sets the backarrowKey resource to "true".
846            Ps = 6 9  -> Enable left and right margin mode (DECLRMM),
847          VT420 and up.
848            Ps = 8 0  -> Enable Sixel Display Mode (DECSDM), VT330,
849          VT340, VT382.
850            Ps = 9 5  -> Do not clear screen when DECCOLM is set/reset
851          (DECNCSM), VT510 and up.
852            Ps = 1 0 0 0  -> Send Mouse X & Y on button press and
853          release.  See the section Mouse Tracking.  This is the X11
854          xterm mouse protocol.
855            Ps = 1 0 0 1  -> Use Hilite Mouse Tracking, xterm.
856            Ps = 1 0 0 2  -> Use Cell Motion Mouse Tracking, xterm.  See
857          the section Button-event tracking.
858            Ps = 1 0 0 3  -> Use All Motion Mouse Tracking, xterm.  See
859          the section Any-event tracking.
860            Ps = 1 0 0 4  -> Send FocusIn/FocusOut events, xterm.
861            Ps = 1 0 0 5  -> Enable UTF-8 Mouse Mode, xterm.
862            Ps = 1 0 0 6  -> Enable SGR Mouse Mode, xterm.
863            Ps = 1 0 0 7  -> Enable Alternate Scroll Mode, xterm.  This
864          corresponds to the alternateScroll resource.
865            Ps = 1 0 1 0  -> Scroll to bottom on tty output (rxvt).
866          This sets the scrollTtyOutput resource to "true".
867            Ps = 1 0 1 1  -> Scroll to bottom on key press (rxvt).  This
868          sets the scrollKey resource to "true".
869            Ps = 1 0 1 4  -> Enable fastScroll resource, xterm.
870            Ps = 1 0 1 5  -> Enable urxvt Mouse Mode.
871            Ps = 1 0 1 6  -> Enable SGR Mouse PixelMode, xterm.
872            Ps = 1 0 3 4  -> Interpret "meta" key, xterm.  This sets the
873          eighth bit of keyboard input (and enables the eightBitInput
874          resource).
875            Ps = 1 0 3 5  -> Enable special modifiers for Alt and
876          NumLock keys, xterm.  This enables the numLock resource.
877            Ps = 1 0 3 6  -> Send ESC   when Meta modifies a key, xterm.
878          This enables the metaSendsEscape resource.
879            Ps = 1 0 3 7  -> Send DEL from the editing-keypad Delete
880          key, xterm.
881            Ps = 1 0 3 9  -> Send ESC  when Alt modifies a key, xterm.
882          This enables the altSendsEscape resource, xterm.
883            Ps = 1 0 4 0  -> Keep selection even if not highlighted,
884          xterm.  This enables the keepSelection resource.
885            Ps = 1 0 4 1  -> Use the CLIPBOARD selection, xterm.  This
886          enables the selectToClipboard resource.
887            Ps = 1 0 4 2  -> Enable Urgency window manager hint when
888          Control-G is received, xterm.  This enables the bellIsUrgent
889          resource.
890            Ps = 1 0 4 3  -> Enable raising of the window when Control-G
891          is received, xterm.  This enables the popOnBell resource.
892            Ps = 1 0 4 4  -> Reuse the most recent data copied to
893          CLIPBOARD, xterm.  This enables the keepClipboard resource.
894            Ps = 1 0 4 5  -> Extended Reverse-wraparound mode
895          (XTREVWRAP2), xterm.
896            Ps = 1 0 4 6  -> Enable switching to/from Alternate Screen
897          Buffer, xterm.  This works for terminfo-based systems,
898          updating the titeInhibit resource.
899            Ps = 1 0 4 7  -> Use Alternate Screen Buffer, xterm.  This
900          may be disabled by the titeInhibit resource.
901            Ps = 1 0 4 8  -> Save cursor as in DECSC, xterm.  This may
902          be disabled by the titeInhibit resource.
903            Ps = 1 0 4 9  -> Save cursor as in DECSC, xterm.  After
904          saving the cursor, switch to the Alternate Screen Buffer,
905          clearing it first.  This may be disabled by the titeInhibit
906          resource.  This control combines the effects of the 1 0 4 7
907          and 1 0 4 8  modes.  Use this with terminfo-based applications
908          rather than the 4 7  mode.
909            Ps = 1 0 5 0  -> Set terminfo/termcap function-key mode,
910          xterm.
911            Ps = 1 0 5 1  -> Set Sun function-key mode, xterm.
912            Ps = 1 0 5 2  -> Set HP function-key mode, xterm.
913            Ps = 1 0 5 3  -> Set SCO function-key mode, xterm.
914            Ps = 1 0 6 0  -> Set legacy keyboard emulation, i.e, X11R6,
915          xterm.
916            Ps = 1 0 6 1  -> Set VT220 keyboard emulation, xterm.
917            Ps = 2 0 0 1  -> Enable readline mouse button-1, xterm.
918            Ps = 2 0 0 2  -> Enable readline mouse button-2, xterm.
919            Ps = 2 0 0 3  -> Enable readline mouse button-3, xterm.
920            Ps = 2 0 0 4  -> Set bracketed paste mode, xterm.
921            Ps = 2 0 0 5  -> Enable readline character-quoting, xterm.
922            Ps = 2 0 0 6  -> Enable readline newline pasting, xterm.
923
924CSI Ps i  Media Copy (MC).
925            Ps = 0  -> Print screen (default).
926            Ps = 4  -> Turn off printer controller mode.
927            Ps = 5  -> Turn on printer controller mode.
928            Ps = 1 0  -> HTML screen dump, xterm.
929            Ps = 1 1  -> SVG screen dump, xterm.
930
931CSI ? Ps i
932          Media Copy (MC), DEC-specific.
933            Ps = 1  -> Print line containing cursor.
934            Ps = 4  -> Turn off autoprint mode.
935            Ps = 5  -> Turn on autoprint mode.
936            Ps = 1 0  -> Print composed display, ignores DECPEX.
937            Ps = 1 1  -> Print all pages.
938
939CSI Pm l  Reset Mode (RM).
940            Ps = 2  -> Keyboard Action Mode (KAM).
941            Ps = 4  -> Replace Mode (IRM).
942            Ps = 1 2  -> Send/receive (SRM).
943            Ps = 2 0  -> Normal Linefeed (LNM).
944
945CSI ? Pm l
946          DEC Private Mode Reset (DECRST).
947            Ps = 1  -> Normal Cursor Keys (DECCKM), VT100.
948            Ps = 2  -> Designate VT52 mode (DECANM), VT100.
949            Ps = 3  -> 80 Column Mode (DECCOLM), VT100.
950            Ps = 4  -> Jump (Fast) Scroll (DECSCLM), VT100.
951            Ps = 5  -> Normal Video (DECSCNM), VT100.
952            Ps = 6  -> Normal Cursor Mode (DECOM), VT100.
953            Ps = 7  -> No Auto-Wrap Mode (DECAWM), VT100.
954            Ps = 8  -> No Auto-Repeat Keys (DECARM), VT100.
955            Ps = 9  -> Don't send Mouse X & Y on button press, xterm.
956            Ps = 1 0  -> Hide toolbar (rxvt).
957            Ps = 1 2  -> Stop blinking cursor (AT&T 610).
958            Ps = 1 3  -> Disable blinking cursor (reset only via
959          resource or menu).
960            Ps = 1 4  -> Disable XOR of blinking cursor control sequence
961          and menu.
962            Ps = 1 8  -> Don't Print Form Feed (DECPFF), VT220.
963            Ps = 1 9  -> Limit print to scrolling region (DECPEX),
964          VT220.
965            Ps = 2 5  -> Hide cursor (DECTCEM), VT220.
966            Ps = 3 0  -> Don't show scrollbar (rxvt).
967            Ps = 3 5  -> Disable font-shifting functions (rxvt).
968            Ps = 4 0  -> Disallow 80 -> 132 mode, xterm.
969            Ps = 4 1  -> No more(1) fix (see curses resource).
970            Ps = 4 2  -> Disable National Replacement Character sets
971          (DECNRCM), VT220.
972            Ps = 4 3  -> Disable Graphic Expanded Print Mode (DECGEPM),
973          VT340.
974            Ps = 4 4  -> Turn off margin bell, xterm.
975            Ps = 4 4  -> Disable Graphic Print Color Mode (DECGPCM),
976          VT340.
977            Ps = 4 5  -> No Reverse-wraparound mode (XTREVWRAP), xterm.
978            Ps = 4 5  -> Disable Graphic Print Color Syntax (DECGPCS),
979          VT340.
980            Ps = 4 6  -> Stop logging (XTLOGGING), xterm.  This is
981          normally disabled by a compile-time option.
982            Ps = 4 7  -> Use Normal Screen Buffer, xterm.
983            Ps = 4 7  -> Disable Graphic Rotated Print Mode (DECGRPM),
984          VT340.
985            Ps = 6 6  -> Numeric keypad mode (DECNKM), VT320.
986            Ps = 6 7  -> Backarrow key sends delete (DECBKM), VT340,
987          VT420.  This sets the backarrowKey resource to "false".
988            Ps = 6 9  -> Disable left and right margin mode (DECLRMM),
989          VT420 and up.
990            Ps = 8 0  -> Disable Sixel Display Mode (DECSDM), VT330,
991          VT340, VT382.  Turns on "Sixel Scrolling".  See the section
992          Sixel Graphics and mode 8 4 5 2 .
993            Ps = 9 5  -> Clear screen when DECCOLM is set/reset
994          (DECNCSM), VT510 and up.
995            Ps = 1 0 0 0  -> Don't send Mouse X & Y on button press and
996          release.  See the section Mouse Tracking.
997            Ps = 1 0 0 1  -> Don't use Hilite Mouse Tracking, xterm.
998            Ps = 1 0 0 2  -> Don't use Cell Motion Mouse Tracking,
999          xterm.  See the section Button-event tracking.
1000            Ps = 1 0 0 3  -> Don't use All Motion Mouse Tracking, xterm.
1001          See the section Any-event tracking.
1002            Ps = 1 0 0 4  -> Don't send FocusIn/FocusOut events, xterm.
1003            Ps = 1 0 0 5  -> Disable UTF-8 Mouse Mode, xterm.
1004            Ps = 1 0 0 6  -> Disable SGR Mouse Mode, xterm.
1005            Ps = 1 0 0 7  -> Disable Alternate Scroll Mode, xterm.  This
1006          corresponds to the alternateScroll resource.
1007            Ps = 1 0 1 0  -> Don't scroll to bottom on tty output
1008          (rxvt).  This sets the scrollTtyOutput resource to "false".
1009            Ps = 1 0 1 1  -> Don't scroll to bottom on key press (rxvt).
1010          This sets the scrollKey resource to "false".
1011            Ps = 1 0 1 4  -> Disable fastScroll resource, xterm.
1012            Ps = 1 0 1 5  -> Disable urxvt Mouse Mode.
1013            Ps = 1 0 1 6  -> Disable SGR Mouse Pixel-Mode, xterm.
1014            Ps = 1 0 3 4  -> Don't interpret "meta" key, xterm.  This
1015          disables the eightBitInput resource.
1016            Ps = 1 0 3 5  -> Disable special modifiers for Alt and
1017          NumLock keys, xterm.  This disables the numLock resource.
1018            Ps = 1 0 3 6  -> Don't send ESC  when Meta modifies a key,
1019          xterm.  This disables the metaSendsEscape resource.
1020            Ps = 1 0 3 7  -> Send VT220 Remove from the editing-keypad
1021          Delete key, xterm.
1022            Ps = 1 0 3 9  -> Don't send ESC when Alt modifies a key,
1023          xterm.  This disables the altSendsEscape resource.
1024            Ps = 1 0 4 0  -> Do not keep selection when not highlighted,
1025          xterm.  This disables the keepSelection resource.
1026            Ps = 1 0 4 1  -> Use the PRIMARY selection, xterm.  This
1027          disables the selectToClipboard resource.
1028            Ps = 1 0 4 2  -> Disable Urgency window manager hint when
1029          Control-G is received, xterm.  This disables the bellIsUrgent
1030          resource.
1031            Ps = 1 0 4 3  -> Disable raising of the window when Control-
1032          G is received, xterm.  This disables the popOnBell resource.
1033            Ps = 1 0 4 5  -> No Extended Reverse-wraparound mode
1034          (XTREVWRAP2), xterm.
1035            Ps = 1 0 4 6  -> Disable switching to/from Alternate Screen
1036          Buffer, xterm.  This works for terminfo-based systems,
1037          updating the titeInhibit resource.  If currently using the
1038          Alternate Screen Buffer, xterm switches to the Normal Screen
1039          Buffer.
1040            Ps = 1 0 4 7  -> Use Normal Screen Buffer, xterm.  Clear the
1041          screen first if in the Alternate Screen Buffer.  This may be
1042          disabled by the titeInhibit resource.
1043            Ps = 1 0 4 8  -> Restore cursor as in DECRC, xterm.  This
1044          may be disabled by the titeInhibit resource.
1045            Ps = 1 0 4 9  -> Use Normal Screen Buffer and restore cursor
1046          as in DECRC, xterm.  This may be disabled by the titeInhibit
1047          resource.  This combines the effects of the 1 0 4 7  and 1 0 4
1048          8  modes.  Use this with terminfo-based applications rather
1049          than the 4 7  mode.
1050            Ps = 1 0 5 0  -> Reset terminfo/termcap function-key mode,
1051          xterm.
1052            Ps = 1 0 5 1  -> Reset Sun function-key mode, xterm.
1053            Ps = 1 0 5 2  -> Reset HP function-key mode, xterm.
1054            Ps = 1 0 5 3  -> Reset SCO function-key mode, xterm.
1055            Ps = 1 0 6 0  -> Reset legacy keyboard emulation, i.e,
1056          X11R6, xterm.
1057            Ps = 1 0 6 1  -> Reset keyboard emulation to Sun/PC style,
1058          xterm.
1059            Ps = 2 0 0 1  -> Disable readline mouse button-1, xterm.
1060            Ps = 2 0 0 2  -> Disable readline mouse button-2, xterm.
1061            Ps = 2 0 0 3  -> Disable readline mouse button-3, xterm.
1062            Ps = 2 0 0 4  -> Reset bracketed paste mode, xterm.
1063            Ps = 2 0 0 5  -> Disable readline character-quoting, xterm.
1064            Ps = 2 0 0 6  -> Disable readline newline pasting, xterm.
1065
1066CSI Pm m  Character Attributes (SGR).
1067            Ps = 0  -> Normal (default), VT100.
1068            Ps = 1  -> Bold, VT100.
1069            Ps = 2  -> Faint, decreased intensity, ECMA-48 2nd.
1070            Ps = 3  -> Italicized, ECMA-48 2nd.
1071            Ps = 4  -> Underlined, VT100.
1072            Ps = 5  -> Blink, VT100.
1073          This appears as Bold in X11R6 xterm.
1074            Ps = 7  -> Inverse, VT100.
1075            Ps = 8  -> Invisible, i.e., hidden, ECMA-48 2nd, VT300.
1076            Ps = 9  -> Crossed-out characters, ECMA-48 3rd.
1077            Ps = 2 1  -> Doubly-underlined, ECMA-48 3rd.
1078            Ps = 2 2  -> Normal (neither bold nor faint), ECMA-48 3rd.
1079            Ps = 2 3  -> Not italicized, ECMA-48 3rd.
1080            Ps = 2 4  -> Not underlined, ECMA-48 3rd.
1081            Ps = 2 5  -> Steady (not blinking), ECMA-48 3rd.
1082            Ps = 2 7  -> Positive (not inverse), ECMA-48 3rd.
1083            Ps = 2 8  -> Visible, i.e., not hidden, ECMA-48 3rd, VT300.
1084            Ps = 2 9  -> Not crossed-out, ECMA-48 3rd.
1085            Ps = 3 0  -> Set foreground color to Black.
1086            Ps = 3 1  -> Set foreground color to Red.
1087            Ps = 3 2  -> Set foreground color to Green.
1088            Ps = 3 3  -> Set foreground color to Yellow.
1089            Ps = 3 4  -> Set foreground color to Blue.
1090            Ps = 3 5  -> Set foreground color to Magenta.
1091            Ps = 3 6  -> Set foreground color to Cyan.
1092            Ps = 3 7  -> Set foreground color to White.
1093            Ps = 3 9  -> Set foreground color to default, ECMA-48 3rd.
1094            Ps = 4 0  -> Set background color to Black.
1095            Ps = 4 1  -> Set background color to Red.
1096            Ps = 4 2  -> Set background color to Green.
1097            Ps = 4 3  -> Set background color to Yellow.
1098            Ps = 4 4  -> Set background color to Blue.
1099            Ps = 4 5  -> Set background color to Magenta.
1100            Ps = 4 6  -> Set background color to Cyan.
1101            Ps = 4 7  -> Set background color to White.
1102            Ps = 4 9  -> Set background color to default, ECMA-48 3rd.
1103
1104          Some of the above note the edition of ECMA-48 which first
1105          describes a feature.  In its successive editions from 1979 to
1106          1991 (2nd 1979, 3rd 1984, 4th 1986, and 5th 1991), ECMA-48
1107          listed codes through 6 5 (skipping several toward the end of
1108          the range).  Most of the ECMA-48 codes not implemented in
1109          xterm were never implemented in a hardware terminal.  Several
1110          (such as 3 9  and 4 9 ) are either noted in ECMA-48 as
1111          implementation defined, or described in vague terms.
1112
1113          The successive editions of ECMA-48 give little attention to
1114          changes from one edition to the next, except to comment on
1115          features which have become obsolete.  ECMA-48 1st (1976) is
1116          unavailable; there is no reliable source of information which
1117          states whether "ANSI" color was defined in that edition, or
1118          later (1979).  The VT100 (1978) implemented the most commonly
1119          used non-color video attributes which are given in the 2nd
1120          edition.
1121
1122          While 8-color support is described in ECMA-48 2nd edition, the
1123          VT500 series (introduced in 1993) were the first DEC terminals
1124          implementing "ANSI" color.  The DEC terminal's use of color is
1125          known to differ from xterm; useful documentation on this
1126          series became available too late to influence xterm.
1127
1128          If 16-color support is compiled, the following aixterm
1129          controls apply.  Assume that xterm's resources are set so that
1130          the ISO color codes are the first 8 of a set of 16.  Then the
1131          aixterm colors are the bright versions of the ISO colors:
1132
1133            Ps = 9 0  -> Set foreground color to Black.
1134            Ps = 9 1  -> Set foreground color to Red.
1135            Ps = 9 2  -> Set foreground color to Green.
1136            Ps = 9 3  -> Set foreground color to Yellow.
1137            Ps = 9 4  -> Set foreground color to Blue.
1138            Ps = 9 5  -> Set foreground color to Magenta.
1139            Ps = 9 6  -> Set foreground color to Cyan.
1140            Ps = 9 7  -> Set foreground color to White.
1141            Ps = 1 0 0  -> Set background color to Black.
1142            Ps = 1 0 1  -> Set background color to Red.
1143            Ps = 1 0 2  -> Set background color to Green.
1144            Ps = 1 0 3  -> Set background color to Yellow.
1145            Ps = 1 0 4  -> Set background color to Blue.
1146            Ps = 1 0 5  -> Set background color to Magenta.
1147            Ps = 1 0 6  -> Set background color to Cyan.
1148            Ps = 1 0 7  -> Set background color to White.
1149
1150          If xterm is compiled with the 16-color support disabled, it
1151          supports the following, from rxvt:
1152            Ps = 1 0 0  -> Set foreground and background color to
1153          default.
1154
1155          XTerm maintains a color palette whose entries are identified
1156          by an index beginning with zero.  If 88- or 256-color support
1157          is compiled, the following apply:
1158          o   All parameters are decimal integers.
1159          o   RGB values range from zero (0) to 255.
1160          o   The 88- and 256-color support uses subparameters described
1161              in ISO-8613-6 for indexed color.  ISO-8613-6 also mentions
1162              direct color, using a similar scheme.  xterm supports
1163              that, too.
1164          o   xterm allows either colons (standard) or semicolons
1165              (legacy) to separate the subparameters (but after the
1166              first colon, colons must be used).
1167
1168          The indexed- and direct-color features are summarized in the
1169          FAQ, which explains why semicolon is accepted as a
1170          subparameter delimiter:
1171
1172            Can I set a color by its number?
1173
1174
1175          These ISO-8613-6 controls (marked in ECMA-48 5th edition as
1176          "reserved for future standardization") are supported by xterm:
1177            Ps = 3 8 : 2 : Pi : Pr : Pg : Pb -> Set foreground color
1178          using RGB values.  If xterm is not compiled with direct-color
1179          support, it uses the closest match in its palette for the
1180          given RGB Pr/Pg/Pb.  The color space identifier Pi is ignored.
1181            Ps = 3 8 : 5 : Ps -> Set foreground color to Ps, using
1182          indexed color.
1183            Ps = 4 8 : 2 : Pi : Pr : Pg : Pb -> Set background color
1184          using RGB values.  If xterm is not compiled with direct-color
1185          support, it uses the closest match in its palette for the
1186          given RGB Pr/Pg/Pb.  The color space identifier Pi is ignored.
1187            Ps = 4 8 : 5 : Ps -> Set background color to Ps, using
1188          indexed color.
1189
1190          This variation on ISO-8613-6 is supported for compatibility
1191          with KDE konsole:
1192            Ps = 3 8 ; 2 ; Pr ; Pg ; Pb -> Set foreground color using
1193          RGB values.  If xterm is not compiled with direct-color
1194          support, it uses the closest match in its palette for the
1195          given RGB Pr/Pg/Pb.
1196            Ps = 4 8 ; 2 ; Pr ; Pg ; Pb -> Set background color using
1197          RGB values.  If xterm is not compiled with direct-color
1198          support, it uses the closest match in its palette for the
1199          given RGB Pr/Pg/Pb.
1200
1201          In each case, if xterm is compiled with direct-color support,
1202          and the resource directColor is true, then rather than
1203          choosing the closest match, xterm asks the X server to
1204          directly render a given color.
1205
1206CSI > Pp ; Pv m
1207CSI > Pp m
1208          Set/reset key modifier options (XTMODKEYS), xterm.  Set or
1209          reset resource-values used by xterm to decide whether to
1210          construct escape sequences holding information about the
1211          modifiers pressed with a given key.
1212
1213          The first parameter Pp identifies the resource to set/reset.
1214          The second parameter Pv is the value to assign to the
1215          resource.
1216
1217          If the second parameter is omitted, the resource is reset to
1218          its initial value.  Values 3  and 5  are reserved for keypad-
1219          keys and string-keys.
1220
1221            Pp = 0  -> modifyKeyboard.
1222            Pp = 1  -> modifyCursorKeys.
1223            Pp = 2  -> modifyFunctionKeys.
1224            Pp = 4  -> modifyOtherKeys.
1225
1226          If no parameters are given, all resources are reset to their
1227          initial values.
1228
1229CSI ? Pp m
1230          Query key modifier options (XTQMODKEYS), xterm.
1231
1232          The parameter Pp identifies the resource to query.
1233
1234            Pp = 0  -> modifyKeyboard.
1235            Pp = 1  -> modifyCursorKeys.
1236            Pp = 2  -> modifyFunctionKeys.
1237            Pp = 4  -> modifyOtherKeys.
1238
1239          XTerm's response can be used to restore this state, because it
1240          is formatted as an XTMODKEYS control, i.e.,
1241
1242            CSI > Pp m
1243
1244          where
1245
1246            Pp = 0  -> modifyKeyboard.
1247            Pp = 1  -> modifyCursorKeys.
1248            Pp = 2  -> modifyFunctionKeys.
1249            Pp = 4  -> modifyOtherKeys.
1250
1251CSI Ps n  Device Status Report (DSR).
1252            Ps = 5  -> Status Report.
1253          Result ("OK") is CSI 0 n
1254            Ps = 6  -> Report Cursor Position (CPR) [row;column].
1255          Result is CSI r ; c R
1256
1257          Note: it is possible for this sequence to be sent by a
1258          function key.  For example, with the default keyboard
1259          configuration the shifted F1 key may send (with shift-,
1260          control-, alt-modifiers)
1261
1262            CSI 1 ; 2  R , or
1263            CSI 1 ; 5  R , or
1264            CSI 1 ; 6  R , etc.
1265
1266          The second parameter encodes the modifiers; values range from
1267          2 to 16.  See the section PC-Style Function Keys for the
1268          codes.  The modifyFunctionKeys and modifyKeyboard resources
1269          can change the form of the string sent from the modified F1
1270          key.
1271
1272CSI > Ps n
1273          Disable key modifier options, xterm.  These modifiers may be
1274          enabled via the CSI > Pm m sequence.  This control sequence
1275          corresponds to a resource value of "-1", which cannot be set
1276          with the other sequence.
1277
1278          The parameter identifies the resource to be disabled:
1279
1280            Ps = 0  -> modifyKeyboard.
1281            Ps = 1  -> modifyCursorKeys.
1282            Ps = 2  -> modifyFunctionKeys.
1283            Ps = 4  -> modifyOtherKeys.
1284
1285          If the parameter is omitted, modifyFunctionKeys is disabled.
1286          When modifyFunctionKeys is disabled, xterm uses the modifier
1287          keys to make an extended sequence of function keys rather than
1288          adding a parameter to each function key to denote the
1289          modifiers.
1290
1291CSI ? Ps n
1292          Device Status Report (DSR, DEC-specific).
1293            Ps = 6  -> Report Cursor Position (DECXCPR).  The response
1294          [row;column] is returned as
1295          CSI ? r ; c R
1296          (assumes the default page, i.e., "1").
1297            Ps = 1 5  -> Report Printer status.  The response is
1298          CSI ? 1 0 n  (ready).  or
1299          CSI ? 1 1 n  (not ready).
1300            Ps = 2 5  -> Report UDK status.  The response is
1301          CSI ? 2 0 n  (unlocked)
1302          or
1303          CSI ? 2 1 n  (locked).
1304            Ps = 2 6  -> Report Keyboard status.  The response is
1305          CSI ? 2 7 ; 1 ; 0 ; 0 n  (North American).
1306
1307          The last two parameters apply to VT300 & up (keyboard ready)
1308          and VT400 & up (LK01) respectively.
1309
1310            Ps = 5 5  -> Report Locator status.  The response is CSI ? 5
1311          3 n  Locator available, if compiled-in, or CSI ? 5 0 n  No
1312          Locator, if not.
1313            Ps = 5 6  -> Report Locator type.  The response is CSI ? 5 7
1314          ; 1 n  Mouse, if compiled-in, or CSI ? 5 7 ; 0 n  Cannot
1315          identify, if not.
1316            Ps = 6 2  -> Report macro space (DECMSR).  The response is
1317          CSI Pn *  { .
1318            Ps = 6 3  -> Report memory checksum (DECCKSR), VT420 and up.
1319          The response is DCS Pt ! ~ x x x x ST .
1320              Pt is the request id (from an optional parameter to the
1321          request).
1322              The x's are hexadecimal digits 0-9 and A-F.
1323            Ps = 7 5  -> Report data integrity.  The response is CSI ? 7
1324          0 n  (ready, no errors).
1325            Ps = 8 5  -> Report multi-session configuration.  The
1326          response is CSI ? 8 3 n  (not configured for multiple-session
1327          operation).
1328
1329CSI > Ps p
1330          Set resource value pointerMode (XTSMPOINTER), xterm.  This is
1331          used by xterm to decide whether to hide the pointer cursor as
1332          the user types.
1333
1334          Valid values for the parameter:
1335            Ps = 0  -> never hide the pointer.
1336            Ps = 1  -> hide if the mouse tracking mode is not enabled.
1337            Ps = 2  -> always hide the pointer, except when leaving the
1338          window.
1339            Ps = 3  -> always hide the pointer, even if leaving/entering
1340          the window.
1341
1342          If no parameter is given, xterm uses the default, which is 1 .
1343
1344CSI ! p   Soft terminal reset (DECSTR), VT220 and up.
1345
1346CSI Pl ; Pc " p
1347          Set conformance level (DECSCL), VT220 and up.
1348
1349          The first parameter selects the conformance level.  Valid
1350          values are:
1351            Pl = 6 1  -> level 1, e.g., VT100.
1352            Pl = 6 2  -> level 2, e.g., VT200.
1353            Pl = 6 3  -> level 3, e.g., VT300.
1354            Pl = 6 4  -> level 4, e.g., VT400.
1355            Pl = 6 5  -> level 5, e.g., VT500.
1356
1357          The second parameter selects the C1 control transmission mode.
1358          This is an optional parameter, ignored in conformance level 1.
1359          Valid values are:
1360            Pc = 0  -> 8-bit controls.
1361            Pc = 1  -> 7-bit controls (DEC factory default).
1362            Pc = 2  -> 8-bit controls.
1363
1364          The 7-bit and 8-bit control modes can also be set by S7C1T and
1365          S8C1T, but DECSCL is preferred.
1366
1367CSI Ps $ p
1368          Request ANSI mode (DECRQM).  For VT300 and up, reply DECRPM is
1369            CSI Ps; Pm $ y
1370          where Ps is the mode number as in SM/RM, and Pm is the mode
1371          value:
1372            0 - not recognized
1373            1 - set
1374            2 - reset
1375            3 - permanently set
1376            4 - permanently reset
1377
1378CSI ? Ps $ p
1379          Request DEC private mode (DECRQM).  For VT300 and up, reply
1380          DECRPM is
1381            CSI ? Ps; Pm $ y
1382          where Ps is the mode number as in DECSET/DECSET, Pm is the
1383          mode value as in the ANSI DECRQM.
1384          Two private modes are read-only (i.e., 1 3  and 1 4 ),
1385          provided only for reporting their values using this control
1386          sequence.  They correspond to the resources cursorBlink and
1387          cursorBlinkXOR.
1388CSI # p
1389CSI Pm # p
1390          Push video attributes onto stack (XTPUSHSGR), xterm.  This is
1391          an alias for CSI # { , used to work around language
1392          limitations of C#.
1393
1394CSI > Ps q
1395            Ps = 0  -> Report xterm name and version (XTVERSION).
1396          The response is a DSR sequence identifying the version:
1397            DCS > | text ST
1398
1399CSI Ps q  Load LEDs (DECLL), VT100.
1400            Ps = 0  -> Clear all LEDS (default).
1401            Ps = 1  -> Light Num Lock.
1402            Ps = 2  -> Light Caps Lock.
1403            Ps = 3  -> Light Scroll Lock.
1404            Ps = 2 1  -> Extinguish Num Lock.
1405            Ps = 2 2  -> Extinguish Caps Lock.
1406            Ps = 2 3  -> Extinguish Scroll Lock.
1407
1408CSI Ps SP q
1409          Set cursor style (DECSCUSR), VT520.
1410            Ps = 0  -> blinking block.
1411            Ps = 1  -> blinking block (default).
1412            Ps = 2  -> steady block.
1413            Ps = 3  -> blinking underline.
1414            Ps = 4  -> steady underline.
1415            Ps = 5  -> blinking bar, xterm.
1416            Ps = 6  -> steady bar, xterm.
1417
1418CSI Ps " q
1419          Select character protection attribute (DECSCA), VT220.  Valid
1420          values for the parameter:
1421            Ps = 0  -> DECSED and DECSEL can erase (default).
1422            Ps = 1  -> DECSED and DECSEL cannot erase.
1423            Ps = 2  -> DECSED and DECSEL can erase.
1424
1425CSI # q   Pop video attributes from stack (XTPOPSGR), xterm.  This is an
1426          alias for CSI # } , used to work around language limitations
1427          of C#.
1428
1429CSI Ps ; Ps r
1430          Set Scrolling Region [top;bottom] (default = full size of
1431          window) (DECSTBM), VT100.
1432
1433CSI ? Pm r
1434          Restore DEC Private Mode Values (XTRESTORE), xterm.  The value
1435          of Ps previously saved is restored.  Ps values are the same as
1436          for DECSET.
1437
1438          Like Restore Cursor (DECRC), this uses a one-level cache.
1439          Unlike Restore Cursor, specific settings can be saved and
1440          restored independently.  Only those modes listed as parameters
1441          are restored.
1442
1443CSI Pt ; Pl ; Pb ; Pr ; Pm $ r
1444          Change Attributes in Rectangular Area (DECCARA), VT400 and up.
1445            Pt ; Pl ; Pb ; Pr denotes the rectangle.
1446            Pm denotes the SGR attributes to change: 0, 1, 4, 5, 7.
1447
1448CSI s     Save cursor, available only when DECLRMM is disabled (SCOSC,
1449          also ANSI.SYS).
1450
1451CSI Pl ; Pr s
1452          Set left and right margins (DECSLRM), VT420 and up.  This is
1453          available only when DECLRMM is enabled.
1454
1455CSI > Ps s
1456          Set/reset shift-escape options (XTSHIFTESCAPE), xterm.  This
1457          corresponds to the shiftEscape resource.
1458
1459          Valid values for the parameter:
1460            Ps = 0  -> allow shift-key to override mouse protocol.
1461            Ps = 1  -> conditionally allow shift-key as modifier in
1462          mouse protocol.
1463
1464          These resource values are disallowed in the control sequence:
1465            Ps = 2  -> always allow shift-key as modifier in mouse
1466          protocol.
1467            Ps = 3  -> never allow shift-key as modifier in mouse
1468          protocol.
1469
1470          If no parameter is given, xterm uses the default, which is 0 .
1471
1472CSI ? Pm s
1473          Save DEC Private Mode Values (XTSAVE), xterm.  Ps values are
1474          the same as for DECSET.
1475
1476          Like Save Cursor (DECSC), this uses a one-level cache.  Unlike
1477          Save Cursor, specific settings can be saved and restored
1478          independently.  Only those modes listed as parameters are
1479          saved.
1480
1481CSI Ps ; Ps ; Ps t
1482          Window manipulation (XTWINOPS), dtterm, extended by xterm.
1483          These controls may be disabled using the allowWindowOps
1484          resource.
1485
1486          xterm uses Extended Window Manager Hints (EWMH) to maximize
1487          the window.  Some window managers have incomplete support for
1488          EWMH.  For instance, fvwm, flwm and quartz-wm advertise
1489          support for maximizing windows horizontally or vertically, but
1490          in fact equate those to the maximize operation.
1491
1492          Valid values for the first (and any additional parameters)
1493          are:
1494            Ps = 1  -> De-iconify window.
1495            Ps = 2  -> Iconify window.
1496            Ps = 3 ;  x ;  y -> Move window to [x, y].
1497            Ps = 4 ;  height ;  width -> Resize the xterm window to
1498          given height and width in pixels.  Omitted parameters reuse
1499          the current height or width.  Zero parameters use the
1500          display's height or width.
1501            Ps = 5  -> Raise the xterm window to the front of the
1502          stacking order.
1503            Ps = 6  -> Lower the xterm window to the bottom of the
1504          stacking order.
1505            Ps = 7  -> Refresh the xterm window.
1506            Ps = 8 ;  height ;  width -> Resize the text area to given
1507          height and width in characters.  Omitted parameters reuse the
1508          current height or width.  Zero parameters use the display's
1509          height or width.
1510            Ps = 9 ;  0  -> Restore maximized window.
1511            Ps = 9 ;  1  -> Maximize window (i.e., resize to screen
1512          size).
1513            Ps = 9 ;  2  -> Maximize window vertically.
1514            Ps = 9 ;  3  -> Maximize window horizontally.
1515            Ps = 1 0 ;  0  -> Undo full-screen mode.
1516            Ps = 1 0 ;  1  -> Change to full-screen.
1517            Ps = 1 0 ;  2  -> Toggle full-screen.
1518            Ps = 1 1  -> Report xterm window state.
1519          If the xterm window is non-iconified, it returns CSI 1 t .
1520          If the xterm window is iconified, it returns CSI 2 t .
1521            Ps = 1 3  -> Report xterm window position.
1522          Note: X Toolkit positions can be negative, but the reported
1523          values are unsigned, in the range 0-65535.  Negative values
1524          correspond to 32768-65535.
1525          Result is CSI 3 ; x ; y t
1526            Ps = 1 3 ;  2  -> Report xterm text-area position.
1527          Result is CSI 3 ; x ; y t
1528            Ps = 1 4  -> Report xterm text area size in pixels.
1529          Result is CSI  4 ;  height ;  width t
1530            Ps = 1 4 ;  2  -> Report xterm window size in pixels.
1531          Normally xterm's window is larger than its text area, since it
1532          includes the frame (or decoration) applied by the window
1533          manager, as well as the area used by a scroll-bar.
1534          Result is CSI  4 ;  height ;  width t
1535            Ps = 1 5  -> Report size of the screen in pixels.
1536          Result is CSI  5 ;  height ;  width t
1537            Ps = 1 6  -> Report xterm character cell size in pixels.
1538          Result is CSI  6 ;  height ;  width t
1539            Ps = 1 8  -> Report the size of the text area in characters.
1540          Result is CSI  8 ;  height ;  width t
1541            Ps = 1 9  -> Report the size of the screen in characters.
1542          Result is CSI  9 ;  height ;  width t
1543            Ps = 2 0  -> Report xterm window's icon label.
1544          Result is OSC  L  label ST
1545            Ps = 2 1  -> Report xterm window's title.
1546          Result is OSC  l  label ST
1547            Ps = 2 2 ; 0  -> Save xterm icon and window title on stack.
1548            Ps = 2 2 ; 1  -> Save xterm icon title on stack.
1549            Ps = 2 2 ; 2  -> Save xterm window title on stack.
1550            Ps = 2 3 ; 0  -> Restore xterm icon and window title from
1551          stack.
1552            Ps = 2 3 ; 1  -> Restore xterm icon title from stack.
1553            Ps = 2 3 ; 2  -> Restore xterm window title from stack.
1554            Ps >= 2 4  -> Resize to Ps lines (DECSLPP), VT340 and VT420.
1555          xterm adapts this by resizing its window.
1556
1557          XTWINOPS 2 2  (save/push title) and 2 3  (restore/pop title)
1558          accept an optional third parameter for direct access to the
1559          stack.  Parameters in the range 1 through 10, may be used to
1560          store the title into the stack or retrieve the title from the
1561          stack without pushing/popping.
1562
1563CSI > Pm t
1564          This xterm control sets one or more features of the title
1565          modes (XTSMTITLE), xterm.  Each parameter enables a single
1566          feature.
1567            Ps = 0  -> Set window/icon labels using hexadecimal.
1568            Ps = 1  -> Query window/icon labels using hexadecimal.
1569            Ps = 2  -> Set window/icon labels using UTF-8.
1570            Ps = 3  -> Query window/icon labels using UTF-8.  (See
1571          discussion of Title Modes)
1572
1573CSI Ps SP t
1574          Set warning-bell volume (DECSWBV), VT520.
1575            Ps = 0  or 1  -> off.
1576            Ps = 2 , 3  or 4  -> low.
1577            Ps = 5 , 6 , 7 , or 8  -> high.
1578
1579CSI Pt ; Pl ; Pb ; Pr ; Pm $ t
1580          Reverse Attributes in Rectangular Area (DECRARA), VT400 and
1581          up.
1582            Pt ; Pl ; Pb ; Pr denotes the rectangle.
1583            Pm denotes the attributes to reverse, i.e.,  1, 4, 5, 7.
1584
1585CSI u     Restore cursor (SCORC, also ANSI.SYS).
1586
1587CSI & u   User-Preferred Supplemental Set (DECRQUPSS), VT320, VT510.
1588          Response is DECAUPSS.
1589
1590CSI Ps SP u
1591          Set margin-bell volume (DECSMBV), VT520.
1592            Ps = 0 , 5 , 6 , 7 , or 8  -> high.
1593            Ps = 1  -> off.
1594            Ps = 2 , 3  or 4  -> low.
1595
1596CSI " v   Request Displayed Extent (DECRQDE), VT340, VT420.
1597          Response is
1598            CSI Ph; Pw; Pc; Pr; Pp " v
1599          where
1600            Ph is the number of lines of the current page
1601            Pw is the number of columns of the current page
1602            Pc is the column number at the top-left of the window
1603            Pr is the row number at the top-left of the window
1604            Pp is the current page number
1605
1606CSI Pt ; Pl ; Pb ; Pr ; Pp ; Pt ; Pl ; Pp $ v
1607          Copy Rectangular Area (DECCRA), VT400 and up.
1608            Pt ; Pl ; Pb ; Pr denotes the rectangle.
1609            Pp denotes the source page.
1610            Pt ; Pl denotes the target location.
1611            Pp denotes the target page.
1612
1613CSI Ps $ w
1614          Request presentation state report (DECRQPSR), VT320 and up.
1615            Ps = 0  -> error.
1616            Ps = 1  -> cursor information report (DECCIR).
1617          Response is
1618            DCS 1 $ u Pt ST
1619          Refer to the VT420 programming manual, which requires six
1620          pages to document the data string Pt,
1621            Ps = 2  -> tab stop report (DECTABSR).
1622          Response is
1623            DCS 2 $ u Pt ST
1624          The data string Pt is a list of the tab-stops, separated by
1625          "/" characters.
1626
1627CSI Pt ; Pl ; Pb ; Pr ' w
1628          Enable Filter Rectangle (DECEFR), VT420 and up.
1629          Parameters are [top;left;bottom;right].
1630          Defines the coordinates of a filter rectangle and activates
1631          it.  Anytime the locator is detected outside of the filter
1632          rectangle, an outside rectangle event is generated and the
1633          rectangle is disabled.  Filter rectangles are always treated
1634          as "one-shot" events.  Any parameters that are omitted default
1635          to the current locator position.  If all parameters are
1636          omitted, any locator motion will be reported.  DECELR always
1637          cancels any previous rectangle definition.
1638
1639CSI Ps x  Request Terminal Parameters (DECREQTPARM).
1640          if Ps is a "0" (default) or "1", and xterm is emulating VT100,
1641          the control sequence elicits a response of the same form whose
1642          parameters describe the terminal:
1643            Ps -> the given Ps incremented by 2.
1644            Pn = 1  <- no parity.
1645            Pn = 1  <- eight bits.
1646            Pn = 1  <- 2 8  transmit 38.4k baud.
1647            Pn = 1  <- 2 8  receive 38.4k baud.
1648            Pn = 1  <- clock multiplier.
1649            Pn = 0  <- STP flags.
1650
1651CSI Ps * x
1652          Select Attribute Change Extent (DECSACE), VT420 and up.
1653            Ps = 0  -> from start to end position, wrapped.
1654            Ps = 1  -> from start to end position, wrapped.
1655            Ps = 2  -> rectangle (exact).
1656
1657CSI Pc ; Pt ; Pl ; Pb ; Pr $ x
1658          Fill Rectangular Area (DECFRA), VT420 and up.
1659            Pc is the character to use.
1660            Pt ; Pl ; Pb ; Pr denotes the rectangle.
1661
1662CSI Ps # y
1663          Select checksum extension (XTCHECKSUM), xterm.  The bits of Ps
1664          modify the calculation of the checksum returned by DECRQCRA:
1665            0  -> do not negate the result.
1666            1  -> do not report the VT100 video attributes.
1667            2  -> do not omit checksum for blanks.
1668            3  -> omit checksum for cells not explicitly initialized.
1669            4  -> do not mask cell value to 8 bits or ignore combining
1670          characters.
1671
1672CSI Pi ; Pg ; Pt ; Pl ; Pb ; Pr * y
1673          Request Checksum of Rectangular Area (DECRQCRA), VT420 and up.
1674          Response is
1675          DCS Pi ! ~ x x x x ST
1676            Pi is the request id.
1677            Pg is the page number.
1678            Pt ; Pl ; Pb ; Pr denotes the rectangle.
1679            The x's are hexadecimal digits 0-9 and A-F.
1680
1681CSI Ps ; Pu ' z
1682          Enable Locator Reporting (DECELR).
1683          Valid values for the first parameter:
1684            Ps = 0  -> Locator disabled (default).
1685            Ps = 1  -> Locator enabled.
1686            Ps = 2  -> Locator enabled for one report, then disabled.
1687          The second parameter specifies the coordinate unit for locator
1688          reports.
1689          Valid values for the second parameter:
1690            Pu = 0  or omitted -> default to character cells.
1691            Pu = 1  <- device physical pixels.
1692            Pu = 2  <- character cells.
1693
1694CSI Pt ; Pl ; Pb ; Pr $ z
1695          Erase Rectangular Area (DECERA), VT400 and up.
1696            Pt ; Pl ; Pb ; Pr denotes the rectangle.
1697
1698CSI Pm ' {
1699          Select Locator Events (DECSLE).
1700          Valid values for the first (and any additional parameters)
1701          are:
1702            Ps = 0  -> only respond to explicit host requests (DECRQLP).
1703          This is default.  It also cancels any filter rectangle.
1704            Ps = 1  -> report button down transitions.
1705            Ps = 2  -> do not report button down transitions.
1706            Ps = 3  -> report button up transitions.
1707            Ps = 4  -> do not report button up transitions.
1708
1709CSI # {
1710CSI Pm # {
1711          Push video attributes onto stack (XTPUSHSGR), xterm.  The
1712          optional parameters correspond to the SGR encoding for video
1713          attributes, except for colors (which do not have a unique SGR
1714          code):
1715            Ps = 1  -> Bold.
1716            Ps = 2  -> Faint.
1717            Ps = 3  -> Italicized.
1718            Ps = 4  -> Underlined.
1719            Ps = 5  -> Blink.
1720            Ps = 7  -> Inverse.
1721            Ps = 8  -> Invisible.
1722            Ps = 9  -> Crossed-out characters.
1723            Ps = 2 1  -> Doubly-underlined.
1724            Ps = 3 0  -> Foreground color.
1725            Ps = 3 1  -> Background color.
1726
1727          If no parameters are given, all of the video attributes are
1728          saved.  The stack is limited to 10 levels.
1729
1730CSI Pt ; Pl ; Pb ; Pr $ {
1731          Selective Erase Rectangular Area (DECSERA), VT400 and up.
1732            Pt ; Pl ; Pb ; Pr denotes the rectangle.
1733
1734CSI Pt ; Pl ; Pb ; Pr # |
1735          Report selected graphic rendition (XTREPORTSGR), xterm.  The
1736          response is an SGR sequence which contains the attributes
1737          which are common to all cells in a rectangle.
1738            Pt ; Pl ; Pb ; Pr denotes the rectangle.
1739
1740CSI Ps $ |
1741          Select columns per page (DECSCPP), VT340.
1742            Ps = 0  -> 80 columns, default if Ps omitted.
1743            Ps = 8 0  -> 80 columns.
1744            Ps = 1 3 2  -> 132 columns.
1745
1746CSI Ps ' |
1747          Request Locator Position (DECRQLP).
1748          Valid values for the parameter are:
1749            Ps = 0 , 1 or omitted -> transmit a single DECLRP locator
1750          report.
1751
1752          If Locator Reporting has been enabled by a DECELR, xterm will
1753          respond with a DECLRP Locator Report.  This report is also
1754          generated on button up and down events if they have been
1755          enabled with a DECSLE, or when the locator is detected outside
1756          of a filter rectangle, if filter rectangles have been enabled
1757          with a DECEFR.
1758
1759            <- CSI Pe ; Pb ; Pr ; Pc ; Pp &  w
1760
1761          Parameters are [event;button;row;column;page].
1762          Valid values for the event:
1763            Pe = 0  <- locator unavailable - no other parameters sent.
1764            Pe = 1  <- request - xterm received a DECRQLP.
1765            Pe = 2  <- left button down.
1766            Pe = 3  <- left button up.
1767            Pe = 4  <- middle button down.
1768            Pe = 5  <- middle button up.
1769            Pe = 6  <- right button down.
1770            Pe = 7  <- right button up.
1771            Pe = 8  <- M4 button down.
1772            Pe = 9  <- M4 button up.
1773            Pe = 1 0  <- locator outside filter rectangle.
1774          The "button" parameter is a bitmask indicating which buttons
1775          are pressed:
1776            Pb = 0  <- no buttons down.
1777            Pb & 1  <- right button down.
1778            Pb & 2  <- middle button down.
1779            Pb & 4  <- left button down.
1780            Pb & 8  <- M4 button down.
1781          The "row" and "column" parameters are the coordinates of the
1782          locator position in the xterm window, encoded as ASCII
1783          decimal.
1784          The "page" parameter is not used by xterm.
1785
1786CSI Ps * |
1787          Select number of lines per screen (DECSNLS), VT420 and up.
1788
1789CSI # }   Pop video attributes from stack (XTPOPSGR), xterm.  Popping
1790          restores the video-attributes which were saved using XTPUSHSGR
1791          to their previous state.
1792
1793CSI Ps; Pf; Pb, |
1794          Assign Color (DECAC), VT525 only.
1795            Ps selects the color item
1796            Pf is the foreground color index 0..15
1797            Pb is the background color index 0..15
1798          Color items:
1799            Ps = 1  -> normal text
1800            Ps = 2  -> window frame
1801          xterm uses the SGR color palette with DECAC color item 1 to
1802          update the VT100 window colors, like OSC  1 0  and 1 1 .
1803
1804CSI Ps; Pf; Pb, }
1805          Alternate Text Color (DECATC), VT525 only.  This feature
1806          specifies the colors to use when DECSTGLT is selected to 1 or
1807          2.
1808            Ps selects attribute combinations
1809            Pf is the foreground color index 0..15
1810            Pb is the background color index 0..15
1811          Attribute combinations:
1812            Ps = 0  -> normal text
1813            Ps = 1  -> bold
1814            Ps = 2  -> reverse
1815            Ps = 3  -> underline
1816            Ps = 4  -> blink
1817            Ps = 5  -> bold reverse
1818            Ps = 6  -> bold underline
1819            Ps = 7  -> bold blink
1820            Ps = 8  -> reverse underline
1821            Ps = 9  -> reverse blink
1822            Ps = 1 0  -> underline blink
1823            Ps = 1 1  -> bold reverse underline
1824            Ps = 1 2  -> bold reverse blink
1825            Ps = 1 3  -> bold underline blink
1826            Ps = 1 4  -> reverse underline blink
1827            Ps = 1 5  -> bold reverse underline blink
1828
1829CSI Ps ' }
1830          Insert Ps Column(s) (default = 1) (DECIC), VT420 and up.
1831
1832CSI Ps $ }
1833          Select active status display (DECSASD), VT320 and up.
1834            Ps = 0  -> main (default)
1835            Ps = 1  -> status line
1836
1837CSI Ps ' ~
1838          Delete Ps Column(s) (default = 1) (DECDC), VT420 and up.
1839
1840CSI Ps $ ~
1841          Select status line type (DECSSDT), VT320 and up.
1842            Ps = 0  -> none
1843            Ps = 1  -> indicator (default)
1844            Ps = 2  -> host-writable.
1845
1846
1847Operating System Commands
1848
1849OSC Ps ; Pt BEL
1850
1851OSC Ps ; Pt ST
1852          Set Text Parameters, xterm.  Some control sequences return
1853          information:
1854          o   For colors and font, if Pt is a "?", the control sequence
1855              elicits a response which consists of the control sequence
1856              which would set the corresponding value.
1857          o   A few of these control sequences began with dtterm (codes
1858              0 , 1 , and 2 ).  Code 3  in dtterm sets the working
1859              directory for the next session.  XTerm does that with the
1860              spawn-new-terminal action.
1861
1862          XTerm accepts either BEL  or ST  for terminating OSC
1863          sequences, and when returning information, uses the same
1864          terminator used in a query.  While the latter is preferred,
1865          the former is supported for legacy applications:
1866          o   Although documented in the changes for X.V10R4 (December
1867              1986), BEL  as a string terminator dates from X11R4
1868              (December 1989).
1869          o   Since XFree86-3.1.2Ee (August 1996), xterm has accepted ST
1870              (the documented string terminator in ECMA-48).
1871
1872          Ps specifies the type of operation to perform:
1873            Ps = 0  -> Change Icon Name and Window Title to Pt.
1874            Ps = 1  -> Change Icon Name to Pt.
1875            Ps = 2  -> Change Window Title to Pt.
1876            Ps = 3  -> Set X property on top-level window.  Pt should be
1877          in the form "prop=value", or just "prop" to delete the
1878          property.
1879            Ps = 4 ; c ; spec -> Change Color Number c to the color
1880          specified by spec.
1881
1882          The spec can be a name or RGB specification as per
1883          XParseColor.  Any number of c/spec pairs may be given.  The
1884          color numbers correspond to the ANSI colors 0-7, their bright
1885          versions 8-15, and if supported, the remainder of the 88-color
1886          or 256-color table.
1887
1888          If a "?" is given rather than a name or RGB specification,
1889          xterm replies with a control sequence of the same form which
1890          can be used to set the corresponding color.  Because more than
1891          one pair of color number and specification can be given in one
1892          control sequence, xterm can make more than one reply.
1893
1894            Ps = 5 ; c ; spec -> Change Special Color Number c to the
1895          color specified by spec.
1896
1897          The spec parameter can be a name or RGB specification as per
1898          XParseColor.  Any number of c/spec pairs may be given.  The
1899          special colors can also be set by adding the maximum number of
1900          colors (e.g., 88 or 256) to these codes in an OSC 4  control:
1901
1902              Pc = 0  <- resource colorBD (BOLD).
1903              Pc = 1  <- resource colorUL (UNDERLINE).
1904              Pc = 2  <- resource colorBL (BLINK).
1905              Pc = 3  <- resource colorRV (REVERSE).
1906              Pc = 4  <- resource colorIT (ITALIC).
1907
1908            Ps = 6 ; c ; f -> Enable/disable Special Color Number c.
1909          The second parameter tells xterm to enable the corresponding
1910          color mode if nonzero, disable it if zero.  OSC 6  is the same
1911          as OSC 1 0 6 .
1912
1913          If no parameters are given, this control has no effect.
1914
1915          The 10 colors (below) which may be set or queried using 1 0
1916          through 1 9  are denoted dynamic colors, since the
1917          corresponding control sequences were the first means for
1918          setting xterm's colors dynamically, i.e., after it was
1919          started.  They are not the same as the ANSI colors (however,
1920          the dynamic text foreground and background colors are used
1921          when ANSI colors are reset using SGR 3 9  and 4 9 ,
1922          respectively).  These controls may be disabled using the
1923          allowColorOps resource.  At least one parameter is expected
1924          for Pt.  Each successive parameter changes the next color in
1925          the list.  The value of Ps tells the starting point in the
1926          list.  The colors are specified by name or RGB specification
1927          as per XParseColor.
1928
1929               Resource                 Description
1930               -----------------------+-----------------------------
1931               foreground             | VT100 text foreground color
1932               background             | VT100 text background color
1933               cursorColor            | text cursor color
1934               pointerColor           | pointer foreground color
1935               pointerColorBackground | pointer background
1936               (foreground)           | Tektronix foreground color
1937               (background)           | Tektronix background color
1938               highlightColor         | highlight background color
1939               (cursorColor)          | Tektronix cursor color
1940               highlightTextColor     | highlight foreground color
1941               -----------------------+-----------------------------
1942
1943
1944          The Tektronix colors are initially set from the VT100 colors,
1945          but after that can be set independently using these control
1946          sequences.
1947
1948          If a "?" is given rather than a name or RGB specification,
1949          xterm replies with a control sequence of the same form which
1950          can be used to set the corresponding dynamic color.  Because
1951          more than one pair of color number and specification can be
1952          given in one control sequence, xterm can make more than one
1953          reply.
1954
1955            Ps = 1 0  -> Change VT100 text foreground color to Pt.
1956            Ps = 1 1  -> Change VT100 text background color to Pt.
1957            Ps = 1 2  -> Change text cursor color to Pt.
1958            Ps = 1 3  -> Change pointer foreground color to Pt.
1959            Ps = 1 4  -> Change pointer background color to Pt.
1960            Ps = 1 5  -> Change Tektronix foreground color to Pt.
1961            Ps = 1 6  -> Change Tektronix background color to Pt.
1962            Ps = 1 7  -> Change highlight background color to Pt.
1963            Ps = 1 8  -> Change Tektronix cursor color to Pt.
1964            Ps = 1 9  -> Change highlight foreground color to Pt.
1965
1966            Ps = 2 2  -> Change pointer cursor shape to Pt.  The
1967          parameter Pt sets the pointerShape resource.  If Pt is empty,
1968          or does not match any of the standard names, n  uses the
1969          resource's default "xterm" shape.
1970
1971            Ps = 4 6  -> Change Log File to Pt.  The parameter Pt sets
1972          the logFile resource.  Logging is normally disabled by a
1973          compile-time option.
1974
1975            Ps = 5 0  -> Set Font to Pt.  These controls may be disabled
1976          using the allowFontOps resource.  If Pt begins with a "#",
1977          index in the font menu, relative (if the next character is a
1978          plus or minus sign) or absolute.  A number is expected but not
1979          required after the sign (the default is the current entry for
1980          relative, zero for absolute indexing).
1981
1982          The same rule (plus or minus sign, optional number) is used
1983          when querying the font.  The remainder of Pt is ignored.
1984
1985          A font can be specified after a "#" index expression, by
1986          adding a space and then the font specifier.
1987
1988          If the TrueType Fonts menu entry is set (the renderFont
1989          resource), then this control sets/queries the faceName
1990          resource.
1991
1992            Ps = 5 1  -> reserved for Emacs shell.
1993
1994            Ps = 5 2  -> Manipulate Selection Data.  These controls may
1995          be disabled using the allowWindowOps resource.  The parameter
1996          Pt is parsed as
1997               Pc ; Pd
1998
1999          The first, Pc, may contain zero or more characters from the
2000          set c , p , q , s , 0 , 1 , 2 , 3 , 4 , 5 , 6 , and 7 .  It is
2001          used to construct a list of selection parameters for
2002          clipboard, primary, secondary, select, or cut-buffers 0
2003          through 7 respectively, in the order given.  If the parameter
2004          is empty, xterm uses s 0 , to specify the configurable
2005          primary/clipboard selection and cut-buffer 0.
2006
2007          The second parameter, Pd, gives the selection data.  Normally
2008          this is a string encoded in base64 (RFC-4648).  The data
2009          becomes the new selection, which is then available for pasting
2010          by other applications.
2011
2012          If the second parameter is a ? , xterm replies to the host
2013          with the selection data encoded using the same protocol.  It
2014          uses the first selection found by asking successively for each
2015          item from the list of selection parameters.
2016
2017          If the second parameter is neither a base64 string nor ? ,
2018          then the selection is cleared.
2019
2020            Ps = 6 0  -> Query allowed features (XTQALLOWED).  XTerm
2021          replies with
2022
2023            OSC 6 0  ; Pt ST
2024
2025          where Pt is a comma-separated list of the allowed optional
2026          runtime features, i.e., zero or more of these resource names:
2027
2028            allowColorOps
2029            allowFontOps
2030            allowMouseOps
2031            allowPasteControls
2032            allowTcapOps
2033            allowTitleOps
2034            allowWindowOps
2035
2036            Ps = 6 1  -> Query disallowed features (XTQDISALLOWED).  The
2037          second parameter (i.e., the main feature) must be one of the
2038          resource names returned by OSC 6 0 .  XTerm replies with
2039
2040            OSC 6 1  ; Pt ST
2041
2042          where Pt is a comma-separated list of the optional runtime
2043          features which would be disallowed if the main feature is
2044          disabled.
2045
2046            Ps = 1 0 4 ; c -> Reset Color Number c.  It is reset to the
2047          color specified by the corresponding X resource.  Any number
2048          of c parameters may be given.  These parameters correspond to
2049          the ANSI colors 0-7, their bright versions 8-15, and if
2050          supported, the remainder of the 88-color or 256-color table.
2051          If no parameters are given, the entire table will be reset.
2052
2053            Ps = 1 0 5 ; c -> Reset Special Color Number c.  It is reset
2054          to the color specified by the corresponding X resource.  Any
2055          number of c parameters may be given.  These parameters
2056          correspond to the special colors which can be set using an OSC
2057          5  control (or by adding the maximum number of colors using an
2058          OSC 4  control).
2059
2060          If no parameters are given, all special colors will be reset.
2061
2062            Ps = 1 0 6 ; c ; f -> Enable/disable Special Color Number c.
2063          The second parameter tells xterm to enable the corresponding
2064          color mode if nonzero, disable it if zero.
2065
2066              Pc = 0  <- resource colorBDMode (BOLD).
2067              Pc = 1  <- resource colorULMode (UNDERLINE).
2068              Pc = 2  <- resource colorBLMode (BLINK).
2069              Pc = 3  <- resource colorRVMode (REVERSE).
2070              Pc = 4  <- resource colorITMode (ITALIC).
2071              Pc = 5  <- resource colorAttrMode (Override ANSI).
2072
2073          If no parameters are given, this control has no effect.
2074
2075          The dynamic colors can also be reset to their default
2076          (resource) values:
2077            Ps = 1 1 0  -> Reset VT100 text foreground color.
2078            Ps = 1 1 1  -> Reset VT100 text background color.
2079            Ps = 1 1 2  -> Reset text cursor color.
2080            Ps = 1 1 3  -> Reset pointer foreground color.
2081            Ps = 1 1 4  -> Reset pointer background color.
2082            Ps = 1 1 5  -> Reset Tektronix foreground color.
2083            Ps = 1 1 6  -> Reset Tektronix background color.
2084            Ps = 1 1 7  -> Reset highlight color.
2085            Ps = 1 1 8  -> Reset Tektronix cursor color.
2086            Ps = 1 1 9  -> Reset highlight foreground color.
2087
2088            Ps = I  ; c -> Set icon to file.  Sun shelltool, CDE dtterm.
2089          The file is expected to be XPM format, and uses the same
2090          search logic as the iconHint resource.
2091
2092            Ps = l  ; c -> Set window title.  Sun shelltool, CDE dtterm.
2093
2094            Ps = L  ; c -> Set icon label.  Sun shelltool, CDE dtterm.
2095
2096
2097Privacy Message
2098
2099PM Pt ST  xterm implements no PM  functions; Pt is ignored.  Pt need not
2100          be printable characters.
2101
2102
2103Special Keyboard Keys
2104
2105Terminal keyboards have two types of keys:
2106
2107o   ordinary keys, which you would use as data, e.g., in a text file,
2108    and
2109
2110o   special keys, which you would use to tell xterm to perform some
2111    action.
2112
2113XTerm detects all of these keys via X key-press and key-release events.
2114It uses the translations resource to decide what to do with these
2115events.
2116
2117o   Ordinary keys are handled with the insert-seven-bit action, or the
2118    insert-eight-bit action.
2119
2120o   Special keys may be handled with other resources.  However, xterm
2121    also has built-in logic to map commonly-used special keys into
2122    characters which your keypress sends to the application running in
2123    xterm.
2124
2125Special keyboard keys send control characters or escape sequences.  This
2126is a convention, making it convenient for applications to detect these
2127keys, rather than a standard.
2128
2129
2130Alt and Meta Keys
2131
2132Many keyboards have keys labeled "Alt".  Few have keys labeled "Meta".
2133However, xterm's default translations use the Meta modifier.  Common
2134keyboard configurations assign the Meta modifier to an "Alt" key.  By
2135using xmodmap one may have the modifier assigned to a different key, and
2136have "real" alt and meta keys.  Here is an example:
2137
2138     ! put meta on mod3 to distinguish it from alt
2139     keycode 64 = Alt_L
2140     clear mod1
2141     add mod1 = Alt_L
2142     keycode 115 = Meta_L
2143     clear mod3
2144     add mod3 = Meta_L
2145
2146
2147The metaSendsEscape resource (and altSendsEscape if altIsNotMeta is set)
2148can be used to control the way the Meta modifier applies to ordinary
2149keys unless the modifyOtherKeys resource is set:
2150
2151o   prefix a key with the ESC  character.
2152
2153o   shift the key from codes 0-127 to 128-255 by adding 128.
2154
2155When modifyOtherKeys is set, ordinary keys may be sent as escape
2156sequences:
2157
2158o   When modifyOtherKeys is set to 1, only the alt- and meta-modifiers
2159    apply.  For example, alt-Tab sends CSI 2 7 ; 3 ; 9 ~ (the second
2160    parameter is "3" for alt, and the third parameter is the ASCII value
2161    of tab, "9").
2162
2163o   When modifyOtherKeys is set to 2, all of the modifiers apply.  For
2164    example, shift-Tab sends CSI 2 7 ; 2 ; 9 ~ rather than CSI Z (the
2165    second parameter is "2" for shift).
2166
2167The formatOtherKeys resource tells n  to change the format of the escape
2168sequences sent when modifyOtherKeys applies.  When modifyOtherKeys is
2169set to 1, for example alt-Tab sends CSI 9 ; 3 u (changing the order of
2170parameters).  One drawback to this format is that applications may
2171confuse it with CSI u  (restore-cursor).
2172
2173The xterm FAQ sections
2174
2175   How can my program distinguish control-I from tab?
2176
2177   XTerm - "Other" Modified Keys
2178
2179go into greater detail on this topic.
2180
2181The table shows the result for a given character "x" with modifiers
2182according to the default translations with the resources set on or off.
2183This assumes altIsNotMeta is set:
2184
2185       key          altSendsEscape   metaSendsEscape   result
2186       -----------+----------------+-----------------+------------
2187       x          | off            | off             | x
2188       Meta-x     | off            | off             | shift
2189       Alt-x      | off            | off             | shift
2190       Alt+Meta-x | off            | off             | shift
2191       x          | ON             | off             | x
2192       Meta-x     | ON             | off             | shift
2193       Alt-x      | ON             | off             | ESC  x
2194       Alt+Meta-x | ON             | off             | ESC  shift
2195       x          | off            | ON              | x
2196       Meta-x     | off            | ON              | ESC  x
2197       Alt-x      | off            | ON              | shift
2198       Alt+Meta-x | off            | ON              | ESC  shift
2199       x          | ON             | ON              | x
2200       Meta-x     | ON             | ON              | ESC  x
2201       Alt-x      | ON             | ON              | ESC  x
2202       Alt+Meta-x | ON             | ON              | ESC  x
2203       -----------+----------------+-----------------+------------
2204
2205
2206
2207PC-Style Function Keys
2208
2209If xterm does minimal translation of the function keys, it usually does
2210this with a PC-style keyboard, so PC-style function keys result.  Sun
2211keyboards are similar to PC keyboards.  Both have cursor and scrolling
2212operations printed on the keypad, which duplicate the smaller cursor and
2213scrolling keypads.
2214
2215X does not predefine NumLock (used for VT220 keyboards) or Alt (used as
2216an extension for the Sun/PC keyboards) as modifiers.  These keys are
2217recognized as modifiers when enabled by the numLock resource, or by the
2218"DECSET 1 0 3 5 " control sequence.
2219
2220The cursor keys transmit the following escape sequences depending on the
2221mode specified via the DECCKM escape sequence.
2222
2223                  Key            Normal     Application
2224                  -------------+----------+-------------
2225                  Cursor Up    | CSI A    | SS3 A
2226                  Cursor Down  | CSI B    | SS3 B
2227                  Cursor Right | CSI C    | SS3 C
2228                  Cursor Left  | CSI D    | SS3 D
2229                  -------------+----------+-------------
2230
2231The home- and end-keys (unlike PageUp and other keys also on the 6-key
2232editing keypad) are considered "cursor keys" by xterm.  Their mode is
2233also controlled by the DECCKM escape sequence:
2234
2235                    Key        Normal     Application
2236                    ---------+----------+-------------
2237                    Home     | CSI H    | SS3 H
2238                    End      | CSI F    | SS3 F
2239                    ---------+----------+-------------
2240
2241
2242The application keypad transmits the following escape sequences
2243depending on the mode specified via the DECKPNM and DECKPAM escape
2244sequences.  Use the NumLock key to override the application mode.
2245
2246Not all keys are present on the Sun/PC keypad (e.g., PF1, Tab), but are
2247supported by the program.
2248
2249      Key              Numeric    Application   Terminfo   Termcap
2250      ---------------+----------+-------------+----------+----------
2251      Space          | SP       | SS3 SP      | -        | -
2252      Tab            | TAB      | SS3 I       | -        | -
2253      Enter          | CR       | SS3 M       | kent     | @8
2254      PF1            | SS3 P    | SS3 P       | kf1      | k1
2255      PF2            | SS3 Q    | SS3 Q       | kf2      | k2
2256      PF3            | SS3 R    | SS3 R       | kf3      | k3
2257      PF4            | SS3 S    | SS3 S       | kf4      | k4
2258      * (multiply)   | *        | SS3 j       | -        | -
2259      + (add)        | +        | SS3 k       | -        | -
2260      , (comma)      | ,        | SS3 l       | -        | -
2261      - (minus)      | -        | SS3 m       | -        | -
2262      . (Delete)     | .        | CSI 3 ~     | -        | -
2263      / (divide)     | /        | SS3 o       | -        | -
2264      0 (Insert)     | 0        | CSI 2 ~     | -        | -
2265      1 (End)        | 1        | SS3 F       | kc1      | K4
2266      2 (DownArrow)  | 2        | CSI B       | -        | -
2267      3 (PageDown)   | 3        | CSI 6 ~     | kc3      | K5
2268      4 (LeftArrow)  | 4        | CSI D       | -        | -
2269      5 (Begin)      | 5        | CSI E       | kb2      | K2
2270      6 (RightArrow) | 6        | CSI C       | -        | -
2271      7 (Home)       | 7        | SS3 H       | ka1      | K1
2272      8 (UpArrow)    | 8        | CSI A       | -        | -
2273      9 (PageUp)     | 9        | CSI 5 ~     | ka3      | K3
2274      = (equal)      | =        | SS3 X       | -        | -
2275      ---------------+----------+-------------+----------+----------
2276
2277They also provide 12 function keys, as well as a few other special-
2278purpose keys:
2279
2280                       Key        Escape Sequence
2281                       ---------+-----------------
2282                       F1       | SS3 P
2283                       F2       | SS3 Q
2284                       F3       | SS3 R
2285                       F4       | SS3 S
2286                       F5       | CSI 1 5 ~
2287                       F6       | CSI 1 7 ~
2288                       F7       | CSI 1 8 ~
2289                       F8       | CSI 1 9 ~
2290                       F9       | CSI 2 0 ~
2291                       F10      | CSI 2 1 ~
2292                       F11      | CSI 2 3 ~
2293                       F12      | CSI 2 4 ~
2294                       ---------+-----------------
2295
2296
2297Note that F1 through F4 are prefixed with SS3 , while the other keys are
2298prefixed with CSI .  Older versions of xterm implement different escape
2299sequences for F1 through F4, with a CSI  prefix.  These can be activated
2300by setting the oldXtermFKeys resource.  However, since they do not
2301correspond to any hardware terminal, they have been deprecated.  (The
2302DEC VT220 reserves F1 through F5 for local functions such as Setup).
2303
2304                       Key        Escape Sequence
2305                       ---------+-----------------
2306                       F1       | CSI 1 1 ~
2307                       F2       | CSI 1 2 ~
2308                       F3       | CSI 1 3 ~
2309                       F4       | CSI 1 4 ~
2310                       ---------+-----------------
2311
2312In normal mode, i.e., a Sun/PC keyboard when the sunKeyboard resource is
2313false (and none of the other keyboard resources such as oldXtermFKeys
2314resource is set), xterm encodes function key modifiers as parameters
2315appended before the final character of the control sequence.  As a
2316special case, the SS3  sent before F1 through F4 is altered to CSI  when
2317sending a function key modifier as a parameter.
2318
2319                    Code     Modifiers
2320                  ---------+---------------------------
2321                     2     | Shift
2322                     3     | Alt
2323                     4     | Shift + Alt
2324                     5     | Control
2325                     6     | Shift + Control
2326                     7     | Alt + Control
2327                     8     | Shift + Alt + Control
2328                     9     | Meta
2329                     10    | Meta + Shift
2330                     11    | Meta + Alt
2331                     12    | Meta + Alt + Shift
2332                     13    | Meta + Ctrl
2333                     14    | Meta + Ctrl + Shift
2334                     15    | Meta + Ctrl + Alt
2335                     16    | Meta + Ctrl + Alt + Shift
2336                  ---------+---------------------------
2337
2338For example, shift-F5 would be sent as CSI 1 5 ; 2 ~
2339
2340If the alwaysUseMods resource is set, the Meta modifier also is
2341recognized, making parameters 9 through 16.
2342
2343The codes used for the PC-style function keys were inspired by a feature
2344of the VT510, referred to in its reference manual as DECFNK.  In the
2345DECFNK scheme, codes 2-8 identify modifiers for function-keys and
2346cursor-, editing-keypad keys.  Unlike xterm, the VT510 limits the
2347modifiers which can be used with cursor- and editing-keypad keys.
2348Although the name "DECFNK" implies that it is a mode, the VT510 manual
2349mentions it only as a feature, which (like xterm) interacts with the
2350DECUDK feature.  Unlike xterm, VT510/VT520 provide an extension to
2351DECUDK (DECPFK and DECPAK) which apparently was the reason for the
2352feature in those terminals, i.e., for identifying a programmable key
2353rather than making it simple for applications to obtain modifier
2354information.  It is not described in the related VT520 manual.  Neither
2355manual was readily available at the time the feature was added to xterm.
2356
2357On the other hand, the VT510 and VT520 reference manuals do document a
2358related feature.  That is its emulation of the SCO console, which is
2359similar to the "xterm-sco" terminal description.  The SCO console
2360function-keys are less useful to applications developers than the
2361approach used by xterm because
2362
2363o   the relationship between modifiers and the characters sent by
2364    function-keys is not readily apparent, and
2365
2366o   the scheme is not extensible, i.e., it is an ad hoc assignment
2367    limited to two modifiers (shift and control).
2368
2369
2370VT220-Style Function Keys
2371
2372However, xterm is most useful as a DEC VT102 or VT220 emulator.  Set the
2373sunKeyboard resource to true to force a Sun/PC keyboard to act like a
2374VT220 keyboard.
2375
2376The VT102/VT220 application keypad transmits unique escape sequences in
2377application mode, which are distinct from the cursor and scrolling
2378keypad:
2379
2380            Key            Numeric    Application   VT100?
2381            -------------+----------+-------------+----------
2382            Space        | SP       | SS3 SP      | no
2383            Tab          | TAB      | SS3 I       | no
2384            Enter        | CR       | SS3 M       | yes
2385            PF1          | SS3 P    | SS3 P       | yes
2386            PF2          | SS3 Q    | SS3 Q       | yes
2387            PF3          | SS3 R    | SS3 R       | yes
2388            PF4          | SS3 S    | SS3 S       | yes
2389            * (multiply) | *        | SS3 j       | no
2390            + (add)      | +        | SS3 k       | no
2391            , (comma)    | ,        | SS3 l       | yes
2392            - (minus)    | -        | SS3 m       | yes
2393            . (period)   | .        | SS3 n       | yes
2394            / (divide)   | /        | SS3 o       | no
2395            0            | 0        | SS3 p       | yes
2396            1            | 1        | SS3 q       | yes
2397            2            | 2        | SS3 r       | yes
2398            3            | 3        | SS3 s       | yes
2399            4            | 4        | SS3 t       | yes
2400            5            | 5        | SS3 u       | yes
2401            6            | 6        | SS3 v       | yes
2402            7            | 7        | SS3 w       | yes
2403            8            | 8        | SS3 x       | yes
2404            9            | 9        | SS3 y       | yes
2405            = (equal)    | =        | SS3 X       | no
2406            -------------+----------+-------------+----------
2407
2408
2409The VT100/VT220 keypad did not have all of those keys.  They were
2410implemented in xterm in X11R1 (1987), defining a mapping of all X11 keys
2411which might be provided on a keypad.  For instance, a Sun4/II type-4
2412keyboard provided "=" (equal), "/" (divide), and "*" (multiply).
2413
2414While the VT420 provided the same keypad, the VT520 used a PC-keyboard.
2415Because that keyboard's keypad lacks the "," (comma), it was not
2416possible to use EDT's delete-character function with the keypad.  XTerm
2417solves that problem for the VT220-keyboard configuration by mapping
2418
2419  Ctrl +  to ,  and
2420  Ctrl -  to -
2421
2422The VT220 provides a 6-key editing keypad, which is analogous to that on
2423the PC keyboard.  It is not affected by DECCKM or DECKPNM/DECKPAM:
2424
2425                   Key        Normal     Application
2426                   ---------+----------+-------------
2427                   Insert   | CSI 2 ~  | CSI 2 ~
2428                   Delete   | CSI 3 ~  | CSI 3 ~
2429                   Home     | CSI 1 ~  | CSI 1 ~
2430                   End      | CSI 4 ~  | CSI 4 ~
2431                   PageUp   | CSI 5 ~  | CSI 5 ~
2432                   PageDown | CSI 6 ~  | CSI 6 ~
2433                   ---------+----------+-------------
2434
2435
2436The VT220 provides 8 additional function keys.  With a Sun/PC keyboard,
2437access these keys by Control/F1 for F13, etc.
2438
2439                       Key        Escape Sequence
2440                       ---------+-----------------
2441                       F13      | CSI 2 5 ~
2442                       F14      | CSI 2 6 ~
2443                       F15      | CSI 2 8 ~
2444                       F16      | CSI 2 9 ~
2445                       F17      | CSI 3 1 ~
2446                       F18      | CSI 3 2 ~
2447                       F19      | CSI 3 3 ~
2448                       F20      | CSI 3 4 ~
2449                       ---------+-----------------
2450
2451
2452
2453VT52-Style Function Keys
2454
2455A VT52 does not have function keys, but it does have a numeric keypad
2456and cursor keys.  They differ from the other emulations by the prefix.
2457Also, the cursor keys do not change:
2458
2459                   Key            Normal/Application
2460                   -------------+--------------------
2461                   Cursor Up    | ESC A
2462                   Cursor Down  | ESC B
2463                   Cursor Right | ESC C
2464                   Cursor Left  | ESC D
2465                   -------------+--------------------
2466
2467The keypad is similar:
2468
2469            Key            Numeric    Application   VT52?
2470            -------------+----------+-------------+----------
2471            Space        | SP       | ESC ? SP    | no
2472            Tab          | TAB      | ESC ? I     | no
2473            Enter        | CR       | ESC ? M     | no
2474            PF1          | ESC P    | ESC P       | yes
2475            PF2          | ESC Q    | ESC Q       | yes
2476            PF3          | ESC R    | ESC R       | yes
2477            PF4          | ESC S    | ESC S       | no
2478            * (multiply) | *        | ESC ? j     | no
2479            + (add)      | +        | ESC ? k     | no
2480            , (comma)    | ,        | ESC ? l     | no
2481            - (minus)    | -        | ESC ? m     | no
2482            . (period)   | .        | ESC ? n     | yes
2483            / (divide)   | /        | ESC ? o     | no
2484            0            | 0        | ESC ? p     | yes
2485            1            | 1        | ESC ? q     | yes
2486            2            | 2        | ESC ? r     | yes
2487            3            | 3        | ESC ? s     | yes
2488            4            | 4        | ESC ? t     | yes
2489            5            | 5        | ESC ? u     | yes
2490            6            | 6        | ESC ? v     | yes
2491            7            | 7        | ESC ? w     | yes
2492            8            | 8        | ESC ? x     | yes
2493            9            | 9        | ESC ? y     | yes
2494            = (equal)    | =        | ESC ? X     | no
2495            -------------+----------+-------------+----------
2496
2497
2498
2499Sun-Style Function Keys
2500
2501The xterm program provides support for Sun keyboards more directly, by a
2502menu toggle that causes it to send Sun-style function key codes rather
2503than VT220.  Note, however, that the sun and VT100 emulations are not
2504really compatible.  For example, their wrap-margin behavior differs.
2505
2506Only function keys are altered; keypad and cursor keys are the same.
2507The emulation responds identically.  See the xterm-sun terminfo entry
2508for details.
2509
2510
2511HP-Style Function Keys
2512
2513Similarly, xterm can be compiled to support HP keyboards.  See the
2514xterm-hp terminfo entry for details.
2515
2516
2517Non-Function Keys
2518
2519On a DEC terminal keyboard, some of the keys which one would expect to
2520see labeled as function keys had special names.  The keys actually send
2521character sequences as if they were the expected function keys, but the
2522special names are used in documentation.  Because other keyboards may
2523use those names, xterm maps the X key symbols which have the
2524corresponding names into the character sequences which the original DEC
2525keyboard would send.
2526
2527These mappings are used for the DEC (VT220) and other keyboards:
2528
2529     Label           DEC          SUN            HP         SCO
2530     --------------+------------+--------------+----------+----------
2531     Up            | SS3 A      | SS3 A        | ESC A    | CSI A
2532     Down          | SS3 B      | SS3 B        | ESC B    | CSI B
2533     Right         | SS3 C      | SS3 C        | ESC C    | CSI C
2534     Left          | SS3 D      | SS3 D        | ESC D    | CSI D
2535     Clear         | -          | -            | ESC J    | -
2536     Find          | CSI 1 ~    | CSI 1 z      | ESC h    | -
2537     Insert        | CSI 2 ~    | CSI 2 z      | ESC Q    | CSI L
2538     Delete        | CSI 3 ~    | CSI 3 z      | ESC P    | -
2539     Keypad Insert | CSI 2 ~    | CSI 2 z      | ESC Q    | CSI L
2540     Keypad Delete | CSI 3 ~    | CSI 3 z      | ESC P    | -
2541     Remove        | CSI 3 ~    | CSI 3 z      | ESC P    | -
2542     Select        | CSI 4 ~    | CSI 4 z      | ESC F    | -
2543     Prior         | CSI 5 ~    | CSI 2 1 6 z  | ESC T    | CSI I
2544     Next          | CSI 6 ~    | CSI 2 2 2 z  | ESC S    | CSI G
2545     Help          | CSI 2 8 ~  | CSI 1 9 6 z  | -        | -
2546     Menu          | CSI 2 9 ~  | CSI 1 9 7 z  | -        | -
2547     Home          | -          | CSI 2 1 4 z  | ESC h    | CSI H
2548     End           | -          | CSI 2 2 0 z  | ESC F    | CSI F
2549     Begin         | -          | CSI 2 1 8 z  | -        | CSI E
2550     --------------+------------+--------------+----------+----------
2551
2552
2553
2554The Alternate Screen Buffer
2555
2556XTerm maintains two screen buffers.  The Normal Screen Buffer allows you
2557to scroll back to view saved lines of output up to the maximum set by
2558the saveLines resource.  The Alternate Screen Buffer is exactly as large
2559as the display, contains no additional saved lines.  When the Alternate
2560Screen Buffer is active, you cannot scroll back to view saved lines.
2561XTerm provides control sequences and menu entries for switching between
2562the two.
2563
2564Most full-screen applications use terminfo or termcap to obtain strings
2565used to start/stop full-screen mode, i.e., smcup and rmcup for terminfo,
2566or the corresponding ti and te for termcap.  The titeInhibit resource
2567removes the ti and te strings from the TERMCAP string which is set in
2568the environment for some platforms.  That is not done when xterm is
2569built with terminfo libraries because terminfo does not provide the
2570whole text of the termcap data in one piece.  It would not work for
2571terminfo anyway, since terminfo data is not passed in environment
2572variables; setting an environment variable in this manner would have no
2573effect on the application's ability to switch between Normal and
2574Alternate Screen buffers.  Instead, the newer private mode controls
2575(such as 1 0 4 9 ) for switching between Normal and Alternate Screen
2576buffers simply disable the switching.  They add other features such as
2577clearing the display for the same reason: to make the details of
2578switching independent of the application that requests the switch.
2579
2580
2581Bracketed Paste Mode
2582
2583When bracketed paste mode is set, pasted text is bracketed with control
2584sequences so that the program can differentiate pasted text from typed-
2585in text.  When bracketed paste mode is set, the program will receive:
2586   ESC [ 2 0 0 ~ ,
2587followed by the pasted text, followed by
2588   ESC [ 2 0 1 ~ .
2589For background and discussion, see the FAQ:
2590
2591  XTerm - bracketed-paste
2592
2593
2594
2595Readline Modes
2596
2597Several modes provide support for mouse button events in readline.
2598Bracketed paste is one of these readline modes, but is used more widely.
2599
2600Some assumptions (particular mouse buttons) and limitations (the mouse
2601is clicked on the current row on the screen) apply:
2602
26032 0 0 1   If mouse button 1 is used to end or extend a selection (the
2604          select-end action), and if the cursor position is on the same
2605          row as the mouse-click, send left/right cursor control
2606          sequences to the host to adjust the cursor position to match
2607          the mouse click.
2608
26092 0 0 2   When pasting text (the insert-selection action which is
2610          normally bound to mouse button 2), if mouse protocol is not
2611          enabled, and if the cursor position is on the same row as the
2612          mouse-click, send left/right cursor control sequences to the
2613          host to adjust the cursor position to match the mouse click.
2614
26152 0 0 3   If mouse button 3 is double-clicked when ending or extending a
2616          selection, (the select-end action), and if the cursor position
2617          is on the same line as the mouse-click:
2618
2619          o   Send left/right cursor control sequences to the host to
2620              adjust the cursor position to match the mouse click.
2621
2622          o   In addition to the same row, the selection may be part of
2623              a wrapped line as in other xterm selections (see the
2624              Selection Functions section in the manual page).
2625
2626          o   After adjusting the cursor position, xterm sends erase-
2627              characters (one for each character in the selection) to
2628              tell the host to delete the selected text.
2629
26302 0 0 5   When writing a selection to the host (i.e., pasting text),
2631          escape each character with the literal-next (Ctrl-V)
2632          character.
2633
26342 0 0 6   Normally when xterm writes selections to the host, it
2635          translates newlines to carriage returns.  This mode disables
2636          the translation, passing newlines literally.
2637
2638
2639Title Modes
2640
2641The window- and icon-labels can be set or queried using control
2642sequences.  As a VT220-emulator, xterm "should" limit the character
2643encoding for the corresponding strings to ISO-8859-1.  Indeed, it used
2644to be the case (and was documented) that window titles had to be
2645ISO-8859-1.  This is no longer the case.  However, there are many
2646applications which still assume that titles are set using ISO-8859-1.
2647So that is the default behavior.
2648
2649If xterm is running with UTF-8 encoding, it is possible to use window-
2650and icon-labels encoded using UTF-8.  That is because the underlying X
2651libraries (and many, but not all) window managers support this feature.
2652
2653The utf8Title X resource setting tells xterm to disable a reconversion
2654of the title string back to ISO-8859-1, allowing the title strings to be
2655interpreted as UTF-8.  The same feature can be enabled using the title
2656mode control sequence described in this summary.
2657
2658Separate from the ability to set the titles, xterm provides the ability
2659to query the titles, returning them either in ISO-8859-1 or UTF-8.  This
2660choice is available only while xterm is using UTF-8 encoding.
2661
2662Finally, the characters sent to, or returned by a title control are less
2663constrained than the rest of the control sequences.  To make them more
2664manageable (and constrained), for use in shell scripts, xterm has an
2665optional feature which decodes the string from hexadecimal (for setting
2666titles) or for encoding the title into hexadecimal when querying the
2667value.
2668
2669
2670Mouse Tracking
2671
2672The VT widget can be set to send the mouse position and other
2673information on button presses.  These modes are typically used by
2674editors and other full-screen applications that want to make use of the
2675mouse.
2676
2677There are two sets of mutually exclusive modes:
2678
2679o   mouse protocol
2680
2681o   protocol encoding
2682
2683The mouse protocols include DEC Locator mode, enabled by the DECELR CSI
2684Ps ; Ps '  z control sequence, and is not described here (control
2685sequences are summarized above).  The remaining five modes of the mouse
2686protocols are each enabled (or disabled) by a different parameter in the
2687"DECSET CSI ? Pm h " or "DECRST CSI ? Pm l " control sequence.
2688
2689Manifest constants for the parameter values are defined in xcharmouse.h
2690as follows:
2691
2692     #define SET_X10_MOUSE               9
2693     #define SET_VT200_MOUSE             1000
2694     #define SET_VT200_HIGHLIGHT_MOUSE   1001
2695     #define SET_BTN_EVENT_MOUSE         1002
2696     #define SET_ANY_EVENT_MOUSE         1003
2697
2698     #define SET_FOCUS_EVENT_MOUSE       1004
2699
2700     #define SET_ALTERNATE_SCROLL        1007
2701
2702     #define SET_EXT_MODE_MOUSE          1005
2703     #define SET_SGR_EXT_MODE_MOUSE      1006
2704     #define SET_URXVT_EXT_MODE_MOUSE    1015
2705     #define SET_PIXEL_POSITION_MOUSE    1016
2706
2707The motion reporting modes are strictly xterm extensions, and are not
2708part of any standard, though they are analogous to the DEC VT200 DECELR
2709locator reports.
2710
2711Normally, parameters (such as pointer position and button number) for
2712all mouse tracking escape sequences generated by xterm encode numeric
2713parameters in a single character as value+32.  For example, !  specifies
2714the value 1.  The upper left character position on the terminal is
2715denoted as 1,1.  This scheme dates back to X10, though the normal mouse-
2716tracking (from X11) is more elaborate.
2717
2718
2719X10 compatibility mode
2720
2721X10 compatibility mode sends an escape sequence only on button press,
2722encoding the location and the mouse button pressed.  It is enabled by
2723specifying parameter 9 to DECSET.  On button press, xterm sends CSI M
2724CbCxCy (6 characters).
2725
2726o   Cb is button-1, where button is 1, 2 or 3.
2727
2728o   Cx and Cy are the x and y coordinates of the mouse when the button
2729    was pressed.
2730
2731
2732Normal tracking mode
2733
2734Normal tracking mode sends an escape sequence on both button press and
2735release.  Modifier key (shift, ctrl, meta) information is also sent.  It
2736is enabled by specifying parameter 1000 to DECSET.  On button press or
2737release, xterm sends CSI M CbCxCy.
2738
2739o   The low two bits of Cb encode button information:
2740
2741              0=MB1 pressed,
2742              1=MB2 pressed,
2743              2=MB3 pressed, and
2744              3=release.
2745
2746o   The next three bits encode the modifiers which were down when the
2747    button was pressed and are added together:
2748
2749              4=Shift,
2750              8=Meta, and
2751              16=Control.
2752
2753    The shift and control modifiers are normally irrelevant because
2754    xterm uses the control modifier with mouse for popup menus, and the
2755    shift modifier is used in the default translations for button
2756    events.
2757
2758    There is no predefined meta modifier.  XTerm checks first if the
2759    keysyms listed in the predefined modifiers include Meta_L or Meta_R.
2760    If found, xterm uses that modifier for meta.  Next, it tries Alt_L
2761    or Alt_R.  If none of those are found, xterm uses the mod1 modifier,
2762    This is not necessarily the "Meta" key according to xmodmap(1).
2763
2764o   Cx and Cy are the x and y coordinates of the mouse event, encoded as
2765    in X10 mode.
2766
2767
2768Wheel mice
2769
2770Wheel mice may return buttons 4 and 5.  Those buttons are represented by
2771the same event codes as buttons 1 and 2 respectively, except that 64 is
2772added to the event code.  Release events for the wheel buttons are not
2773reported.
2774
2775By default, the wheel mouse events (buttons 4 and 5) are translated to
2776scroll-back and scroll-forw actions, respectively.  Those actions
2777normally scroll the whole window, as if the scrollbar was used.
2778
2779However if Alternate Scroll mode is set, then cursor up/down controls
2780are sent when the terminal is displaying the Alternate Screen Buffer.
2781The initial state of Alternate Scroll mode is set using the
2782alternateScroll resource.
2783
2784
2785Other buttons
2786
2787Some wheel mice can send additional button events, e.g., by tilting the
2788scroll wheel left and right.
2789
2790Additional buttons are encoded like the wheel mice,
2791
2792o   by adding 64 (for buttons 6 and 7), or
2793
2794o   by adding 128 (for buttons 8 through 11).
2795
2796Past button 11, the encoding is ambiguous because the same code may
2797correspond to different button/modifier combinations.
2798
2799It is not possible to use these buttons (6-11) in xterm's translations
2800resource because their names are not in the X Toolkit's symbol table.
2801However, applications can check for the reports, e.g., button 7 (left)
2802and button 6 (right) with a Logitech mouse.
2803
2804
2805Highlight tracking
2806
2807Mouse highlight tracking notifies a program of a button press, receives
2808a range of lines from the program, highlights the region covered by the
2809mouse within that range until button release, and then sends the program
2810the release coordinates.  It is enabled by specifying parameter 1001 to
2811DECSET.  Highlighting is performed only for button 1, though other
2812button events can be received.
2813
2814Warning: this mode requires a cooperating program, else xterm will hang.
2815
2816On button press, the same information as for normal tracking is
2817generated; xterm then waits for the program to send mouse tracking
2818information.  All X events are ignored until the proper escape sequence
2819is received from the pty:
2820CSI Ps ; Ps ; Ps ; Ps ; Ps T
2821
2822The parameters are func, startx, starty, firstrow, and lastrow:
2823
2824o   func is non-zero to initiate highlight tracking and zero to abort.
2825
2826o   startx and starty give the starting x and y location for the
2827    highlighted region.
2828
2829o   The ending location tracks the mouse, but will never be above row
2830    firstrow and will always be above row lastrow.  (The top of the
2831    screen is row 1.)
2832
2833When the button is released, xterm reports the ending position one of
2834two ways:
2835
2836o   if the start and end coordinates are the same locations:
2837
2838    CSI t CxCy
2839
2840o   otherwise:
2841
2842    CSI T CxCyCxCyCxCy
2843
2844The parameters are startx, starty, endx, endy, mousex, and mousey:
2845
2846o   startx, starty, endx, and endy give the starting and ending
2847    character positions of the region.
2848
2849o   mousex and mousey give the location of the mouse at button up, which
2850    may not be over a character.
2851
2852
2853Button-event tracking
2854
2855Button-event tracking is essentially the same as normal tracking, but
2856xterm also reports button-motion events.  Motion events are reported
2857only if the mouse pointer has moved to a different character cell.  It
2858is enabled by specifying parameter 1002 to DECSET.  On button press or
2859release, xterm sends the same codes used by normal tracking mode.
2860
2861o   On button-motion events, xterm adds 32 to the event code (the third
2862    character, Cb).
2863
2864o   The other bits of the event code specify button and modifier keys as
2865    in normal mode.  For example, motion into cell x,y with button 1
2866    down is reported as
2867
2868    CSI M @ CxCy
2869
2870    ( @  = 32 + 0 (button 1) + 32 (motion indicator) ).  Similarly,
2871    motion with button 3 down is reported as
2872
2873    CSI M B CxCy
2874
2875    ( B  = 32 + 2 (button 3) + 32 (motion indicator) ).
2876
2877
2878Any-event tracking
2879
2880Any-event mode is the same as button-event mode, except that all motion
2881events are reported, even if no mouse button is down.  It is enabled by
2882specifying 1003 to DECSET.
2883
2884
2885FocusIn/FocusOut
2886
2887FocusIn/FocusOut can be combined with any of the mouse events since it
2888uses a different protocol.  When set, it causes xterm to send CSI I
2889when the terminal gains focus, and CSI O  when it loses focus.
2890
2891
2892Extended coordinates
2893
2894The original X10 mouse protocol limits the Cx and Cy ordinates to 223
2895(=255 - 32).  XTerm supports more than one scheme for extending this
2896range, by changing the protocol encoding:
2897
2898UTF-8 (1005)
2899          This enables UTF-8 encoding for Cx and Cy under all tracking
2900          modes, expanding the maximum encodable position from 223 to
2901          2015.  For positions less than 95, the resulting output is
2902          identical under both modes.  Under extended mouse mode,
2903          positions greater than 95 generate "extra" bytes which will
2904          confuse applications which do not treat their input as a UTF-8
2905          stream.  Likewise, Cb will be UTF-8 encoded, to reduce
2906          confusion with wheel mouse events.
2907
2908          Under normal mouse mode, positions outside (160,94) result in
2909          byte pairs which can be interpreted as a single UTF-8
2910          character; applications which do treat their input as UTF-8
2911          will almost certainly be confused unless extended mouse mode
2912          is active.
2913
2914          This scheme has the drawback that the encoded coordinates will
2915          not pass through luit(1) unchanged, e.g., for locales using
2916          non-UTF-8 encoding.
2917
2918SGR (1006)
2919          The normal mouse response is altered to use
2920
2921          o   CSI < followed by semicolon-separated
2922
2923          o   encoded button value,
2924
2925          o   Px and Py ordinates and
2926
2927          o   a final character which is M  for button press and m  for
2928              button release.
2929
2930          The encoded button value in this case does not add 32 since
2931          that was useful only in the X10 scheme for ensuring that the
2932          byte containing the button value is a printable code.
2933
2934          o   The modifiers are encoded in the same way.
2935
2936          o   A different final character is used for button release to
2937              resolve the X10 ambiguity regarding which button was
2938              released.
2939
2940          The highlight tracking responses are also modified to an SGR-
2941          like format, using the same SGR-style scheme and button-
2942          encodings.
2943
2944URXVT (1015)
2945          The normal mouse response is altered to use
2946
2947          o   CSI followed by semicolon-separated
2948
2949          o   encoded button value,
2950
2951          o   the Px and Py ordinates and final character M .
2952
2953          This uses the same button encoding as X10, but printing it as
2954          a decimal integer rather than as a single byte.
2955
2956          However, CSI M  can be mistaken for DL (delete lines), while
2957          the highlight tracking CSI T  can be mistaken for SD (scroll
2958          down), and the Window manipulation controls.  For these
2959          reasons, the 1015 control is not recommended; it is not an
2960          improvement over 1006.
2961
2962SGR-Pixels (1016)
2963          Use the same mouse response format as the 1006 control, but
2964          report position in pixels rather than character cells.
2965
2966
2967Graphics
2968
2969
2970Sixel Graphics
2971
2972If xterm is configured as VT240, VT241, VT330, VT340 or VT382 using the
2973decTerminalID or decGraphicsID resource, it supports Sixel Graphics
2974controls, a paletted bitmap graphics system using sets of six vertical
2975pixels as the basic element.
2976
2977CSI Ps c  Send Device Attributes (Primary DA), DEC graphics terminals,
2978          xterm.  xterm responds to Send Device Attributes (Primary DA)
2979          with these additional codes:
2980            Ps = 4  -> Sixel graphics.
2981
2982CSI ? Pm h
2983          Set Mode (with corresponding Reset Mode CSI ? Pm l ):
2984            Ps = 8 0  -> Sixel Display Mode (DECSDM), VT330, VT340,
2985          VT382.
2986            Ps = 1 0 7 0  -> use private color registers for each
2987          graphic, xterm.
2988            Ps = 8 4 5 2  -> Sixel scrolling leaves cursor to right of
2989          graphic, RLogin, xterm.
2990
2991DCS Pa ; Pb ; Ph q  Ps..Ps ST
2992          Send SIXEL image, DEC graphics terminals, VT330, VT340, VT382.
2993          See:
2994
2995             VT330/VT340 Programmer Reference Manual Volume 2:
2996             Graphics Programming
2997             Chapter 14 Graphics Programming
2998
2999          The sixel data device control string has three positional
3000          parameters, following the q  with sixel data.
3001            Pa -> pixel aspect ratio
3002            Pb -> background color option
3003            Ph -> horizontal grid size (ignored).
3004            Ps -> sixel data
3005
3006
3007ReGIS Graphics
3008
3009If xterm is configured as VT125, VT240, VT241, VT330 or VT340 using the
3010decTerminalID or decGraphicsID resource, it supports Remote Graphic
3011Instruction Set, a graphics description language.
3012
3013CSI Ps c  Send Device Attributes (Primary DA), DEC graphics terminals,
3014          xterm.  xterm responds to Send Device Attributes (Primary DA)
3015          with these additional codes:
3016            Ps = 3  -> ReGIS graphics.
3017
3018CSI ? Pm h
3019          Set Mode, xterm.  xterm has these additional private Set Mode
3020          values:
3021            Ps = 1 0 7 0  -> use private color registers for each
3022          graphic.
3023
3024DCS Pm p Pr..Pr ST
3025          Enter or exit ReGIS, VT300, xterm.  See:
3026
3027             VT330/VT340 Programmer Reference Manual Volume 2:
3028             Graphics Programming
3029             Chapter 1 Introduction to ReGIS
3030
3031          The ReGIS data device control string has one positional
3032          parameter with four possible values:
3033            Pm = 0 -> resume command, use fullscreen mode.
3034            Pm = 1 -> start new command, use fullscreen mode.
3035            Pm = 2 -> resume command, use command display mode.
3036            Pm = 3 -> start new command, use command display mode.
3037
3038A few of the VT330/VT340 private modes conflict with xterm.  Codes 4 0
3039to 4 7  were first used by xterm in X10R4 (December 1986).  While X11R1
3040xterm dropped codes 4 1  and 4 2 , the remaining ones are still used.
3041The VT330/VT340 introduced in April 1987 uses 4 4  to 4 7  for color
3042graphics printing controls.  When configured for ReGIS, xterm uses the
3043VT330/VT340 interpretation of these private modes.
3044
3045
3046Non-VT100 Modes
3047
3048
3049Tektronix 4014 Mode
3050
3051Most of these sequences are standard Tektronix 4014 control sequences.
3052Graph mode supports the 12-bit addressing of the Tektronix 4014.  The
3053major features missing are the write-through and defocused modes.  This
3054document does not describe the commands used in the various Tektronix
3055plotting modes but does describe the commands to switch modes.
3056
3057Some of the sequences are specific to xterm.  The Tektronix emulation
3058was added in X10R4 (1986).  The VT240, introduced two years earlier,
3059also supported Tektronix 4010/4014.  Unlike xterm, the VT240
3060documentation implies (there is an obvious error in section 6.9
3061"Entering and Exiting 4010/4014 Mode") that exiting back to ANSI mode is
3062done by resetting private mode 3 8  (DECTEK) rather than ESC ETX .  A
3063real Tektronix 4014 would not respond to either.
3064
3065BEL       Bell (Ctrl-G).
3066
3067BS        Backspace (Ctrl-H).
3068
3069TAB       Horizontal Tab (Ctrl-I).
3070
3071LF        Line Feed or New Line (Ctrl-J).
3072
3073VT        Cursor up (Ctrl-K).
3074
3075FF        Form Feed or New Page (Ctrl-L).
3076
3077CR        Carriage Return (Ctrl-M).
3078
3079ESC ETX   Switch to VT100 Mode (ESC  Ctrl-C).
3080
3081ESC ENQ   Return Terminal Status (ESC  Ctrl-E).
3082
3083ESC FF    PAGE (Clear Screen) (ESC  Ctrl-L).
3084
3085ESC SO    Begin 4015 APL mode (ESC  Ctrl-N).  This is ignored by xterm.
3086
3087ESC SI    End 4015 APL mode (ESC  Ctrl-O).  This is ignored by xterm.
3088
3089ESC ETB   COPY (Save Tektronix Codes to file COPYyyyy-mm-dd.hh:mm:ss).
3090            ETB  (end transmission block) is the same as Ctrl-W.
3091
3092ESC CAN   Bypass Condition (ESC  Ctrl-X).
3093
3094ESC SUB   GIN mode (ESC  Ctrl-Z).
3095
3096ESC FS    Special Point Plot Mode (ESC  Ctrl-\).
3097
3098ESC 8     Select Large Character Set.
3099
3100ESC 9     Select #2 Character Set.
3101
3102ESC :     Select #3 Character Set.
3103
3104ESC ;     Select Small Character Set.
3105
3106OSC Ps ; Pt BEL
3107          Set Text Parameters of VT window.
3108            Ps = 0  -> Change Icon Name and Window Title to Pt.
3109            Ps = 1  -> Change Icon Name to Pt.
3110            Ps = 2  -> Change Window Title to Pt.
3111            Ps = 4 6  -> Change Log File to Pt.  This is normally
3112          disabled by a compile-time option.
3113
3114ESC `     Normal Z Axis and Normal (solid) Vectors.
3115
3116ESC a     Normal Z Axis and Dotted Line Vectors.
3117
3118ESC b     Normal Z Axis and Dot-Dashed Vectors.
3119
3120ESC c     Normal Z Axis and Short-Dashed Vectors.
3121
3122ESC d     Normal Z Axis and Long-Dashed Vectors.
3123
3124ESC h     Defocused Z Axis and Normal (solid) Vectors.
3125
3126ESC i     Defocused Z Axis and Dotted Line Vectors.
3127
3128ESC j     Defocused Z Axis and Dot-Dashed Vectors.
3129
3130ESC k     Defocused Z Axis and Short-Dashed Vectors.
3131
3132ESC l     Defocused Z Axis and Long-Dashed Vectors.
3133
3134ESC p     Write-Thru Mode and Normal (solid) Vectors.
3135
3136ESC q     Write-Thru Mode and Dotted Line Vectors.
3137
3138ESC r     Write-Thru Mode and Dot-Dashed Vectors.
3139
3140ESC s     Write-Thru Mode and Short-Dashed Vectors.
3141
3142ESC t     Write-Thru Mode and Long-Dashed Vectors.
3143
3144FS        Point Plot Mode (Ctrl-\).
3145
3146GS        Graph Mode (Ctrl-]).
3147
3148RS        Incremental Plot Mode (Ctrl-^ ).
3149
3150US        Alpha Mode (Ctrl-_).
3151
3152
3153VT52 Mode
3154
3155Parameters for cursor movement are at the end of the ESC Y  escape
3156sequence.  Each ordinate is encoded in a single character as value+32.
3157For example, !  is 1.  The screen coordinate system is 0-based.
3158
3159ESC <     Exit VT52 mode (Enter VT100 mode).
3160
3161ESC =     Enter alternate keypad mode.
3162
3163ESC >     Exit alternate keypad mode.
3164
3165ESC A     Cursor up.
3166
3167ESC B     Cursor down.
3168
3169ESC C     Cursor right.
3170
3171ESC D     Cursor left.
3172
3173ESC F     Enter graphics mode.
3174
3175ESC G     Exit graphics mode.
3176
3177ESC H     Move the cursor to the home position.
3178
3179ESC I     Reverse line feed.
3180
3181ESC J     Erase from the cursor to the end of the screen.
3182
3183ESC K     Erase from the cursor to the end of the line.
3184
3185ESC Y Ps Ps
3186          Move the cursor to given row and column.
3187
3188ESC Z     Identify.
3189            -> ESC  /  Z  ("I am a VT52.").
3190
3191
3192Further reading
3193
3194
3195Technical manuals
3196
3197Manuals for hardware terminals are more readily available than
3198similarly-detailed documentation for terminal emulators such as aixterm,
3199shelltool, dtterm.
3200
3201However long, the technical manuals have problems:
3202
3203o   DEC's manuals did not provide a comprehensive comparison of the
3204    features in different model.
3205
3206    Host Interface Functions Checklist by Peter Sichel (January 12,
3207    1994) is helpful.  This spreadsheet is useful for noting which model
3208    introduced a given feature (although there are a few apparent errors
3209    such as the DECRQSS feature cited for VT320 whereas the technical
3210    manual omits it).
3211
3212o   Sometimes the manuals disagree.  For example, DEC's standard
3213    document (DEC STD 070) for terminals says that DECSCL performs a
3214    soft reset (DECSTR), while the VT420 manual says it does a hard
3215    reset (RIS).
3216
3217o   Sometimes the manuals are simply incorrect.  For example, testing a
3218    DEC VT420 in 1996 showed that the documented code for a valid or
3219    invalid response to DECRQSS was reversed.
3220
3221    The VT420 test results were incorporated into the vttest program.
3222    At the time, DEC STD 070 was not available, but it also agrees with
3223    vttest.  Later, documentation for the DEC VT525 was shown to have
3224    the same flaw.
3225
3226o   The VT330/VT340 reference manual for graphics programming documents
3227    sixel graphics in some detail in chapter 14.  Overlooked in the
3228    first edition, the second edition mentions Sixel Scrolling.  The
3229    VT382 Kanji and Thai manuals provide less information, about sixel
3230    graphics, but do mention DECSDM.  They differ in their comment about
3231    the private mode DECSDM (CSI ? 8 0 h ), which each manual agrees
3232    should set the Sixel Scrolling feature.  The VT330/VT340 graphics
3233    programming manual (second edition, March 1988) says
3234
3235        When sixel display mode is set, the Sixel Scrolling feature is
3236        enabled.
3237        When sixel display mode is reset, the Sixel Scrolling feature is
3238        disabled.
3239
3240    while the VT382 Kanji manual (page 6-6, undated) says
3241
3242        Disable sixel scroll
3243
3244    and the VT382 Thai manual (page C-30, August 1989) says
3245
3246        No Sixel scrolling
3247
3248    The standard (DEC STD 070) in chapter 9 (August 3, 1990) states on
3249    page 17 that video devices will scroll when advancing the Sixel
3250    active position past the bottom margin, but on page 19, in the
3251    section on deviations, states that VT125 and VT240 did not scroll in
3252    this situation.  The standard does not mention VT330/VT340 or VT382.
3253    Nor does it document DECSDM.
3254
3255o   Not all details are clear even in DEC STD 070 (which is more than
3256    twice the length of the VT520 programmer's reference manual, and
3257    almost three times longer than the VT420 reference manual).
3258    However, as an internal standards document, DEC STD 070 is more
3259    likely to describe the actual behavior of DEC's terminals than the
3260    more polished user's guides.
3261
3262That said, here are technical manuals which have been used in developing
3263xterm.  Not all were available initially.  In August 1996 for instance,
3264the technical references were limited to EK-VT220-HR-002 and EK-
3265VT420-UG.002.  Shortly after, Richard Shuford sent a copy of EK-VT3XX-
3266TP-001.  Still later (beginning in 2003), Paul Williams' vt100.net site
3267provided EK-VT102-UG-003, EK-VT220-RM-002, EK-VT420-RM-002, EK-VT520-RM
3268A01, EK-VT100-TM-003, and EK-VT102-UG-003.  In addition, several
3269documents were found on the bitsavers site.
3270
3271o   DECscope User's Manual.
3272    Digital Equipment Corporation (EK-VT5X-OP-001 1975).
3273
3274o   VT100 Series Video Terminal Technical Manual.
3275    Digital Equipment Corporation (EK-VT100-TM-003, July 1982).
3276
3277o   VT100 User Guide.
3278    Digital Equipment Corporation (EK-VT100-UG-003, June 1981).
3279
3280o   VT102 User Guide.
3281    Digital Equipment Corporation (EK-VT102-UG-003, February 1982).
3282
3283o   VT220 Programmer Pocket Guide.
3284    Digital Equipment Corporation (EK-VT220-HR-002, July 1984).
3285
3286o   VT220 Programmer Reference Manual.
3287    Digital Equipment Corporation (EK-VT220-RM-002, August 1984).
3288
3289o   VT240 Programmer Reference Manual.
3290    Digital Equipment Corporation (EK-VT240-RM-002, October 1984).
3291
3292o   VT330/VT340 Programmer Reference Manual
3293    Volume 1: Text Programming.
3294    Digital Equipment Corporation (EK-VT3XX-TP-001, March 1987).
3295
3296o   VT330/VT340 Programmer Reference Manual
3297    Volume 2: Graphics Programming.
3298    Digital Equipment Corporation (EK-VT3XX-GP-001, March 1987).
3299
3300o   VT330/VT340 Programmer Reference Manual
3301    Volume 2: Graphics Programming.
3302    Digital Equipment Corporation (EK-VT3XX-GP-002, May 1988).
3303
3304o   VT382 Kanji Display Terminal
3305    Programmer Reference Manual.
3306    Digital Equipment Corporation (EK-VT382-RM-001, undated).
3307
3308o   VT382 Thai Display Terminal
3309    Installing and Using Manual.
3310    Digital Equipment Corporation (EK-VT38T-UG-001, August 1989).
3311
3312o   Installing and Using
3313    The VT420 Video Terminal
3314    (North American Model).
3315    Digital Equipment Corporation (EK-VT420-UG.002, February 1990).
3316
3317o   VT420 Programmer Reference Manual.
3318    Digital Equipment Corporation (EK-VT420-RM-002, February 1992).
3319
3320o   VT510 Video Terminal
3321    Programmer Information.
3322    Digital Equipment Corporation (EK-VT510-RM B01, November 1993).
3323
3324o   VT520/VT525 Video Terminal
3325    Programmer Information.
3326    Digital Equipment Corporation (EK-VT520-RM A01, July 1994).
3327
3328o   Digital ANSI-Compliant Printing Protocol
3329    Level 2 Programming Reference Manual
3330    Digital Equipment Corporation (EK-PPLV2-PM B01, August 1994).
3331
3332o   Disk Operating System
3333    DOS 2.00
3334    Microsoft, Inc.
3335    First edition, January 1983.
3336
3337o   4014 and 4014-1 Computer Display Terminal
3338    User's Manual.
3339    Tektronix, Inc.  (070-1647-00, November 1979).
3340
3341
3342Standards
3343
3344The DEC terminal family (VT100 through VT525) is upward-compatible,
3345using standards plus extensions, e.g., "private modes".  Not all
3346commonly-used features are standard.  For example, scrolling regions are
3347not found in ECMA-48.  On the other hand, ECMA-48 was not intended to be
3348all-encompassing.  Quoting from the second edition:
3349
3350    Full conformance to a standard means that all its requirements are
3351    met.  For such conformance to be unique the standard must contain no
3352    options.  This is typically the case for hardware standards, for
3353    instance Standard ECMA-10 for data interchange on punched tapes.
3354
3355    This Standard ECMA-48 is of a different nature and as a result, it
3356    is only practicable to envisage limited conformance to it, as
3357    defined hereunder.
3358
3359    This Standard addresses a whole class of devices which can vary
3360    greatly from each other depending on the application for which a
3361    device has been specifically designed.  Obviously, a product which
3362    implements all facilities described in this standard - thus being in
3363    "full conformance" with it - whilst theoretically possible, would be
3364    technically and economically unthinkable.
3365
3366Again, it is possible to find discrepancies in the standards:
3367
3368o   The printed ECMA-48 5th edition (1991) and the first PDF produced
3369    for that edition (April 1998) state that SD (scroll down) ends with
3370    05/14, i.e., ^ , which disagrees with DEC's VT420 hardware
3371    implementation and DEC's manuals which use 05/04 T .  (A few other
3372    terminals such as AT&T 5620 and IBM 5151 also used 05/04, but the
3373    documentation and dates are lacking).
3374
3375    ECMA created a new PDF in April 2003 which changed that detail to
3376    use T , and later in 2008 provided PDFs of the earlier editions
3377    which used T .
3378
3379o   The first edition of ECMA-48 has not been available, to compare.  As
3380    of September 2021, ECMA's website provides a copy of ECMA-46 in its
3381    place.
3382
3383    Earlier versions of ISO 6429 have never been available.  The first
3384    three editions of ISO 6429 were issued in 1983, 1988, and 1992.
3385
3386o   ANSI X3.64-1979 does not list color as a feature of the SGR sequence
3387    (page 49).
3388
3389    In Appendix A, it mentions ECMA-48:
3390
3391        (8) This document represents a coordinated effort to develop a
3392        single technical standard in the United States and Europe (see
3393        ECMA-48 standard entitled Additional Controls for Character
3394        Imaging Input/Output Devices).
3395
3396    Appendix H clarifies the relationship between these documents
3397    somewhat though it confuses the first two editions of ECMA-48.  The
3398    typo for "work" versus "owkr" appears in the original document:
3399
3400        ANSI X3.64-1979, and ECMA-48, Additional Controls for Character-
3401        Imaging I/O Devices, were developed in parallel, with close
3402        liaison.  ISO DP 6429, Additional Control Functions for
3403        Character-Imaging Devices, was developed as a synthesis of X3.64
3404        and ECMA-48.  During this process, some control functions as
3405        well as additional selective parameters were added.  Except for
3406        point 1 below, X3.64 is a subset of ISO 6429.  Although the two
3407        standards use different language, the intent is that the subset
3408        is technically identical.  X3.64 was balloted and forwarded
3409        prior to the final resolution of ISO 6429 and does not
3410        incorporate the owkr of IS0/TC97/SC2 in completing ISO 6429.
3411        Revision of X3.64 will attempt to incorporate those elements and
3412        assumptions of X3.64.
3413
3414    ANSI X3.64 goes on to say that the SGR codes 8, 30-47 are in ISO
3415    6429.  It includes 38 and 39, but omits 48 and 49.  At the time, ISO
3416    6429's first edition was still four years in the future.  The writer
3417    probably was referring to the ongoing process of making ECMA-48
3418    second edition into the ISO standard.
3419
3420o   The VT320, VT420, VT520 manuals claim that DECSCL does a hard reset
3421    (RIS).
3422
3423    Both the VT220 manual and DEC STD 070 (which documents levels 1-4 in
3424    detail) state that it is a soft reset, e.g., DECSTR.
3425
3426Here are the relevant standards:
3427
3428o   Additional Controls for Use with American National Standard Code for
3429    Information Interchange, ANSI X3.64-1979
3430    FIPS Publication 86. July 18, 1979.
3431    American National Standards Institute, Inc.
3432
3433o   ECMA-35: Character Code Structure and Extension Techniques
3434    (6th Edition, December 1994).
3435
3436o   ECMA-43: 8-bit Coded Character Set Structure and Rules
3437    (3rd Edition, December 1991).
3438
3439o   ECMA-48: Control Functions for Coded Character Sets
3440    (5th Edition, June 1991).
3441
3442o   DEC STD 070 Video Systems Reference Manual.
3443    Digital Equipment Corporation (A-MN-ELSM070-00-0000 Rev H, December
3444    3, 1991).
3445
3446
3447Miscellaneous
3448
3449A few hardware terminals survived into the 1990s only as terminal
3450emulators.  Documentation for these and other terminal emulators which
3451have influenced xterm are generally available only in less-accessible
3452and less-detailed manual pages.
3453
3454o   XTerm supports control sequences for manipulating its window which
3455    were implemented by Sun's shelltool program.  This was part of
3456    SunView (SunOS 3.0, 1986).  The change-notes for xterm's resize
3457    program in X10.4 (1986) mention its use of these "Sun tty emulation
3458    escape sequences" for resizing the window.  The X10.4 xterm program
3459    recognized these sequences for resizing the terminal, except for the
3460    iconify/deiconify pair.  SunView also introduced the SIGWINCH
3461    signal, used by the X10.4 xterm and mentioned in its CHANGES file:
3462
3463        The window size is passed to the operating system via TIOCSWINSZ
3464        (4.3) or TIOCSSIZE (sun).  A SIGWINCH signal is sent if the
3465        vtXXX window is resized.
3466
3467    While support for the Sun control-sequences remained in resize, the
3468    next release of xterm (X11R1 in 1987) omitted the code for
3469    interpreting them.
3470
3471    Later, the SunView program was adapted for the OPEN LOOK environment
3472    introduced 1988-1990.
3473
3474    Still later, in 1995, OPEN LOOK was abandoned in favor of CDE.  The
3475    CDE terminal emulator dtterm implemented those controls, with a
3476    couple of additions.
3477
3478    Starting in July 1996, xterm re-implemented those control sequences
3479    (based on the dtterm manual pages) and further extended the group of
3480    window controls.
3481
3482    There were two sets of controls (CSI Ps [ ; Pm ; Pm ] t , and OSC Ps
3483    text ST ) implemented by shelltool, documented in appendix E of both
3484    PHIGS Programming Manual (1992), and the unpublished X Window System
3485    User's Guide (OPEN LOOK Edition) (1995).  The CDE program kept
3486    those, and added a few new ones.
3487
3488    Code         Sun   CDE   XTerm   Description
3489    -----------+-----+-----+-------+---------------------------------
3490    CSI 1 t    | yes | yes |  yes  | de-iconify
3491    CSI 2 t    | yes | yes |  yes  | iconify
3492    CSI 3 t    | yes | yes |  yes  | move window to pixel-position
3493    CSI 4 t    | yes | yes |  yes  | resize window in pixels
3494    CSI 5 t    | yes | yes |  yes  | raise window to front of stack
3495    CSI 6 t    | yes | yes |  yes  | raise window to back of stack
3496    CSI 7 t    | yes | yes |  yes  | refresh window
3497    CSI 8 t    | yes | yes |  yes  | resize window in chars
3498    CSI 9 t    |  -  |  -  |  yes  | maximize/unmaximize window
3499    CSI 1 0 t  |  -  |  -  |  yes  | to/from full-screen
3500    CSI 1 1 t  | yes | yes |  yes  | report if window is iconified
3501    CSI 1 2 t  |  -  |  -  |   -   | -
3502    CSI 1 3 t  | yes | yes |  yes  | report window position
3503    CSI 1 4 t  | yes | yes |  yes  | report window size in pixels
3504    CSI 1 5 t  |  -  |  -  |  yes  | report screen size in pixels
3505    CSI 1 6 t  |  -  |  -  |  yes  | report character cell in pixels
3506    CSI 1 7 t  |  -  |  -  |   -   | -
3507    CSI 1 8 t  | yes | yes |  yes  | report window size in chars
3508    CSI 1 9 t  |  -  |  -  |  yes  | report screen size in chars
3509    CSI 2 0 t  |  -  | yes |  yes  | report icon label
3510    CSI 2 1 t  |  -  | yes |  yes  | report window title
3511    CSI 2 2 t  |  -  |  -  |  yes  | save window/icon title
3512    CSI 2 3 t  |  -  |  -  |  yes  | restore window/icon title
3513    CSI 2 4 t  |  -  |  -  |  yes  | resize window (DECSLPP)
3514    OSC 0 ST   |  -  | yes |  yes  | set window and icon title
3515    OSC 1 ST   |  -  | yes |  yes  | set icon label
3516    OSC 2 ST   |  -  | yes |  yes  | set window title
3517    OSC 3 ST   |  -  | n/a |  yes  | set X server property
3518    OSC I ST   | yes | yes |  yes  | set icon to file
3519    OSC l ST   | yes | yes |  yes  | set window title
3520    OSC L ST   | yes | yes |  yes  | set icon label
3521    -----------+-----+-----+-------+---------------------------------
3522
3523    Besides the Sun-derived OSC controls for setting window title and
3524    icon label, dtterm also supported the xterm controls for the same
3525    feature.
3526
3527    The CDE source was unavailable for inspection until 2012, so that
3528    clarification of the details of the window operations relied upon
3529    vttest.
3530
3531o   The SCOSC/SCORC control sequences for saving/restoring the cursor
3532    and for saving/restoring "DEC Private Mode Values" (XTSAVE and
3533    XTRESTORE) may appear to be related (since the "save" controls both
3534    end with s ), but that is coincidental.  The latter was introduced
3535    in X10.4 (December 1986):
3536
3537        Most Dec Private mode settings can be saved away internally
3538        using \E[?ns, where n is the same number to set or reset the Dec
3539        Private mode.  The mode can be restored using \E[?nr.  This can
3540        be used in termcap for vi(1), for example, to turn off saving of
3541        lines, but restore whatever the original state was on exit.
3542
3543    while  the  SCOSC/SCORC  pair  was  added  in  1995  by XFree86 (and
3544    documented long afterwards).
3545
3546    The SCO  ANSI  console  terminal  descriptions  did  not  use  these
3547    controls  (they  used the VT100-compatible SC/RC pair).  SCOSC/SCORC
3548    were an artifact of DOS 2.00 (January 1983), by Microsoft and  later
3549    supported by SCO and other vendors.
3550
3551    The  SCOSC/SCORC pair is considered a private mode because the final
3552    characters (s  and u ) fall in the range from "`" to "~" (octal 0140
3553    to  octal 0176).  Other private control sequences can be constructed
3554    by using octets 074 to 077 (characters "<", "=", ">", or "?") at the
3555    beginning  of  the  parameter  string.   The  XTSAVE  and  XTRESTORE
3556    controls use "?") in this manner.
3557
3558    Because  the  XTSAVE  and  XTRESTORE  controls  are  private,  other
3559    terminals  may  behave differently.  For example, DEC (a contributor
3560    to the early xterm as well as a manufacturer of terminals)  used  an
3561    incompatible  private control in one of its terminals more than five
3562    years later (for the VT420 PCTerm, announced in February 1992).
3563
3564    In that model of the VT420, CSI ? Pm;  Pc  r  selects  the  PC  TERM
3565    emulation  mode.  When this mode is enabled, the keyboard sends scan
3566    codes rather than characters (analogous to X keyboard events).   The
3567    first  parameter of this private control enables or disables PC TERM
3568    mode, while the second selects a character set.  An ambiguity arises
3569    if an application omits the second parameter.  In that special case,
3570    it cannot be distinguished from XTRESTORE.  DEC did  not  take  this
3571    into account when designing the feature.
3572
3573    If  there  were  potential  users, xterm could accommodate this by a
3574    resource setting.  In retrospect (thirty years  later),  there  have
3575    been  no  uses  of  PC TERM, while the XTRESTORE feature is still in
3576    use.
3577
3578o   The aixterm manual page gives the format of the control sequence for
3579    foreground  and  background  colors  8-15, but does not specify what
3580    those colors are.  That is implied by the description's  mention  of
3581    HFT:
3582
3583        The aixterm command provides a standard terminal type for
3584        programs that do not interact directly with Enhanced X-Windows.
3585        This command provides an emulation for a VT102 terminal or a
3586        high function terminal (HFT).  The VT102 mode is activated by
3587        the -v flag.
3588
3589    Unlike xterm, there are no resource names for the 16 colors, leaving
3590    the reader to assume that the mapping is  hard-coded.   The  control
3591    sequences  for  colors 8-15 are not specified by ECMA-48, but rather
3592    (as done in other instances by xterm) chosen to  not  conflict  with
3593    current or future standards.
3594