Trailing-Edge - PDP-10 Archives - steco_19840320_1er_E35 - 10,5676/teco/newsrc/tecfcm.mac
There are 3 other files named tecfcm.mac in the archive. Click here to see a list.
	SUBTTL	Introduction

; Copyright (c) 1981, 1982 Stevens Institute of Technology, Hoboken, New Jersey
; 07030.

; This software may be used and copied provided that this copyright notice
;is included, and provided that copies of all modifications are sent to:
;	TECO Project
;	Computer Center
;	Stevens Institute of Technology
;	Castle Point Station
;	Hoboken, New Jersey    07030
; The information in this software is subject to change without notice
; and should not be construed as a commitment by Stevens Institute of
; Technology.

  ; Search needed universals

	SEARCH	TECUNV		; TECO universal file

  ; Generate the prologue

	TECVER==200		; Major version number
	TECMIN==1		; Minor version number
	TECEDT==1145		; Edit level
	TECWHO==0		; Last editor

	PROLOGUE(FCM,<TECO F command processing>)	; Generate the TITLE and other stuff
	SUBTTL	Table of Contents
	SUBTTL	Revision History


Start of Version 200A(1126)

1145	By: Nick Bush		On: 8-Febuary-1982
	Re-write command input routines to implement FI command. As part of this
	allow user to set prompt by storing the prompt text for normal commands in
	the Q-register 'COMMAND-PROMPT'.
	SUBTTL	F commands -- Initialization

;.hl1 FC$INI
;This routine will initialize the F command processing module.
; Usage:
;	(Return)
; On return:
;	- Module initialized

	$CODE				; Generate code for this

FC$INI:	POPJ	P,			; Just return for now
	SUBTTL	F commands -- FI -- Input from terminal

;.hl1 FICMD

FICMD:	SETZ	T1,			; No Default Q-register
	PUSHJ	P,SCNQRG		; Scan off the Q-register name
	  ERROR	E.IQN			; Complain
	MOVE	P1,T1			; Copy the QRG address
	MOVEI	T1,XCTBUF		; Point to the execution buffer
	MOVEI	T2,SKRCH		; Input routine
	PUSHJ	P,SCNKEY		; Scan off a keyword
	  ERROR	E.UTK			; Failed, problem.
	MOVE	T1,[XWD -FILEN,FITBL]	; Get the table pointer
	PUSHJ	P,FNDKWD		; Find the keyword
	  ERROR	E.IKW			; Illegal keyword
	MOVE	P2,T1			; Copy the index to a safer place
	MOVE	T1,P1			; Get the QRG address back
	PUSHJ	P,QTXTEI		; Make sure it has text
	LOAD.	T2,BLKPT,(T1)		; Get the end of the buffer
	MOVE	P4,T2			; Get a copy of the position
	LOAD.	P3,BLKEND,(T1)		; Get the end address
	STOR.	P3,BLKPT,(T1)		; And make that the current position
	MOVE	T1,P1			; Get the address of the QRG
	PUSHJ	P,C$CINI		; Initialze the command input
	LOAD	T1,$QRFLG(P1),QR$DLC	; Get the display last CRLF flag
	PUSH	P,T1			; Save it
	BITON	T1,QR$DLC,$QRFLG(P1)	; And make sure it is on now

	TXO	F,F.INFI		; Flag we are in an FI command
	PUSHJ	P,@2(P2)		; Call the right routine
	TXZ	F,F.INFI		; No longer in FI

	POP	P,T1			; Get the QR$DLC flag back
	STOR	T1,$QRFLG(P1),QR$DLC	; Store it back

; Now to return the string argument to the caller

	LOAD.	T2,TPTADR,+$QRTPT(P1)	; Get the text block address again
	LOAD.	T1,BLKEND,(T2)		; Get the new end of the buffer
	CAMGE	T1,P4			; Did something get deleted?
	 MOVE	P4,T1			; Yes, can't put PT after END
	STOR.	P4,BLKPT,(T2)		; Store the old position back
	SUB	T1,P3			; Compute the number of characters
	JUMPLE	T1,[SETZ T1,		; Flag we want a null string
		PJRST	PASRET]		; And pass the argument on
	PUSHJ	P,GETSTR		; Get buffer
	LOAD.	T4,TPTADR,+$QRTPT(P1)	; Get the buffer address
	XMOVEI	T1,.BKTLN(T4)		; Get the address of the text
	MOVE	T2,P3			; Get the old end
	IDIVI	T2,5			; Compute the byte and word offset
	ADD	T1,T2			; Build the address
	TDO	T1,BTAB-1(T3)		; Build the byte pointer
	LOAD.	T2,BLKEND,(T4)		; Get the end of the buffer
	SUB	T2,P3			; Compute the number of characters
	LOAD.	T3,TPTADR,+SARG$1	; Get the address of the destination
	XMOVEI	T4,$QRTPT(P1)		; Get the TPT address
	PUSHJ	P,M$INSS		; Insert the string
	PJRST	PASRET			; And return to the caller
	SUBTTL	F commands -- FI -- Dispatch table

