-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconsole_codes.4.html
1721 lines (1255 loc) · 65.8 KB
/
console_codes.4.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>console_codes(4) — Linux manual pages</title>
<link rel="stylesheet" href="../stylesheet/manpages.css" type="text/css" />
<link rel="home" href="../index.html" title="console_codes(4) — Linux manual pages" />
<script type="text/javascript" src="../stylesheet/manpages.js" xml:space="preserve">
</script>
<link rel="icon" href="../stylesheet/icon.gif" type="image/gif" />
</head>
<body onload="javascript:init()">
<div class="refentry" title="console_codes(4) — Linux manual pages">
<a id="console-codes.4" name="console-codes.4" shape="rect"> </a>
<div class="titlepage"> </div>
<div class="refnamediv">
<h2>Name</h2>
<p>console_codes — Linux console escape and control
sequences</p>
</div>
<div class="refsect1" title="DESCRIPTION">
<a id="console-codes-4_sect1" name="console-codes-4_sect1" shape="rect"> </a>
<h2>DESCRIPTION</h2>
<p>The Linux console implements a large subset of the VT102
and ECMA-48/ISO 6429/ANSI X3.64 terminal controls, plus
certain private-mode sequences for changing the color
palette, character-set mapping, etc. In the tabular
descriptions below, the second column gives ECMA-48 or DEC
mnemonics (the latter if prefixed with DEC) for the given
function. Sequences without a mnemonic are neither ECMA-48
nor VT102.</p>
<p>After all the normal output processing has been done, and
a stream of characters arrives at the console driver for
actual printing, the first thing that happens is a
translation from the code used for processing to the code
used for printing.</p>
<p>If the console is in UTF-8 mode, then the incoming bytes
are first assembled into 16-bit Unicode codes. Otherwise each
byte is transformed according to the current mapping table
(which translates it to a Unicode value). See the
<span class="emphasis"><em>Character Sets</em></span> section
below for discussion.</p>
<p>In the normal case, the Unicode value is converted to a
font index, and this is stored in video memory, so that the
corresponding glyph (as found in video ROM) appears on the
screen. Note that the use of Unicode (and the design of the
PC hardware) allows us to use 512 different glyphs
simultaneously.</p>
<p>If the current Unicode value is a control character, or we
are currently processing an escape sequence, the value will
treated specially. Instead of being turned into a font index
and rendered as a glyph, it may trigger cursor movement or
other control functions. See the <span class="emphasis"><em>Linux Console Controls</em></span> section
below for discussion.</p>
<p>It is generally not good practice to hard-wire terminal
controls into programs. Linux supports a <span class="citerefentry"><span class="refentrytitle">terminfo</span>(5)</span> database of
terminal capabilities. Rather than emitting console escape
sequences by hand, you will almost always want to use a
terminfo-aware screen library or utility such as <span class="citerefentry"><span class="refentrytitle">ncurses</span>(3)</span>, <span class="citerefentry"><span class="refentrytitle">tput</span>(1)</span>, or <a class="link" href="../htmlman1/reset.1.html" target="_top" shape="rect"><span class="citerefentry"><span class="refentrytitle">reset</span>(1)</span></a>.</p>
<div class="refsect2" title="Linux Console Controls">
<a id="console-codes-4_sect2" name="console-codes-4_sect2" shape="rect"> </a>
<h3>Linux Console Controls</h3>
<p>This section describes all the control characters and
escape sequences that invoke special functions (i.e.,
anything other than writing a glyph at the current cursor
location) on the Linux console.</p>
<p><span class="emphasis"><em>Control
characters</em></span></p>
<p>A character is a control character if (before
transformation according to the mapping table) it has one
of the 14 codes 00 (NUL), 07 (BEL), 08 (BS), 09 (HT), 0a
(LF), 0b (VT), 0c (FF), 0d (CR), 0e (SO), 0f (SI), 18
(CAN), 1a (SUB), 1b (ESC), 7f (DEL). One can set a "display
control characters" mode (see below), and allow 07, 09, 0b,
18, 1a, 7f to be displayed as glyphs. On the other hand, in
UTF-8 mode all codes 00-1f are regarded as control
characters, regardless of any "display control characters"
mode.</p>
<p>If we have a control character, it is acted upon
immediately and then discarded (even in the middle of an
escape sequence) and the escape sequence continues with the
next character. (However, ESC starts a new escape sequence,
possibly aborting a previous unfinished one, and CAN and
SUB abort any escape sequence.) The recognized control
characters are BEL, BS, HT, LF, VT, FF, CR, SO, SI, CAN,
SUB, ESC, DEL, CSI. They do what one would expect:</p>
<p>BEL (0x07, <code class="literal">^G</code>) beeps;</p>
<p>BS (0x08, <code class="literal">^H</code>) backspaces
one column (but not past the beginning of the line);</p>
<p>HT (0x09, <code class="literal">^I</code>) goes to the
next tab stop or to the end of the line if there is no
earlier tab stop;</p>
<p>LF (0x0A, <code class="literal">^J</code>), VT (0x0B,
<code class="literal">^K</code>) and FF (0x0C, <code class="literal">^L</code>) all give a linefeed, and if LF/NL
(new-line mode) is set also a carriage return;</p>
<p>CR (0x0D, <code class="literal">^M</code>) gives a
carriage return;</p>
<p>SO (0x0E, <code class="literal">^N</code>) activates the
G1 character set;</p>
<p>SI (0x0F, <code class="literal">^O</code>) activates the
G0 character set;</p>
<p>CAN (0x18, <code class="literal">^X</code>) and SUB
(0x1A, <code class="literal">^Z</code>) interrupt escape
sequences;</p>
<p>ESC (0x1B, <code class="literal">^[</code>) starts an
escape sequence;</p>
<p>DEL (0x7F) is ignored;</p>
<p>CSI (0x9B) is equivalent to ESC [.</p>
<p><span class="emphasis"><em>ESC- but not
CSI-sequences</em></span></p>
<div class="informaltable">
<table style="border-collapse: collapse;">
<colgroup span="1">
<col span="1" />
<col span="1" />
<col span="1" />
</colgroup>
<tbody>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC c</td>
<td style="" align="left" rowspan="1" colspan="1">RIS</td>
<td style="" align="left" rowspan="1" colspan="1">Reset.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC D</td>
<td style="" align="left" rowspan="1" colspan="1">IND</td>
<td style="" align="left" rowspan="1" colspan="1">Linefeed.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC E</td>
<td style="" align="left" rowspan="1" colspan="1">NEL</td>
<td style="" align="left" rowspan="1" colspan="1">Newline.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC H</td>
<td style="" align="left" rowspan="1" colspan="1">HTS</td>
<td style="" align="left" rowspan="1" colspan="1">Set tab stop at current
column.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC M</td>
<td style="" align="left" rowspan="1" colspan="1">RI</td>
<td style="" align="left" rowspan="1" colspan="1">Reverse linefeed.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC Z</td>
<td style="" align="left" rowspan="1" colspan="1">DECID</td>
<td style="" align="left" rowspan="1" colspan="1">DEC private
identification. The kernel returns the string ESC [
? 6 c, claiming that it is a VT102.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC 7</td>
<td style="" align="left" rowspan="1" colspan="1">DECSC</td>
<td style="" align="left" rowspan="1" colspan="1">Save current state
(cursor coordinates, attributes, character sets
pointed at by G0, G1).</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC 8</td>
<td style="" align="left" rowspan="1" colspan="1">DECRC</td>
<td style="" align="left" rowspan="1" colspan="1">Restore state most
recently saved by ESC 7.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC [</td>
<td style="" align="left" rowspan="1" colspan="1">CSI</td>
<td style="" align="left" rowspan="1" colspan="1">Control sequence
introducer</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC %</td>
<td style="" align="left" rowspan="1" colspan="1"> </td>
<td style="" align="left" rowspan="1" colspan="1">Start sequence selecting
character set</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC % @</td>
<td style="" align="left" rowspan="1" colspan="1"> </td>
<td style="" align="left" rowspan="1" colspan="1"> Select
default (ISO 646 / ISO 8859-1)</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC % G</td>
<td style="" align="left" rowspan="1" colspan="1"> </td>
<td style="" align="left" rowspan="1" colspan="1"> Select
UTF-8</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC % 8</td>
<td style="" align="left" rowspan="1" colspan="1"> </td>
<td style="" align="left" rowspan="1" colspan="1"> Select
UTF-8 (obsolete)</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC # 8</td>
<td style="" align="left" rowspan="1" colspan="1">DECALN</td>
<td style="" align="left" rowspan="1" colspan="1">DEC screen alignment test
− fill screen with E's.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC (</td>
<td style="" align="left" rowspan="1" colspan="1"> </td>
<td style="" align="left" rowspan="1" colspan="1">Start sequence defining
G0 character set</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC ( B</td>
<td style="" align="left" rowspan="1" colspan="1"> </td>
<td style="" align="left" rowspan="1" colspan="1"> Select
default (ISO 8859-1 mapping)</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC ( 0</td>
<td style="" align="left" rowspan="1" colspan="1"> </td>
<td style="" align="left" rowspan="1" colspan="1"> Select
VT100 graphics mapping</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC ( U</td>
<td style="" align="left" rowspan="1" colspan="1"> </td>
<td style="" align="left" rowspan="1" colspan="1"> Select
null mapping − straight to character ROM</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC ( K</td>
<td style="" align="left" rowspan="1" colspan="1"> </td>
<td style="" align="left" rowspan="1" colspan="1"> Select
user mapping − the map that is loaded by
the utility <span class="citerefentry"><span class="refentrytitle">mapscrn</span>(8)</span>.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC )</td>
<td style="" align="left" rowspan="1" colspan="1"> </td>
<td style="" align="left" rowspan="1" colspan="1">Start sequence defining
G1 (followed by one of B, 0, U, K, as above).</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC ></td>
<td style="" align="left" rowspan="1" colspan="1">DECPNM</td>
<td style="" align="left" rowspan="1" colspan="1">Set numeric keypad
mode</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC =</td>
<td style="" align="left" rowspan="1" colspan="1">DECPAM</td>
<td style="" align="left" rowspan="1" colspan="1">Set application keypad
mode</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">ESC ]</td>
<td style="" align="left" rowspan="1" colspan="1">OSC</td>
<td style="" align="left" rowspan="1" colspan="1">(Should be: Operating
system command) ESC ] P <code class="function">nrrggbb</code>: set palette, with
parameter given in 7 hexadecimal digits after the
final P :-(. Here <em class="replaceable"><code>n</code></em> is the color
(0-15), and <code class="function">rrggbb</code>
indicates the red/green/blue values (0-255). ESC ]
R: reset palette</td>
</tr>
</tbody>
</table>
</div>
<p><span class="emphasis"><em>ECMA-48 CSI
sequences</em></span></p>
<p>CSI (or ESC [) is followed by a sequence of parameters,
at most NPAR (16), that are decimal numbers separated by
semicolons. An empty or absent parameter is taken to be 0.
The sequence of parameters may be preceded by a single
question mark.</p>
<p>However, after CSI [ (or ESC [ [) a single character is
read and this entire sequence is ignored. (The idea is to
ignore an echoed function key.)</p>
<p>The action of a CSI sequence is determined by its final
character.</p>
<div class="informaltable">
<table style="border-collapse: collapse;">
<colgroup span="1">
<col span="1" />
<col span="1" />
<col span="1" />
</colgroup>
<tbody>
<tr>
<td style="" align="left" rowspan="1" colspan="1">@</td>
<td style="" align="left" rowspan="1" colspan="1">ICH</td>
<td style="" align="left" rowspan="1" colspan="1">Insert the indicated # of
blank characters.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">A</td>
<td style="" align="left" rowspan="1" colspan="1">CUU</td>
<td style="" align="left" rowspan="1" colspan="1">Move cursor up the
indicated # of rows.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">B</td>
<td style="" align="left" rowspan="1" colspan="1">CUD</td>
<td style="" align="left" rowspan="1" colspan="1">Move cursor down the
indicated # of rows.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">C</td>
<td style="" align="left" rowspan="1" colspan="1">CUF</td>
<td style="" align="left" rowspan="1" colspan="1">Move cursor right the
indicated # of columns.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">D</td>
<td style="" align="left" rowspan="1" colspan="1">CUB</td>
<td style="" align="left" rowspan="1" colspan="1">Move cursor left the
indicated # of columns.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">E</td>
<td style="" align="left" rowspan="1" colspan="1">CNL</td>
<td style="" align="left" rowspan="1" colspan="1">Move cursor down the
indicated # of rows, to column 1.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">F</td>
<td style="" align="left" rowspan="1" colspan="1">CPL</td>
<td style="" align="left" rowspan="1" colspan="1">Move cursor up the
indicated # of rows, to column 1.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">G</td>
<td style="" align="left" rowspan="1" colspan="1">CHA</td>
<td style="" align="left" rowspan="1" colspan="1">Move cursor to indicated
column in current row.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">H</td>
<td style="" align="left" rowspan="1" colspan="1">CUP</td>
<td style="" align="left" rowspan="1" colspan="1">Move cursor to the
indicated row, column (origin at 1,1).</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">J</td>
<td style="" align="left" rowspan="1" colspan="1">ED</td>
<td style="" align="left" rowspan="1" colspan="1">Erase display (default:
from cursor to end of display). ESC [ 1 J: erase
from start to cursor.
ESC [ 2 J: erase whole display.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">K</td>
<td style="" align="left" rowspan="1" colspan="1">EL</td>
<td style="" align="left" rowspan="1" colspan="1">Erase line (default: from
cursor to end of line). ESC [ 1 K: erase from start
of line to cursor.
ESC [ 2 K: erase whole line.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">L</td>
<td style="" align="left" rowspan="1" colspan="1">IL</td>
<td style="" align="left" rowspan="1" colspan="1">Insert the indicated # of
blank lines.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">M</td>
<td style="" align="left" rowspan="1" colspan="1">DL</td>
<td style="" align="left" rowspan="1" colspan="1">Delete the indicated # of
lines.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">P</td>
<td style="" align="left" rowspan="1" colspan="1">DCH</td>
<td style="" align="left" rowspan="1" colspan="1">Delete the indicated # of
characters on the current line.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">X</td>
<td style="" align="left" rowspan="1" colspan="1">ECH</td>
<td style="" align="left" rowspan="1" colspan="1">Erase the indicated # of
characters on the current line.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">a</td>
<td style="" align="left" rowspan="1" colspan="1">HPR</td>
<td style="" align="left" rowspan="1" colspan="1">Move cursor right the
indicated # of columns.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">c</td>
<td style="" align="left" rowspan="1" colspan="1">DA</td>
<td style="" align="left" rowspan="1" colspan="1">Answer
ESC [ ? 6 c: "I am a VT102".</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">d</td>
<td style="" align="left" rowspan="1" colspan="1">VPA</td>
<td style="" align="left" rowspan="1" colspan="1">Move cursor to the
indicated row, current column.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">e</td>
<td style="" align="left" rowspan="1" colspan="1">VPR</td>
<td style="" align="left" rowspan="1" colspan="1">Move cursor down the
indicated # of rows.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">f</td>
<td style="" align="left" rowspan="1" colspan="1">HVP</td>
<td style="" align="left" rowspan="1" colspan="1">Move cursor to the
indicated row, column.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">g</td>
<td style="" align="left" rowspan="1" colspan="1">TBC</td>
<td style="" align="left" rowspan="1" colspan="1">Without parameter: clear
tab stop at the current position.
ESC [ 3 g: delete all tab stops.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">h</td>
<td style="" align="left" rowspan="1" colspan="1">SM</td>
<td style="" align="left" rowspan="1" colspan="1">Set Mode (see
below).</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">l</td>
<td style="" align="left" rowspan="1" colspan="1">RM</td>
<td style="" align="left" rowspan="1" colspan="1">Reset Mode (see
below).</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">m</td>
<td style="" align="left" rowspan="1" colspan="1">SGR</td>
<td style="" align="left" rowspan="1" colspan="1">Set attributes (see
below).</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">n</td>
<td style="" align="left" rowspan="1" colspan="1">DSR</td>
<td style="" align="left" rowspan="1" colspan="1">Status report (see
below).</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">q</td>
<td style="" align="left" rowspan="1" colspan="1">DECLL</td>
<td style="" align="left" rowspan="1" colspan="1">Set keyboard LEDs. ESC [
0 q: clear all LEDs ESC [ 1 q: set Scroll Lock LED
ESC [ 2 q: set Num Lock LED
ESC [ 3 q: set Caps Lock LED</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">r</td>
<td style="" align="left" rowspan="1" colspan="1">DECSTBM</td>
<td style="" align="left" rowspan="1" colspan="1">Set scrolling region;
parameters are top and bottom row.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">s</td>
<td style="" align="left" rowspan="1" colspan="1">?</td>
<td style="" align="left" rowspan="1" colspan="1">Save cursor
location.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">u</td>
<td style="" align="left" rowspan="1" colspan="1">?</td>
<td style="" align="left" rowspan="1" colspan="1">Restore cursor
location.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">`</td>
<td style="" align="left" rowspan="1" colspan="1">HPA</td>
<td style="" align="left" rowspan="1" colspan="1">Move cursor to indicated
column in current row.</td>
</tr>
</tbody>
</table>
</div>
<p><span class="emphasis"><em>ECMA-48 Set Graphics
Rendition</em></span></p>
<p>The ECMA-48 SGR sequence ESC [ <code class="function">parameters</code> m sets display attributes.
Several attributes can be set in the same sequence,
separated by semicolons. An empty parameter (between
semicolons or string initiator or terminator) is
interpreted as a zero.</p>
<div class="informaltable">
<table style="border-collapse: collapse;">
<colgroup span="1">
<col span="1" />
<col span="1" />
</colgroup>
<tbody>
<tr>
<td style="" align="left" rowspan="1" colspan="1">param</td>
<td style="" align="left" rowspan="1" colspan="1">result</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">0</td>
<td style="" align="left" rowspan="1" colspan="1">reset all attributes to
their defaults</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">1</td>
<td style="" align="left" rowspan="1" colspan="1">set bold</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">2</td>
<td style="" align="left" rowspan="1" colspan="1">set half-bright
(simulated with color on a color display)</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">4</td>
<td style="" align="left" rowspan="1" colspan="1">set underscore (simulated
with color on a color display) (the colors used to
simulate dim or underline are set using ESC ]
...)</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">5</td>
<td style="" align="left" rowspan="1" colspan="1">set blink</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">7</td>
<td style="" align="left" rowspan="1" colspan="1">set reverse video</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">10</td>
<td style="" align="left" rowspan="1" colspan="1">reset selected mapping,
display control flag, and toggle meta flag (ECMA-48
says "primary font").</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">11</td>
<td style="" align="left" rowspan="1" colspan="1">select null mapping, set
display control flag, reset toggle meta flag
(ECMA-48 says "first alternate font").</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">12</td>
<td style="" align="left" rowspan="1" colspan="1">select null mapping, set
display control flag, set toggle meta flag (ECMA-48
says "second alternate font"). The toggle meta flag
causes the high bit of a byte to be toggled before
the mapping table translation is done.</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">21</td>
<td style="" align="left" rowspan="1" colspan="1">set normal intensity
(ECMA-48 says "doubly underlined")</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">22</td>
<td style="" align="left" rowspan="1" colspan="1">set normal intensity</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">24</td>
<td style="" align="left" rowspan="1" colspan="1">underline off</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">25</td>
<td style="" align="left" rowspan="1" colspan="1">blink off</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">27</td>
<td style="" align="left" rowspan="1" colspan="1">reverse video off</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">30</td>
<td style="" align="left" rowspan="1" colspan="1">set black foreground</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">31</td>
<td style="" align="left" rowspan="1" colspan="1">set red foreground</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">32</td>
<td style="" align="left" rowspan="1" colspan="1">set green foreground</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">33</td>
<td style="" align="left" rowspan="1" colspan="1">set brown foreground</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">34</td>
<td style="" align="left" rowspan="1" colspan="1">set blue foreground</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">35</td>
<td style="" align="left" rowspan="1" colspan="1">set magenta
foreground</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">36</td>
<td style="" align="left" rowspan="1" colspan="1">set cyan foreground</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">37</td>
<td style="" align="left" rowspan="1" colspan="1">set white foreground</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">38</td>
<td style="" align="left" rowspan="1" colspan="1">set underscore on, set
default foreground color</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">39</td>
<td style="" align="left" rowspan="1" colspan="1">set underscore off, set
default foreground color</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">40</td>
<td style="" align="left" rowspan="1" colspan="1">set black background</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">41</td>
<td style="" align="left" rowspan="1" colspan="1">set red background</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">42</td>
<td style="" align="left" rowspan="1" colspan="1">set green background</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">43</td>
<td style="" align="left" rowspan="1" colspan="1">set brown background</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">44</td>
<td style="" align="left" rowspan="1" colspan="1">set blue background</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">45</td>
<td style="" align="left" rowspan="1" colspan="1">set magenta
background</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">46</td>
<td style="" align="left" rowspan="1" colspan="1">set cyan background</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">47</td>
<td style="" align="left" rowspan="1" colspan="1">set white background</td>
</tr>
<tr>
<td style="" align="left" rowspan="1" colspan="1">49</td>
<td style="" align="left" rowspan="1" colspan="1">set default background
color</td>
</tr>
</tbody>
</table>
</div>
<p><span class="emphasis"><em>ECMA-48 Mode
Switches</em></span></p>
<div class="variablelist">
<dl>
<dt><span class="term">ESC [ 3 h</span></dt>
<dd>
<p>DECCRM (default off): Display control chars.</p>
</dd>
<dt><span class="term">ESC [ 4 h</span></dt>
<dd>
<p>DECIM (default off): Set insert mode.</p>
</dd>
<dt><span class="term">ESC [ 20 h</span></dt>
<dd>
<p>LF/NL (default off): Automatically follow echo of
LF, VT or FF with CR.</p>
</dd>
</dl>
</div>
<p><span class="emphasis"><em>ECMA-48 Status Report
Commands</em></span></p>
<div class="variablelist">
<dl>
<dt><span class="term">ESC [ 5 n</span></dt>
<dd>
<p>Device status report (DSR): Answer is ESC [ 0 n
(Terminal OK).</p>
</dd>
<dt><span class="term">ESC [ 6 n</span></dt>
<dd>
<p>Cursor position report (CPR): Answer is ESC [
<em class="replaceable"><code>y</code></em> ;
<em class="replaceable"><code>x</code></em> R, where
<em class="replaceable"><code>x,y</code></em> is the
cursor location.</p>
</dd>
</dl>
</div>
<p><span class="emphasis"><em>DEC Private Mode
(DECSET/DECRST) sequences</em></span></p>
<p>These are not described in ECMA-48. We list the Set Mode
sequences; the Reset Mode sequences are obtained by
replacing the final 'h' by 'l'.</p>
<div class="variablelist">
<dl>
<dt><span class="term">ESC [ ? 1 h</span></dt>
<dd>
<p>DECCKM (default off): When set, the cursor keys
send an ESC O prefix, rather than ESC [.</p>
</dd>
<dt><span class="term">ESC [ ? 3 h</span></dt>
<dd>
<p>DECCOLM (default off = 80 columns): 80/132 col
mode switch. The driver sources note that this alone
does not suffice; some user-mode utility such as
<span class="citerefentry"><span class="refentrytitle">resizecons</span>(8)</span> has to
change the hardware registers on the console video
card.</p>
</dd>
<dt><span class="term">ESC [ ? 5 h</span></dt>
<dd>
<p>DECSCNM (default off): Set reverse-video mode.</p>
</dd>