Google
 

Trailing-Edge - PDP-10 Archives - LCG_Integration_Tools_Clearinghouse_T20_v7_30Apr86 - tools/sed-for-vms/sedbyu.mar
There are 5 other files named sedbyu.mar in the archive. Click here to see a list.
.TITLE	SEDBYU - Terminal-dependent definitions for BYU version of SED

.LIBRARY /SEDITB.MLB/

.ENABLE DEBUG
.DISABLE GLOBAL		;Show undefined variables as errors

.EXTERNAL SETCHBF, F, PUTSQ1, PUTSTG, PUTTYP, PUTNUM, SNZVAL
.EXTERNAL TTCHAN, TBFSIZ, RESTORE_TTY, HOMPOS, KEYPAD, TERMTYPE

;Some character definitions
CR=13		;Carriage return
LF=10		;Line feed

;Define the nonstandard terminal types
BYU$_RAM6211 = ^XFE	;Ramtek 6211 graphics terminal
BYU$_INF200 = ^XFD	;Infoton 200
BYU$_VT52 = ^XFC	;DEC VT52 (not Visual-200)

$IODEF		;Define the I/O function values
$DCDEF		;Define the device types
FLGDEF		;Define the flag bits
SEQDEF		;and the character sequence definitions
TRMDEF		;and the words in the terminal output table

.PSECT	CODE,NOWRT,EXE,LONG

;Routine to call at startup

START:	MOVL	TERMTYPE,R1	;Get the terminal type
	MOVL	#NAMLEN,R2	;Length of terminal name table
10$:	CMPL	L^NAMTAB(R2),R1	;See if in table
	BEQL	20$		;It is
	SUBL	#4,R2		;No - try again
	BGEQ	10$
	BRW	TRMERR		;Not found - error
20$:	TSTL	R2		;Is it Visual-200?
	BEQL	VIS200		;Yes - already set up by default
	MOVL	L^OT.TAB(R2),R10	;Reset address of output table
	MOVL	L^ESCTAB(R2),ESCKEY	;Reset input subtable for escape key
	CMPB	R1,#BYU$_RAM6211 ;Is it a Ramtek 6211?
	BEQL	VT100		;Yes - it (sort of) emulates a VT100
	CMPB	R1,#DT$_VT100	;Is it a VT100?
	BEQL	VT100		;Yes
	CMPB	R1,#DT$_VT125	;Is it a VT125?
	BEQL	VT100		;Yes - it's really a VT100 then
	CMPB	R1,#BYU$_VT52	;Is it a DEC VT52?
	BEQL	VT52		;Yes
	CMPB	R1,#DT$_VT52	;Is it a Visual 200?
	BNEQ	STARTX	    	;No - don't need any additional setup
VIS200:	BISL	#M_NHP,F	;Set /NOHELP
	TSTB	KEYPAD		;/KEYPAD seen?
	BGEQ	STARTX		;No
	JSB	VTXKPD		;Yes - go set it up
STARTX:	RSB			;Then return

VT100:	MOVAB	VT100A,R1	;Assume VT100 is in VT52 mode.  Set to VT100 mode
				;Also set alt. keypad mode
	JSB	PUTSTG		;Set the mode
	JSB	PUTTYP
	MOVB	#-1,ALTKPD	;Remember that alt. keypad mode is set
	TSTB	KEYPAD		;Did user specify /NOKEYPAD?
	BGTR	10$		;No
	JSB	VTXKPD		;Yes - reset keypad mode
10$:	CMPW	#132,SETCHBF+6	;Is width 132?
	BNEQ	STARTX		;No
	MOVL	#132,CPL(R10)	;Yes - set the line width
	BRB	STARTX
VT100A:	.ASCIZ	<^O33>/=/<^O33>/</ ;Set VT100 mode, alternate keypad mode

VT52:	MOVL	L^ESCTAB(R2),VT5ESC ;Point to the right escape subtable
	MOVAB	VT52A,R1	;Set keypad mode
	JSB	PUTSTG
	JSB	PUTTYP
	MOVB	#-1,ALTKPD	;Remember alt. keypad mode is set
	TSTB	KEYPAD		;Did user specify /NOKEYPAD?
	BGTR	10$		;No
	JSB	VTXKPD		;Yes - reset keypad mode
10$:	BRB	STARTX
VT52A:	.ASCIZ	<^O33>/=/	;Set alternate keypad mode

STOP:	TSTB	ALTKPD		;Need to unset alt keypad mode?
	BEQL	STOPX		;No
	MOVAB	VT100B,R1	;Yes - get out of it
	JSB	PUTSTG
	JSB	PUTTYP
STOPX:	RSB
VT100B:	.ASCIZ	<^O33>/>/

TRMERR::MOVL	#TRMELN,TBFSIZ	;Save the length of the message
	$QIOW_S	CHAN=TTCHAN,-	;Output the error message
		FUNC=#IO$_WRITEVBLK!IO$M_NOFORMAT,-
		P1=TRMERM,-
		P2=TBFSIZ
	CALLS	#0,RESTORE_TTY	;Restore the original terminal settings
	RET


;Define the pointers to the terminal tables

;Type of each supported terminal
NAMTAB::.LONG	DT$_VT52	;Visual 200 terminal
	.LONG	DT$_VT100	;VT100 terminal
	.LONG	DT$_VT125	;VT125 terminal
	.LONG	DT$_FT1		;Televideo 910 is foreign terminal 1
	.LONG	BYU$_INF200	;Infoton 200
	.LONG	BYU$_RAM6211	;Ramtek 6211
	.LONG	BYU$_VT52	;DEC VT52 terminal
NAMLEN==.-NAMTAB-4		;Length of this table