>; End of FINAM macro definition



	SUBTTL	F commands -- FI -- INPUT-FILE

;.hl2  FI$INP
;This routine will parse an input file specification.

	FALL	FI$OUT			; Just input a file spec
>; End of TOPS10
	JMPS	FIIN.1			; Do the messy version

; At this point we know that the prompt has been output to the terminal.
; All that need be done is to just do a GTJFN% and a JFNS% to get the
; full file specification associated with it.

	MOVX	T1,GJ%SHT+GJ%NEW+GJ%FNS	; Get the bits
	MOVX	T2,<.PRIOU,,.PRIIN>	; Get the JFNs to use
	GTJFN%				; Get the file specification
	 ERJMP	FIIN.2			; Failed, handle it
	MOVE	T2,T1			; Get the JFN and flags
	MOVX	T1,<<X(DEV)>!<X(DIR)>!<X(NAM)>!<X(TYP)>!<X(GEN)>!<X(PRO)>!<X(ACT)>!JS%PAF>
	MOVE	T3,[XWD -1,FILSPC]	; Get the file specification
	JFNS%				; Convert the JFN to a string
	SETZ	P1,			; Clear the last byte
	IDPB	P1,T3			; . . .
	CLOSF%				; Close the JFN
>; End of TOPS20
	SUBTTL	F commands -- FI -- OUTPUT-FILE

;.hl2 FI$OUT
;This routine will parse an output file specification.

	FALL	FI$LIN		; Just get a line's worth
>; End of TOPS10 conditional
	SUBTTL	F commands -- FI$LIN -- LINE

;.hl2 FI$LIN
;This routine will parse a line that ends with a standard monitor break

; Mask of break characters

FI$LIN:	PUSHJ	P,C$PRMT	; First output the prompt

; Now loop getting characters until we get an EOL.

FLIN.0:	PUSHJ	P,C$ICHE	; Get a character with editing
	JUMPGE	CH,FLIN.1	; If editing character, just try again
	MOVE	T1,CINQRG	; Get the QRG address
	LOAD.	T1,TPTADR,+$QRTPT(T1) ; And set up to check
	CFMG.	T2,BLKPT,(T1),PMTLEN ; Anything after the prompt?
	 JRST	FI$LIN		; No, start from the top
	JRST	FLIN.0		; Yes, just get another character

FLIN.1:	CAXN	CH,.CHCNR	; Control-R?
	 JRST	FLIN.R		; Yes, go handle it
	MOVX	T1,BRKCHR	; Get the mask of break characters
	LSH	T1,(CH)		; Is it one?
	JUMPGE	T1,FLIN.0	; No, try again
	MOVE	T1,CINQRG	; Get the QRG address
	BITON	T2,QR$UPD,$QRFLG(T1) ; Flag that it needs updating
	PUSHJ	P,C$DLCH	; Yes, remove it from the buffer
	 POPJ	P,		; Should really happen, but ignore it
	CAXE	CH,.CHLFD	; Was it a line feed?
	 POPJ	P,		; No, all done
	MOVE	T1,CINQRG	; Get the QRG address
	LOAD.	T1,TPTADR,+$QRTPT(T1) ; And the address of the buffer
	LOAD.	T2,BLKPT,(T1)	; Get the pointer
	SOJL	T2,.POPJ	; If nothing else, just return
	IDIVI	T2,5		; Convert to word/byte
	ADD	T1,T2		; Point to the correct place
	ADDX	T1,.BKTLN	;  .  .  .
	TDO	T1,BTAB(T3)	;  .  .  .
	LDB	CH,T1		; Get the character
	CAXN	CH,.CHCRT	; Is it the CR of a CRLF?
	 PUSHJ	P,C$DLCH	; Yes, delete the character
	  JFCL			; Ignore error return
	POPJ	P,		; And return

; Here on a control-R.

FLIN.R:	PUSHJ	P,C$DLCH	; No, delete on character
	 JFCL			; Ignore the error return
	JMPS	FLIN.V		; Video mode?
	XCT	$CRCTU(CRT)	; Kill the line from the screen
	PUSHJ	P,C$RPRT	; Reprint it
	JRST	FLIN.1		; And go for the next character

FLIN.V:	PUSHJ	P,V$CTRG	; Do the update
	JRST	FLIN.1		; And try again

;.hl2 FI$CMD
;This routine will parse text that ends with two escape characters.

FI$CMD:	SETZ	CH,		; Flag nothing typed in yet
	PUSHJ	P,C$INPT	; Just input the command text
	 JRST	FI$CMD		; Until he gets it right
	POPJ	P,		; All done

; This routine will input a single character appending it to the Q-register.

	PUSHJ	P,C$ICHE	; Input a character
	POPJ	P,		; And return
	SUBTTL	Low segment

	$IMPURE			; Impure data area
	LOWVER(FCM,1)		; Low segment version number


FILSPC:	BLOCK	40		; File specification
>; End of TOPS20 conditional


	END			; End of TECFCM