.TITLE KEYPAD - PARSE VT100 KEYPAD COMMANDS .IDENT /01.2/ .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: KEYPAD ; Author: Robin Miller ; Date: March 23, 1982 ; ; Description: ; ; This module is used to check the valid VT100 keypad command for ; the LIST program. The commands will emulate a subset of the EDT keypad. ; If the command is invalid, the user is prompted for another command. ; ; ; Modification History: ; ;- .ENABL AMA CR = 15 ; ASCII FOR CARRIAGE RETURN ;+ ; ; 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 RETKEY ; '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 COMMA ; 'l' COMMA .WORD MINUS ; 'm' MINUS .WORD 0 ; 'n' PERIOD .WORD 0 ; 'o' .WORD KEY0 ; 'p' 0 key .WORD 0 ; 'q' 1 key .WORD 0 ; 'r' 2 key .WORD 0 ; 's' 3 key .WORD KEY4 ; 't' 4 key .WORD KEY5 ; 'u' 5 key .WORD 0 ; 'v' 6 key .WORD KEY7 ; 'w' 7 key .WORD KEY8 ; 'x' 8 key .WORD 0 ; 'y' 9 key ; GOLD/command table. GLDCMD: ; 1st word used as 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 RETKEY ; 'M' ENTER .WORD 0 ; 'N' .WORD 0 ; 'O' .WORD 0 ; 'P' PF1 .WORD PF2 ; 'Q' PF2 .WORD GPF3 ; 'R' PF3 .WORD PF4 ; 'S' PF4 ; End of uppercase table. .WORD COMMA ; 'l' COMMA .WORD MINUS ; 'm' MINUS .WORD 0 ; 'n' PERIOD .WORD 0 ; 'o' .WORD KEY0 ; 'p' 0 key .WORD 0 ; 'q' 1 key .WORD 0 ; 'r' 2 key .WORD 0 ; 's' 3 key .WORD GKEY4 ; 't' 4 key .WORD GKEY5 ; 'u' 5 key .WORD 0 ; 'v' 6 key .WORD KEY7 ; 'w' 7 key .WORD KEY8 ; 'x' 8 key .WORD 0 ; 'y' 9 key ; ASCIZ commands for VT100 keypad. .NLIST BEX RETKEY: .BYTE ,0 ; RETURN KEY UPAROW: .ASCIZ ".-1" ; BACKUP 1 LINE DNAROW: .ASCIZ ".+1" ; ADVANCE 1 LINE RTAROW: .ASCIZ "RI" ; MOVE SCREEN RIGHT LFAROW: .ASCIZ "LE" ; MOVE SCREEN LEFT PF2: .ASCIZ "KEY" ; DISPLAY VT100 KEYPAD PF3: .ASCIZ "FN" ; FIND NEXT PF4: .ASCIZ "NE" ; NEXT FILE COMMA: .ASCIZ "PR" ; PRINT FILE MINUS: .ASCIZ "DE" ; DELETE FILE KEY0: .ASCIZ ".1" ; ADVANCE/BACKUP 1 LINE KEY4: .ASCIZ "AD" ; SET ADVANCE DIRECTION KEY5: .ASCIZ "BA" ; SET BACKWARD DIRECTION KEY7: .ASCIZ "PA" ; FIND THE NEXT PAGE KEY8: .ASCIZ "SEC" ; ADVANCE/BACKUP SECTION GPF3: .ASCIZ "FI" ; FIND A STRING GKEY4: .ASCIZ "BO" ; BOTTOM OF FILE GKEY5: .ASCIZ "TO" ; TOP OF FILE .EVEN ;+ ; ; KEYPAD - Check VT100 keypad command. ; ; This routine is entered when the command is terminated by an escape ; sequence (IS.ESQ) for a status return. 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) - contains the last character of the escape sequence. ; ; Outputs: ; C clear/set = success/failure. ; R0 = address of ASCIZ command on success. ; ;- KEYPAD:: CLRB GLDCMD ; INIT GOLD COMMAND FLAG CALL CHKKEY ; CHECK VT100 KEY BCS 100$ ; IF CS, INVALID KEY TSTB GLDCMD ; GOLD KEY TYPED ? BEQ 10$ ; IF EQ, NO CALL GETCMD ; GET THE NEXT KEY ADD R1,R0 ; POINT TO END OF INPUT DEC R0 ; POINT TO LAST BYTE CALL CHKKEY ; CHECK VT100 KEY AGAIN BCS 100$ ; IF CS, INVALID KEY ADD #GLDTBL,R0 ; INDEX INTO GOLD TABLE BR 20$ ; AND CONTINUE ... 10$: ADD #KEYTBL,R0 ; POINT TO THE ENTRY 20$: MOV (R0),R1 ; GET THE COMMAND ADDRESS BEQ 100$ ; IF EQ, KEY NOT DEFINED MOV #CMD,R0 ; COPY TO THE COMMAND BUFFER MOV R0,-(SP) ; SAVE STARTING ADDRESS 30$: MOVB (R1)+,(R0)+ ; COPY THE NEXT BYTE BNE 30$ ; LOOP UNTIL DONE MOV (SP)+,R0 ; RESTORE STARTING ADDR CLC ; SHOW SUCCESS RETURN ; AND RETURN ... 100$: SEC ; SHOW FAILURE RETURN ;+ ; ; CHKKEY - Check the VT100 keypad escape sequence. ; ; Inputs: ; (R0) = last byte of escape sequenece. ; ; Outputs: ; C clear/set = success/failure. ; R0 = the table index on success. ; ;- 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 .END