;Address of Terminal Output Table for each Terminal
TERMNL::
OT.TAB:	.ADDRESS VS2.OT		;Visual-200
	.ADDRESS VT1.OT		;VT100
	.ADDRESS VT1.OT		;VT125
	.ADDRESS T91.OT		;Televideo 910
	.ADDRESS IN2.OT		;Infoton 200
	.ADDRESS RAM.OT		;Ramtek 6211
	.ADDRESS VT5.OT		;DEC VT52

;Escape subtable (input table) for each terminal
ESCTAB:	.SIGNED_WORD VS2.T1-VS2.OT	;Relative address of Visual-200 table
	.WORD	-VS2.S1		;Length of Visual-200 table
	.SIGNED_WORD VT1.T1-VT1.OT	;Relative address of VT100 table
	.WORD   -VT1.S1		;Length of VT100 table
	.SIGNED_WORD VT1.T1-VT1.OT	;Relative address of VT125 table
	.WORD   -VT1.S1		;Length of VT125 table
	.SIGNED_WORD T91.T1-T91.OT	;Relative address of Televideo 910 table
	.WORD	-T91.S1		;Length of Televideo 910 teble
	.SIGNED_WORD IN2.T1-IN2.OT	;Relative address of Infoton 200 table
	.WORD	-IN2.S1		;Length of Infoton 200 table
	.SIGNED_WORD RAM.T1-RAM.OT	;Relative address of Ramtek 6211 table
	.WORD   -RAM.S1		;Length of Ramtek 6211 table
	.SIGNED_WORD VT5.T1-VT5.OT	;Relative address of DEC VT52 table
	.WORD	-VT5.S1		;Length of VT52 table

;Terminal name table (used by the /Z= switch processor)
TRMNAM::.ASCII	/VIS200  /
	.ASCII	/VT100   /
	.ASCII	/VT125   /
	.ASCII	/TLV910  /
	.ASCII	/INF200  /
	.ASCII	/RAM6211 /
	.ASCII	/VT52    /

.PSECT	RWDATA,WRT,EXE,PAGE

ALTKPD:	.BLKB	1		;Flag for alternate keypad mode
.SUBTITLE	Terminal Input Table

;Terminal Input Table - tells what control characters or sequences
;invoke which commands

	.LONG	$RESET		; 177	RUBOUT
ITABLE:	.LONG	$SUBST		;   0	^@
	.LONG	$INSSP		;   1	^A
	.LONG	$SETFI		;   2	^B
	.LONG	$ABORT		;   3	^C
	.LONG	$INSLN		;   4	^D
	.LONG	$SRCBK		;   5	^E
	.LONG	$DELLN		;   6	^F
	.LONG	$PUT		;   7	^G
	.LONG	$CURLF		;  10	^H
	.LONG	$TAB		;  11	^I
	.LONG	$CURDN		;  12	^J
	.LONG	$CURUP		;  13	^K
	.LONG	$CURRT		;  14	^L
	.LONG	$RETRN		;  15	^M
	.LONG	$SWTCH		;  16	^N
	.LONG	$ENTCC		;  17	^O
	.LONG	$GOTO		;  20	^P
	.LONG	$RLBKP		;  21	^Q
	.LONG	$SRCFW		;  22	^R
	.LONG	$DELSP		;  23	^S
	.LONG	$RLFWL		;  24	^T
	.LONG	$BKTAB		;  25	^U
	.LONG	$PICK		;  26	^V
	.LONG	$RLBKL		;  27	^W
	.LONG	$EXEC		;  30	^X
	.LONG	$RLFWP		;  31	^Y
	.LONG	$EXIT		;  32	^Z
ESCKEY:	.SIGNED_WORD VS2.T1-VS2.OT	;  33	ESCAPE needs a subtable
	.WORD	-VS2.S1
	.LONG	$SLDRT		;  34	^\
	.LONG	$ERSLN		;  35	^]
	.LONG	$SLDLF		;  36	^^
	.LONG	$LINE		;  37	^_
.SUBTITLE	Escape subtable for terminals that don't have function keys

IN2.T1:
T91.T1:	.WORD	^O33,$ENTER	;Escape Escape == ENTER
	.WORD	^A"a",$RECAL	;Escape a == RECALL
	.WORD	^A"b",$BLINE	;Escape b == START-OF-LINE
	.WORD	^A"c",$CASE	;Escape c == CASE
	.WORD	^A"d",$DELCH	;Escape d == DELETE-CHARACTER
	.WORD	^A"e",$ELINE	;Escape e == END-OF-LINE
	.WORD	^A"h",$CURHM	;Escape h == CURSOR-HOME
	.WORD	^A"i",$INMOD	;Escape i == INSERT-MODE
	.WORD	^A"j",$DNTAB	;Escape j == DOWN-TAB
	.WORD	^A"k",$ERSLN	;Escape k == ERASE-LINE
	.WORD	^A"l",$SLDLF	;Escape l == SLIDE-LEFT
	.WORD	^A"m",$MARK	;Escape m == MARK
	.WORD	^A"o",$WINDW	;Escape o == WINDOW
	.WORD	^A"q",$REWRT	;Escape q == REWRITE-SCREEN
	.WORD	^A"r",$SLDRT	;Escape r == SLIDE-RIGHT
	.WORD	^A"s",$SAVE	;Escape s == SAVE-FILE
	.WORD	^A"t",$RLTAB	;Escape t == REAL-TAB
	.WORD	^A"u",$UPTAB	;Escape u == UP-TAB
	.WORD	^A"v",$CLRLN	;Escape v == CLEAR-LINE
	.WORD	^A"w",$ERSWD	;Escape w == ERASE-WORD
	.WORD	^A"x",$LINE	;Escape x == BEG/END-OF-LINE
	.WORD	^A"y",$TBSET	;Escape y == TAB-SET
	.WORD	^A"z",$RESET	;Escape z == RESET
	.WORD	^A"/",$HELP	;Escape / == HELP
