cterm.txt 46.1 KB
Newer Older
1
$Id: cterm.txt,v 1.79 2020/04/28 19:39:13 deuce Exp $
2
3

CTerm terminal characteristics:
4
5
------------------------------

6
7
8
9
10
11
12
End of line behaviour (wrapping):
The cursor is moved to the first character of the next line
as soon as a character is written to the last column of the
current line, not on the next character.  A tab will wrap
to the next line only if the current cursor position is the
last character on the line.

13
14
15
16
17
18
19
20
21
22
23
I'm often asked why I don't use VT semantics for wrapping.
The primary reason is that the person asking almost certainly
doesn't know what the VT semantics are, they just want
SyncTERM to behave the same as some other terminal they like.

Not only have the VT semantics never been properly
implemented in any terminal, they even varied between
different actual hardware VT terminals.  Luckily, everything
is on the internet now, so you can see the details and results
here: https://github.com/mattiase/wraptest

24
25
Control characters:

26
0x00 - NUL:
27
28
29
30
31
	In doorway mode, indicates that the next character is
	a literal character.  The IBM CP437 character will
	be displayed.  This allows ESC and other control
	characters to be placed on the screen.

32
33
0x07 - BEL:
	Beep
34

35
0x08 - BS:
36
37
38
39
	Non-destructive backspace.  Moves cursor position to
	the previous column unless the current column is the
	first, in which case no operation is performed.

40
41
0x09 - HT:
	Moves to the next horizontal tab stop.  Does not overwrite
42
43
44
45
46
	any characters in between.  If there are no tab stops left
	in the line, moves to the first position of the next line.
	If the starting position is on the last line, will perform
	a scroll, filling the new line at bottom with the current
	attribute.
47

48
49
50
51
52
53
54
55
0x0A - LF:
	Move cursor position to same column of the next row.
	If current row is the last row, scrolls the screen up
	and fills the new row with the current attribute.

0x0D - CR:
	Move cursor position to column 1 of the current line

56
57
58
59
Control Codes:
--------------

Control codes are in the following format:
deuce's avatar
deuce committed
60
ESC {'0' (ZERO) to '~'}
61
62
	Legal combinations which are not handled are silently dropped.

63
64
65
66
67
ESC E	Next Line (NEL)
	Moves to the line home position of the next line.
	(Same as CR LF)

ESC H	Set Tab (HTS)
deuce's avatar
deuce committed
68
	Sets a tab stop at the current column
69

deuce's avatar
deuce committed
70
71
	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

72
ESC M	Reverse Line Feed (RI)
deuce's avatar
deuce committed
73
74
75
	Move up one line

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf
76

77
ESC P	Device Control String (DCS)
deuce's avatar
deuce committed
78
79
	Begins a string consisting of the characters 0x08 - 0x0d and
	0x20-0x7e, terminated by a String Terminator (ST)
80
	Supported DCS string values:
