cterm.txt 27.4 KB
Newer Older
1
2
3
$Id$

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
Control characters:

15
16
17
18
19
20
NUL:
	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.

21
22
23
24
CR:
	Move cursor position to column 1 of the current line

LF:
25
	Move cursor position to same column of the next row.
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
	If current row is the last row, scrolls the screen up
	and fills the new row with the current attribute.

BS:
	Non-destructive backspace.  Moves cursor position to
	the previous column unless the current column is the
	first, in which case no operation is performed.

0x07:
	Beep

TAB:
	Moves to the next tab stop.  Does not overwrite any
	characters in between.  If the starting position is
	last column, advances to next line.  If starting
	position is the last column of the last line, performs
	a scroll, filling the new line at bottom with the
	current attribute and moves to the first character in
	the new line.

Control Codes:
--------------

Control codes are in the following format:
ESC {SPACE to '/'}{'0' (ZERO) to '~'}
	There may be multiple characters from the {SPACE to '/'} set
	before the terminating '0' to '~'

	Legal combinations which are not handled are silently dropped.

56
ESC D	(Disabled in current code)
57
58
59
60
	Scrolls window up one line filling the bottom line with the
	current attribute.
	SOURCE: BANSI.TXT

61
ESC M	(Disabled in current code)
62
63
64
65
	Scrolls window down one line filling the top line with the
	current attribute
	SOURCE: BANSI.TXT

deuce's avatar
deuce committed
66
67
68
69
70
71
ESC _	Application Program String
ESC P	Device Control String
ESC ^	Privacy Message
	Begins a string consisting of the characters 0x08 - 0x0d and
	0x20-0x7e, terminated by a String Terminator (ST)
	The string is currently ignored.
72
73
74
75
76
77
78
79
80
81
82
83
84
85
ESC ]	Operating System Command
	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
86

87
88
89
90
91
92
93
		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

deuce's avatar
deuce committed
94
95
96
ESC X	Start Of String
	As the above strings, but may contain any characters except
	a Start Of String sequence or a String Terminator sequence.
97
	The string is currently ignored.
deuce's avatar
deuce committed
98
99
100

ESC \	String Terminator

101
102
103
Control Sequences:
------------------