;Same commands, but upper case version
	.WORD	^A"A",$RECAL	;Escape A == RECALL
	.WORD	^A"B",$BLINE	;Escape B == START-OF-LINE
	.WORD	^A"C",$CASE	;Escape C == CASE
	.WORD	^A"D",$DELCH	;Escape D == DELETE-CHARACTER
	.WORD	^A"E",$ELINE	;Escape E == END-OF-LINE
	.WORD	^A"H",$CURHM	;Escape H == CURSOR-HOME
	.WORD	^A"I",$INMOD	;Escape I == INSERT-MODE (TLV910 BACKSPACE key sends ESC,I
	.WORD	^A"J",$DNTAB	;Escape J == DOWN-TAB
	.WORD	^A"K",$ERSLN	;Escape K == ERASE-LINE
	.WORD	^A"L",$SLDLF	;Escape L == SLIDE-LEFT
	.WORD	^A"M",$MARK	;Escape M == MARK
	.WORD	^A"O",$WINDW	;Escape O == WINDOW
	.WORD	^A"Q",$REWRT	;Escape Q == REWRITE-SCREEN
	.WORD	^A"R",$SLDRT	;Escape R == SLIDE-RIGHT
	.WORD	^A"S",$SAVE	;Escape S == SAVE-FILE
	.WORD	^A"T",$RLTAB	;Escape T == REAL-TAB
	.WORD	^A"U",$UPTAB	;Escape U == UP-TAB
	.WORD	^A"V",$CLRLN	;Escape V == CLEAR-LINE
	.WORD	^A"W",$ERSWD	;Escape W == ERASE-WORD
	.WORD	^A"X",$LINE	;Escape X == BEG/END-OF-LINE
	.WORD	^A"Y",$TBSET	;Escape Y == TAB-SET
	.WORD	^A"Z",$RESET	;Escape Z == RESET
	.WORD	^A"?",$HELP	;Escape ? == HELP
T91.S1=.-T91.T1
IN2.S1=.-IN2.T1
.SUBTITLE	VT52 Output Table

;VT52 Terminal Tables

VT5.OT:	.BYTE	^O33,^A"A",0,0		;Cursor up
	.BYTE	^O33,^A"B",0,0		;Cursor down
	.BYTE	^O33,^A"C",0,0		;Cursor right
	.BYTE	8,0,0,0			;Cursor left
	.BYTE	^O33,^A"H",0,0		;Cursor home
	.BYTE	^O33,^A"J",0,0		;Clear to end of page
	.BYTE	^O33,^A"K",0,0		;Clear to end of line
	.BYTE	10,0,0,0		;Roll up and clear line
	.BYTE	^O33,^A"I",0,0		;Roll down and clear line
	.LONG	0			;Protect on (none)
	.LONG	0 			;Protect off (none)
	.LONG	0			;Insert line (none)
	.LONG	0			;Insert space (none)
	.LONG	0			;Delete line (none)
	.LONG	0 		      	;Delete space (none)
	.ASCII	<^O33>/Y7 /		;Move to bottom
	.BYTE	0,^XFF			;Define pointer to long ascii string
	.SIGNED_WORD 20$-VT5.OT		;Home and clear entire page
	.ADDRESS	VT5.PC		;Routine to position to character
	.ADDRESS	VT5.PL		;Routine to position to start of line
	.LONG	24			;Lines per page
	.LONG	80			;Characters per line
	.LONG	M_SLW!M_TBS!M_MRK	;Flags (no protect, hard tabs)
	.ADDRESS	START		;Routine to call on entry
	.ADDRESS	STOP		;Routine to call on exit
	.LONG	0			;No nulls needed
	.ADDRESS	VT5ITBL		;Address of input character table
	.BYTE	^A"~",0,0,0		;Mark to display on enter
	.ADDRESS	VTXKPD		;Routine to manipulate keypad mode

20$:	.BYTE	^O33,^A"H",^O33,^A"J",0	;Character string to home and clear page

;VT52 escape subtable

VT5.T1:	.WORD	^A"P",$ENTER		;ESCAPE P == ENTER
	.WORD	^A"R",$RESET		;ESCAPE R == RESET
	.WORD	^A"A",$CURUP		;ESCAPE A == UP
	.WORD	^A"B",$CURDN		;ESCAPE B == DOWN
	.WORD	^A"C",$CURRT		;ESCAPE C == RIGHT
	.WORD	^A"D",$CURLF		;ESCAPE D == LEFT
	.WORD	^A"Q",$RECAL		;ESCAPE Q == RECALL
	.WORD	^A"S",$CURHM		;ESCAPE S == HOME
	.WORD	^A"?"			;ESCAPE ? needs a subtable
	.SIGNED_WORD	VT5.T2-VT5.OT	;Offset to subtable
VT5.S1=.-VT5.T1

VT5.T2:	.WORD	^A"t",$BLINE		;ESCAPE ? t == START-OF-LINE
	.WORD	^A"v",$ELINE		;ESCAPE ? v == END-OF-LINE
	.WORD	^A"r",$DNTAB		;ESCAPE ? r == DOWN-TAB
	.WORD	^A"x",$UPTAB		;ESCAPE ? x == UP-TAB
	.WORD	^A"y",$CASE		;ESCAPE ? y == CASE
	.WORD	^A"n",$ERSWD		;ESCAPE ? n == ERASE-WORD
	.WORD	^A"p",$RLTAB		;ESCAPE ? p == REAL-TAB
	.WORD	^A"w",$MARK		;ESCAPE ? w == MARK
	.WORD	^A"M",$INMOD		;ESCAPE ? M == INSERT-MODE
	.WORD	^A"u",$REWRT		;ESCAPE ? u == REWRITE-SCREEN
	.WORD	^A"q",$WINDW		;ESCAPE ? q == WINDOW
	.WORD	^A"s",$HELP		;ESCAPE ? s == HELP
	.WORD	^A"l",$SAVE		;ESCAPE ? l == SAVE-FILE
	.WORD	^A"m",$TBSET		;ESCAPE ? m == TAB-SET/CLEAR
	.LONG	0			;End of table
.SUBTITLE	Visual-200 Output Table

;Visual-200 Terminal (in VT52+ mode) Tables

VS2.OT:	.BYTE	^O33,^A"A",0,0		;Cursor up
	.BYTE	^O33,^A"B",0,0		;Cursor down
	.BYTE	^O33,^A"C",0,0		;Cursor right
	.BYTE	8,0,0,0			;Cursor left
	.BYTE	^O33,^A"H",0,0		;Cursor home
	.BYTE	^O33,^A"y",0,0		;Clear to end of page
	.BYTE	^O33,^A"x",0,0		;Clear to end of line
	.BYTE	10,0,0,0		;Roll up and clear line
	.BYTE	^O33,^A"I",0,0		;Roll down and clear line
	.BYTE	^O33,^A"4",0,0		;Protect on (to low intensity)
	.BYTE	^O33,^A"3",0,0		;Protect off (normal intensity)
	.BYTE	^O33,^A"L",0,0		;Insert line
	.BYTE	0,^XFF			;Define pointer to long ascii string
	.SIGNED_WORD 10$-VS2.OT		;Insert space
	.BYTE	^O33,^A"M",0,0		;Delete line
	.BYTE	^O33,^A"O",0,0		;Delete space
	.ASCII	<^O33>/Y7 /		;Move to bottom
	.BYTE	0,^XFF			;Define pointer to long ascii string
	.SIGNED_WORD 20$-VS2.OT		;Home and clear entire page
	.ADDRESS	VT5.PC		;Routine to position to character
	.ADDRESS	VT5.PL		;Routine to position to start of line
	.LONG	24			;Lines per page
	.LONG	80			;Characters per line
	.LONG	M_SLW			;Flags (slow [not really, but like it this way])
	.ADDRESS	START		;Routine to call on entry
	.ADDRESS	STOP		;Routine to call on exit
	.WORD	2			;Number of nulls to output
	.BYTE	0,^X7F			;Null character to output
	.ADDRESS	ITABLE		;Address of input character table
	.LONG	0			;No mark to display on enter
	.ADDRESS	VTXKPD		;Routine to manipulate keypad mode

10$:	.ASCIZ	<^O33>/i /<^O33>/j/	;Character string to insert space
20$:	.BYTE	^O33,^A"H",^O33,^A"y",^O15,0 ;Character string to home and clear page
.SUBTITLE	Escape subtable for Visual-200

VS2.T1:	.WORD	^O33,$ENTER	;ESCAPE ESCAPE == ENTER
	.WORD	^A"H",$CURHM	;ESCAPE H == HOME		  (HOME key)
	.WORD	^A"A",$CURUP	;ESCAPE A == UP			  (/\  key)
	.WORD	^A"B",$CURDN	;ESCAPE B == DOWN		  (\/  key)
	.WORD	^A"C",$CURRT	;ESCAPE C == RIGHT		  (->  key)
	.WORD	^A"D",$CURLF	;ESCAPE D == LEFT		  (<-  key)
	.WORD	^A"P",$ENTER	;ESCAPE P == ENTER		  (F0  key)
	.WORD	^A"Q",$RECAL	;ESCAPE Q == RECALL		  (F1  key)
	.WORD	^A"R",$INMOD	;ESCAPE R == INSERT/MODE	  (F2  key)
	.WORD	^A" ",$DELCH	;ESCAPE space == DELETE-CHARACTER (F3  key)
	.WORD	^A"!",$RLTAB	;ESCAPE ! == REAL TAB (E-C-C I)	  (F4  key)
	.WORD	^A'"',$MARK	;ESCAPE " == MARK		  (F5  key)
	.WORD	^A"#",$LINE	;ESCAPE # == B/E OF LINE	  (F6  key)
	.WORD	^A"$",$CASE	;ESCAPE $ == CASE		  (F7  key)
	.WORD	^A"%",$WINDW	;ESCAPE % == WINDOW		  (F8  key)
	.WORD	^A"&",$HELP	;ESCAPE & == HELP		  (F9  key)
	.WORD	^A"'",$BLINE	;ESCAPE ' == START-OF-LINE	  (F10 key)
	.WORD	^A"(",$ELINE	;ESCAPE ( == END-OF-LINE	  (F11 key)
	.WORD	^A")",$UPTAB	;ESCAPE ) == UP-TAB		  (F12 key)
	.WORD	^A"*",$DNTAB	;ESCAPE * == DOWN-TAB		  (F13 key)
	.WORD	^A"L",$INSLN	;ESCAPE L == INSERT-LINE	  (IL  key)
	.WORD	^A"M",$DELLN	;ESCAPE M == DELETE-LINE	  (DL  key)
	.WORD	^A"K",$ERSLN	;ESCAPE K == ERASE-LINE		  (EL  key)
	.WORD	^A"i",$INSSP	;ESCAPE i == INSERT SPACES	  (IC  key)
	.WORD	^A"j",$INSSP	;ESCAPE j == also INSERT SPACES	  (IC  key)
	.WORD	^A"O",$DELSP	;ESCAPE O == DELETE SPACES	  (DC  key)
	.WORD	^A"f",$ERSWD	;ESCAPE f == ERASE-WORD		  (EF  key)
	.WORD	^A"^",$SAVE	;ESCAPE ^ == SAVE-FILE		  (CPY key)
	.WORD	^A"-",$SAVE	;ESCAPE - == SAVE-FILE		  (CPY key)
	.WORD	^A"1",$TBSET	;ESCAPE 1 == SET/CLEAR-TABS	  (ST  key)
;	.WORD	^A"2",$SUBST	;ESCAPE 2 == CLEAR-TABS		  (CT  key)
				;ESCAPE J ==			  (EP  key)
	.WORD	^A"]",$REWRT	;ESCAPE ] == REWRITE-SCREEN	  (PRT key)
	.WORD	^A"t",$CLRLN	;ESCAPE t == CLEAR-LINE		  (CL  key)
	.WORD	^A"?"		;ESCAPE ? needs a subtable	  (keypad mode)
	.SIGNED_WORD	VS2.T2-VS2.OT	;Offset to subtable