81
82
83
84
85
86
87
88
89
		"CTerm:Font:p1:<b64>"
		Indicates the string is a loadable font. (CTerm 1.213)

		p1 is a font slot number, which must be higher than the last
		default defined font (See CSI sp D for list of predefined
		fonts). <b64> is the base64 encoded font data.  Font size is
		deduced from the size of the data.  This replaces the now
		deprecated CSI = Ps1 ; Ps2 {

90

deuce's avatar
deuce committed
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
		[ p1 [ ; p2 ] ] q
		Defaults:  p1 = 0  p2 = 0
		Indicates the string is a sixel sequence.

		p1 selects the vertical height of a single pixel.  This
		may be overridden by the raster attributes command, and
		is deprecated.  Supported values
		
			Value      Vertical Size
			-----      -------------
			0,1,5,6    2 pixels
			2          5 pixels
			3,4        3 pixels
			7,8,9      1 pixel

		p2 indicates if unset sixels should be set to the current
		background colour.  If p2 is 1, positions specified as 0
		remain at their current colour.

		Any additional parameters are ignored.

		The rest of the string is made up of sixel data characters and
		sixel control functions.  Sixel data characters are in the
		rage of '?' (0x3f) to '~' (0x7e).  Each sixel data character
		represents six vertical pixels.  The data is extracted by
		subtracting 0x3f from the ASCII value of the character.
		The least significant bit is the topmost pixel.

                Sixel Control Functions
                ! Pn X
			Graphics Repeat Introducer
			The character X is repeated Pn times.
		" p1 ; p2 [ ; p3 [ ; p4 ] ]
			Raster Attributes
			p1 indicates the vertical size in pixels of each
			sixel.  p2 indicates the horizontal size in pixels.
			p3 and p4 define the height and width (in sixels)
			respectively of a block to fill with the background
			colour.  This block may not extend past the current
			bottom of the screen.  If any pixel data characters
			proceed this command, it is ignored.
		# p1
			Colour Select
			Selects the current foreground colour from the
			sixel palette.
		# p1 ; p2 ; p3 ; p4 ; p5
			Palette map
			Defines sixel palette entry p1 and sets it as the
			current foreground colour.  p2 specifies the colour
			space to define the colour in, the only supported
			value is 2.  p3, p4, and p5 specify the red, green,
			and blue content as a percentage (0-100).
		$
			Graphics Carriage Return
			Returns the active position to the left border of
			the same sixel row.  Generally, one pass per colour
			is used.  In passes after the first one, sixels
			with a value of zero are not overwritten with the
			background colour.
		-
			Graphics New Line
			Moves the active position to the left border of the
			next sixel row.

155

deuce's avatar
deuce committed
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
		$ q pt
		Request Status String (DECRQSS)

		pt is the intermediate and/or final characters of a control
		function to query the status of.  The terminal will send a
		response in the format

		DCS p1 $ r pt ST

		p1 is 1 if the terminal supports querying the control
		function and 0 if it does not.

		pt is the characters in the control function except the CSI
		characters.

deuce's avatar
deuce committed
171
172
173
		Currently supported values of p1:

		m	Request SGR parameters
174
		r	Request top and bottom margins
175
		s	Request left and right margins
176
177
178
		t	Request height in lines
		$|	Request width in columns
		*|	Request height in lines
deuce's avatar
deuce committed
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

		p1 [ ; p2 [ ; p3 ] ! z
		Define Macro (DECDMAC)
		Defaults: p2 = 0  p3 = 0
		
		Sets a macro to be replayed using CSI Pn * z

		p1 is the macro number to set, and make be between 0 and
		63 inclusive.

		If p2 is zero, the macro numbered p1 will be deleted. If
		p2 is one, all macros are deleted.
		
		If p3 is zero, the macro is defined using ASCII characters
		(0x20 - 0x7e and 0xa0 - 0xff only) if p3 is one, the macro
		is defined using hex pairs.
		
		When the macro is defined using hex pairs, a repeat
		sequence may be included in the format of ! Pn ; D..D ;
		Pn specifies the number of repeats (default of one instance)
		D..D is the sequence of pairs to send Pn times.  The 
		terminating ; may be left out if the sequence to be
		repeated ends at the end of the string.

204
205
206
ESC X	Start Of String (SOS)
	As the above strings, but may contain any characters except
	a Start Of String sequence or a String Terminator sequence.
deuce's avatar
deuce committed
207
	The string is currently ignored.
deuce's avatar
deuce committed
208

209
210
211
ESC \	String Terminator (ST)

ESC ]	Operating System Command (OSC)
212
213
214
215
216
217
218
219
220
221
222
223
224
	Begins a string consisting of the characters 0x08 - 0x0d and
	0x20-0x7e, terminated by a String Terminator (ST)
	Supported OSC values:
		4;(pX;pY)...
		Specifies one or more palette redefinitions.
		pX is the palette index, and pY is the colour definition
		Color format:
			rgb:R/G/B
			Where R, G, and B are a sequence of one to four
			hex digits representing the value of the
			red, green, and blue channels respectively.

		SOURCE: xterm
deuce's avatar
deuce committed
225

226
227
228
229
230
231
232
		104 [ ; Ps ... ]
		Resets palette entry to default.  If the entire string
		is "104", resets all colours.  Otherwise, only each index
		separated by a semicolon is reset.

		SOURCE: xterm

233
234
235
ESC ^	Privacy Message (PM)
	Begins a string consisting of the characters 0x08 - 0x0d and
	0x20-0x7e, terminated by a String Terminator (ST)
236
	The string is currently ignored.
deuce's avatar
deuce committed
237

238
239
240
241
ESC _	Application Program String (APS)
	Begins a string consisting of the characters 0x08 - 0x0d and
	0x20-0x7e, terminated by a String Terminator (ST)
	The string is currently ignored.
deuce's avatar
deuce committed
242

243
ESC c	Reset to Initial State (RIS)
deuce's avatar
deuce committed
244
245
246
	Resets all the terminal settings, clears the screen, and homes
	the cursor.

247
248
249
Control Sequences:
------------------

250
251
252
Control sequences start with the Control Sequence Introducer which is
ESC [  CSI will be used to express this from now on.

253
Control sequences are in the following format:
254
CSI {'0' (ZERO) to '?'}{SPACE to '/'}{'@' to '~'}
255
256
257
258
	There may be multiple characters from the {'0' (ZERO) to '?'}
	and {SPACE to '/'} before the terminating {'@' to '~'} character.

	Legal combinations not handled are silently dropped.
259
	Illegal combinations are displayed.
260
261
262
263

Sequence Parameters:
	Parameters are expressed by the {'0' (ZERO) to '?'} character set.
	Sequences which use parameters use decimal parameters separated by
deuce's avatar
deuce committed
264
	a ';'.  The use of a ':' from the set is reserved.
265
266
267
	If the parameter string begins with '<', '=', '>', or '?' then
	this is a non-standard extension to the ANSI spec.

deuce's avatar
deuce committed
268
269
270
271
272
273
	Pn          Indicates a single numeric parameter
	Pn1 ; Pn2   Two numeric parameters
	Pn...       Any number of numeric parameters
	Ps          Single selective parameter
	Ps1 ; Ps1   Two selective parameters
	Ps...       Any numer of selective parameters
274

deuce's avatar
deuce committed
275
	If a default is defined, the parameter is optional
276

277
CSI Pn @ (ICH)
deuce's avatar
deuce committed
278
	Insert Character(s)
deuce's avatar
deuce committed
279
280
	Defaults: Pn = 1
	Moves text from the current position to the right edge Pn characters
281
	to the right, with rightmost characters going off-screen and the
deuce's avatar
deuce committed
282
283
284
285
	resulting hole being filled with the current attribute.

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

286
287
CSI Pn SP @ (SL)
	Scroll Left
288
289
290
291
292
293
294
	Defaults: Pn = 1
	Shifts the contents of the screen left Pn columns(s) with
	leftmost columns going off-screen and the resulting hole being
	filled with the current attribute.

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

295
CSI Pn A (CUU)
deuce's avatar
deuce committed
296
	Cursor Up
deuce's avatar
deuce committed
297
298
	Defaults: Pn = 1
	Moves the cursor position up Pn lines from the current position.
deuce's avatar
deuce committed
299
300
301
302
303
	Attempting to move past the screen boundaries stops the cursor
	at the screen boundary.

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

304
305
CSI Pn SP A (SR)
	Scroll Right
306
307
308
309
310
311
312
	Defaults: Pn = 1
	Shifts the contents of the screen right Pn columns(s) with
	rightmost columns going off-screen and the resulting hole being
	filled with the current attribute.

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

313
CSI Pn B (CUD)
deuce's avatar
deuce committed
314
	Cursor Down
deuce's avatar
deuce committed
315
316
	Defaults: Pn = 1
	Moves the cursor position down Pn lines from the current position.
deuce's avatar
deuce committed
317
318
319
320
321
	Attempting to move past the screen boundaries stops the cursor
	at the screen boundary.

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

322
CSI Pn C (CUF)
deuce's avatar
deuce committed
323
	Cursor Right
deuce's avatar
deuce committed
324
325
	Defaults: Pn = 1
	Moves the cursor position right Pn columns from the current position.
deuce's avatar
deuce committed
326
327
328
329
330
	Attempting to move past the screen boundaries stops the cursor
	at the screen boundary.

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

331
CSI Pn D (CUB)
deuce's avatar
deuce committed
332
	Cursor Left
deuce's avatar
deuce committed
333
334
	Defaults: Pn = 1
	Moves the cursor position left Pn columns from the current position.
deuce's avatar
deuce committed
335
336
337
338
339
	Attempting to move past the screen boundaries stops the cursor
	at the screen boundary.

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

340
CSI Ps1 ; Ps2 sp D (FNT)
341
	Font Selection
deuce's avatar
deuce committed
342
	Defaults: Ps1 = 0  Ps2 = 0
343
	"sp" indicates a single space character.
deuce's avatar
deuce committed
344
345
	Sets font Ps1 to be the one indicated by Ps2.  Currently four fonts are
	supported.  Ps2 must be between 0 and 255.  Not all output types support
346
	font selection.  Only X11 and SDL currently do.
deuce's avatar
deuce committed
347
	Supported Ps1 values:
348
		0  - Default font
deuce's avatar
deuce committed
349
		1  - Font selected by the high intensity bit when CSI ? 31 h
350
		     is enabled
deuce's avatar
deuce committed
351
		2  - Font selected by the blink intensity bit when CSI ? 34 h
352
353
		     is enabled
		3  - Font selected by both the high intensity and blink bits
deuce's avatar
deuce committed
354
		     when both CSI ? 31 h and CSI ? 34 h are enabled
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
	Currently included fonts are:
		0  - Codepage 437 English
		1  - Codepage 1251 Cyrillic, (swiss)
		2  - Russian koi8-r
		3  - ISO-8859-2 Central European
		4  - ISO-8859-4 Baltic wide (VGA 9bit mapped)
		5  - Codepage 866 (c) Russian
		6  - ISO-8859-9 Turkish
		7  - haik8 codepage (use only with armscii8 screenmap)
		8  - ISO-8859-8 Hebrew
		9  - Ukrainian font koi8-u
		10 - ISO-8859-15 West European, (thin)
		11 - ISO-8859-4 Baltic (VGA 9bit mapped)
		12 - Russian koi8-r (b)
		13 - ISO-8859-4 Baltic wide
		14 - ISO-8859-5 Cyrillic
		15 - ARMSCII-8 Character set
		16 - ISO-8859-15 West European
		17 - Codepage 850 Multilingual Latin I, (thin)
		18 - Codepage 850 Multilingual Latin I
		19 - Codepage 885 Norwegian, (thin)
		20 - Codepage 1251 Cyrillic
		21 - ISO-8859-7 Greek
		22 - Russian koi8-r (c)
		23 - ISO-8859-4 Baltic
		24 - ISO-8859-1 West European
		25 - Codepage 866 Russian
		26 - Codepage 437 English, (thin)
		27 - Codepage 866 (b) Russian
		28 - Codepage 885 Norwegian
		29 - Ukrainian font cp866u
		30 - ISO-8859-1 West European, (thin)
		31 - Codepage 1131 Belarusian, (swiss)
388
389
390
391
392
		32 - Commodore 64 (UPPER)
		33 - Commodore 64 (Lower)
		34 - Commodore 128 (UPPER)
		35 - Commodore 128 (Lower)
		36 - Atari
deuce's avatar
deuce committed
393
394
		37 - P0T NOoDLE (Amiga)
		38 - mO'sOul (Amiga)
395
		39 - MicroKnight Plus (Amiga)
deuce's avatar
deuce committed
396
		40 - Topaz Plus (Amiga)
397
		41 - MicroKnight (Amiga)
deuce's avatar
deuce committed
398
399
		42 - Topaz (Amiga)

400
401
402
	Not all fonts are supported in all modes.  If a font is not supported
	in the current mode, no action is taken, but there should be a
	non-zero 'Font Selection result' value in the Font State Report.
403

deuce's avatar
deuce committed
404
405
	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

406
CSI Pn E (CNL)
deuce's avatar
deuce committed
407
	Cursor Next Line
deuce's avatar
deuce committed
408
409
	Defaults: Pn = 1
	Moves the cursor to the first column of the line Pn down from the
deuce's avatar
deuce committed
410
411
	current position. Attempting to move past the screen boundaries
	stops the cursor at the screen boundary.
deuce's avatar
deuce committed
412
413
414

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

415
CSI Pn F (CPL)
416
	Cursor Preceding Line
deuce's avatar
deuce committed
417
	Defaults: Pn = 1
418
	Moves the cursor to the first column of the row Pn up from the
419
420
	current position.  Attempting to move past the screen boundaries
	stops the cursor at the screen boundary.
421
422
423

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

424
CSI Pn G (CHA)
deuce's avatar
deuce committed
425
	Cursor Character Absolute
deuce's avatar
deuce committed
426
427
	Defaults: Pn = 1
	Movies the cursor to column Pn of the current row.
428

deuce's avatar
deuce committed
429
430
	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

431
CSI Pn1 ; Pn2 H (CUP)
432
	Cursor Position
deuce's avatar
deuce committed
433
434
	Defaults: Pn1 = 1  Pn2 = 1
	Moves the cursor to the Pn2th column of the Pn1th line.
deuce's avatar
deuce committed
435
436
437

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

deuce's avatar
deuce committed
438
439
440
441
442
443
444
445
CSI Pn I (CHT)
	Cursor Forward Tabulation
	Defaults: Pn = 1
	Move the cursor to the Pn-th next tab stop.
	Basically the same as sending TAB Pn times.

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

446
CSI Ps J (ED)
deuce's avatar
deuce committed
447
	Erase in Page
deuce's avatar
deuce committed
448
449
	Defaults: Ps = 0
	Erases from the current screen according to the value of Ps
deuce's avatar
deuce committed
450
451
452
453
454
455
456
	0 - Erase from the current position to the end of the screen.
	1 - Erase from the current position to the start of the screen.
	2 - Erase entire screen.  As a violation of ECMA-048, also moves
	    the cursor to position 1/1 as a number of BBS programs assume
	    this behaviour.
	Erased characters are set to the current attribute.

deuce's avatar
deuce committed
457
	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf
deuce's avatar
deuce committed
458
459
	SOURCE BANSI.TXT

460
CSI Ps K (EL)
deuce's avatar
deuce committed
461
	Erase in Line
deuce's avatar
deuce committed
462
463
	Defaults: Ps = 0
	Erases from the current line according to the value pf Ps
deuce's avatar
deuce committed
464
465
466
467
468
469
470
	0 - Erase from the current position to the end of the line.
	1 - Erase from the current position to the start of the line.
	2 - Erase entire line.
	Erased characters are set to the current attribute.

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

471
CSI Pn L (IL)
deuce's avatar
deuce committed
472
	Insert Line(s)
deuce's avatar
deuce committed
473
474
	Defaults: Pn = 1
	Inserts Pn lines at the current line position.  The current line and
475
	those after it are scrolled down and the new empty lines are filled
deuce's avatar
deuce committed
476
477
	with the current attribute.  If the cursor is not currently inside
	the scrolling margins, has no effect.
deuce's avatar
deuce committed
478
479
480

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

481
CSI Pn M (DL)
deuce's avatar
deuce committed
482
	Delete Line(s) / "ANSI" Music
deuce's avatar
deuce committed
483
484
	Defaults: Pn = 1
	Deletes the current line and the Pn - 1 lines after it scrolling the
deuce's avatar
deuce committed
485
486
	first non-deleted line up to the current line and filling the newly
	empty lines at the end of the screen with the current attribute.
deuce's avatar
deuce committed
487
488
	If the cursor is not currently inside the scrolling margins, has no
	effect.
deuce's avatar
deuce committed
489
490
	If "ANSI" Music is fully enabled (CSI = 2 M), performs "ANSI" music
	instead.
deuce's avatar
deuce committed
491
492
493
494
495
	See "ANSI" MUSIC section for more details.

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf
	SOURCE: BANSI.TXT

deuce's avatar
deuce committed
496
497
CSI = Ps M (CTSAM)
	CTerm Set ANSI Music
deuce's avatar
deuce committed
498
499
500
501
502
503
504
505
506
507
	NON-STANDARD EXTENSION.
	Defaults:  Ps = 0
	Sets the current state of ANSI music parsing.
	0 - Only CSI | will introduce an ANSI music string.
	1 - Both CSI | and CSI N will introduce an ANSI music string.
	2 - CSI |, CSI N, and CSI M will all introduce an ANSI music string.
	    In this mode, Delete Line will not be available.

	SOURCE: CTerm only.

508
509
CSI N (BCAM)
	BananaCom ANSI Music
deuce's avatar
deuce committed
510
	"ANSI" Music / Not implemented.
deuce's avatar
deuce committed
511
	If "ANSI" Music is set to BananaCom (CSI = 1 M) or fully enabled
512
	(CSI = 2 M) performs "ANSI" music.  See "ANSI" MUSIC section for more
deuce's avatar
deuce committed
513
	details.
deuce's avatar
deuce committed
514
515
516

	SOURCE: BANSI.TXT

517
CSI Pn P (DCH)
deuce's avatar
deuce committed
518
	Delete Character
deuce's avatar
deuce committed
519
	Defaults: Pn = 1
520
521
522
	Deletes the character at the current position by shifting all
	characters from the current column + p1 left to the current column.
	Opened blanks at the end of the line are filled with the current
deuce's avatar
deuce committed
523
524
	attribute.  If the cursor is not currently inside the scrolling
	margins, has no effect.
deuce's avatar
deuce committed
525
526
527

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

528
CSI Pn S (SU)
deuce's avatar
deuce committed
529
	Scroll Up
deuce's avatar
deuce committed
530
531
	Defaults: Pn = 1
	Scrolls all text on the screen up Pn lines.  New lines emptied at the
deuce's avatar
deuce committed
532
	bottom are filled with the current attribute.
deuce's avatar
deuce committed
533
534
535

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

deuce's avatar
deuce committed
536
537
CSI ? Ps1 ; Ps2 S (XTSRGA)
	XTerm Set or Request Graphics Attribute
538
539
540
541
542
543
	If Ps1 is 2, and Ps2 is 1, replies with the graphics screen information
	in the following format: CSI ? 2 ; 0 ; Px ; Py S
	Where Px is the width of the screen in pixels and Py is the height.

	SOURCE: XTerm

deuce's avatar
deuce committed
544
CSI Pn T (SD)
deuce's avatar
deuce committed
545
	Scroll Down
deuce's avatar
deuce committed
546
547
	Defaults: Pn = 1
	Scrolls all text on the screen down Pn lines.  New lines emptied at the
deuce's avatar
deuce committed
548
	top are filled with the current attribute.
deuce's avatar
deuce committed
549
550

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf
551

552
553
554
CSI U
	NON-STANDARD (Disabled in current code)
	Clear screen with default attribute.
deuce's avatar
deuce committed
555
556
	This code is *supposed* to go to the "next page" according to the
	ANSI/ECMA specs with CSI V going to "previous page"
557
558
559

	SOURCE: BANSI.TXT

deuce's avatar
deuce committed
560
CSI Pn X (ECH)
561
	Erase Character
deuce's avatar
deuce committed
562
	Defaults: Pn = 1
563
564
	Erase p1 characters starting at the current character.  Will not erase
	past the end of line.
565
	Erased characters are set to the current attribute.
deuce's avatar
deuce committed
566
	This can erase across scroll margins.
567
568
569

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

deuce's avatar
deuce committed
570
CSI Pn Y (CVT)
deuce's avatar
deuce committed
571
572
573
574
575
576
577
	Cursor Line Tabulation
	Defaults: Pn = 1
	Move the cursor to the Pn-th next tab stop.
	Basically the same as sending TAB Pn times.

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

deuce's avatar
deuce committed
578
CSI Pn Z (CBT)
579
	Cursor Backward Tabulation
deuce's avatar
deuce committed
580
	Defaults: Pn = 1
581
	Move the cursor to the p1th preceding tab stop.  Will not go past the
deuce's avatar
deuce committed
582
	start of the line.
583
584
585

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

deuce's avatar
deuce committed
586
CSI Pn ` (HPA)
deuce's avatar
deuce committed
587
588
589
590
591
592
593
	Character Position Absolute
	Defaults: Pn = 1
	Move the cursor to the specified position on the current row.
	Will not go past the end of the line.

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

deuce's avatar
deuce committed
594
CSI Pn a (HPR)
deuce's avatar
deuce committed
595
596
597
598
599
600
601
602
	Cursor Position Forward
	Defaults: Pn = 1
	Moves the cursor position forward Pn columns from the current position.
	Attempting to move past the screen boundaries stops the cursor
	at the screen boundary.

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

deuce's avatar
deuce committed
603
CSI Pn b (REP)
deuce's avatar
deuce committed
604
605
606
607
608
609
610
	Repeat
	Defaults: Pn = 1
	Repeats the previous graphic character Pn times.  Will not repeat
	escape sequences.

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

deuce's avatar
deuce committed
611
CSI Ps c (DA)
612
	Device Attributes
deuce's avatar
deuce committed
613
614
	Defaults: Ps = 0
	If Ps is 0, CTerm will reply with the sequence:
615
        CSI = 67;84;101;114;109;pN c
deuce's avatar
deuce committed
616
	64;84;101;114;109 is the ASCII values of the "CTerm" string.  pN is the
617
618
619
620
621
	CVS revision ID of CTerm with dots converted to semi-colons
	(e.g. "1;156").  Use the CVS revision to detect if a specific feature
	is available.  If you are adding features to a forked version of cterm,
	please do so by	adding an extra parameter to the end, not by
	incrementing any existing one!
622

deuce's avatar
deuce committed
623
624
	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

deuce's avatar
deuce committed
625
CSI < Ps c (CTDA)
deuce's avatar
deuce committed
626
627
628
629
630
631
632
	CTerm Device Attributes

	Defaults: Ps = 0
	If Pn is 0, CTerm will reply with the sequence:
        CSI < 0 ; Ps... c

	Possible values for Ps:
633
	1 - Loadable fonts are availabe via Device Control Strings
deuce's avatar
deuce committed
634
635
636
637
638
639
	2 - Palette entries may be modified via an Operating System Command
	    string
	3 - Pixel operations are supported (currently, sixel graphics)
	4 - The current font may be selected via CSI Ps1 ; Ps2 sp D
	5 - More than the standard 16 colours may by configured via
	    Operating System Command strings
640
641
	6 - Extended palette is available
	7 - Mouse is available
deuce's avatar
deuce committed
642

deuce's avatar
deuce committed
643
CSI Ps d (VPA)
deuce's avatar
deuce committed
644
645
646
647
648
649
	Line Position Absolute
	Defaults: Ps = 1
	Moves to row specified by Ps.

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

deuce's avatar
deuce committed
650
651
652
653
654
655
656
CSI Pn SP d (TSR)
	Tab Stop Remove
	Defaults: None
	Removes a tab stop at postion Pn.

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

657
658
CSI Pn e (VPR)
	Line Position Forward
deuce's avatar
deuce committed
659
660
661
662
663
	Defaults: Ps = 1
	Moves forward Ps rows.

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

664
665
CSI Pn1 ; Pn2 (HVP)
	Character and Line Position
deuce's avatar
deuce committed
666
667
668
669
670
	Defaults: Pn1 = 1  Pn2 = 1
	Moves the cursor to the Pn2th column of the Pn1th line.

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

671
672
CSI Ps g (TBC)
	Tabulation Clear
deuce's avatar
deuce committed
673
	Defaults: Pn = 0
674
	Deletes tab stops according to the values of P1:
deuce's avatar
deuce committed
675
676
677
678
679
680
	0 - Deletes tab stop at current position.
	3 - Deletes all tab stops.
	5 - Deletes all tab stops.

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

deuce's avatar
deuce committed
681
CSI = 255 h (BCSET)
deuce's avatar
deuce committed
682
683
684
685
686
	NON-STANDARD EXTENSION
	Enable DoorWay Mode

	SOURCE: BANSI.TXT

deuce's avatar
deuce committed
687
CSI ? Ps... h (DECSET)
deuce's avatar
deuce committed
688
689
690
691
692
693
694
695
696
697
698
699
700
	NON-STANDARD EXTENSION
	Set Mode
	Sets one or more mode.  The following modes are supported:

	6 -  Enable origin mode.
	     In this mode, position parameters are relative to the top left of
	     the scrolling region, not the screen.  Defaults to reset.
	     SOURCE: Digital VT102 User Guide
	7 -  Enable auto wrap
	     This is the normal mode in which a write to the last column of a
	     row will move the cursor to the start of the next line triggering
	     a scroll if required to create a new line.  Defaults to set.
	     SOURCE: Digital VT102 User Guide
deuce's avatar
deuce committed
701
702
703
704
705
	9 -  X10 compatible mouse reporting
	     Mouse button presses will send a CSI M <button> <x> <y>
	     Where <button> is ' ' + button number (0-based)
	     <x> and <y> are '!' + position (0-based)
	     SOURCE: xterm
deuce's avatar
deuce committed
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
	25 - Display the cursor.  Defaults to set.
	     SOURCE: "Installing and Using the VT320 Video Terminal"
	31 - Enable bright alt character set
	     With this mode set, the bright (1) graphic rendition selects
	     characters from an alternate character set.  Defaults to reset.
	32 - Bright Intensity Disable
	     This makes the bright intensity bit not control the intensity.
	     Mostly for use with CSI ? 31 h to permit fonts in the same
	     colours.  Defaults to reset.
	33 - Blink to Bright Intensity Background
	     With this mode set, the blink (5,6) graphic renditions cause the
	     background colour to be high intensity rather than causing blink.
	     Defaults to reset.
	34 - Enable blink alt character set
	     With this mode set, the blink (5, 6) graphic renditions selects
	     characters from an alternate character set.  Defaults to reset
	35 - Blink Disabled
	     This makes the blink (5, 6) graphic renditions not cause the
	     character to blink.  Mostly for use with CSI ? 34 h to permit
	     fonts to be used without blinking.  Defaults to reset.
726
727
728
	69 - DEC Left Right Margin Mode enabled
	     Enables CSI s to set the left/right margins, and disables CSI s
	     from saving the current cursor position.
deuce's avatar
deuce committed
729
730
731
732
733
734
735
736
737
	80 - Sixel Scrolling Enabled
	     When this is set, the sixel active position begins in the
	     upper-left corner of the currently active text position.
	     When the sixel active position reaches the bottom of the
	     page, the page is scrolled up.  At the end of the sixel
	     string, a sixel newline is appended, and the current cursor
	     position is the one in which the bottom sixel is in.
	     Defaults to set.
	     SOURCE: VT330/VT340 Programmer Reference Manual
deuce's avatar
deuce committed
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
	1000 -  Normal tracking mode mouse reporting
	     Mouse button presses will send a CSI M <button> <x> <y>
	     Where <button> is ' ' + button number (0-based)
	     Mouse button releases will use a button number of 4
	     <x> and <y> are '!' + position (0-based)
	     SOURCE: xterm
	1001 -  Highlight tracking mode mouse reporting
	     (Not supported by SyncTERM)
	     SOURCE: xterm
	1002 -  Button-event tracking mode mouse reporting
	     Mouse button presses and movement when a button is pressed
	     will send a CSI M <button> <x> <y>
	     Where <button> is ' ' + button number (0-based)
	     32 is added to the button number for movement events.
	     Mouse button releases will use a button number of 4
	     <x> and <y> are '!' + position (0-based)
	     SOURCE: xterm
	1003 -  Any-event tracking mode mouse reporting
	     Mouse button presses and movement
	     will send a CSI M <button> <x> <y>
	     Where <button> is ' ' + button number (0-based)
	     32 is added to the button number for movement events.
	     Mouse button releases will use a button number of 4
	     <x> and <y> are '!' + position (0-based)
	     If no button is pressed, it acts as though button 0 is.
	     SOURCE: xterm
	1004 -  Focus-event tracking mode mouse reporting
	     (Not supported by SyncTERM)
	     SOURCE: xterm
	1005 -  UTF-8 encoded extended coordinates
	     (Not supported by SyncTERM)
	     SOURCE: xterm
	1006 -  SGR encoded extended coordinates
	     Instead of the CSI M method, the format of mouse reporting
	     is change to CSI < Pb ; Px ; Py M for presses and
	     CSI < Pb ; Px ; Py m for releases.
	     Instead of CSI M
	     Px and Py are one-based.
	     Pb remains the same (32 added for movement)
	     Button 3 is not used for release (separate code)
	     SOURCE: xterm
	1007 -  Alternate scroll mode
	     (Not supported by SyncTERM)
	     SOURCE: xterm
	1015 -  URXVT encoded extended coordinates
	     (Not supported by SyncTERM)
	     SOURCE: xterm
deuce's avatar
deuce committed
785

deuce's avatar
deuce committed
786
CSI Pn j (HPB)
deuce's avatar
deuce committed
787
788
789
790
791
792
793
794
	Character Position Backward
	Defaults: Pn = 1
	Moves the cursor position left Pn columns from the current position.
	Attempting to move past the screen boundaries stops the cursor
	at the screen boundary.

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

deuce's avatar
deuce committed
795
CSI Pn k (VPB)
deuce's avatar
deuce committed
796
797
798
799
800
801
802
803
	Line Position Backward
	Defaults: Pn = 1
	Moves the cursor position up Pn lines from the current position.
	Attempting to move past the screen boundaries stops the cursor
	at the screen boundary.

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf

deuce's avatar
deuce committed
804
CSI = 255 l (BCRST)
deuce's avatar
deuce committed
805
806
807
808
809
	NON-STANDARD EXTENSION
	Disable DoorWay Mode

	SOURCE: BANSI.TXT

deuce's avatar
deuce committed
810
CSI ? Ps... l (DECRST)
deuce's avatar
deuce committed
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
	NON-STANDARD EXTENSION
	Reset Mode
	Resets one or more mode.  The following modes are supported:

	6 -  Origin Mode
	     With this mode reset, position parameters are relative to the
	     top left of the screen, not the scrolling region.  Defaults
	     to reset.
	     SOURCE: Digital VT102 User Guide
	7 -  Disable auto wrap
	     Resetting this mode causes a write to the last column of a to
	     leave the cursor where it was before the write occurred,
	     overwriting anything which was previously written to the same
	     position.
	     SOURCE: Digital VT102 User Guide
deuce's avatar
deuce committed
826
	9 -  Disable X10 compatible mouse reporting
deuce's avatar
deuce committed
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
	25 - Hide the cursor.  Defaults to set.
	     SOURCE: "Installing and Using the VT320 Video Terminal"
	31 - Disable bright alt character set
	     With this mode reset, the bright (1) graphic rendition does not
	     select an alternative font.  Defaults to reset.
	32 - Bright Intensity Enable
	     When reset, bright intensity graphics rendition behaves normally.
	     Defaults to reset.
	33 - Disable Blink to Bright Intensity Background
	     With this mode set, the blink (5,6) graphic renditions do not
	     affect the background colour.  Defaults to reset.
	34 - Disable blink alt character set
	     With this mode reset, the blink (5, 6) graphic renditions do not
	     select characters from an alternate character set.  Defaults to
	     reset.
	35 - Blink Enable
	     With this mode reset, the blink (5,6) graphic renditions behave
	     normally (cause the characters to blink).  Defaults to reset.
845
846
847
848
	69 - DEC Left Right Margin Mode disabled
	     Disables CSI s from setting the left/right margins, and changes
	     it back to saving the current cursor position.  The current
	     left/right margins are maintained.
deuce's avatar
deuce committed
849
850
851
852
853
854
855
856
	80 - Sixel Scrolling Disabled
	     When this is reset, the sixel active position begins in the
	     upper-left corner of the page.  Any commands that attempt to
	     advance the sixel position past the bottom of the page are
	     ignored.  At the end of the sixel string, the current cursor
	     position is unchanged from where it was when the sixel string
	     started.  Defaults to set.
	     SOURCE: VT330/VT340 Programmer Reference Manual
deuce's avatar
deuce committed
857
858
859
860
861
	1000 -  Disable Normal tracking mode mouse reporting
	     SOURCE: xterm
	1001 -  Disable Highlight tracking mode mouse reporting
	     (Not supported by SyncTERM)
	     SOURCE: xterm
862
	1002 -  Disable Button-event tracking mode mouse reporting
deuce's avatar
deuce committed
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
	     SOURCE: xterm
	1003 -  Disable Any-event tracking mode mouse reporting
	     SOURCE: xterm
	1004 -  Disable Focus-event tracking mode mouse reporting
	     (Not supported by SyncTERM)
	     SOURCE: xterm
	1005 -  Disable UTF-8 encoded extended coordinates
	     (Not supported by SyncTERM)
	     SOURCE: xterm
	1006 -  Disable SGR encoded extended coordinates
	     SOURCE: xterm
	1007 -  Disable Alternate scroll mode
	     (Not supported by SyncTERM)
	     SOURCE: xterm
	1015 -  Disable URXVT encoded extended coordinates
	     (Not supported by SyncTERM)
	     SOURCE: xterm
deuce's avatar
deuce committed
880

deuce's avatar
deuce committed
881
CSI Ps... m (SGR)
882
	Select Graphic Rendition
deuce's avatar
deuce committed
883
	Defaults: Ps1 = 0
deuce's avatar
deuce committed
884
	Sets or clears one or more text attributes.  Unlimited parameters are
deuce's avatar
deuce committed
885
	supported and are applied in received order.  The following are
886
	supported:
887
888
889
890
891
892
	                                        Blink Bold FG BG TF TB (Modified)
	0 -  Default attribute, white on black     X    X  X  X  X  X
	1 -  Bright Intensity                           X        X
	2 -  Dim intensity                              X        X
	5 -  Blink (By definition, slow blink)     X                X
	6 -  Blink (By definition, fast blink)     X                X
893
	     NOTE: Both blinks are the same speed.
894
895
	7 -  Negative Image - Reverses FG and BG           X  X  X  X
	8 -  Concealed characters, sets the                X     X  X
896
	     foreground colour to the background
897
	     colour.
898
899
900
	22 - Normal intensity                           X        X
	25 - Steady (Not blinking)                 X                X
	27 - Positive Image - Reverses FG and BG           X  X  X  X
901
	     NOTE: This should be a separate
902
903
	           attribute than 7 but this
	           implementation makes them equal
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
	30 - Black foreground                              X     X
	31 - Red foreground                                X     X
	32 - Green foreground                              X     X
	33 - Yellow foreground                             X     X
	34 - Blue foreground                               X     X
	35 - Magenta foreground                            X     X
	36 - Cyan foreground                               X     X
	37 - White foreground                              X     X
	38 - Extended Foreground (see notes)                     X
	39 - Default foreground (same as white)	           X     X
	40 - Black background                                 X     X
	41 - Red background                                   X     X
	42 - Green background                                 X     X
	43 - Yellow background                                X     X
	44 - Blue background                                  X     X
	45 - Magenta background                               X     X
	46 - Cyan background                                  X     X
	47 - White background                                 X     X
	48 - Extended Background (see notes)                        X
	49 - Default background (same as black)               X     X
924
925
926

	All others are ignored.

927
928
929
930
931
932
933
	Blink indicates the blink bit.
	Bold indicates the bold bit.
	FG indicates the foreground colour.
	BG indicates the background colour.
	TF indicates that the Tru Colour foreground is changed.
	TB indicates that the Tru Colour background is changed.

934
935
936
937
938
	NOTE: For 38 and 48, two additional formats are supported, a palette
	selection and a direct colour selection.

	For palette selection, an additional two parameters are required
	after that value.  They are considered part of the 38/48, not separate
deuce's avatar
deuce committed
939
940
941
942
943
944
945
946
947
	values.  The first additional parameter must be a 5.  The second
	additional parameter specified the palette index to use.  To set the
	foreground to orange, and the background to a fairly dark grey, you
	would send:
	CSI 38 ; 5 ; 214 ; 48 ; 5 ; 238 m

	The default palette is the XTerm 256-colour palette.  See here:
	https://jonasjacek.github.io/colors/

948
	For direct colour selection, an additional four parameters are required
949
	after that value.  They are considered part of the 38/48, not separate
950
951
952
953
954
955
	values.  The first additional parameter must be a 2.  The second,
	third, and fourth specify the R/G/B values respectively. CTerm handles
	this with an internal temporary palette, so scrollback may not have the
	correct colours.  The internal palette is large enough for all cells in
	a 132x60 screen to have unique foreground and background colours
	though, so the current screen should always be as expected.
956

957
	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf
deuce's avatar
deuce committed
958
	SOURCE: XTerm
959

deuce's avatar
deuce committed
960
CSI Ps n (DSR)
961
	Device Status Report
deuce's avatar
deuce committed
962
	Defaults: Ps = 0
deuce's avatar
deuce committed
963
	A request for a status report.  CTerm handles the following three
deuce's avatar
deuce committed
964
965
	requests:
	5	- Request a DSR
966
967
		  CTerm will always reply with CSI 0 n indicating 
		  "ready, no malfunction detected"
deuce's avatar
deuce committed
968
969
970
	6	- Request active cursor position
		  CTerm will reply with CSI y ; x R where y is the current line
		  and x is
971
		  the current row.
deuce's avatar
deuce committed
972
	255	- NON-STANDARD EXTENSION (BCDSR)
deuce's avatar
deuce committed
973
		  Replies as though a CSI 6 n was received with the cursor in
974
975
		  the bottom right corner.  i.e.: Returns the terminal size as
		  a position report.
976
977

	SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf
deuce's avatar
deuce committed
978
		(parameters 5 and 6 only)
979
980
	SOURCE: BANSI.TXT (parameter 255)

deuce's avatar
deuce committed
981
CSI = Ps n (CTSMRR)
deuce's avatar
deuce committed
982
983
984
985
986
	NON-STANDARD EXTENSION
	State/Mode Request/Report
	Defaults: Ps = 1

	When Ps is 1, CTerm will respond with a Font State Report of the form
987
	CSI = 1 ;pF ;pR ;pS0 ;pS1 ;pS2 ;pS3 n
deuce's avatar
deuce committed
988
989
990
	pF is the first available loadable-font slot number
	pR is the result of the previous "Font Selection" request:
		0 = successful font selection
991
		1 = failed font selection
deuce's avatar
deuce committed
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
		99 = no font selection request has been received
	pS0 - pS3 contain the font slots numbers of previously successful
	"Font Selection" requests into the 4 available alternate-font
	style/attribute values:
		pS0 - normal attribute font slot
		PS1 - high intensity foreground attribute font slot
		PS2 - blink attribute font slot
		PS3 - high intensity blink attribute font slot

	When Ps is 2, CTerm will respond with a Mode Report of the form
	CSI = 2[;pN [;pN] [...]] n
	Where pN represent zero or more mode values set previously
	(e.g. via CSI ? pN h).	Mode values cleared (disabled via CSI ? pN l)
	will not be included in the set of values returned in the Mode
	Report.  If no modes are currently set, an empty parameter will be
	included as the first and only pN.

1009
1010
1011
1012
1013
	When Ps is 3, CTerm will respond with a Mode Report of the form
	CSI = 3 ; pH ; pW n
	Where pH is the height of a character cell in pixels, and pW is
	the width of a character cell in pixels.

deuce's avatar
deuce committed
1014
1015
	SOURCE: CTerm only.

1016
CSI ? Ps [ ; Pn ] n (DECDSR)
deuce's avatar
deuce committed
1017

1018
1019
	When Ps is 62 (DECMSR) and there is no Pn, CTerm will respond
	with a Mode Report of the form
1020
1021
1022
1023
1024
1025
	CSI 32767 * {
	This indicates that 524,272 bytes are available for macro storage.
	This is not actually true, SyncTERM will use all available memory
	for macro storage, but some software checks this value, and some
	parsers don't allow more than INT16_MAX parameter values.

1026
1027
1028
1029
1030
	When Ps is 63 (DECCKSR) Pn defaults to 1, and CTerm will respond
	with a checksum of the defined macros in the form
	DCS Pn ! xxxx ST
	Where xxxx is the hex checksum.

deuce's avatar
deuce committed
1031
	SOURCE: VT420
deuce's avatar
deuce committed
1032

deuce's avatar
deuce committed
1033
CSI Pn1 ; Pn2 r (DECSTBM)
deuce's avatar
deuce committed
1034
1035
1036
1037
1038
1039
1040
	NON-STANDARD EXTENSION.
	Set Top and Bottom Margins
	Defaults: Pn1 = 1
	          Pn2 = last line on screen
	Selects top and bottom margins, defining the scrolling region. Pn1 is
	the line number of the first line in the scrolling region. Pn2 is the
	line number of the bottom line.
1041
1042
	
	SOURCE: xterm
deuce's avatar
deuce committed
1043

deuce's avatar
deuce committed
1044
CSI Ps1 ; Ps2 * r (DECSCS)
deuce's avatar
deuce committed
1045
	NON-STANDARD EXTENSION.
deuce's avatar
deuce committed
1046
	Set the output emulation speed (Select Communication Speed).
deuce's avatar
deuce committed
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
	If Ps1 or Ps2 are omitted, causes output speed emulation to stop
	Ps1 may be empty.
	Sequence is ignored if Ps1 is not empty, 0, or 1.
	The value of Ps2 sets the output speed emulation as follows:

	Value		Speed
	-----		-----
	empty, 0	Unlimited
	1		300
	2		600
	3		1200
	4		2400
	5		4800
	6		9600
	7		19200
	8		38400
	9		57600
	10		76800
	11		115200

	SOURCE: VT4xx Specification from http://www.vt100.net/

deuce's avatar
deuce committed
1069
CSI ? Ps... s (CTSMS)
1070
	NON-STANDARD EXTENSION
1071
	Save Mode Setting
deuce's avatar
deuce committed
1072
	Saves the current mode states as specified by CSI ? l and CSI ? h.  If
deuce's avatar
deuce committed
1073
1074
	Ps1 is omitted, saves all such states.  If one or more values of Ps is
	included, saves only the specified states (arguments to CSI ? l/h).
deuce's avatar
deuce committed
1075

1076
	SOURCE: SyncTERM only
1077

deuce's avatar
deuce committed
1078
CSI Pn1 ; Pn2 s (DECSLRM)
1079
1080
1081
1082
1083
        (Only when DEC Left Right Margin Mode  - 69 - is enabled)
	NON-STANDARD EXTENSION.
	Set Left and Right Margins
	Defaults: Pn1 = 1
	          Pn2 = last column on screen
1084
	If either Pn1 or Pn2 is zero, the current setting is retained.
1085
1086
1087
1088
1089
1090
	Selects left and right margins, defining the scrolling region. Pn1 is
	the column number of the first column in the scrolling region. Pn2 is
	the column number of the right column.

	SOURCE: xterm

deuce's avatar
deuce committed
1091
CSI s (SCOSC)
1092
        (Only when DEC Left Right Margin Mode  - 69 - is disabled)
1093
1094
1095
	NON-STANDARD EXTENSION
	Save Current Position
	Saves the current cursor position for later restoring with CSI u
1096
1097
	although this is non-standard, it's so widely used in the BBS world
	that any terminal program MUST implement it.
deuce's avatar
deuce committed
1098

1099
	SOURCE: ANSI.SYS
1100

deuce's avatar
deuce committed
1101
CSI Ps ; Pn1 ; Pn2 ; Pn3 t (CT24BC)
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
	NON-STANDARD EXTENSION
	Select a 24-bit colour
	If Ps is 0, sets the background colour.
	If Ps is 1, sets the foreground colour.
	Pn1, Pn2, Pn3 contains the RGB value to set.
	CTerm handles this with an internal temporary palette, so scrollback
	may not have the correct colours.  The internal palette is large
	enough for all cells in a 132x60 screen to have unique foreground
	and background colours though, so the current screen should always
	be as expected.

deuce's avatar
deuce committed
1113
CSI ? Ps...  u (CTRMS)
1114
	NON-STANDARD EXTENSION
1115
	Restore Mode Setting
deuce's avatar
deuce committed
1116
	Saves the current mode states as specified by CSI ? l and CSI ? h.  If
deuce's avatar
deuce committed
1117
1118
	Ps is omitted, saves all such states.  If one or more values of Ps is
	included, restores all the specified states (arguments to CSI ? l/h)
deuce's avatar
deuce committed
1119

1120
	SOURCE: SyncTERM only
1121

deuce's avatar
deuce committed
1122
CSI u (SCORC)
deuce's avatar
deuce committed
1123
	NON-STANDARD EXTENSION
1124
	Restore Cursor Position
1125
1126
	Move the cursor to the last position saved by CSI s.  If no position
	has been saved, the cursor is not moved.
1127

1128
	SOURCE: ANSI.SYS
1129

deuce's avatar
deuce committed
1130
CSI 2 $ w (DECTABSR)
deuce's avatar
deuce committed
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
	Request Tab Stop Report
	Requests a list of tab stops.
	The list is in the form:
	
	DCS 2 $ u Pt ST
	
	The string Pt is a list of tab stops separated by /s.
	
	SOURCE: VT320

1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
CSI Pn1 ; Ps ; Pn2 ; Pn3 ; Pn4 ; Pn5 * y (DECRQCRA)
	Request Checksum of Rectangular Area
	Returns a checksum for the specified rectangular area.
	Pn1 is an ID that is returned in the response.
	Ps MUST be 1
	Pn2 specifies the top row of the rectangle
	Pn3 specifies the left column of the rectangle
	Pn4 specifies the bottom row of the rectangle
	Pn5 specifies the right column of the rectangle
	The return value is in the format of DCS Pn1 ! ~ xxxx ST
	Where xxxx is the hex value of the checksum.

	Source: VT420

1155
1156
CSI Pn * z (DECINVM)
	Invoke Macro
1157
1158
1159
1160
	Invokes a macro.
	Pn specifies the macro number.  If Pn is not 0..63, no action is
	taken.

deuce's avatar
deuce committed
1161
CSI = Ps1 ; Ps2 { (CTOSF)
1162
	NON-STANDARD EXTENSION (Deprecated)
deuce's avatar
deuce committed
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
	Defaults:  Ps1 = 255  Ps2 = 0
	Indicates that a font block is following.
	Ps1 indicates the font slot to place the loaded font into.  This must
	be higher than the last default defined font (See CSI sp D for list
	of predefined fonts)  Ps2 indicates font size according to the
	following table:
		0 - 8x16 font, 4096 bytes.
		1 - 8x14 font, 3584 bytes.
		2 - 8x8 font, 2048 bytes.

1173
1174
	The DCS font string should be used instead as of CTerm 1.213

deuce's avatar
deuce committed
1175
1176
	SOURCE: CTerm only.

1177
1178
"ANSI" Music
============
deuce's avatar
deuce committed
1179
This is the place where the BBS world completely fell on it's face in ANSI
1180
usage.  A programmer with either TeleMate or QModem (the first two programs to
deuce's avatar
deuce committed
1181
support "ANSI" music as far as I can tell) decided they needed a method of
1182
playing music on a BBS connection.  They decided to add an "unused" ANSI code
deuce's avatar
deuce committed
1183
1184
1185
and go their merry way.  Since their product didn't implement CSI M (Delete
line) they assumed it was unused and blissfully broke the spec.  They defined
"ANSI" music as:
1186
CSI M <music string> 0x0e
deuce's avatar
deuce committed
1187

1188
They used a subset of IBM BASICs PLAY statement functionality for ANSI music
1189
strings which often start with "MF" or "MB", so the M after the CSI was often
deuce's avatar
deuce committed
1190
considered as part of the music string.  You would see things such as:
1191
CSI MFABCD 0x0e and the F would not be played as a note.  This just added
deuce's avatar
deuce committed
1192
1193
further confusion to the mess.

1194
1195
1196
1197
1198
1199
1200
Later on, BananaCom realized the conflict between delete line and music, so
they added *another* broken code CSI N (Properly, erase in field... not
implemented in many BBS clients) which was to provide an "unbroken" method of
playing music strings.  They also used CSI Y to disambiguate delete line, CSI Y
is supposed to be a vertical tab (also not implemented in very many clients).
BananaCom also introduced many more non-standard and standard-breaking control
sequences which are not supported by CTerm.
deuce's avatar
deuce committed
1201
1202
1203
1204
1205
1206

CTerm has further introduced a standard compliant ANSI music introducer CSI |

By default, CTerm allows both CSI N and CSI | to introduce a music string.
Allowed introducers are set by CSI = p1 M as defined above.

1207
The details of ANSI music then are as follows:
deuce's avatar
deuce committed
1208
1209
1210
1211
1212
1213
The following characters are allowed in music strings:
"aAbBcCdDeEfFgGlLmMnNoOpPsStT0123456789.-+#<> "
If any character not in this list is present, the music string is ignored as
is the introducing code.

If the introducing code is CSI M the first char is examined, and if it is
deuce's avatar
deuce committed
1214
1215
1216
a one of "BbFfLlSs" or if it is "N" or "n" and is not followed by a decimal
digit, then the music string is treated as though an M is located in front
of the first character.
deuce's avatar
deuce committed
1217
1218

The music string is then parsed with the following sequences supported:
1219
Mx sets misc. music parameters where x is one of the following:
deuce's avatar
deuce committed
1220
1221
1222
	F - Plays music in the foreground, waiting for music to complete
	    playing before more characters are processed.
	B - Play music in the background, allowing normal processing to
1223
	    continue.
1224
	N - "Normal" not legato, not staccato
deuce's avatar
deuce committed
1225
	L - Play notes legato
1226
	S - Play notes staccato
deuce's avatar
deuce committed
1227
T### Sets the tempo of the music where ### is one or more decimal digits.
deuce's avatar
deuce committed
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
	If the decimal number is greater than 255, it is forced to 255.
	If it is less than 32, it is forced to 32.  The number signifies
	quarter notes per minute.
	The default tempo is 120.
O### Sets the octave of the music where ### is one or more decimal digits.
	If the decimal number is greater than 6, it is forced to 6.
	The default octave is 4.
N### Plays a single note by number.  Valid values are 0 - 71.  Invalid
	values are played as silence.  Note zero is C in octave 0.
	See following section for valid note modifiers.
1238
A, B, C, D, E, F, G, or P Plays the named note or pause from the current
deuce's avatar
deuce committed
1239
	octave.  An "Octave" is the rising sequence of the following notes:
deuce's avatar
deuce committed
1240
1241
	C, C#, D, D#, E, F, F#, G, G#, A, A#, B
	This is contrary to normal music terminology.
deuce's avatar
deuce committed
1242
	The special note "P" is a pause.
deuce's avatar
deuce committed
1243
1244
1245
1246
1247
	Notes may be followed by one or more modifier characters which
	are applied in order.  If one overrides a previous one, the last
	is used.  The valid modifiers are:
	+ - Sharp.  The next highest semitone is played.
		Each sharp character will move up one semitone, so "C++"
1248
		is equivalent to "D".
deuce's avatar
deuce committed
1249
1250
	# - Sharp.  The next highest semitone is played.
		Each sharp character will move up one semitone, so "C##"
1251
		is equivalent to "D".
deuce's avatar
deuce committed
1252
1253
	- - Flat.  The next lowest semitone is played.
		Each flat character will move down one semitone, so "D--"
1254
		is equivalent to "C".
deuce's avatar
deuce committed
1255
	. - Duration is 1.5 times what it would otherwise be.  Dots are not
1256
1257
		cumulative, so "C.." is equivalent to "C."
	### - Notelength as a reciprocal of the fraction of a whole note to
deuce's avatar
deuce committed
1258
1259
		play the note for.  For example, 4 would indicate a 1/4 note.
		The default note length is 4.
1260
L### Set the notelength parameter for all following notes which do not have
1261
1262
1263
	one specified (ie: override the quarter-note default)  Legal note
	lengths are 1-64 indicating the reciprocal of the fraction (ie: 4
	indicates a 1/4 note).
1264
<	Move the next lowest octave.
deuce's avatar
deuce committed
1265
1266
1267
1268
1269
1270
	Octave cannot go above six or below zero.
>	Move to the next highest octave.
	Octave cannot go above six or below zero.

The lowest playable character is C in octave zero.  The frequencies for the
six C notes for the seven octaves in rising order are:
1271
65.406, 130.810, 261.620, 523.250, 1046.500, 2093.000, 4186.000
deuce's avatar
deuce committed
1272
1273
1274

Purists will note that the lower three octaves are not exactly one half of
the next higher octave in frequency.  This is due to lost resolution of
1275
low frequencies.  The notes *sound* correct to me.  If anyone can give me
deuce's avatar
deuce committed
1276
1277
an excellent reason to change them (and more correct integer values for all
notes) I am willing to do that assuming the notes still sound "right".
1278

1279
!!!PLEASE NOTE!!! If you are playing some ANSI Music then ask the user if they
1280
heard it, ALWAYS follow it with an 0x0f 0x0e is the shift lock character which
1281
1282
1283
*will* cause people with anything but an ANSI-BBS terminal (ie: *nix users
using the bundled telnet app) to have their screen messed up.  0x0f "undoes"
the 0x0e.