-
Notifications
You must be signed in to change notification settings - Fork 8
/
supdup.mss
2160 lines (1742 loc) · 98.5 KB
/
supdup.mss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
@make(epap) @comment[-*-scribe-*-]
@case[draft, memo={@textform(memo=(@parm<text>))},
loser={@textform(memo=())}]
@Style(stringmax=20000)
@case[draft, memo={
@pageheading(even, right "The SUPDUP Protocol", left "Page @ref(page)")
@pageheading(odd, left "Richard M. Stallman", right "Page @ref(page)")}]
@define(narrow, leftmargin +.25inch, indent 0)
@modify(description, leftmargin +.25inch, indent -.25inch)
@textform(BigSection=[@memo<@newpage()>
@section(@parm(text))])
@begin(TitleBox,Fixed .75inch)
@case[draft, memo={
@Center(MASSACHUSETTS INSTITUTE OF TECHNOLOGY
ARTIFICIAL INTELLIGENCE LABORATORY)
@blankspace(.4inches)
@flushleft(AI Memo 644@>@Value(Date))
@blankspace(.5inches)
@Majorheading(The SUPDUP Protocol)
@MajorHeading(by)
@MajorHeading(Richard M. Stallman)},
loser={
@modify(majorheading,below 0)
@modify(heading,Above 0.6cm)
@MajorHeading(The SUPDUP Protocol)
@Heading(Richard M. Stallman
Artificial Intelligence Lab
Massachusetts Institute of Technology
Cambridge, MA 02139)
}]
@end(TitleBox)
@Begin(Abstract)
The SUPDUP protocol provides for login to a remote
system over a network with terminal-independent output, so that only the
local system need know how to handle the user's terminal.
It offers facilities for graphics and for local assistance to
remote text editors. This memo contains a complete description
of the SUPDUP protocol in fullest possible detail.
@memo<
@B(Keywords:) Communications, Display, Networks.
>
@end(Abstract)
@Begin(ResearchCredit)
This report describes work done at the Artificial Intelligence Laboratory
of the Massachusetts Institute of Technology. Support for the laboratory's
research is provided in part by the Advanced Research Projects Agency of the
Department of Defense under Office of Naval Research contract N00014-80-C-0505.
@End(ResearchCredit)
@Unnumbered(Introduction)
The SUPDUP protocol is a superior replacement for the TELNET protocol.
Its name means "Super Duper".
The basic purpose of the two protocols is the same: allow a user to log
in to a remote system connected to his local system by a network, as if
his terminal were directly connected to the remote system. Both
protocols define a "virtual terminal" which the remote system is
expected to use. The difference is that TELNET's "Network Virtual
Terminal" is an obsolete teletype, whereas SUPDUP's virtual terminal is
a display, capable (optionally) of powerful operations on
text, drawing pictures, and invisibly sharing the work of a text editor
running on the computer, all totally under the computer's control.
The cost associated with SUPDUP is that the remote system must be
capable of communicating with SUPDUP's virtual terminal.
Most operating systems understand nothing more than simple printing
terminals, leaving everything else to user programs. The SUPDUP virtual
display terminal is not a superset of the simple printing terminal, so
these operating systems cannot serve as the remote system for SUPDUP.
They can support user programs which make SUPDUP connections to other
systems. Since these operating systems have the deficiency that every
user program which does display must know the details of operation of
each type of terminal to be used, they are inferior anyway; a modern
operating system which provides terminal-independent display support
will have no trouble supporting SUPDUP, or anything like SUPDUP.
SUPDUP can operate over any pair of streams which transmit 8-bit
bytes.
The SUPDUP protocol was created initially by taking the formats
of data in the terminal input and output buffers of ITS,@footnote(The
Incompatible Timesharing System) and the ITS terminal characteristics
words. It has grown by layer on layer of extensions, and ought to be
redesigned from scratch for simplicity. If you do not need to
communicate with systems that support the existing SUPDUP protocol,
you might as well design the low-level details anew. The higher level
design decisions of SUPDUP are reasonably good to follow.
All numbers except number of bits are octal unless followed by a
decimal point; thus, 12 and 10@. are the same.
Bits in a word are numbered in decimal from the sign bit (bit 0) to
the least significant bit (bit 35, in a 36-bit word). Sizes of words
and fields are also decimal.
Data words, and bits and fields within them, are referred to by the
names that are conventional on ITS. The names of bits and fields are
those provided for assembler language programs on ITS.
@Section[SUPDUP Initialization]
A SUPDUP connection is created using the standard connection-creation
mechanism for the network in use. For the Arpanet, this is the ICP.
For the Chaosnet, this would be the exchange of an RFC, an OPN and a
STS packet. The SUPDUP protocol itself becomes concerned only after
this has been done.
The initialization of a SUPDUP connection involves sending terminal
characteristics information to the remote system and a greeting
message to the local system. The greeting message is ASCII text, one
character per byte, terminated with a %TDNOP code (see below). It
should simply be printed on the console by the local system. The
terminal characteristics information is made up of several 36-bit
words, which are precisely the internal terminal characteristics words
of ITS. Each word is
broken up into 6 6-bit bytes, which are sent most significant first,
each in one 8-bit byte. The words are
@enumerate[
A count. The high 18 bits of this word contain minus the number of
words that follow. This permits new words of terminal characteristics
to be defined without requiring all local-system SUPDUP programs to
be changed. The server will supply a default value for any
characteristics words defined in the future and not mentioned below.
The TCTYP variable. This should always contain 7. If the server is an
ITS, this tells it to assume that its terminal is a SUPDUP virtual
terminal.
The TTYOPT variable. This contains many bits and fields.
The height of the screen.
The width of the screen minus one. The reason that one is subtracted is
that if one column is used (as on ITS) to indicate line continuation,
this is the effective width of the screen for the user's text.
The number of lines by which the terminal will scroll automatically if an attempt is
made to Linefeed past the bottom of the screen. This value
is under the control of the physical terminal being used,
but the local system is expected to know the value by virtue
of knowing what type of terminal is in use. It then informs
the remote system by passing this value. For most terminals,
this should be 1.
The TTYSMT variable. This contains bits and fields that describe the
graphics and local editing capabilities of the terminal.
]
The TTYOPT word contains these bits:
@description[
%TOCLC (bit 2)@\The remote system should convert lower case characters
to upper case. This is the initial value of a user option. If the
local system has such an option as well, the local setting should be
propagated. Otherwise, this bit should be zero.
%TOERS (bit 3)@\The terminal can erase selectively;
that is, it supports the output commands %TDEOL, %TDDLF, and
optionally %TDEOF (see below).
%TOMVB (bit 5)@\The terminal can move its cursor backwards.
(When SUPDUP was invented, model 33 teletypes were still in use!)
%TOSAI (bit 6)@\The terminal can handle codes 000 through 037, and
177, as printing characters.
%TOSA1 (bit 7)@\The remote system should output codes 000 through 037,
and 177, as themselves, expecting them to be printing characters.
This is the initial value of a user-settable option, and it should not
be set unless %TOSAI is also set.
%TOOVR (bit 8)@\The terminal can overprint. That is, if two printing
characters are output at the same position with no erasing in between,
they will both be visible. Any terminal which can move the cursor
back and @i[cannot] overprint will be assumed to handle %TDDLF, since
it can do so by means of the sequence Backspace Space Backspace.
%TOMVU (bit 9)@\The terminal can move its cursor upwards. That is, it
is a display terminal with some form of cursor control.
%TOMOR (bit 10)@\The remote system should pause, in whatever fashion
it likes to do so, at the bottom of a screen of output. This is the
initial value of a user option, and it should be set to @i[one].
%TOROL (bit 11)@\The remote system should scroll, as opposed to wrap
around, when output goes past the bottom of the screen. This is the
initial value of a user option, and can be set whichever way the local
system expects its users to prefer. On ITS, the default is to wrap.
%TOLWR (bit 13)@\The terminal can generate lower-case characters as
input.
%TOFCI (bit 14)@\The terminal keyboard has Control and Meta keys and
can generate all the meaningful codes of the 12-bit character code
(see below).
%TOLID (bit 16)@\The terminal can do insert/delete line; it supports
the %TDILP and %TDDLP commands.
%TOCID (bit 17)@\The terminal can do insert/delete character; it
supports the %TDICP and %TDDCP commands.
%TPCBS (bit 30)@\The local system is sending 034-escape sequences on
input. This bit @i[must be set].
%TPORS (bit 32)@\The local system should be notified with a %TDORS
when the remote system attempts to abort output. This bit @i[should be
set].
%TPRSC (bit 33)@\The local system implements the region-scrolling
commands %TDRSU and %TDRSD, which scroll an arbitrary portion of the
screen.
]
The TTYSMT variable contains these bits and fields:
@begin[description]
%TQMCH (bits 0-2)@\CPU type.
1 indicates a PDP-11. 2 indicates an Imlac PDS1. 3 indicates a PDS4.
0 indicates anything else. 4 through 7 are undefined.
%TQHGT (bits 3-7)@\Character height in pixels, for the SUPDUP Graphics Protocol.
This is the interline spacing for the font used for ordinary character output.
The total usable screen height is this times the screen height in characters
which applies to ordinary character output.
%TQWID (bits 8-11)@\Character width in pixels, for the font used for
ordinary character output. The total usable screen width in pixels is
this parameter times the screen width in characters, as used for
ordinary character output.
%TQVIR (bit 12)@\The local system supports virtual coordinates in the
SUPDUP Graphics Protocol.
%TQBNK (bit 13)@\The local system supports blinking objects in the
SUPDUP Graphics Protocol.
%TQXOR (bit 14)@\The local system supports XOR mode in the
SUPDUP Graphics Protocol.
%TQREC (bit 15)@\The local system supports rectangle commands in the
SUPDUP Graphics Protocol.
%TQSET (bit 16)@\The local system supports multiple object sets in the
SUPDUP Graphics Protocol.
%TQGRF (bit 17)@\The local system supports the SUPDUP Graphics
Protocol.
%TRGIN (bit 18)@\The local system supports graphics input in the
SUPDUP Graphics Protocol.
%TRGHC (bit 19)@\The local system supports a hardcopy output device in the
SUPDUP Graphics Protocol.
%TRLED (bit 20)@\The local system supports the Local Editing Protocol.
%TRSCN (bit 21)@\The local system supports scan-line output in the
SUPDUP Graphics Protocol.
%TRLSV (bits 22-24)@\If this value @i<n> is nonzero, the local system
supports line saving. Furthermore, the largest allowed label is
4@+[@i<n>].
%TRANT (bits 25-27)@\If this value @i<n> is nonzero, the local system
supports approximately 4@+[@i<n>] lines of anticipatory output.
@end[description]
@Section[SUPDUP Input]
The SUPDUP input language provides for the transmission of MIT
extended ASCII, described in detail below. This is a 12-bit character
code, but not all possible 12-bit codes are assigned a meaning. Some
of those that are not are used as special commands by the local
editing protocol.
To transmit 12-bit data on an 8-bit connection, it must be encoded.
The encoding used is that the 8-bit byte value 034 is an escape code.
To transmit the value 034, send two 034's. Codes 200 and up are
encoded into sequences starting with 034. Specifically, to encode
@i[m]*200+@i[n], send 034, @i[m]+100, @i[n]. Other sequences starting
with 034 serve other purposes, described below.
The %TOFCI bit in TTYOPT should be set if the terminal actually has the
ability to generate all the meaningful codes of extended ASCII. If
%TOFCI is zero, SUPDUP input is restricted to a subset which is
essentially ASCII (but 034 must still be encoded as a sequence of two
034's). The Local Editing Protocol assumes that %TOFCI is one, and uses
a 9-bit subset of the 12-bit character set for its editing commands.
A character in the 12-bit character set is composed of a @i[basic
character], which makes up the bottom 7 bits, and 5 @i[bucky bits]. The
2000 bit and the 1000 bit are currently unused. The 400 bit stands for
the @i[Meta] shift key, and the 200 bit stands for the @i[Control] shift
key. These two bits can be added to any character, and are significant
in editing commands. The 4000 bit is used to extend the set of basic
characters.
The 7-bit basic character is usually interpreted as an ASCII
character, except that only these codes in the range 0 through 037 are
allowed:
@itemize[
Backspace (code 010)
Tab (code 011)
Linefeed (code 012)
VT (code 013)
Formfeed (code 014)
Return (code 015)
Call (code 032)
Altmode (code 033)
Backnext (code 037)
]
Backspace, Tab, Linefeed, Formfeed, and Return were derived from the
ASCII formatting control characters with the same codes, and they will
often echo like those ASCII characters.
The 4000 bit gives a non-ASCII interpretation to the basic
character. For example, codes 4000 through 4037 are used for
additional printing characters for symbols which are not in ASCII.
They represent the characters produced, on output, by codes 0 through
37 (which, in the SUPDUP output language, must signify printing
characters if they mean anything at all). Local system SUPDUP programs
do not
need to support these characters, and most do not (so we do not list
their pictorial appearances). If the local-system SUPDUP program does
provide
for output of codes 0 through 37 as printing characters, the %TOSAI bit
in TTYOPT should be one. Otherwise, it should not
ever send codes 4000 through 4037 as input.
4177 is another additional printing character, which is echoed as code
177 (again, used only if %TOSAI is set). 4101, 4102, 4103 and 4110 are
used for four special command keys, which are called @i[escape],
@i[break], @i[clear] and @i[help]. Only @i[help] receives much use.
All other combinations of the 4000 bit with various basic characters
are used for special purposes of the protocol, or are undefined.
Codes 4105 (4000 plus E) and 4123 (4000 plus S) are used by the Local
Editing Protocol. Code 4124 (4000 plus T) is used by the Line Saving
Protocol. Codes 4130 (4000 plus X) and 4131 (4000 plus Y) are used by
the SUPDUP Graphics Protocol.
A server system that has no application for MIT extended ASCII should
convert it into ordinary ASCII as follows:
@itemize[
Discard all but the low 8 bits of the 12-bit character.
If the 200 bit is set, clear it, and the 100 bit and the 40 bit. Thus,
control-bit plus A is converted into ASCII control-A.
]
The encoded SUPDUP input consists entirely of byte values less than 200.
Byte values 200 and above are used for special commands that are not
"terminal input". On ITS, these commands are processed by the network
server program, whereas 034 escape sequences are processed by the
system's terminal driver.
@itemize[
The two byte sequence 300 301 says to log out the remote job and break
the connection.
The two byte sequence 300 302 introduces "console location" text.
This text is meant for human consumption, and describes the location
in some sense of the local system or the user's terminal or both. It
is supplied to the remote system so that system can use it to respond
to inquiries about the user's location. The console location text
should be made up of ASCII printing characters, and is terminated with
a zero byte.]
@Section[SUPDUP Output]
Once the SUPDUP connection is initialized, all output uses the SUPDUP
output language. In this language, codes 0 through 177 are used only
to represent printing characters which are expected to advance the
cursor one position to the right. Most terminals support only codes
40 through 176, and only those codes will be sent. If the terminal
supports other codes as printing characters, that fact is indicated by
the %TOSAI bit in TTYOPT. In any case, codes 011
through 015 do @i[not] have their ASCII formatting significance.
All other output operations are represented by commands with codes
from 200 to 377. Some of these commands are followed by extra argument
bytes. The contents of an argument byte may be anything from 0 to
377, and its meaning is determined by the command
it follows. The traditional names of these commands are six
characters long and start with %TD. The commands are:
@begin[description]
%TDMOV (code 200)@\Four arguments, the old vertical and horizontal
position followed by the new vertical and horizontal position. Move
the cursor to the new position, assuming that it was at the specified
old position. The local system should forget its opinion of the old
cursor position and use what the %TDMOV says. This would be absurd on
a display terminal; %TDMOV is used only for printing terminals. For
actual displays, %TDMV0 (see below) is used.
%TDEOF (code 202)@\No arguments. Erase to end of screen. The cursor
does not move.
%TDEOL (code 203)@\No arguments. Erase to end of line. The cursor
does not move.
%TDDLF (code 204)@\No arguments. Erase the character after the
cursor. The cursor does not move.
%TDCRL (code 207)@\No arguments. Advance the cursor to the next line
and clear it. At the bottom of the screen, this is expected to scroll
the text on the screen by a fixed number of lines. The number of
lines the terminal will scroll by is not expected to be under
the control of the remote system. Instead, the TTYROL terminal
characteristics word is used to tell the remote system how many lines
the terminal @i[will] scroll.
%TDNOP (code 210)@\No arguments. Do nothing.
%TDORS (code 214)@\No arguments. This command marks the place in the
data stream at which the remote system executed an abort-output
operation. See the next section.
%TDQOT (code 215)@\One argument, which should be passed on directly to
the terminal. This is used for transmitting 8-bit data, such as a
program being downloaded into a terminal attached to the local system.
%TDFS (code 216)@\No arguments. Move the cursor right one position.
This could be done just as well with a %TDMV0; %TDFS is used for data
compression.
%TDMV0 (code 217)@\Two argument bytes: the vertical position and the
horizontal position. Just move the cursor.
%TDCLR (code 220)@\No arguments. Clear the screen and move the cursor
to the top left corner.
%TDBEL (code 221)@\No arguments. Ring the terminal's bell.
%TDINI (code 222)@\No arguments. Informs the terminal that the remote
system has just been started. This is only sent to hard-wired
terminals. Network connections will never receive this command,
because no network connections exist when the system is started.
%TDILP (code 223)@\One argument, a number. Insert that many blank
lines at the vertical position of the cursor, pushing the following
lines down. The cursor does not move.
%TDDLP (code 224)@\One argument, a number. Delete that many lines at
the vertical position of the cursor and below, moving the following
lines up, and creating blank lines at the bottom of the screen. The
cursor does not move.
%TDICP (code 225)@\One argument, a number. Insert that many blank
character positions after the cursor, pushing following text on the
line to the right. The last few positions on the line are pushed off
the right margin and discarded. Other text lines are not affected.
The cursor does not move.
%TDDCP (code 226)@\One argument, a number. Delete that many character
positions after the cursor, moving following text on the line left to
fill them up, and creating blank positions at the right margin. Other
lines are not affected, and the cursor does not move
%TDBOW (code 227)@\No arguments. Display printing characters that
follow as white-on-black.
%TDRST (code 230)@\No arguments. Reset %TDBOW mode and any other such
options as may be defined later.
%TDGRF (code 231)@\Variable number of arguments. This introduces a
sequence of SUPDUP Graphics Protocol operations. The SUPDUP Graphics
Protocol is documented in a separate section below.
%TDRSU (code 232)@\Two arguments, the number of lines in the region to
be scrolled, and the number of lines to scroll it by. The region
consisting of the specified number of lines, starting with the line
that the cursor is on, is scrolled up by an amount specified by the
second argument. Lines scrolled out of the top of the region are
lost, and blank lines are created at the bottom of the region.
This operation is equivalent to a %TDDLP at the top of the region
followed by a %TDILP above the place where the blank lines should be
created, above the bottom of the region. However, %TDRSU can avoid
disturbing the lines below the region even momentarily, which looks
better.
%TDRSD (code 233)@\Two arguments. Like %TDRSU but scrolls the region
down instead of up.
@end[description]
The Local Editing Protocol introduces several additional %TD codes. See
the section on the Local Editing Protocol for details on implementing
them.
@description[
%TDSYN (code 240)@\Do-Local-Echoing. Two arguments, a
resynchronize code from the last resynchronize received, and the
number of input characters received by the remote system since that
resynchronize. If the synchronization constraint is satisfied, the
local system will begin local editing.
%TDECO (code 241)@\Prepare-for-Local-Editing. No arguments.
Tells the local system to begin sending resynchronizes, which will
enable the remote system to send a %TDSYN.
@multiple[
%TDEDF (code 242)@\Define-Char. Normally followed by two argument bytes
which encode a
9-bit input character and a 5-bit function code; the function code
specifies the editing action of the input character when the user types
it. The bottom seven
bits of each byte are taken, and the two are combined (first byte most
significant) into a 14-bit number. The top 5 bits of this number are
the function code.
Function code 37 serves as an escape: a third argument byte follows,
which contains the actual function code. This is how function codes
larger than 37 are specified.
The other 9 bits are normally the character whose local editing function
is being defined. It is a 12-bit MIT extended ASCII character whose top
three bits are taken as zero. This means that not all 12-bit codes can
be specified; so the local editing protocol only applies to input
characters with codes 777 and below. Any input character which
contains the 4000 bit is always handled remotely. (The 1000 and 2000
bits are unused in the 12-bit character set.)
If the terminal does
not have Control and Meta keys, and transmits ASCII (%TOFCI is not
set), %TDEDF will still speak in terms of 9-bit characters.
Definitions specified for 9-bit characters in the range 300 through
337 should be applied to the ASCII control characters 000 through 037.
Definitions for 9-bit characters in the range 040 through 177 should
be applied to the ASCII characters with the same values.
@tag(caseindirect)
A counterintuitive feature of MIT extended ASCII is that Control-A and
Control-a are two different characters. Their codes are 301 and 341.
Most programs interpret these two characters the same way, and most
editors will want to tell the local system to interpret the two the same
way. In the Local Editing Protocol this is done by defining the
lower-case character with function code 22, which means "use the
definition of a related character". For characters whose basic
character is a lower case letter, the related character used is the
corresponding upper case character. Thus, defining character 341
(Control-a) with code 22 tells the local system to use the definition of
character 301 (Control-A). For a non-lower-case character with the
Control bit (200) set, the related character is obtained by turning off
bits 200 and 100. Thus, Control-I (311) turns into Tab (011, which is
ASCII Control-I). Code 22 should be used only with lower case characters
and control characters.
Some function codes are special, and do something other than define a
character. With these, the 9 bits are used to transmit arguments
associated with the operation being performed. Here is how.
@begin[description]
Code 31@\Set Word Syntax. The syntax is specified for the ASCII
character which is the low 7 bits of the accompanying 9-bit character.
The 200 bit of the 9-bit character says what the syntax @i[is]: if it
is 1, the character is a separator. If it is 0, the character is part
of a word.
Code 32@\Set Insertion Mode. The 9 bits contain the insertion mode.
Code 33@\Initialize. The word syntax table is set so that only
letters and digits are part of words. Insertion mode is set to 1.
The fill column is set to 0. All character definitions are set to
code 0 except these:
@begin[itemize]
Lower case letters, with or without Control or Meta, are set to code
22 (use the definition of the related upper case character). These are
characters 140 through 172, 340 through 372, 540 through 572, and 740
through 772.
All printing characters except lower case letters are set to code 7
(self-insert). These are characters 40 through 140, and 173 through 176.
Digits, with either Control, Meta or both, are set to code 27 (specify
repeat count). These are characters 260 through 271, 460 through 471,
and 660 through 671.
@end[itemize]
Code 34@\Set Margin. The top 2 bits of the 9 say which margin to set:
0, 1, 2, 3 stand for left, top, right, bottom. The remaining 7 bits
specify that margin, as a distance from the actual screen edge behind
it.
Code 41@\Set Fill Column. The 9 bits contain the value of the fill
column, or zero if there is to be no fill column.
@end[description]
]
%TDNLE (code 243)@\Stop-Local-Editing. No arguments.
%TDTSP (code 244)@\Space-for-Tab. No arguments. Used to output spaces
which are part of the representation of an ASCII tab character in the
text being edited.
%TDCTB (code 245)@\Line-Beginning-Continued. No arguments. States that
the beginning of this screen line is not at the beginning of a line of
the text being edited.
%TDCTE (code 246)@\Line-End-Continued. No arguments. States that
the line of text which appears on this screen line extends beyond the
end of the screen line.
%TDMLT (code 247)@\Multi-Position-Char. Two arguments, the width of
the character about to be displayed, and its character code. The
width specifies the number of
character positions, following the cursor, which belong to the
representation of a single
character of the text being edited. This command sequence should be
followed immediately by output to fill up those positions.
]
The Line Saving Protocol introduces four additional commands:
@description[
%TDSVL (code 250)@\Save-Lines. Three arguments: a number of lines
@i<n>, followed by two 7-bit bytes of label number @i<l> (low byte first).
@i<n> lines starting with the line the cursor is on have their contents
saved under labels @i<l>, @i<l>+1, ... @i<l>+@i<n>-1.
%TDRSL (code 251)@\Restore-Lines. Three arguments bytes, the same as for
%TDSVL. The contents saved under @i<n> labels starting at label @i<l> are
restored onto the screen on lines starting with the one the cursor is
on. If any of the labels is not defined, one or more Label-Failure
commands are sent to the remote system to report this.
%TDSSR (code 252)@\Set-Saving-Range. Two arguments which specify the
range of columns of line contents to save and restore in %TDSVL and
%TDRSL. The first argument is the first column to save. The second
is the last column to save, plus one.
%TDSLL (code 253)@\Set-Local-Label. Two arguments, the low and high
7-bit bytes of a label number. This label number, and numbers
immediately below it, will be used label the saved contents of any
lines pushed off the screen by locally handled editing commands.
]
One more command is used together with either local editing or line
saving for anticipatory output.
@description[
@begin[multiple]
%TDMCI (code 254)@\Move-Cursor-Invisible. One argument, a logical
vertical position which is a 14-bit @i[signed] number transmitted low
7 bits first. Positions the cursor at an invisible line so that
anticipatory text transmission can be done. Output to the invisible
line continues until a cursor motion %TD command is received.
The specified vertical position
signifies the relationship between the text on this line and that on
the screen: if lines 2 through 20 are in use for editing (according to
the editing margins), then an invisible line with vertical position 30
contains the text that would appear 10 lines below the last text
actually displayed. This information is for the use of locally-handled
scrolling commands.
The invisible lines displayed this way will be remembered by the
local system for the use of locally handled scrolling commands, if
the local system can handle any. Also, the contents can be saved
under a label and then restored into actual visibility under the
control of the remote editor.
@end[multiple]
]
@Section[Aborting Output in SUPDUP]
When a SUPDUP server program is asked to abort (discard) output
already transmitted, it sends a %TDORS character. At the same time,
it sends an interrupt to the local system if the
network between them permits this. The local system should keep a
count of the number of such interrupts minus the number of %TDORSes
received. When this count is positive, all output received must be
discarded and only scanned for %TDORSes. It is legitimate for this
count to become negative.
When the %TDORS is read which decrements the count back to zero, the
local system must transmit the current cursor position to the remote
system. The remote system is waiting for this, because it does not
know how much output the local system actually discarded, and
therefore it does not know where the terminal cursor ended up. The
cursor position is transmitted using a four byte sequence:
034 020 @i<vpos> @i<hpos>. The remote system should hold all output and
not transmit any more until this command is received.
If the network does not provide for interrupts (high-priority messages),
the local system should send the cursor position whenever a %TDORS is
received.
@Section[Non-Network Terminals]
SUPDUP can also be used to communicate with directly wired or dial-up
terminals, which we call non-network terminals. The key point of
distinction is that "networks" provide buffering, flow control and
error recovery, so that SUPDUP as used over networks need not be
concerned with these things. When SUPDUP is used with non-network
terminals, they must all be provided for.
The buffering is provided in the remote system's terminal controller
and in the terminal itself. The flow control, and associated error
recovery, are provided by an extension of the SUPDUP protocol. This
flow control mechanism was inspired by TCP [see TCP] and is
immeasurably superior to the XON/XOFF mechanism by which many
terminals deprive the user of the use of two valuable editing
commands.
Flow control works by means of an @i[allocation], stored in the remote
system, which is the number of characters which the remote system can
send to the terminal without overloading it. After this many have
been sent, the remote system must cease transmission until it is sent
an input command giving more allocation. The terminal sends this
command when it has made room in its buffer by processing and removing
characters from it.
To begin using flow control, the terminal should send the sequence 034
032, which initializes the allocation to zero. Then it should send
the sequence 034 001 @i[n], where @i[n] is the number of characters of
buffer space available for output. This increments the allocation by @i[n].
Several 034 001 @i[n] sequences can be used to set the allocation to a
value above 177.
The remote system should remember the allocation it has received and
decrement it each time a character is transmitted. The terminal
should count the number of output characters processed and removed
from the terminal's buffer for output; every so often, another 034 001
@i[n] sequence should be sent containing the number of characters
processed since the last 034 001 @i[n]. For example, the terminal could
send 034 001 030 each time it processes another 30 characters of
output. By sending this sequence, it gives the remote system
permission to fill up that part of the buffer again.
This flow control mechanism has the advantage that it introduces no
delay if the buffering capacity does not become full, while never
requiring the remote system to respond quickly to any particular input
signal. An even greater advantage is that it does not impinge on the
character set available for input from the terminal, since it uses the
034 escape mechanism, and 034 can be transmitted with the sequence 034
034.
Because line noise can cause allocate commands to be garbled, if the
terminal receives no output for a considerable period of time, it
should send another 034 032 followed by 034 001 @i[n]. This will make
sure that the remote system and the terminal agree on the allocation.
This is the only error recovery provided. To achieve error recovery
for data as well, one must essentially implement a network
protocol over the line. That is beyond the scope of SUPDUP.
ITS performs an additional encoding on SUPDUP output data over
non-network lines. It encodes the data into 7-bit bytes so that it
can be sent through old terminal controllers which cannot output 8-bit
bytes. Other systems should not need to use this encoding. Codes 0
through 176 are transmitted as is. Code 177 is transmitted as 177
followed by 1. Code 2@i[nn] is transmitted as 177 followed by @i[nn]+2.
All cursor positions are transmitted with 1 added to them to reduce
the frequency with which bytes containing zero must be sent; this is
also to avoid problems with old controllers.
The 300-sequences may not be used as input and the terminal should not
send them. This is because they are normally processed by the network server,
which is not in use for a non-network line.
@Unnumbered[SUPDUP Graphics Protocol]
The SUPDUP Graphics Protocol allows pictures to be transmitted and
updated across an ordinary SUPDUP connection, requiring minimal support
from the remote operating system. Its features are
@itemize[
It is easy to do simple things.
Any program on the server host can at any time begin
outputting pictures. No special preparations are needed.
No additional network connections are needed. Graphics
operations go through the normal text output connection.
It does not require a network. It is suitable for use with locally
connected intelligent display terminals, and by programs which need not
know whether they are being used locally or remotely. It can be the
universal means of expression of terminal graphics output, for whatever
destination.
Loss or interpolation of output, due to a "silence" command typed by
the user or to the receipt of a message, does not leave the local
system confused (though it may garble the interrupted picture itself).
The local system is not required to remember the
internal "semantic" structure of the picture being
displayed, but just the lines and points, or even just bits
in a bit matrix.
Like the rest of the SUPDUP protocol, SUPDUP Graphics is terminal-independent.
]
The terminal capabilities associated with the SUPDUP Graphics Protocol are
described by bits and fields in the TTYSMT variable, described above.
One of these bits is %TQGRF, which indicates that the local system is able
to handle the SUPDUP Graphics Protocol in the first place.
Graphics output is done with one special %TD command, %TDGRF. This
command is followed by any number of graphics operations, which are
characters in the range 0 through 177. These are just the ordinary
printing characters, but in graphics mode they receive a special
interpretation described below. Characters in their role as graphics operations
have symbolic names starting with %GO, such as %GOMVA and %GOELA.
Some graphics operations themselves take arguments, which follow the operations
and are composed of more characters in the range 0 through 177.
Any character 200 or above leaves graphics mode and then is interpreted
normally as a %TD command. This way, the amount of misinterpretation of output
due to any interruption of a sequence of graphics operations is bounded.
Normally, %TDNOP is used to terminate a sequence of graphics operations.
Some other %TD commands interact with SUPDUP Graphics.
The %TDRST command should reset all graphics modes to their normal
states, as described below. %TDCLR resets some graphics state information.
@section[Graphics Coordinates]
Graphics mode uses a cursor position which is remembered from one
graphics operation to the next while in graphics mode. The graphics
mode cursor is not the same one used by normal type-out: graphics
protocol operations have no effect on the normal type-out cursor, and
normal type-out has no effect on the graphics mode cursor. In
addition, the graphics cursor's position is measured in pixels rather
than in characters. The relationship between the two units (pixels and
characters) is recorded by the %TQHGT and %TQWID fields of the TTYSMT
variable of the terminal, which contain the height and width in pixels
of the box occupied by a normal-size character. The size of the screen in either
dimension is assumed to be the size of a character box times the
number of characters in that direction on the screen. If the screen
is actually bigger than that, the excess may or may not be part of
the visible area; the remote system will not know that it exists, in any
case.
Each coordinate of the cursor position is a 14-bit signed number,
with zero at the center of the screen. Positive coordinates go up
and to the left. If the screen dimension is even, the visible
negative pixels extend one unit farther than the positive ones, in
proper two's complement fashion. Excessively large values of the
coordinates will be off the screen, but are still meaningful.
These coordinates in units of pixels are called @i[physical
coordinates].
Local systems may optionally support @i[virtual coordinates] as well. A
virtual coordinate is still a 14-bit signed number, but instead of being
in units of physical pixels on the terminal, it is assumed that +4000
octal is the top of the screen or the right edge, while -4000 octal is
the bottom of the screen or the left edge. The terminal is responsible
for scaling virtual coordinates into units of pixels. The %TQVIR bit in
the TTYSMT variable indicates that the local system supports virtual
coordinates. When the remote system wants to use virtual coordinates, it
should send a %GOVIR; to use physical coordinates again, it should send
a %GOPHY. For robustness, every %TDGRF should be followed by a %GOVIR
or %GOPHY right away so that following commands will be interpreted
properly even if the last %GOVIR or %GOPHY was lost.
The virtual coordinates are based on a square. If the visible
area on the terminal is not a square, then the standard virtual range
should correspond to a square around the center of the screen, and the
rest of the visible area should correspond to virtual coordinates
just beyond the normally visible range.
Graphics protocol operations take two types of cursor position
arguments, absolute ones and relative ones. Operations that take
position arguments generally have two forms, one for relative position
and one for absolute. A relative address consists of two offsets,
delta-X and delta-Y, from the old cursor position. Each offset is a
7-bit two's complement number occupying one character. An absolute
address consists of two coordinates, the X followed by the Y, each being
14 bits distributed among two characters, with the less significant 7
bits in the first character. Both types of address set the running
cursor position which will be used by the next address, if it is
relative.
Relative addresses are
provided for the sake of data compression only. They do not specify a
permanent constraint between points; the local system is not expected to
have the power to remember objects and constraints. Once an object has
been drawn, no record should be kept of how the cursor positions were
specified.
Although the cursor position on entry to graphics mode remains
set from the last exit, it is wise to reinitialize it with a %GOMVA
operation before any long transfer, to limit the effects of lost output.
It is perfectly legitimate for parts of objects to go off the screen.
What happens to them is not terribly important, as long as it is not
disastrous, does not interfere with the reckoning of the cursor
position, and does not cause later objects, drawn after the cursor
moves back onto the screen, to be misdrawn.
@section[Graphics Operations]
All graphics mode operations have codes between 0 and 177, and symbolic
names which start with %GO. Operations fall into three classes: draw
operations, erase operations, and control operations. The draw operations
have codes running from 100 to 137, while the erase operation codes run
from 140 to 177. The
control operations have codes below 100.
If an operation takes a cursor position argument, the 20 bit in the
operation code usually says whether the cursor position should be
relative or absolute. The 20 bit is one for an absolute address.
Operations to draw an object always have counterparts which erase
the same object. On a bit matrix terminal, erasure and drawing are
almost identical operations. On a display list terminal, erasure
involves searching the display list for an object with the specified
characteristics and deleting it from the list. Thus, on such terminals
you can only count on erasing to work if you specify the object to be
erased exactly the same as the object that was drawn. Any terminal
whose %TOERS bit is set must be able to erase to at least this extent.
For example, there are four operations on lines. They all operate
between the current graphics cursor position and the specified
cursor position argument:
@itemize[
%GODLR (code 101) draw line, relative address.
%GODLA (code 121) draw line, absolute address.
%GOELR (code 141) erase line, relative address.
%GOELA (code 161) erase line, absolute address.
]
Here is how to clear the screen and draw one line.
@example(
%TDRST ;Reset all graphics modes.
%TDGRF ;Enter graphics.
%GOCLR ;Clear the screen.
%GOMVA xx yy ;Set cursor.
%GODLA xx yy ;Draw line from there.
%TDNOP ;Exit graphics.
)
Graphics often uses characters. The %GODCH operation is followed
by a string of characters to be output, terminated by a zero. The
characters must be single-position printing characters. On most
terminals, this limits them to ASCII graphic characters. Terminals
with %TOSAI set in the TTYOPT variable allow all characters 0-177.
The characters are output at the current graphics cursor position (the
lower left hand corner of the first character's rectangle being placed
there), which is moved as the characters are drawn. The normal
type-out cursor is not relevant and its position is not changed. The
cursor position at which the characters are drawn may be in between
the lines and columns used for normal type-out. The %GOECH operation is
similar to %GODCH but erases the characters specified in it. To clear
out a row of character positions on a bit matrix terminal without
having to respecify the text, a rectangle operation may be used.
@Section(Graphics Input)
The %TRGIN bit in the right half of the TTYSMT variable indicates
that the terminal can supply a graphic input in the form of a cursor
position on request. Sending a %GOGIN operation to the terminal asks to
read the cursor position. It should be followed by an argument
character that will be included in the reply, and will serve to
associate
the reply with the particular request for input that elicited it. The
reply should have the form of a Top-Y character (code 4131), followed
by the reply code character as just described, followed by an absolute
cursor position. Since Top-Y is not normally meaningful as input,
%GOGIN replies can be distinguished reliably from keyboard input.
Unsolicited graphic input should be sent using a Top-X instead of a
Top-Y, so that the program can distinguish the two. Instead of a reply
code, for which there is no need, the terminal should send an encoding
of the buttons pressed by the user on his input device. For a
three-button mouse, the low two bits contain the number of the button
(1, 2 or 3 from left to right), and the next two bits contain the
number of times the button was clicked.