VS2.S1=.-VS2.T1

;Visual 200 commands when in alternate keypad mode

VS2.T2:	.WORD	^A"M",$ENTER	;Keypad ENTER
	.WORD	^A"l",$SAVE	;Keypad ,
;	.WORD	^A"m",$ENTER	;Keypad -
	.WORD	^A"n",$REWRT	;Keypad .
	.WORD	^A"p",$INVRT	;Keypad 0
	.WORD	^A"q",$ERSLN	;Keypad 1
	.WORD	^A"r",$ERSWD	;Keypad 2
;	.WORD	^A"s",$ENTER	;Keypad 3
	.WORD	^A"t",$DELLN	;Keypad 4
	.WORD	^A"u",$DELSP	;Keypad 5
	.WORD	^A"v",$SUBST	;Keypad 6
	.WORD	^A"w",$INSLN	;Keypad 7
	.WORD	^A"x",$INSSP	;Keypad 8
	.WORD	^A"y",$TBSET	;Keypad 9
	.LONG	0
.SUBTITLE	Infoton 200 Output Table

IN2.OT:	.BYTE	^O34,0,0,0	;Cursor up
	.BYTE	^O12,0,0,0	;Cursor down
	.BYTE	^O31,0,0,0	;Cursor right
	.BYTE	^O10,0,0,0	;Cursor left
	.BYTE	^O32,0,0,0	;Cursor home
	.LONG	0		;Clear to end of page (none)
	.LONG	0		;Clear to end of line (none)
	.BYTE	^O12,0,0,0	;Roll up and clear line
	.LONG	0		;Roll down and clear line (none)
	.LONG	0		;Protect on (none)
	.LONG	0		;Protect off (none)
	.LONG	0		;Insert line (none)
	.LONG	0		;Insert space (none)
	.LONG	0		;Delete line (none)
	.LONG	0		;Delete space (none)
	.BYTE	^O27,^A" ",^A"7",0 ;Move to bottom
	.BYTE	^O14,^O14,^O15,0 ;Home and clear entire page
	.ADDRESS IN2.PC		;Routine to position to character
	.ADDRESS IN2.PL		;Routine to position to start of line
	.LONG	24		;Lines per page
	.LONG	80		;Characters per line
	.LONG	M_LSD!M_MRK!M_SLW!M_WRP ;Flags
	.ADDRESS START		;Routine to call on entry
	.ADDRESS STOP		;Routine to call on exit
	.BYTE	^O177,0		;Null character
	.WORD	2		;Number of nulls to output
	.ADDRESS ITABLE		;Address of input character table
	.BYTE	^A"~",0,0,0	;Mark to display on enter
	.LONG	0		;Routine to set/reset keypad mode
