C
C SUBROUTINE CMDMUN(LINE)
C   MUNGES UP COMMAND LINES PASSED IN ARGUMENT TO ALLOW
C  SPECIAL KEYS TO BE RECOGNIZED.
C  DEFAULT VERSION JUST RETURNS
C THIS VERSION (FOR VAX) ASSUMES ESCAPE SEQUENCES ARESENT TO
C THE PROGRAM AND HANDLES ANSI ARROW KEYS AND PF2 KEY.
	SUBROUTINE CMDMUN(LINE)
	LOGICAL*1 LINE(120),LC
	LI=1
C ALLOW ARROWS OR OTHER SIMILAR KEYS TO BE RECOGNIZED
	LL=LINE(LI)
	IF(LL.EQ.27)GOTO 1000
C IF WE SEE [, COULB BE THAT ESC GOT EATEN BY VMS...
	IF(LINE(LI).EQ.'[')GOTO 1000
C CONVERT LOWER TO UPPER CASE
	NMX=120
	DO 41 N=1,120
C CHECK FOR DOUBLE QUOTE (34 DECIMAL). LEAVE L.C. IF SO
	NNN=LINE(N)
	IF(NNN.EQ.34)NMX=2
C IF WE SEE " CHARACTER THEN ONLY CONVERT 1ST 2 CHARACTERS TO U.C.
41	CONTINUE
	DO 1 N=1,NMX
	LL=LINE(N)
	IF(LL.GT.96.AND.LL.LE.123)LL=LL-32
	LINE(N)=LL
1	CONTINUE
	IF(LINE(1).NE.'M')GOTO 2000
	LI=2
	GOTO 1000
1000	CONTINUE
C HANDLE ESCAPE SEQUENCES
C ENCODE VT100 SEQUENCES HERE. MUST MODIFY FOR OTHERS.
C IF VMS PASSES 2 ESCS, PASS 1ST, TEST SECOND.
	LL=LINE(LI+1)
	IF(LL.EQ.27)LI=LI+1
	LC=LINE(LI+1)
	IF(LC.EQ.'['.OR.LC.EQ.'O'.OR.LC.EQ.'?')LC=LINE(LI+2)
	IF(LC.NE.'Q')GOTO 10
C MAKE PF2 MEAN HELP, JUST LIKE EDT
	LINE(LI)=72
C 72 = ASCII FOR 'H'
	GOTO 2000
10	CONTINUE
	IF(LC.GE.'P'.AND.LC.LE.'S')GOTO 2100
C HANDLE INDIRECT CALLS AT 2100 FOR PF1 THRU PF4 IF AANY
	LL=LC
	LL=LL-65
C SUBTRACT ASCII A
	IF (LL.LT.0.OR.LL.GT.3)GOTO 2000
	LK=LL
	IF(LL.EQ.3)LK=2
	IF(LL.EQ.2)LK=3
	LK=LK+49
C ADJUST FOR ASCII VALUE
	LINE(LI)=LK
C STASH NEW CELL IN.
	GOTO 2000
2100	CONTINUE
C GENERATE INDIRECT FILE CALLS FROM PF1, PF3, PF4 KEYS IF ANY
C (THESE GIVE LETTERS P, R, OR S)
	LINE(1)=64
	LINE(2)='K'
	LINE(3)='Y'
	LINE(4)=LC
	LINE(5)=0
C GENERATE @KYP, @KYR, OR @KYS COMMAND ON PF1, PF3, PF4
2000	CONTINUE
	RETURN
	END
