.TITLE AUX - VT100 Auxillary Keypad .IDENT /1.1/ .ENABL LC ;+ ; ; Free software BY ; Project Software & Development, Inc. ; ; This software is furnished for free and may be used and copied as ; desired. This software or any other copies thereof may be provided or ; otherwise made available to any other person. No title to and ; ownership of the software is hereby transferred or allowed. ; ; The information in this software is subject to change without notice ; and should not be construed as a commitment by PROJECT SOFTWARE ; AND DEVELOPMENT, INC. ; ; PROJECT SOFTWARE assumes no responsibility for the use or reliability ; of this software on any equipment whatsoever. ; ; Project Software & Development, Inc. ; 14 Story St. ; Cambridge, Ma. 02138 ; 617-661-1444 ; ; ; Title: AUX.MAC ; Author: Robin Miller ; Date: July 23, 1985 ; ; Description: ; ; This program is used to enable the VT100 family terminal keypad to ; define commands and to allow command line editing. ; ; Modification History: ; ; April 17,18 1986 update to work with Reese IAS F. Borger ; ; November 26, 1985 by Robin Miller. Edit (01), Version 1.1 ; If the command line is terminated without any input characters, ; write a blank to scroll up the screen. This way, the user can ; type the RETURN or ENTER key to scroll the screen up. ; ;- .ENABL AMA .NLIST BEX .MCALL ALUN$S, DIR$, EXIT$S, EXST$S, QIOW$, MRKT$, WTSE$, CLEF$ ; .MCALL ACNDF$, CLOSE$, FINIT$ .MCALL CLOSE$, FINIT$ ; ACNDF$ ; Define account block definitions. ; ; Switch definitions (SWMASK): ; ; Bits to be manipulated by the user go here. ; B.NAR == 1 ; List file on narrow screen. B.WIDE == 2 ; List file on wide screen. B.BELL == 4 ; Ring the bell on messages. B.IMOD == 10 ; Insert or overprint mode. B.ADV == 20 ; Set direction to advance. B.AVO == 40 ; VT100 without advanced video. ; == 100 ; ; == 200 ; b.first == 400 ; first time in, for getmes use ; == 1000 ; ; == 2000 ; ; == 4000 ; ; == 10000 ; B.CTIM == 20000 ; The timer has been canceled. ; == 40000 ; B.STUP == 100000 ; Executing the startup code. ; The default switch mask: DEFSWM == B.STUP!B.ADV!B.AVO!B.BELL ; ; Status bit definitions (STATUS): ; ; Bits to be manipulated by the program go here: ; ; == 1 ; ; == 2 ; ; == 4 ; B.132 == 10 ; Screen put in 132 column mode. B.EXIT == 20 ; The user wants to exit. B.ICMD == 40 ; Internal command was processed. B.MORE == 100 ; Get more input from the user. B.ESQ == 200 ; Escape sequence has been read. ; == 400 ; ; == 1000 ; ; == 2000 ; ; == 4000 ; ; == 10000 ; B.MSG == 20000 ; A message has been displayed. B.FERR == 40000 ; There has been a file error. ; == 100000 ; ; The switch mask and the status word: KEYSTA::.WORD 0 ; Key status. SWMASK::.WORD DEFSWM ; The switch mask. STATUS::.WORD 0 ; The status word. ; Directive Parameter Blocks: ATTACH::QIOW$ IO.ATT,TOLUN,TOEFN,,TIOSB,, DETACH::QIOW$ IO.DET,TOLUN,TOEFN,,TIOSB,, KILLIO: QIOW$ IO.KIL,TOLUN,TOEFN,,,, ; Buffers for above directives: TIOSB:: .BLKW 2 ; Terminal I/O status block. .SBTTL AUX - Start Of Program. ;+ ; ; AUX - Start of program. ; ;- AUX:: call MCRSUB ; do reese mcr things ALUN$S #TOLUN,#"TI,#0 ; Assign a LUN to TI0:. MOV @#.FSRPT,R0 ; Get pointer to the FSR. TST A.DFUI(R0) ; Has .FINIT been done (DDT) ? BNE 10$ ; If NE, yes (do it only once) FINIT$ ; Initialize the file storage. ; Determine what system we're running on. 10$: BIS #B.STUP,SWMASK ; Show doing startup code. ; SREX$S #EXIT1 ; Setup and exit AST routine. ; Attach the terminal and check for a VT100 family terminal. DIR$ #ATTACH ; Attach the output device. CALL CHKERR ; Check for any errors. BCS 90$ ; If CS, we had an error. CALL CTTYPE ; Check the terminal type. BCC DOINIT ; If CC, we're ready to go. ; We come here on fatal errors during above startup code. 90$: MOV #EX$SEV,R0 ; Set severe status code. JMP EXST ; And exit with the status. ; Prompt for file name(s) to display. DOINIT: CALL SETUP ; Do the initial task setup. call nomess ; disable messages CALL CLWRAP ; Disable automatic wrap-around. CALL DOLINK ; Setup the command buffer links. CALL AFTSPN ; Enable the auxillary keypad. CALL PRLOOP ; Prompt the user for commands. JMP EXIT ; Exit the program. .SBTTL PRLOOP - Prompt the user for commands. ; Prompt the user for commands. PRLOOP::BIT #B.EXIT,STATUS ; Does the user want to exit now ? BNE 100$ ; If NE, yes. MOV IENTRY,R5 ; Copy the file entry address. BIT #B.MORE,STATUS ; Get more input from the user ? BNE 10$ ; If EQ, yes (don't write prompt). bit #b.first,status ; first time into AUX? bne 9$ ; br if not bis #b.first,status ; first time in, do getmes thing, then call getmes ; don't do it any more 9$: CALL WRITPR ; Prepare and write the prompt. 10$: CLR KEYSTA ; Clear the key status bits. MOV #CMDBUF,R0 ; Set address of the input buffer. MOV #CMDSIZ,R1 ; Set the maximum input byte count. CALL GETCMD ; Read a command from the user. 11$: BIC #B.MORE!B.ICMD,STATUS ; Reset the various status flags. BIT #B.EXIT,STATUS ; Does the user want to exit ? BNE 100$ ; If NE, yes. ; If nothing was entered, write a blank line to scroll the screen. TST R1 ; Was a command line entered ? BNE 15$ ; If NE, yes (do the parse). (01) CALL WRTBLA ; No, write a blank line. (01) BR PRLOOP ; And prompt the user again. (01) ; Parse the command line. 15$: CLR CMDPTR ; Show no command line pointer. CLR CMDEND ; Show no command in progess. BIC #B.ICMD,STATUS ; Clear the internal command flag. MOV #START,R5 ; Set the starting state table address. CALL DOPARS ; Parse the command line enetered: ; Inputs: ; R0 = The buffer address. ; R1 = The buffer byte count. ; R5 = The starting state address. BIT #B.EXIT,STATUS ; Does the user want to exit ? BNE 100$ ; If NE, yes. BIT #B.ICMD,STATUS ; Was this an internal command ? BNE 20$ ; If NE, yes (don't save it). CALL SAVCMD ; Else, save the last command line. 20$: BR PRLOOP ; Prompt for the next command. 100$: RETURN .SBTTL DOLINK - Setup the command buffer links. ;+ ; ; DOLINK - Setup the command buffer links. ; ; This routine is used to setup the forward and backward links for the ; command buffers. These buffers are used to save command line text. ; ; Inputs: ; None. ; ; Outputs: ; All registers are preserved. ; ;- DOLINK::CALL $SAVAL ; Save all registers. MOV #CMDTBL,R0 ; Set the command table address. MOV #CMDMAX,R1 ; Set the maximum buffer count. MOV R0,R2 ; Set address of the last entry. MOV R0,CMDENT ; Set address of the first entry. MOV R0,R4 ; Save the start table address. 10$: MOV R2,R0 ; Copy address of current entry. MOV R2,R3 ; Copy the current entry address. ADD #,R2 ; Set address of the next entry. SUB #,R3 ; Set address of previous entry. MOV R2,C.FORW(R0) ; Set pointer to the next entry. MOV R3,C.BACK(R0) ; Set pointer to the last entry. CLR C.BUFF(R0) ; Clear first word of the buffer. SOB R1,10$ ; Loop until all buffers are done. MOV R4,C.FORW(R0) ; Last buffer links back to top. MOV R0,C.BACK(R4) ; Top buffer links to bottom. RETURN .SBTTL GETKEY - Get the key definition text. ;+ ; ; GETKEY - Get the key definition text. ; ; This command is called when an escape sequence or a control key is detected. ; After getting the key definition if the command is an internal command (!), ; that command is parsed and executed. If it is not an internal command, the ; definition is appended to or inserted into the current command line buffer. ; ; Inputs: ; R0 = The command line buffer. ; R1 = The command line byte count. ; Does not include the escape sequence size. ; ; Implicit Inputs: ; B.ESQ in STATUS = Escape sequence enetered. ; ; Outputs: ; C bit clear/set = non-internal/internal command. ; ; All registers are preserved. ; ; Implicit Outputs: ; B.ESQ is cleared in STATUS. ; ;- .ENABL LSB GETKEY::CALL $SAVAL ; Save all registers. CLR KEYSTA ; Clear the key status bits. BIT #B.ESQ,STATUS ; Was an escape sequence entered ? BNE 10$ ; If NE, yes. CALL CTRKEY ; Else, check the control key. BCS 100$ ; If CS, key is not defined. MOV R0,R3 ; Copy the command line address. ADD R1,R3 ; Point to the control key. CLRB (R3) ; Delete the control key. BR 20$ ; Else, use common code ... 10$: CALL KEYPAD ; Check for a valid keypad command. ; Outputs: ; R2 = The key entry address. BCS 90$ ; If CS, key is not defined. 20$: MOVB K.STAT(R2),KEYSTA ; Copy the key status bits. MOVB K.SIZE(R2),R1 ; Copy the key command size. MOV K.BUFF(R2),R0 ; Copy the key command address. BEQ 90$ ; If EQ, key is not defined. CMPB (R0),#'! ; Is this an internal command ? BNE 30$ ; If NE, no. MOV #START,R5 ; Set the starting state table address. CALL DOPARS ; Parse the command line enetered: BR 100$ ; Use common return ... ; Not an internal command, insert string into the command line. 30$: BIT #S.ERAS,KEYSTA ; Erase current command line ? BEQ 40$ ; If EQ, no. CLR CMDPTR ; Clear the command pointer. CLR CMDEND ; Clear end of command line. CALL REFCMD ; Update the terminal screen. 40$: MOV R0,R2 ; Copy the key string address. CALL INSSTR ; Insert string and update screen. BR 100$ ; Use common return ... 90$: BIT #S.TERM,KEYSTA ; Key used to terminate command ? BNE 100$ ; If NE, yes (no message). ERRMSG NOKEY, 100$: BIC #B.ESQ,STATUS ; Reset escape sequence flag. RETURN .DSABL LSB .SBTTL SETUP - Do the initial task setup. ;+ ; ; SETUP - Do the initial task setup. ; ; Inputs: ; None. ; ; Outputs: ; All registers are preserved. ; ;- SETUP:: JSR R2,$SAVVR ; Save R0 - R2. ; Setup the default Command Line Interpreter (CLI). ; DIR$ #GETCLI ; Get the CLI information. ; CALL CHKDIR ; Check/report any errors. ; BCS 10$ ; If CS, we've had an error. ; MOV #CLIBUF,R0 ; Copy the CLI info buffer. ; MOV G.CITK(R0),DEFCLI ; Setup the Radix-50 ; MOV G.CITK+2(R0),DEFCLI+2 ; default CLI name. ; Read the accounting block to get the username. ;10$: DIR$ #GINUAB ; Get the user account block. ; CALL CHKDIR ; Check/report any errors. 100$: RETURN .SBTTL EXIT - Close Open Files And Exit ;+ ; ; EXIT - Close any open files and exit to the system. ; ;- EXIT:: CALL WRTEOF ; Write the end of file sequence. CALL SEWRAP ; Reenable automatic wrap-around. MOV #EX$SUC,R0 ; Set the success status code. ; Exit with the status code in R0. EXST:: DIR$ #DETACH ; Detach terminal call okmess ; re-enable messages EXST$S R0 ; Exit with the status. ; This code is entered by the abort AST. EXIT1: DIR$ #KILLIO ; Kill any outstanding I/O. call okmess ; re-enable messages EXIT$S ; In case EXST$S fails. .END AUX ; Transfer address.