.SUBTITLE	VT52 and VT100 Terminal Input Table

;Terminal Input Table for VT100 and VT52 terminals - tells what control
;characters or sequences invoke which commands

	.LONG	$DELCH		; 177	RUBOUT
VT5ITBL:
VT1ITBL:.LONG	$SUBST		;   0	^@
	.LONG	$INSSP		;   1	^A
	.LONG	$SETFI		;   2	^B
	.LONG	$ABORT		;   3	^C
	.LONG	$INSLN		;   4	^D
	.LONG	$SRCBK		;   5	^E
	.LONG	$DELLN		;   6	^F
	.LONG	$PUT		;   7	^G
	.LONG	$CURLF		;  10	^H
	.LONG	$TAB		;  11	^I
	.LONG	$CURDN		;  12	^J
	.LONG	$CURUP		;  13	^K
	.LONG	$CURRT		;  14	^L
	.LONG	$RETRN		;  15	^M
	.LONG	$SWTCH		;  16	^N
	.LONG	$ENTCC		;  17	^O
	.LONG	$GOTO		;  20	^P
	.LONG	$RLBKP		;  21	^Q
	.LONG	$SRCFW		;  22	^R
	.LONG	$DELSP		;  23	^S
	.LONG	$RLFWL		;  24	^T
	.LONG	$BKTAB		;  25	^U
	.LONG	$PICK		;  26	^V
	.LONG	$RLBKL		;  27	^W
	.LONG	$EXEC		;  30	^X
	.LONG	$RLFWP		;  31	^Y
	.LONG	$EXIT		;  32	^Z
VT5ESC:
VT1ESC:	.SIGNED_WORD VT1.T1-VT1.OT	;  33	ESCAPE needs a subtable
	.WORD	-VT1.S1
	.LONG	$SLDRT		;  34	^\
	.LONG	$ERSLN		;  35	^]
	.LONG	$SLDLF		;  36	^^
	.LONG	$LINE		;  37	^_