104
105
106
Control sequences start with the Control Sequence Introducer which is
ESC [  CSI will be used to express this from now on.

107
Control sequences are in the following format:
108
CSI {'0' (ZERO) to '?'}{SPACE to '/'}{'@' to '~'}
109
110
111
112
	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.
113
	Illegal combinations are displayed.
114
115
116
117

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
118
	a ';'.  The use of a ':' from the set is reserved.
119
120
121
	If the parameter string begins with '<', '=', '>', or '?' then
	this is a non-standard extension to the ANSI spec.

122
123
124
125
126
127
128
129
130
	Parameters will be shown as pX where X will be a decimal position
	number.  Surrounded by [] indicates the parameter is optional.

CSI = [p1] M
	NON-STANDARD EXTENSION.
	Defaults:  p1 = 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.
131
	2 - CSI |, CSI N, and CSI M will all introduce an ANSI music string.
132
133
134
135
	    In this mode, Delete Line will not be available.

	SOURCE: CTerm only.

136
137
138
139
140
141
142
143
144
145
146
147
148
149
CSI = [ p1 [ ; p2 ] ] {
	NON-STANDARD EXTENSION.
	Defaults:  p1 = 255  p2 = 0
	Indicates that a font block is following.
	p1 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)  p2 indicates font size according to the
	following table:
		0 - 8x16 font, 4096 bytes.
		1 - 8x14 font, 3586 bytes.
		2 - 8x8 font, 2048 bytes.

	SOURCE: CTerm only.

150
CSI = [ p1 [ ; ... ] ] n
151
	NON-STANDARD EXTENSION
152
	State/Mode Request/Report
153
	Defaults: p1 = 1
154

155
	When p1 is 1, CTerm will respond with a Font State Report of the form
156
157
158
159
160
161
        CSI = 1 ;pF ;pR ;pS0 ;pS1 ;pS2 ;pS3 n
	pF is the first available loadable-font slot number
	pR is the result of the previous "Font Selection" request:
		0 = successful font selection
		1 = font selection requests are not supported by client
		2 = required subsystem for font use has not been initialized
162
163
		3 = selected font is not available or is incompatible with
		    current video mode
164
		4 = invalid font slot number specified in request
165
166
		5 = required video mode for selected font is incompatible
		    with current video mode
167
		6 = memory allocation failure
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
		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 p1 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.
184

185
	SOURCE: CTerm only.
186

187
CSI = 255 h
188
189
190
191
192
	NON-STANDARD EXTENSION
	Enable DoorWay Mode

	SOURCE: BANSI.TXT

193
194
CSI ? 6 h
	NON-STANDARD EXTENSION
195
196
197
198
199
200
	Enable origin mode.

	In this mode, position parameters are relative to the top left of the
	scrolling region, not the screen.

	SOURCE: Digital VT102 User Guide
201

202
203
CSI ? 7 h
	NON-STANDARD EXTENSION
204
205
206
207
208
209
210
	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.

	SOURCE: Digital VT102 User Guide
211
212

CSI ? 25 h
213
214
215
216
217
	NON-STANDARD EXTENSION
	Display the cursor

	SOURCE: "Installing and Using the VT320 Video Terminal"

218
CSI ? 31 h
219
	NON-STANDARD EXTENSION
220
	Enable bright alt character set
221

222
223
	With this mode set, the bright (1) graphic rendition selects
	characters from an alternate character set.
224

225
226
CSI ? 32 h
	NON-STANDARD EXTENSION
227
	Bright Intensity Disable
228

229
	This makes the bright intensity bit not control the intensity.
230
231
	Mostly for use with CSI ? 31 h to permit fonts in the same
	colours.
232

233
CSI ? 33 h
234
235
236
237
238
239
	NON-STANDARD EXTENSION
	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

240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
CSI ? 34 h
	NON-STANDARD EXTENSION
	Enable blink alt character set

	With this mode set, the blink (5,6) graphic renditions selects
	characters from an alternate character set.

CSI ? 35 h
	NON-STANDARD EXTENSION
	Blink Disabled

	This makes the blink bit not cause the character to blink.
	Mostly for use with CSI ? 34 h to permit fonts to be used without
	blinking.

255
CSI = 255 l
256
257
258
259
260
	NON-STANDARD EXTENSION
	Disable DoorWay Mode

	SOURCE: BANSI.TXT

261
CSI ? 6 h
262
	NON-STANDARD EXTENSION
263
264
265
266
267
268
	Disable origin mode.

	In this mode, position parameters are relative to the top left of the
	screen, not the scrolling region.

	SOURCE: Digital VT102 User Guide
269

270
271
CSI ? 7 l
	NON-STANDARD EXTENSION
272
273
274
275
276
277
278
	Disable auto wrap.

	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
279

280
CSI ? 25 l
281
	NON-STANDARD EXTENSION
282
283
284
	Hide the cursor

	SOURCE: "Installing and Using the VT320 Video Terminal"
285

286
CSI ? 31 l
287
288
289
	NON-STANDARD EXTENSION
	Disable alt character set

290
	Reverses CSI ? 31 h
291

292
CSI ? 32 l
293
	NON-STANDARD EXTENSION
294
	Bright Intensity Enable
295

296
297
	Causes "bright" foreground characters to be bright.
	Reverses CSI ? 32 h
298

299
CSI ? 33 l
300
301
302
	NON-STANDARD EXTENSION
	Blink Normal

303
	Reverses CSI ? 33 h
304

305
306
307
308
309
310
311
312
313
314
315
316
CSI ? 34 l
	NON-STANDARD EXTENSION
	Disable alt character set

	Reverses CSI ? 34 h

CSI ? 35 l
	NON-STANDARD EXTENSION
	Blink Enabled

	Reverses CSI ? 35 h

317
CSI [ p1 [ ; p2 ] ] * r
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
	NON-STANDARD EXTENSION.
	Set the output emulation speed.
	If p1 or p2 are omitted, causes output speed emulation to stop
	p1 may be empty.
	Sequence is ignored if p1 is not empty, 0, or 1.
	The value of p2 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/
341

342
343
CSI [ p1 [ ; p2 ] ] r
	NON-STANDARD EXTENSION.
344
345
346
347
348
349
	Set Top and Bottom Margins
	Defaults: p1 = 1
		p2 = last line on screen
	Selects top and bottom margins, defining the scrolling region. P1 is
	the line number of the first line in the scrolling region. P2 is the
	line number of the bottom line.
350

deuce's avatar
deuce committed
351
352
353
354
CSI [ p1 ] @
	Insert Character(s)
	Defaults: p1 = 1
	Moves text from the current position to the right edge p1 characters
355
	to the right, with rightmost characters going off-screen and the
deuce's avatar
deuce committed
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
	resulting hole being filled with the current attribute.

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

CSI [ p1 ] A
	Cursor Up
	Defaults: p1 = 1
	Moves the cursor position up p1 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

CSI [ p1 ] B
	Cursor Down
	Defaults: p1 = 1
	Moves the cursor position down p1 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

CSI [ p1 ] C
	Cursor Right
	Defaults: p1 = 1
	Moves the cursor position right p1 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

CSI [ p1 ] D
	Cursor Left
	Defaults: p1 = 1
	Moves the cursor position left p1 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

396
397
398
CSI [ p1 [ ; p2 ] ] sp D
	Font Selection
	Defaults: p1 = 0  p2 = 0
399
	"sp" indicates a single space character.
400
	Sets font p1 to be the one indicated by p2.  Currently four fonts are
401
402
403
404
	supported.  p2 must be between 0 and 255.  Not all output types support
	font selection.  Only X11 and SDL currently do.
	Supported p1 values:
		0  - Default font
405
406
407
408
409
410
		1  - Font selected by the high intensity bit when CSI [ ? 31 h
		     is enabled
		2  - Font selected by the blink intensity bit when CSI [ ? 34 h
		     is enabled
		3  - Font selected by both the high intensity and blink bits
		     when both CSI [ ? 31 h and CSI [ ? 34 h are enabled
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
	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)
444
445
446
447
448
		32 - Commodore 64 (UPPER)
		33 - Commodore 64 (Lower)
		34 - Commodore 128 (UPPER)
		35 - Commodore 128 (Lower)
		36 - Atari
deuce's avatar
deuce committed
449
450
		37 - P0T NOoDLE (Amiga) 
		38 - mO'sOul (Amiga)    
451
452
453
454
		39 - MicroKnight Plus (Amiga)
		40 - Topaz Plus (Amiga)      
		41 - MicroKnight (Amiga)
		42 - Topaz (Amiga)      
455
456
457
	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.
458

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

deuce's avatar
deuce committed
461
462
463
CSI [ p1 ] E
	Cursor Next Line
	Defaults: p1 = 1
464
465
466
467
	Moves the cursor to the first column of the line p1 down from the
	current position. Moving past the bottom of the screen scrolls the
	screen up the remaining number of lines filling newly added lines
	with the current attribute.
deuce's avatar
deuce committed
468
469
470

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

471
472
473
CSI [ p1 ] F
	Cursor Preceding Line
	Defaults: p1 = 1
474
475
476
	Moves the cursor to the first column if the row p1 up from the
	current position.  Attempting to move past the screen boundaries
	stops the cursor at the screen boundary.
477
478
479

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

deuce's avatar
deuce committed
480
481
482
483
CSI [ p1 ] G
	Cursor Character Absolute
	Defaults: p1 = 1
	Movies the cursor to column p1 of the current row.
484

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

deuce's avatar
deuce committed
487
488
CSI [ p1 [ ; p2 ] ] H
CSI [ p1 [ ; p2 ] ] f
489
	Cursor Position
deuce's avatar
deuce committed
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
	Defaults: p1 = 1  p2 = 1
	Moves the cursor to the p2th column of the p1th line.

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

CSI [ p1 ] J
	Erase in Page
	Defaults: p1 = 0
	Erases from the current screen according to the value of p1
	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.

	SOURCE BANSI.TXT

CSI [ p1 ] K
	Erase in Line
	Defaults: p1 = 0
	Erases from the current line according to the value pf p1
	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

CSI [ p1 ] L
	Insert Line(s)
	Defaults: p1 = 1
	Inserts p1 lines at the current line position.  The current line and
523
524
	those after it are scrolled down and the new empty lines are filled
	with the current attribute.
deuce's avatar
deuce committed
525
526
527
528
529
530

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

CSI [ p1 ] M
	Delete Line(s) / "ANSI" Music
	Defaults: p1 = 1
deuce's avatar
deuce committed
531
532
533
534
535
	Deletes the current line and the p1 - 1 lines after it scrolling the
	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.
	If "ANSI" Music is fully enabled (CSI = 2 M), performs "ANSI" music
	instead.
deuce's avatar
deuce committed
536
537
538
539
540
541
542
	See "ANSI" MUSIC section for more details.

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

CSI N
	"ANSI" Music / Not implemented.
deuce's avatar
deuce committed
543
	If "ANSI" Music is set to BananaCom (CSI = 1 M) or fully enabled
544
	(CSI = 2 M) performs "ANSI" music.  See "ANSI" MUSIC section for more
deuce's avatar
deuce committed
545
	details.
deuce's avatar
deuce committed
546
547
548
549
550
551

	SOURCE: BANSI.TXT

CSI [ p1 ] P
	Delete Character
	Defaults: p1 = 1
552
553
554
555
	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
	attribute.
deuce's avatar
deuce committed
556
557
558
559
560
561

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

CSI [ p1 ] S
	Scroll Up
	Defaults: p1 = 1
deuce's avatar
deuce committed
562
563
	Scrolls all text on the screen up p1 lines.  New lines emptied at the
	bottom are filled with the current attribute.
deuce's avatar
deuce committed
564
565
566
567
568
569

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

CSI [ p1 ] T
	Scroll Down
	Defaults: p1 = 1
deuce's avatar
deuce committed
570
571
	Scrolls all text on the screen down p1 lines.  New lines emptied at the
	top are filled with the current attribute.
deuce's avatar
deuce committed
572
573

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

575
576
577
CSI U
	NON-STANDARD (Disabled in current code)
	Clear screen with default attribute.
deuce's avatar
deuce committed
578
579
	This code is *supposed* to go to the "next page" according to the
	ANSI/ECMA specs with CSI V going to "previous page"
580
581
582

	SOURCE: BANSI.TXT

583
584
585
CSI [ p1 ] X
	Erase Character
	Defaults: p1 = 1
586
587
	Erase p1 characters starting at the current character.  Will not erase
	past the end of line.
588
589
590
591
	Erased characters are set to the current attribute.

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

592
593
CSI [ p1 ] Z
	Cursor Backward Tabulation
594
	Defaults: p1 = 1
595
	Move the cursor to the p1th preceding tab stop.  Will not go past the
deuce's avatar
deuce committed
596
	start of the line.
597
598
599

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

600
601
602
603
CSI [ p1 ] c
	Device Attributes
	Defaults: p1 = 0
	If p1 is 0, CTerm will reply with the sequence:
604
        CSI = 67;84;101;114;109;pN c
deuce's avatar
deuce committed
605
	64;84;101;114;109 is the ASCII values of the "CTerm" string.  pN is the
606
607
608
609
610
	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!
611

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

614
615
616
CSI [ p1 [ ; pX ... ] ] m
	Select Graphic Rendition
	Defaults: p1 = 0
deuce's avatar
deuce committed
617
	Sets or clears one or more text attributes.  Unlimited parameters are
deuce's avatar
deuce committed
618
	supported and are applied in received order.  The following are
619
	supported:
deuce's avatar
deuce committed
620
	                                        Blink Bold FG BG (Modified)
621
	0 -  Default attribute, white on black     X    X  X  X
deuce's avatar
deuce committed
622
	1 -  Bright Intensity                           X
623
	2 -  Dim intensity                              X
624
625
626
627
628
	5 -  Blink (By definition, slow blink)     X
	6 -  Blink (By definition, fast blink)     X
	     NOTE: Both blinks are the same speed.
	7 -  Negative Image - Reverses FG and BG           X  X
	8 -  Concealed characters, sets the                X
629
	     foreground colour to the background
630
	     colour.
deuce's avatar
deuce committed
631
632
	22 - Normal intensity                           X
	25 - Steady (Not blinking)                 X
633
634
	27 - Positive Image - Reverses FG and BG           X  X
	     NOTE: This should be a separate
635
636
	           attribute than 7 but this
	           implementation makes them equal
deuce's avatar
deuce committed
637
638
639
640
641
642
643
644
	30 - Black foreground                              X
	31 - Red foreground                                X
	32 - Green foreground                              X
	33 - Yellow foreground                             X
	34 - Blue foreground                               X
	35 - Magenta foreground                            X
	36 - Cyan foreground                               X
	37 - White foreground                              X
645
	39 - Default foreground (same as white)	           X
deuce's avatar
deuce committed
646
647
648
649
650
651
652
653
654
	40 - Black background                                 X
	41 - Red background                                   X
	42 - Green background                                 X
	43 - Yellow background                                X
	44 - Blue background                                  X
	45 - Magenta background                               X
	46 - Cyan background                                  X
	47 - White background                                 X
	49 - Default background (same as black)               X
655
656
657
658
659
660
661
662

	All others are ignored.

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

CSI [ p1 ] n
	Device Status Report
	Defaults: p1 = 0
deuce's avatar
deuce committed
663
	A request for a status report.  CTerm handles the following three
deuce's avatar
deuce committed
664
665
	requests:
	5	- Request a DSR
666
667
		  CTerm will always reply with CSI 0 n indicating 
		  "ready, no malfunction detected"
deuce's avatar
deuce committed
668
669
670
	6	- Request active cursor position
		  CTerm will reply with CSI y ; x R where y is the current line
		  and x is
671
		  the current row.
deuce's avatar
deuce committed
672
	255	- NON-STANDARD EXTENSION
673
		  Replies as though a CSI [ 6 n was received with the cursor in
674
675
		  the bottom right corner.  i.e.: Returns the terminal size as
		  a position report.
676
677

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

681
682
CSI ? [ p1 [ pX ... ] ] s
	NON-STANDARD EXTENSION
683
	Save Mode Setting
deuce's avatar
deuce committed
684
	Saves the current mode states as specified by CSI ? l and CSI ? h.  If
685
	p1 is omitted, saves all such states.  If pX is included, saves only
deuce's avatar
deuce committed
686
687
	the specified states (arguments to CSI ? l/h).

688
	SOURCE: SyncTERM only
689

690
691
692
693
CSI s
	NON-STANDARD EXTENSION
	Save Current Position
	Saves the current cursor position for later restoring with CSI u
694
695
	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
696

697
	SOURCE: ANSI.SYS
698

699
700
CSI ? [ p1 [ pX ... ] ]  u
	NON-STANDARD EXTENSION
701
	Restore Mode Setting
deuce's avatar
deuce committed
702
	Saves the current mode states as specified by CSI ? l and CSI ? h.  If
703
	p1 is omitted, saves all such states.  If pX is included, restores
deuce's avatar
deuce committed
704
705
	all the specified states (arguments to CSI ? l/h)

706
	SOURCE: SyncTERM only
707

708
CSI u
deuce's avatar
deuce committed
709
	NON-STANDARD EXTENSION
710
	Restore Cursor Position
711
712
	Move the cursor to the last position saved by CSI s.  If no position
	has been saved, the cursor is not moved.
713

714
	SOURCE: ANSI.SYS
715
716
717

"ANSI" Music
============
deuce's avatar
deuce committed
718
This is the place where the BBS world completely fell on it's face in ANSI
719
usage.  A programmer with either TeleMate or QModem (the first two programs to
deuce's avatar
deuce committed
720
support "ANSI" music as far as I can tell) decided they needed a method of
721
playing music on a BBS connection.  They decided to add an "unused" ANSI code
deuce's avatar
deuce committed
722
723
724
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:
725
CSI M <music string> 0x0e
deuce's avatar
deuce committed
726

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

733
734
735
736
737
738
739
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
740
741
742
743
744
745

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.

746
The details of ANSI music then are as follows:
deuce's avatar
deuce committed
747
748
749
750
751
752
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
753
754
755
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
756
757

The music string is then parsed with the following sequences supported:
758
Mx sets misc. music parameters where x is one of the following:
deuce's avatar
deuce committed
759
760
761
	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
762
	    continue.
763
	N - "Normal" not legato, not staccato
deuce's avatar
deuce committed
764
	L - Play notes legato
765
	S - Play notes staccato
deuce's avatar
deuce committed
766
T### Sets the tempo of the music where ### is one or more decimal digits.
deuce's avatar
deuce committed
767
768
769
770
771
772
773
774
775
776
	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.
777
A, B, C, D, E, F, G, or P Plays the named note or pause from the current
deuce's avatar
deuce committed
778
	octave.  An "Octave" is the rising sequence of the following notes:
deuce's avatar
deuce committed
779
780
	C, C#, D, D#, E, F, F#, G, G#, A, A#, B
	This is contrary to normal music terminology.
deuce's avatar
deuce committed
781
	The special note "P" is a pause.
deuce's avatar
deuce committed
782
783
784
785
786
	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++"
787
		is equivalent to "D".
deuce's avatar
deuce committed
788
789
	# - Sharp.  The next highest semitone is played.
		Each sharp character will move up one semitone, so "C##"
790
		is equivalent to "D".
deuce's avatar
deuce committed
791
792
	- - Flat.  The next lowest semitone is played.
		Each flat character will move down one semitone, so "D--"
793
		is equivalent to "C".
deuce's avatar
deuce committed
794
	. - Duration is 1.5 times what it would otherwise be.  Dots are not
795
796
		cumulative, so "C.." is equivalent to "C."
	### - Notelength as a reciprocal of the fraction of a whole note to
deuce's avatar
deuce committed
797
798
		play the note for.  For example, 4 would indicate a 1/4 note.
		The default note length is 4.
799
L### Set the notelength parameter for all following notes which do not have
800
801
802
	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).
803
<	Move the next lowest octave.
deuce's avatar
deuce committed
804
805
806
807
808
809
	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:
810
65.406, 130.810, 261.620, 523.250, 1046.500, 2093.000, 4186.000
deuce's avatar
deuce committed
811
812
813

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
814
low frequencies.  The notes *sound* correct to me.  If anyone can give me
deuce's avatar
deuce committed
815
816
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".
817

818
!!!PLEASE NOTE!!! If you are playing some ANSI Music then ask the user if they
819
heard it, ALWAYS follow it with an 0x0f 0x0e is the shift lock character which
820
821
822
*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.