.TITLE AUXKEY - Parse VT100 Keypad Command .IDENT /1.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: AUXKEY.MAC ; Author: Robin Miller ; Date: July 23, 1985 ; ; Description: ; ; This module is used to lookup commands defined to control keys ; or the VT100 keypad keys. ; ; Modification History: ; ; November 26, 1985 by Roin Miller. Version 1.2 ; Define the escape key to terminate the command line. ; ; November 21, 1985 by Robin Miller. Version 1.1 ; Change the show queue commands from a short format (Que /Li:queue) ; to a full format (Que /Fu:queue). ; ;- .ENABL AMA .NLIST BEX .psect code,ro,i,lcl,rel,con ; Command status bits. S.NECO == 1 ; Don't echo command line. NEC = 1 ; Local definition for table. S.ERAS == 2 ; Erase command line. ERA = 2 ; Local definition for table. S.TERM == 4 ; Terminate command line. TRM = 4 ; Local definition for table. S.DCL == 10 ; Spawn the command to DCL. DCL = 10 ; Local definition for table. S.MCR == 20 ; Spawn the command to MCR. MCR = 20 ; Local definition for table. K.STAT == 0 ; Offset to key status. (byte) K.SIZE == 1 ; Offset to key size. (byte) K.BUFF == 2 ; Offset to key buffer. (word) KEYLEN = K.BUFF+2 ; Length of each entry. ; ; Macro to generate command entrys. ; ; Inputs: ; KSTAT The key command status. ; KEYTXT The ASCII key definition. ; .MACRO CMD KSTAT,KEYTXT .NCHR $$$, .BYTE KSTAT .BYTE $$$ .IF NB .PSECT $KEYS,RO,D,REL,CON $$$KEY=. .ASCIZ "KEYTXT" .psect code,ro,i,lcl,rel,con .WORD $$$KEY .IFF .WORD 0 .ENDC .ENDM .SBTTL CTRTBL - Table for control keys. ; ; This table contains entrys for each control key. ; ; Status Command Description ; ------ ------- ----------- CTRTBL: CMD , ;(^@ - 00) Null. CMD , ;(^A - 01) Toggle mode. CMD , ;(^B - 02) Skip backward to character. CMD , ;(^C - 03) Delete the entire line. CMD , ;(^D - 04) Delete to end of the line. CMD , ;(^E - 05) Position to end of the line. CMD , ;(^F - 06) Skip forward to character. CMD , ;(^G - 07) Toggle the default state. CMD , ;(^H - 08) Position to start of line. CMD , ;(^I - 09) HT. CMD , ;(^J - 10) Delete previous word. CMD , ;(^K - 11) VT. CMD , ;(^L - 12) Echo FF. CMD , ;(^M - 13) CR. CMD , ;(^N - 14) Reload user commands CMD , ;(^O - 15) CMD , ;(^P - 16) DLE. CMD , ;(^Q - 17) DC1. CMD , ;(^R - 18) Recall previous commands. CMD , ;(^S - 19) DC3. CMD , ;(^T - 20) Show short status report. CMD , ;(^U - 21) Delete to start of line. CMD , ;(^V - 22) Display the version number. CMD , ;(^W - 23) Refresh the command line. CMD , ;(^X - 24) CMD , ;(^Y - 25) Display user commands CMD , ;(^Z - 26) Exit from the program. CMD TRM, <> ;(^[ - 27) Terminate command line. (ESC) CMD , ;(^\ - 28) FS. CMD , ;(^] - 29) GS. CMD , ;(^^ - 30) RS. CMD , ;(^_ - 31) US. CMD , ;( - 32) SPACE. DELKEY: CMD , ;(Del-127) Delete previous character. .SBTTL KEYTBL - Table of VT100 keypad commands. ; ; ; VT100 table of keypad commands. ; ; The table is indexed into by the last character of the escape sequence. ; ; Status Command Description ; ------ ------- ----------- KEYTBL: CMD , ;No entry zero. CMD , ;(A) Get previous command line. (Up) CMD , ;(B) Get the next command line. (Down) CMD , ;(C) Move the cursor right. (Right) CMD , ;(D) Move the cursor left. (Left) CMD , ;(E) CMD , ;(F) CMD , ;(G) CMD , ;(H) CMD , ;(I) CMD , ;(J) CMD , ;(K) CMD , ;(L) CMD TRM, <> ;(M) Terminate command line. (Enter) CMD , ;(N) CMD , ;(O) CMD , ;(P) Gold. (PF1) CMD , ;(Q) Display keypad layout. (PF2) CMD ERA!MCR, ;(R) VTL for search (PF3) CMD , ;(S) Delete to end of line. (PF4) ;End of uppercase table. CMD , ;(l) Delete forward character. (Comma) CMD , ;(m) Delete forward word. (Minus) CMD ERA!MCR, ;(n) Edit using Edt editor. (Period) CMD , ;(o) CMD ERA!MCR, ;(p) Get a directory. (Key 0) CMD , ;(q) Skip word forward/backward(Key 1) CMD , ;(r) Position to end of line. (Key 2) CMD MCR!ERA, ;(s) KED (Key 3) CMD , ;(t) Set direction forward. (Key 4) CMD , ;(u) Set direction backwards. (Key 5) CMD ERA!MCR, ;(v) Print (Key 6) CMD ERA!MCR!TRM, ;(w) Display logged on users. (Key 7) CMD ERA!MCR!TRM, ;(x) Show the print queues. (Key 8) CMD , ;(y) Clear the terminal screen.(Key 9) .SBTTL GLDTBL - Table of GOLD keypad commands. ; ; GOLD/command table. ; ; Status Command Description ; ------ ------- ----------- GLDTBL: CMD , ;No entry zero. CMD , ;(A) (Up) CMD , ;(B) (Down) CMD , ;(C) (Right) CMD , ;(D) (Left) CMD , ;(E) CMD , ;(F) CMD , ;(G) CMD , ;(H) CMD , ;(I) CMD , ;(J) CMD , ;(K) CMD , ;(L) CMD ERA!MCR, ;(M) Evoke mail function (Enter) CMD , ;(N) CMD , ;(O) CMD , ;(P) Gold. (PF1) CMD , ;(Q) Display the control keys. (PF2) CMD ERA!MCR, ;(R) Use fancy directory pgm (PF3) CMD , ;(S) Undelete line. (PF4) ;End of uppercase table. CMD , ;(l) Undelete character. (Comma) CMD , ;(m) Undelete word. (Minus) CMD ERA!MCR, ;(n) Edit using Teco editor. (Period) CMD , ;(o) CMD ERA!MCR!TRM, ;(p) Sort and write directory. (Key 0) CMD ERA!MCR!TRM, ;(q) Display system. (Key 1) CMD , ;(r) Delete to end of line. (Key 2) CMD ERA!MCR!TRM, ;(s) Spy program (Key 3) CMD MCR!ERA, ;(t) Delete and log files. (Key 4) CMD MCR!ERA, ;(u) Purge files. (Key 5) CMD ERA!MCR, ;(v) Print at lp1 (Key 6) CMD ERA!MCR!TRM, ;(w) Display network. (Key 7) CMD ERA!MCR!TRM, ;(x) Show the batch queues. (Key 8) CMD , ;(y) Toggle the terminal width.(Key 9) ; GOLD key typed falg. .psect rwdata,rw,d,lcl,rel,con GLDCMD: .WORD 0 ; GOLD key typed 1/0 = Yes/No. .psect code,ro,i,lcl,rel,con .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. ; This count does not include the escape sequence size. ; ; Outputs: ; C bit clear/set = key defined/not defined. ; R2 = Address of the key entry. ; ; All other registers are preserved. ; ;- KEYPAD::JSR R5,$SAVRG ; Save R3 - R5. MOV R0,R4 ; Save the input buffer address. MOV R1,R5 ; Save the buffer byte count. ADD R1,R0 ; Point to end of escape sequence. ADD #2,R0 ; Point to the escape sequence. CLRB GLDCMD ; Presume not a GOLD command. CALL CHKKEY ; Check the escape sequence. BCS 90$ ; If CS, it's an invalid key. MUL #KEYLEN,R3 ; Calculate index into table. ADD #KEYTBL,R3 ; 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 GETONE ; Get the next key. ADD #2,R0 ; Point to the escape sequence. CALL CHKKEY ; Check the escape sequence. BCS 90$ ; If CS, it's an invalid key. MUL #KEYLEN,R3 ; Calculate index into table. ADD #GLDTBL,R3 ; Else, index into the gold table. 10$: MOV R3,R2 ; Copy the key entry address. BITB #S.TERM,K.STAT(R2) ; Key terminating command line ? BNE 20$ ; If NE, yes. TSTB K.SIZE(R2) ; Is this key defined ? BEQ 90$ ; If EQ, no. 20$: CLC ; Show we have a valid key. BR 100$ ; Use common return ... 90$: SEC ; Show invalid or undefined key. 100$: MOV R4,R0 ; Restore input buffer address. MOV R5,R1 ; Restore buffer byte count. 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. ; R3 = 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),R3 ; Copy the last byte. BIC #^C177,R3 ; Clear high byte/parity. CMPB R3,#'A ; Is the byte too low ? BLO 100$ ; If LO, yes. CMPB R3,#'T ; Is the byte in range ? BLO 10$ ; If LO, yes. CMPB R3,#'l ; Is the byte too low ? BLO 100$ ; If LO, yes. CMPB R3,#'y ; Are we in range ? BHI 100$ ; If HI, no. SUB #130,R3 ; Start at entry #24. BR 30$ ; And continue ... 10$: CMPB R3,#'P ; Is this key PF1 (GOLD) ? BNE 20$ ; If NE, no. INCB GLDCMD ; Yes, show gold typed. 20$: SUB #100,R3 ; Start at entry #1. 30$: CLC ; Show it's a valid key. BR 100$ ; Use common return ... 90$: SEC ; Show key is invalid. 100$: 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 command line address. ; R1 = The command byte count. ; ; Outputs: ; C bit clear/set = defined/undefined. ; R2 = Address of the key entry. ; ; All other registers are preserved. ; ;- CTRKEY::JSR R5,$SAVRG ; Save R3 - R5. MOV R0,R3 ; Copy the buffer address. ADD R1,R3 ; Point to the control key. MOVB (R3),R3 ; Copy the control character. CMPB R3,#DEL ; Is this the delete character ? BNE 10$ ; If NE, no. MOV #DELKEY,R3 ; Set address of delete key. BR 20$ ; And use common code. 10$: MUL #KEYLEN,R3 ; Calculate index into table. ADD #CTRTBL,R3 ; Add base address of the table. ; Check for the key being defined. 20$: MOV R3,R2 ; Copy the key entry address. BITB #S.TERM,K.STAT(R2) ; Key terminating command line ? BNE 30$ ; If NE, yes. TSTB K.SIZE(R2) ; Is this control key defined ? BEQ 90$ ; If EQ, no. 30$: CLC ; Show control key defined. BR 100$ ; And use common return ... 90$: SEC ; Show key is not defined. 100$: RETURN .END