.SUBTITLE	Ramtek 6211 Output Table

;The RAMTEK 6211 is a VT100 emulator that can't emulate all the VT100
;instructions.  Functions used by SED that are not available include
;the limited scrolling region.

RAM.OT: .BYTE	^O33,^A"[",^A"A",0	;Cursor up
	.BYTE	^O33,^A"[",^A"B",0	;Cursor down
	.BYTE	^O33,^A"[",^A"C",0	;Cursor right
	.BYTE	^O33,^A"[",^A"D",0	;Cursor left
	.BYTE	^O33,^A"[",^A"H",0	;Cursor home
	.BYTE	^O33,^A"[",^A"J",0	;Clear page
	.BYTE	^O33,^A"[",^A"K",0	;Clear line
	.BYTE	^O33,^A"D",0,0		;Roll up and clear line
	.BYTE	^O33,^A"M",0,0		;Roll down and clear line
	.BYTE	0,^XFF			;Define pointer to long ascii string
	.SIGNED_WORD 10$-RAM.OT		;Protect on
	.BYTE	0,^XFF			;Define pointer to long ascii string
	.SIGNED_WORD 20$-RAM.OT		;Protect off
	.LONG	0			;Insert line (none)
	.LONG	0			;Insert space (none)
	.LONG	0			;Delete line (none)
	.LONG	0			;Delete space (none)
	.BYTE	0,^XFF			;Define pointer to long ascii string
	.SIGNED_WORD 30$-RAM.OT		;Move to bottom
	.WORD	0			;Next comes a routine address
	.SIGNED_WORD VT1.HM-RAM.OT	;Home and clear page
	.ADDRESS VT1.PC			;Routine to position to character
	.ADDRESS VT1.PL			;Routine to position to start of line
	.LONG	24			;Lines per page
	.LONG	80			;Characters per line
	.LONG	M_SLW!M_TBS		;Flags (slow TTY, TTY wraps, hardwire tabs
	.ADDRESS START			;Routine to call on entry
	.ADDRESS STOP			;Routine to call on exit
	.LONG	0			;No nulls needed
	.ADDRESS VT1ITBL		;Address of input character table
	.LONG	0			;No mark to display on enter
	.ADDRESS VTXKPD			;Routine to manipulate keypad mode

10$:	.ASCIZ	<^O33>/[7m/
20$:	.ASCIZ	<^O33>/[0m/
30$:	.ASCIZ	<^O33>/[24;1H/

RAM.T1:	.WORD	^A"["			;Escape [ == use subtable
	.SIGNED_WORD VT1.T2-RAM.OT	;Offset to subtable
	.WORD	^A"O"			;Escape O == use subtable
	.SIGNED_WORD VT1.T3-RAM.OT	;Offset to subtable
	.WORD	^O33,$ENTER		;Escape Escape == Enter
RAM.S1=.-RAM.T1
.SUBTITLE	VT100 Output Table

VT1.OT: .BYTE	^O33,^A"[",^A"A",0	;Cursor up
	.BYTE	^O33,^A"[",^A"B",0	;Cursor down
	.BYTE	^O33,^A"[",^A"C",0	;Cursor right
	.BYTE	^O33,^A"[",^A"D",0	;Cursor left
	.BYTE	^O33,^A"[",^A"H",0	;Cursor home
	.BYTE	^O33,^A"[",^A"J",0	;Clear page
	.BYTE	^O33,^A"[",^A"K",0	;Clear line
	.BYTE	^O33,^A"D",0,0		;Roll up and clear line
	.BYTE	^O33,^A"M",0,0		;Roll down and clear line
	.BYTE	0,^XFF			;Define pointer to long ascii string
	.SIGNED_WORD 10$-VT1.OT		;Protect on
	.BYTE	0,^XFF			;Define pointer to long ascii string
	.SIGNED_WORD 20$-VT1.OT		;Protect off
	.WORD	0			;Routine address is next
	.SIGNED_WORD VT1.IL-VT1.OT	;Insert line
	.LONG	0			;Insert space (none)
	.WORD	0			;Routine address is next
	.SIGNED_WORD VT1.DL-VT1.OT	;Delete line
	.LONG	0			;Delete space (none)
	.BYTE	0,^XFF			;Define pointer to long ascii string
	.SIGNED_WORD 30$-VT1.OT		;Move to bottom
	.WORD	0			;Next comes a routine address
	.SIGNED_WORD VT1.HM-VT1.OT	;Home and clear page
	.ADDRESS VT1.PC			;Routine to position to character
	.ADDRESS VT1.PL			;Routine to position to start of line
	.LONG	24			;Lines per page
	.LONG	80			;Characters per line
	.LONG	M_SLW!M_TBS		;Flags (slow TTY, TTY wraps, hardwire tabs
	.ADDRESS START			;Routine to call on entry
	.ADDRESS STOP			;Routine to call on exit
	.LONG	0			;No nulls needed
	.ADDRESS VT1ITBL		;Address of input character table
	.LONG	0			;No mark to display on enter
	.ADDRESS VTXKPD			;Routine to manipulate keypad mode

10$:	.ASCIZ	<^O33>/[7m/
20$:	.ASCIZ	<^O33>/[0m/
30$:	.ASCIZ	<^O33>/[24;1H/
.SUBTITLE	VT100 Escape Subtable

VT1.T1:	.WORD	^A"["			;Escape [ == use subtable
	.SIGNED_WORD VT1.T2-VT1.OT	;Offset to subtable
	.WORD	^A"O"			;Escape O == use subtable
	.SIGNED_WORD VT1.T3-VT1.OT	;Offset to subtable
	.WORD	^O33,$ENTER		;Escape Escape == Enter
	.WORD	^A"J",$JUSTI		;Escape J == justify
	.WORD	^A"j",$JUSTI		;Escape j == justify
	.WORD	^A"M",$MARKR		;Escape M == marker
	.WORD	^A"m",$MARKR		;Escape m == marker
VT1.S1=.-VT1.T1

VT1.T2:	.WORD	^A"A",$CURUP		;Escape [ A == cursor up
	.WORD	^A"B",$CURDN		;Escape [ B == cursor down
	.WORD	^A"C",$CURRT		;Escape [ C == cursor right
	.WORD	^A"D",$CURLF		;Escape [ D == cursor left
	.LONG	0			;End of table

VT1.T3:	.WORD	^A"P",$ENTER		;Escape O P == Enter
	.WORD	^A"R",$RESET		;Escape O R == Reset
	.WORD	^A"S",$CURHM		;Escape O S == Home
	.WORD	^A"Q",$RECAL		;Escape O Q == Recall
	.WORD	^A"M",$INMOD		;Escape O M == Insert-mode

	.WORD	^A"A",$CURUP		;Escape O A == Cursor up
	.WORD	^A"B",$CURDN		;Escape O B == Cursor down
	.WORD	^A"C",$CURRT		;Escape O C == Cursor right
	.WORD	^A"D",$CURLF		;Escape O D == Cursor left

	.WORD	^A"t",$BLINE		;Escape O t == Start-of-line
	.WORD	^A"v",$ELINE		;Escape O v == End-of-line
	.WORD	^A"r",$DNTAB		;Escape O r == Down-tab
	.WORD	^A"x",$UPTAB		;Escape O x == Up-tab
	.WORD	^A"l",$SAVE		;Escape O l == Save file
	.WORD	^A"m",$TBSET		;Escape O m == Tab set/clear
	.WORD	^A"n",$ERSWD		;Escape O n == Erase-word
	.WORD	^A"p",$RLTAB		;Escape O p == Real-tab
	.WORD	^A"w",$MARK		;Escape O w == Mark
	.WORD	^A"y",$CASE		;Escape O y == Case
	.WORD	^A"u",$REWRT		;Escape O U == Rewrite screen
	.WORD	^A"q",$WINDW		;Escape O q == Window
	.WORD	^A"s",$HELP		;Escape O s == Help
	.LONG	0
.SUBTITLE	Televideo 910 Output Tables

T91.OT:	.BYTE	^O13,0,0,0		;Cursor up
	.BYTE	^O12,0,0,0		;  down
	.BYTE	^O14,0,0,0		;  right
	.BYTE	^O10,0,0,0		;  left
	.BYTE	^O36,0,0,0		;  home
	.BYTE	^O33,^A"Y",0,0		;Clear to end of page
	.BYTE	^O33,^A"T",0,0		;Clear to end of line
	.BYTE	^O12,0,0,0		;Roll up and clear line
	.LONG	0			;Roll down and clear line
	.BYTE	^O33,^A")",0,0		;Protect on (none)
	.BYTE	^O33,^A"(",0,0		;Protect off (none)
	.LONG	0			;Insert line (none)
	.LONG	0			;Insert space (none)
	.LONG	0			;Delete line (none)
	.LONG	0			;Delete space (none)
	.BYTE	0,^XFF			;Define pointer to long string
	.SIGNED_WORD 10$-T91.OT		;Move to bottom
	.BYTE	^O36,^O32,0,0		;Home and clear entire page
	.ADDRESS	T91.PC		;Routine to position to character
	.ADDRESS	T91.PL		;Routine to position to start of line
	.LONG	24			;Lines per page
	.LONG	80			;Characters per line
	.LONG	M_SLW			;Terminal dependent flags
	.ADDRESS	START		;Routine to call on entry
	.ADDRESS	STOPX		;Routine to call on exit
	.LONG	0			;No nulls needed
	.ADDRESS	ITABLE		;Address of input character table
	.LONG	0			;No mark to display on enter
	.LONG	0			;No routine to manipulate keypad mode

10$:	.ASCIZ	<^O33>/=7 /		;Move to bottom
.SUBTITLE	VT100 Routines

VT1.HM: MOVAB	10$,R1		;Home and clear page
	JSB	PUTSTG
	JSB	PUTTYP		;Output it now
	SNOOZE	100		;Delay just a little
	RSB			;Then return
10$:	.ASCIZ	<^O33>/[H/<^O33>/[J/

;Insert line (uses limited scrolling region)

VT1.IL:	MOVL	R2,-(SP)	;Save R2
	ADDL3	#1,R7,R1	;Compute current row
	CMPL	R1,LPP(R10)	;Is it on the bottom line?
	BEQL	10$		;Yes - do it differently (for CIT-101s)
	BSBW	VT1.L		;Set up the scrolling region
	MOVL	#^X5B1B,R1
	JSB	PUTSQ1
	ADDL3	#1,R7,R1	;Get the current row
	ADDL	HOMPOS,R1	;Make line number relative to terminal home
	JSB	PUTNUM		;and output decimal in ascii
	MOVAB	VT1ILM,R1
	JSB	PUTSTG		;and make sure we are there
	BRB	VT1.R		;Now restore the initial state

10$:	MOVL	CLN(R10),R1	;On the bottom row, so just clear the line
	JSB	PUTSQ1
	MOVL	(SP)+,R2	;Restore R2
	JMP	PUTTYP		;Output and return

;Delete line (uses limited scrolling region)

VT1.DL:	MOVL	R2,-(SP)	;Save R2
	BSBB	VT1.L		;Set up the scrolling region
	MOVAB	VT1DLM,R1
	JSB	PUTSTG

VT1.R:	MOVAB	VT1RM,R1
	JSB	PUTSTG
	MOVL	(SP)+,R2	;Restore R2
	JMP     PUTTYP          ;Output and return

;Set up scrolling region for insert or delete lines

VT1.L:	MOVAB   VT1.LM,R1
	JSB     PUTSTG
	ADDL3   #1,R7,R1        ;Get the current row
	ADDL	HOMPOS,R1	;Make line number relative to terminal home
	JSB     PUTNUM          ;Output decimal number in ASCII
	MOVAB   VT1.LN,R1
	JMP     PUTSTG
VT1ILM:	.ASCIZ	/;0H/<^O33>/M/
VT1DLM: .ASCIZ  <^O33>/[24;0H/<^O33>/D/
VT1RM:	.ASCIZ  <^O33>/[0;24r/<^O33>/8/
VT1.LM: .BYTE   ^O33,^A"7",^O33,^A"[",0
VT1.LN: .ASCIZ  /;24r/
;Routine to set or reset keypad mode according to the KEYPAD switch.
;If KEYPAD is zero, keypad mode is reset; if KEYPAD is -1, the keypad is
;set to application mode.  If KEYPAD is +1, no action is taken, since the
;switch has not explicitly been specified.

VTXKPD:	TSTB	KEYPAD		;Check the type of keypad desired
	BLSS	10$		;Go set keypad mode
	BEQL	20$		;In this case, reset it
	RSB			;If positive, do nothing
10$:	MOVAB	VTXALTKEY,R1	;Point to the set sequence
	MOVB	#-1,ALTKPD	;Remember keypad mode is set
	BRB	30$		;Go output the sequence
20$:	MOVAB	VTXNRMKEY,R1	;Point to the reset sequence
	CLRB	ALTKPD		;Remember keypad mode is reset
30$:	JSB	PUTSTG		;Put the sequence in the output buffer
	JMP	PUTTYP		;  and output it

VTXALTKEY:.ASCIZ	<^O33>/=/	;Sequence to set alternate keypad mode
VTXNRMKEY:.ASCIZ	<^O33>/>/	;Sequence to reset alternate keypad mode
.SUBTITLE	Cursor Positioning Algorithms

;VT52, Visual 200, Televideo 910 positioning algorithms

T91.PC:	MOVL	#^X3D1B,R1	;"$=" for Televideo 910
	BRB	GEN.PC

VT5.PC:	MOVL	#^X591B,R1	;"$Y" for VT52
GEN.PC:	JSB	PUTSQ1		;Start it off
	ADDL3	#^O40,R7,R1	;Get row position
	MOVB	R1,(R5)+	;Put it in the buffer
	ADDL3	#^O40,R8,R1	;Get column position
	MOVB	R1,(R5)+	;Save it
	RSB			;Then return

T91.PL:	MOVL	#^X3D1B,R1	;"$=" for Televideo 910
	BRB	GEN.PL

VT5.PL:	MOVL	#^X591B,R1	;Get the correct sequence
GEN.PL:	JSB	PUTSQ1		;Start it off
	ADDL3	#^O40,R4,R1	;Get row position
	MOVB	R1,(R5)+	;Save it in the buffer
	MOVB	#^O40,(R5)+	;Move to column zero
	RSB			;Then return

;Infoton 200 positioning algorithms

IN2.PC:	MOVL	#^X17,R1
	JSB	PUTSQ1		;Start it off
	ADDB3	#^A" ",R8,(R5)+	;Get column position
	ADDB3	#^A" ",R7,(R5)+	;Get row position
	RSB			;Done

IN2.PL:	MOVL	#^X2017,R1
	JSB	PUTSQ1		;Start it off (includes move to col 0)
	ADDB3	#^A" ",R4,(R5)+	;Get row position
	RSB			;Done

;VT100 positioning routines MOVE TO ROW (R7), COLUMN (R8)

VT1.PC:	MOVL	#^X5B1B,R1
	JSB	PUTSQ1		;Start it off
	ADDL3	#1,R7,R1	;Get row position
	JSB	PUTNUM
	MOVB	#^A";",(R5)+	;Then a semicolon
	ADDL3	#1,R8,R1	;Get column position
	JSB	PUTNUM
	MOVB	#^A"H",(R5)+	;Then an H
	RSB			;Done

;Move to start of line (R4)

VT1.PL:	MOVL	#^X5B1B,R1	;Start it off
	JSB	PUTSQ1
	ADDL3	#1,R4,R1	;Get row position
	JSB	PUTNUM
	MOVAB	VT1PLM,R1
	JMP	PUTSTG		;Move to first column, then done
VT1PLM:	.ASCIZ	/;0H/

TRMERM:	.ASCII	<CR><LF>\?SEDUTT Unknown terminal type.  Use the DCL command\
	.ASCII	<CR><LF>\"SET TERMINAL/DEVICE_TYPE=type" to declare a known terminal\
	.ASCII	\ type.\<CR><LF>\"type" is one of the following:\<CR><LF><CR><LF>
	.ASCII	\	VT52	=   Visual 200 (in VT52 mode)\<CR><LF>
	.ASCII	\	VT100	=   DEC VT100\<CR><LF>
	.ASCII	\	FT1	=   Televideo 910\<CR><LF><CR><LF>
	.ASCII	\The following terminal types can ONLY be set up by using \
	.ASCII	\the /TERM=type switch:\<CR><LF>
	.ASCII	\	INF200	=   Infoton-200\<CR><LF>
	.ASCII	\	RAM6211	=   Ramtek 6211 graphics terminal\<CR><LF>
	.ASCII	\	VT52	=   DEC VT52\<CR><LF>
	.ASCIZ	<CR><LF>\For more information, type "HELP SED".\<CR><LF>
TRMELN=.-TRMERM

	.END