.TITLE VTLKEY - Parse VT100 Keypad Command .IDENT /1.4/ .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: VTLKEY.MAC ; Author: Robin Miller ; Date: June 30, 1983 ; ; Description: ; ; This module is used to check the valid VT100 keypad commands. The ; commands emulate a subset of the EDT keypad. If the command is invalid, ; the user is prompted for another command. ; ;- .ENABL AMA .NLIST BEX ;+ ; ; Modification History: ; ; March 7, 1985 by Robin Miller. Edit (03), Version 1.4 ; Define CTRL/E to spawn a "EDT file" and CTRL/T to spawn a ; "TECO file/SC" to edit files being displayed. ; ; February 13, 1985 by Robin Miller. Edit (02), Verison 1.3 ; Define CTRL/Z as an "EXIT" command. ; ; June 14, 1984 by Robin Miller. Edit (01), Version 1.2 ; Ignore the error return from the GETCMD routine so CTRL/C and ; CTRL/U are handled properly. ; ; June 12, 1984 by Robin Miller. Version 1.1 ; Added table and routine for control keys. ; ;- .SBTTL CTRTBL - Table for control keys. ; This table contains pointers to ASCII strings for each control key. CTRTBL: .WORD 0 ;(^@ - 00) Null. .WORD 0 ;(^A - 01) SOH. .WORD 0 ;(^B - 02) STX. .WORD 0 ;(^C - 03) ETX. .WORD 0 ;(^D - 04) EOT. .WORD EDITC ;(^E - 05) ENQ. (04) .WORD 0 ;(^F - 06) ACK. .WORD 0 ;(^G - 07) BELL. .WORD UPAROW ;(^H - 08) BS. .WORD 0 ;(^I - 09) HT. .WORD 0 ;(^J - 10) LF. .WORD 0 ;(^K - 11) VT. .WORD 0 ;(^L - 12) FF. .WORD 0 ;(^M - 13) CR. .WORD 0 ;(^N - 14) SO. .WORD 0 ;(^O - 15) SI. .WORD 0 ;(^P - 16) DLE. .WORD 0 ;(^Q - 17) DC1. .WORD GPF2 ;(^R - 18) DC2. .WORD 0 ;(^S - 19) DC3. .WORD TECOC ;(^T - 20) DC4. (04) .WORD 0 ;(^U - 21) NAK. .WORD 0 ;(^V - 22) SYN. .WORD GPF2 ;(^W - 23) ETB. .WORD 0 ;(^X - 24) CAN. .WORD 0 ;(^Y - 25) EM. .WORD EXITC ;(^Z - 26) SUB. (02) .WORD 0 ;( - 27) ESC. .WORD 0 ;(^\ - 28) FS. .WORD 0 ;(^] - 29) GS. .WORD 0 ;(^^ - 30) RS. .WORD 0 ;(^_ - 31) US. .SBTTL KEYTBL - Table of VT100 keypad commands. ;+ ; ; VT100 table of keypad commands. ; ; The table is indexed by the last character of the escape sequence. ; Each entry in the table is a pointer to the associated ASCII command. ; For example, the up arrow ($OA) is the first entry in the table. ; The address pointed to contains the ASCII command to backup one line. ; ;- KEYTBL: .WORD 0 ; No entry zero. .WORD UPAROW ; 'A' UP ARROW .WORD DNAROW ; 'B' DOWN ARROW .WORD RTAROW ; 'C' RIGHT ARROW .WORD LFAROW ; 'D' LEFT ARROW .WORD 0 ; 'E' .WORD 0 ; 'F' .WORD 0 ; 'G' .WORD 0 ; 'H' .WORD 0 ; 'I' .WORD 0 ; 'J' .WORD 0 ; 'K' .WORD 0 ; 'L' .WORD ENTERK ; 'M' ENTER .WORD 0 ; 'N' .WORD 0 ; 'O' .WORD 0 ; 'P' PF1 (GOLD) .WORD PF2 ; 'Q' PF2 .WORD PF3 ; 'R' PF3 .WORD PF4 ; 'S' PF4 ; End of uppercase table. .WORD COMMAK ; 'l' COMMA .WORD MINUSK ; 'm' MINUS .WORD PERIOD ; 'n' PERIOD .WORD 0 ; 'o' .WORD KEY0 ; 'p' 0 key .WORD KEY1 ; 'q' 1 key .WORD KEY2 ; 'r' 2 key .WORD KEY3 ; 's' 3 key .WORD KEY4 ; 't' 4 key .WORD KEY5 ; 'u' 5 key .WORD KEY6 ; 'v' 6 key .WORD KEY7 ; 'w' 7 key .WORD KEY8 ; 'x' 8 key .WORD KEY9 ; 'y' 9 key .SBTTL GLDTBL - Table of GOLD keypad commands. ; GOLD/command table. GLDCMD: ; 1st word used as the GOLD flag. GLDTBL: .WORD 0 ; No entry zero. .WORD UPAROW ; 'A' UP ARROW .WORD DNAROW ; 'B' DOWN ARROW .WORD RTAROW ; 'C' RIGHT ARROW .WORD LFAROW ; 'D' LEFT ARROW .WORD 0 ; 'E' .WORD 0 ; 'F' .WORD 0 ; 'G' .WORD 0 ; 'H' .WORD 0 ; 'I' .WORD 0 ; 'J' .WORD 0 ; 'K' .WORD 0 ; 'L' .WORD GENTER ; 'M' ENTER .WORD 0 ; 'N' .WORD 0 ; 'O' .WORD 0 ; 'P' PF1 .WORD GPF2 ; 'Q' PF2 .WORD GPF3 ; 'R' PF3 .WORD GPF4 ; 'S' PF4 ; End of uppercase table. .WORD GCOMMA ; 'l' COMMA .WORD GMINUS ; 'm' MINUS .WORD GPERIO ; 'n' PERIOD .WORD 0 ; 'o' .WORD GKEY0 ; 'p' 0 key .WORD GKEY1 ; 'q' 1 key .WORD GKEY2 ; 'r' 2 key .WORD GKEY3 ; 's' 3 key .WORD GKEY4 ; 't' 4 key .WORD GKEY5 ; 'u' 5 key .WORD GKEY6 ; 'v' 6 key .WORD GKEY7 ; 'w' 7 key .WORD GKEY8 ; 'x' 8 key .WORD GKEY9 ; 'y' 9 key .SBTTL VTL commands for the keypad. ; VTL commands for the VT100 keypad: ENTERK: .BYTE 0 ; Same as the return key. UPAROW: .ASCIZ "-LI" ; Backup a single line. DNAROW: .ASCIZ "+LI" ; Advance a single line. RTAROW: .ASCIZ "RI" ; Move the screen right LFAROW: .ASCIZ "LE" ; Move the screen left. PF2: .ASCIZ "SH KE" ; Display the VT100 keypad. PF3: .ASCIZ "FN" ; Find the next search string. PF4: .ASCIZ "NE" ; Display the next file. COMMAK: .ASCIZ "PR" ; Print the current file. MINUSK: .ASCIZ "DE" ; Delete the current file. PERIOD: .ASCIZ "SEL" ; Activate select range for write. KEY0: .ASCIZ "LI" ; Advance/backup a single line KEY1: .ASCIZ "SW" ; Swap files (two file display). KEY2: .ASCIZ "SEE" ; Display lines in see-all mode. KEY3: .ASCIZ "RU" ; Enable display of the ruler. KEY4: .ASCIZ "AD" ; Set the advance direction. KEY5: .ASCIZ "BA" ; Set the backward direction. KEY6: .ASCIZ "SET NU" ; Display the record numbers. KEY7: .ASCIZ "PA" ; Find the next page. KEY8: .ASCIZ "SEC" ; Advance/backup a section. KEY9: .ASCIZ "NAR" ; Set to a narrow screen. GPF2: .ASCIZ "REF" ; Refresh the entire screen. GPF3: .ASCIZ "FI" ; Find a search string. GPF4: .ASCIZ "NDI" ; Display files in next directory. GENTER: .ASCIZ "WR SE" ; Write the active select range. GCOMMA: .ASCIZ "SET -NAM" ; Disable the file name display. GMINUS: .ASCIZ "SET NAM" ; Enable the file name display. GPERIO: .ASCIZ "RES" ; Reset the active select range. GKEY0: .ASCIZ "SH HEA" ; Show the current file header. GKEY1: .ASCIZ "SPL" ; Enter the split screen mode. GKEY2: .ASCIZ "-SEE" ; Disable the see-all display. GKEY3: .ASCIZ "-RU" ; Disable the ruler display. GKEY4: .ASCIZ "BO" ; Go to the bottom of the file. GKEY5: .ASCIZ "TO" ; Go to the top of the file. GKEY6: .ASCIZ "SET -NU" ; Disable record number display. GKEY7: .ASCIZ "WR PA" ; Write the current page. GKEY8: .ASCIZ "CLO" ; Close the output file. GKEY9: .ASCIZ "WI" ; Set to a wide screen. EDITC: .ASCIZ "SP EDT $F" ; Edit the current file. (04) EXITC: .ASCIZ "EX" ; Exit from the program. (03) TECOC: .ASCIZ "SP TECO $F/SC" ; Teco the current file. (04) .EVEN .SBTTL KEYPAD - Check the VT100 keypad command. ;+ ; ; KEYPAD - Check the VT100 keypad command. ; ; This routine is entered when the command is terminated by an escape ; sequence (IS.ESQ in the I/O status block). The escape sequence is in ; the input buffer. The last byte is used as an index into the keypad ; table to find a corresponding ASCIZ command. The table contains a ; zero if the key is not defined. ; ; Inputs: ; R0 = The buffer address. ; R1 = The buffer byte count. ; ; Outputs: ; C bit clear/set = success/failure. ; ; R0 = Address of the keypad command. ; R1 = The size of the keypad command. ; ; All other registers are preserved. ; ;- KEYPAD::JSR R5,$SAVRG ; Save R3 - R5. MOV R0,R3 ; Copy the input buffer address. ADD R1,R0 ; Point to end of escape sequence. DEC R0 ; Point at the last character. CLRB GLDCMD ; Presume not a GOLD command. CALL CHKKEY ; Check the escape sequence. BCS 100$ ; If CS, it's an invalid key. ADD #KEYTBL,R0 ; Presume a normal key command. TSTB GLDCMD ; Was the GOLD key typed ? BEQ 10$ ; If EQ, no (presumption correct). ; When the PF1 (GOLD) key is typed, we read another command. MOV #FMTBUF,R0 ; Set address of the input buffer. MOV #CMDSIZ,R1 ; Set the maxiumum input bute count. CALL GETCMD ; Get the next key. ;(01) BCS 20$ ; If CS, error or time to exit. ADD R1,R0 ; Point to end of the string. DEC R0 ; Point to the last character. CALL CHKKEY ; Check the escape sequence. BCS 100$ ; If CS, it's an invalid key. ADD #GLDTBL,R0 ; Else, index into the gold table. 10$: MOV (R0),R1 ; Get the command string address. BEQ 100$ ; If EQ, the key is not defined. MOV R3,R0 ; Restore the original buffer address. ; Copy the keypad command string to the real command buffer. CALL MOVEC ; Copy the character string. 20$: MOV R3,R0 ; Restore the starting address. CALL GETLEN ; Now calculate the command size. CLC ; Show we have a valid key. RETURN ; And return ... 100$: SEC ; Show invalid or undefined key. RETURN .SBTTL CHKKEY - Check for a valid escape sequence. ;+ ; ; CHKKEY - Check for a valid escape sequence. ; ; This routine checks the last byte of the escape sequence to ensure it ; is valid. If it is valid then the offset into the keypad table is ; calculated and returned. ; ; Inputs: ; (R0) = The last byte of escape sequence. ; ; Outputs: ; C bit clear/set = success/failure. ; R0 = The keypad table index on success. ; ; Implicit Outputs: ; The gold flag is set true if the PF1 key is detected. ; ; All other registers are preserved. ; ;- CHKKEY: MOVB (R0),R0 ; COPY THE BYTE BIC #^C177,R0 ; CLEAR HIGH BYTE/PARITY CMPB R0,#'A ; IS THE BYTE TOO LOW ? BLO 100$ ; IF LO, YES CMPB R0,#'T ; IS THE BYTE IN RANGE ? BLO 10$ ; IF LO, YES CMPB R0,#'l ; IS THE BYTE TOO LOW ? BLO 100$ ; IF LO, YES CMPB R0,#'y ; ARE WE IN RANGE ? BHI 100$ ; IF HI, NO SUB #130,R0 ; START AT ENTRY #24 BR 30$ ; AND CONTINUE ... 10$: CMPB R0,#'P ; IS THIS KEY PF1 (GOLD) ? BNE 20$ ; IF NE, NO INCB GLDCMD ; SHOW GOLD COMMAND 20$: SUB #100,R0 ; START AT ENTRY #1 30$: ASL R0 ; MAKE A WORD INDEX CLC ; SHOW SUCCESS RETURN 100$: SEC ; SHOW FAILURE RETURN .SBTTL CTRKEY - Check the control key. ;+ ; ; CTRKEY - Check the control key. ; ; This routine is entered from the input routine when a control key is ; typed by itself. The control key table entry contains zero is the key ; isn't defined. ; ; Inputs: ; R0 = The buffer address (first byte is the control key). ; ; Outputs: ; C bit clear/set = defined/undefined. ; ; R0 = The buffer filled in with the ASCII command. ; R1 = The ASCII command length. ; ;- CTRKEY::JSR R5,$SAVRG ; Save R3 - R5. MOV R0,R4 ; Save the buffer address. MOVB (R0),R3 ; Copy the control character. ASL R3 ; Make it a word index. ADD #CTRTBL,R3 ; Add base address of the table. TST (R3) ; Is there a buffer address ? BEQ 90$ ; If EQ, no. MOV (R3),R1 ; Yes, copy the buffer address. CALL MOVEC ; Copy the ASCII string. MOV R4,R0 ; Set the starting buffer address. CALL GETLEN ; Calculate the string length. CLC ; Show the key is defined. BR 100$ ; And use common return ... 90$: SEC ; Show key is not defined. 100$: RETURN .END