.MCall .Module .Module KEDCM4 RELEASE=V02 VERSION=14 COMMENT=,IDENT=NO,AUDIT=NO,GLOBAL=.KEDC4 ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion of the above copyright notice. This software, or ; any other copies thereof, may not be provided or otherwise ; made available to any other person except for use on such ; system and to one who agrees to these license terms. Title ; to and ownership of the software shall at all times remain ; in Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. ;+ ;COND ; ; VIRTC in KEDCPR controlling generation of SOBs ; ; VT10$0 ; ; $KED$ ;- .Enable LC .Enable GBL ; ;MODULE: KEDCM4 ; ;ABSTRACT: ; ; This module contains the routines to move to the top and bottom ; of the file, to exit the edit session, and the auxiliary file ; command routines. ; ;AUTHOR: DARRELL DUFFY ; ;DATE: 20-July-1979 ; ;REVISION HISTORY: ; ; 20-July-79 Add WRITE SELECT command ; ; 9-Nov-79 Turn off special mode immediately on exit and reset ; CTRL/O to allow for type ahead. ; ; ; 9-OCT-85 George Thissell ; Set user error byte to SUCCESS if the user EXIT 's from session; ; set user error byte to WARNING if the user QUIT 's from session. ; ; .SbTtl USER DEFINITIONS ErrByt =: 53 ;User error byte is 53 Succ$ =: 1 ;ERRBYT's value if user exit'S Warn$ =: 2 ;ERRBYT's value if user quit'S .SbTtl Error Macro Definitions ;+ ;ERROR ; .IIf NDF,$KED$, .Page .IIf NDF,$KED$, .SbTtl Errors from KEDCM4 module ; ; Module: KEDCM4 ; ; Define the error macros for this module ; .MCall ErrDef ErrDef C4,ERROR ;- ;+ ;HELPER ; .IIf NDF,$KED$, .Page .IIf NDF,$KED$, .SbTtl Help from KEDCM4 module ; ; Module: KEDCM4 ; ; Define the help macros for this module ; .MCall HlpDef HlpDef C4 ;- .SbTtl .SbTtl C.TOP - Top of file ; ; C.TOP ; ; Move to top of file ; .Enabl LSB C.Top:: ;~x~ KbLock ;~x~Lock the keyboard Call MovBkw ;~x~Backward one character Bcs 20$ ;~x~Nowhere to go 10$: Call MovBkw ;~x~By characters Bcc 10$ ;~x~Until no more Clc ;Return no error Return ;~x~ ...... 20$: ;~x~ ;+ ;HELPER HELPER ;~x~ ;Attempt to move to top of file when cursor is at top ;- .Dsabl LSB .SbTtl C.BOT - Bottom of file ; ; C.BOT ; ; Move to bottom of file ; .Enabl LSB C.Bot:: ;~x~ KbLocK ;~x~Lock the keyboard Call MovFwd ;~x~Forward one character Bcs 20$ ;~x~Nowhere to go 10$: Call MovFwd ;~x~Forward by characters Bcc 10$ ;~x~Til end Clc ;Return no error Return ;~x~ ...... 20$: ;~x~ ;+ ;HELPER HELPER ;~x~ ;Attempt to move to bottom when cursor is at bottom ;- .Dsabl LSB .SbTtl .SbTtl Auxiliary file command routines .SbTtl .SbTtl C.OPI - Open auxiliary input file ; ; C.OPI - open auxiliary input file ; .Enabl LSB C.OpI:: NoEChk ;~x~No command end check Tst Inspct ;Inspect mode does not allow input Bne 20$ ;~x~Nope not allowed Mov #Ax$Inp,R4 ;File block address Br 10$ ;~x~ ........... .SbTtl C.OPO - Open auxiliary output file ; ; C.OPO - open auxiliary output file ; C.OpO:: NoEChk ;~x~ Mov #Ax$Out,R4 ;File block address ; R1 -> FILE SPEC 10$: CallR $OpFil ;~x~Open file .............. 20$: Jmp NoInsp ;~x~then tell operation is invalid .............. .DSABL LSB .SbTtl C.CLS - Close auxiliary output file ; ; C.CLS - close auxiliary output file ; C.Cls:: EndChk ;~x~Validate command line termination OClose: Call OutOpQ ;~x~Output file open? CallR $ClsFl ;~x~Close the file .............. .SbTtl C.PRGO - Purge the auxiliary output file ; ; C.PRGO - purge auxiliary output file ; C.PrgO:: ;~x~ EndChk ;~x~Validate command line termination Call OutOpQ ;~x~Output file open? CallR $PrgFl ;~x~Purge the file .............. ; ; INPOPQ -- input file open? ; .Enabl LSB InpOpQ: Mov #Ax$Inp,R4 ;~x~Setup file block address BitB #Fst$Ac,F$Sts(R4) ;File active? Beq 10$ ;~x~Nope Return ;~x~ ...... 10$: Pop <> ;~x~Go to caller's caller ;+ ;HELPER HELPER ;~x~ ;Input file not opened before include command ;- .DSABL LSB ; ; OUTOPQ -- output file open ; .Enabl LSB OutOpQ: Mov #Ax$Out,R4 ;~x~Check for active file BitB #Fst$Ac,F$Sts(R4) ;Active? Beq 10$ ;~x~Nope Return ;~x~ ...... 10$: Pop <> ;~x~Return to caller's caller ;+ ;HELPER HELPER ;~x~ ;File for write is not open for a write command ;- .DSABL LSB .SbTtl C.SKIP - Skip command ; ; C.SKIP - skip command ; .Enabl LSB C.Skip:: ;~x~ NoEChk ;~x~No command end check Mov SP,IsFlag ;Set for the skip command Br 10$ ;~x~And do the command ........... .SbTtl C.INCL - Include command ; ; C.INCL - include command ; C.Incl:: ;~x~ NoEChk ;~x~No command end check Clr IsFlag ;Set for include command 10$: Call InpOpQ ;~x~Input file open? Call KNumQ ;~x~Get optional number TstB @R1 ;End of command line? Beq C.ILin ;~x~Assume we want lines Mov #I.Lst,R3 ;Keyword list CallR KyCall ;~x~ .............. ; ; C.IPAG -- include by pages ; .Enabl LSB C.IPag:: ;~x~ Call 110$ ;~x~Setup for include Call PagChk ;~x~Check for line page Beq 20$ ;~x~Yes do lines 10$: Call 60$ ;~x~Copy a char Bcs 30$ ;~x~No good Call PageQ ;~x~Is this the page? Bne 10$ ;~x~Nope Sob R3,10$ ;~x~Yes- count it Return ;~x~ ...... ; ; C.ILIN -- include by lines ; C.ILin:: ;~x~ Call 110$ ;~x~Setup 20$: Call 60$ ;~x~One char Bcs 30$ ;~x~No good Call LTerm ;~x~Line term Bne 20$ ;~x~Keep going Sob R3,20$ ;~x~Loop til done Return ;~x~ ...... 30$: ;~x~ ;+ ;HELPER ; HELPER ;~x~ ; ;The end of the auxiliary input file was reached before the specified ;number of lines or pages was included. ;- ; ; C.IRST -- include rest of file ; C.IRST:: ;~x~ Call 110$ ;~x~Setup 40$: Call 60$ ;~x~Get a char Bcc 40$ ;~x~Til end of file BitB #Fst$Ac,F$Sts(R4) ;File still active? Bne 50$ ;~x~Yes error Clc 50$: Return ;~x~ ...... ; ; Get a char for include ; 60$: Tst CtrlC ;~x~Ctrl/C stop? Bmi 70$ ;~x~Yes- return error Call ChkAbt ;~x~Keep abort count for journal Call $GetCh ;~x~Get a char Bcs 70$ ;~x~No good Mov IsFlag,R2 ;Skip command? Bne 80$ ;~x~Yes- save last n chars Call Insrt ;~x~Insert it Bcc 100$ ;~x~No error Pop <> ;Return to caller's caller ;+ ;HELPER HELPER ;~x~ ;No more space for include ;- 70$: Sec ;~x~Return error for non discript cause Return ;~x~ ...... 80$: Mov #PrmSiz,R1 ;~x~Save last PRMSIZ bytes skipped Sub R1,R2 ;Adjust to beginning of string 90$: MovB 1(R2),(R2)+ ;~x~Move one char down Sob R1,90$ ;~x~Til done MovB R0,@R2 ;Save last char 100$: Clc ;~x~No error Return ;~x~ ...... ; ; Setup for include ; 110$: Call C2EndQ ;~x~Proper end of command line? Tst IsFlag ;Is this the skip command? Beq 130$ ;~x~No- setup for include only Mov #CmdStr+PrmSiz,R0 ;We are going to use the ;command buffer for the file history Mov R0,IsFlag ;Set for skip command Mov #PrmSiz,R1 ;Zero the buffer to start 120$: ClrB -(R0) ;~x~Clear a byte of the string Sob R1,120$ ;~x~Til done 130$: Mov #Ax$Inp,R4 ;~x~Setup file block Mov KNumbr,R3 ;Get rep count Blt 150$ ;~x~No good Bgt 140$ ;~x~Ok Mov #1,R3 ;Assume 1 140$: Tst Inspct ;~x~Inspect mode? Bne 160$ ;~x~Yes- illegal Return ;~x~ ...... 150$: Pop <> ;~x~Callers caller ;+ ;HELPER HELPER ;~x~ ;Count to include was minus ;- 160$: Pop <> ;~x~Callers caller Jmp NoInsp ;~x~then tell operation is invalid .............. ; ; Data for skip and include ; PSect IMPURE IsFlag: .BlkW 1 ;~d~Nonzero for skip PSect KEDCMD .Dsabl LSB .SbTtl PAGEQ - Test for end of page for include or write ;++ ;PAGEQ ; ;FUNCTIONAL DESCRIPTION: ; ; Test for end of page ; ;INPUT: NONE ; ;OUTPUT: ; R3,R4 preserved ; Z set if end of page ;-- PAGEQ: Push ;~x~Save R3 R4 Push Mov #Df$Pag,R3 ;Address of page def Mov -2(R3),R4 ;End address Beq 20$ ;~x~Lines- assume yes Mov R4,R1 ;Start of string Mov IsFlag,R2 ;End of string Bne 10$ ;~x~Ok use it - skip command Mov BCP,R2 ;No use text buffer 10$: Call SpLook ;~x~Look for end of string Beq 20$ ;~x~Yes Pop ;Restore Clz ;No Return ;~x~ ...... 20$: ;~x~ Pop ;Restore Sez ;Yes Return ;~x~ ...... .SbTtl C.WRIT - Write to auxiliary file ; ; C.WRIT - write to auxiliary file ; .Enabl LSB C.Writ:: ;~x~ NoEChk ;~x~No command end check Clr IsFlag ;This is not a skip command Call OutOpQ ;~x~Output file open Call KNumQ ;~x~Arg? TstB @R1 ;End of command line Beq C.WLin ;~x~Assume lines Mov #W.Lst,R3 ;Keyword list CallR KyCall ;~x~ .............. ; ; C.WPAG -- write pages to auxiliary output ; .Dsabl LSB .Enabl LSB C.WPag:: ;~x~ Call 130$ ;~x~Setup Call PagChk ;~x~Check for lines pages Beq 20$ ;~x~Lines 10$: Call 110$ ;~x~Put a char Bcs 30$ ;~x~Quit Call PageQ ;~x~End of page? Bne 10$ ;~x~Go Sob R3,10$ ;~x~Til done Return ;~x~ ...... ; ; C.WLIN -- write lines to output ; C.WLin:: ;~x~ Call 130$ ;~x~Setup 20$: Call 110$ ;~x~Write a char Bcs 30$ ;~x~Done Call LTerm ;~x~End of a line? Bne 20$ ;~x~Keep going Sob R3,20$ ;~x~Til done Return ;~x~ ...... 30$: ;~x~ ;+ ;HELPER ; HELPER ;~x~ ; ;End of file is reached before the specified number of lines or pages ;is written to the auxiliary output file. ;- ; ; C.WRST -- write the rest of the file ; C.WRst:: ;~x~ Call 130$ ;~x~Setup 40$: Call 110$ ;~x~Write a char Bcc 40$ ;~x~Til end Clc ;Return no error Return ;~x~ ...... ; ; C.WSLC -- write the select range ; C.WSlc:: ;~x~ Call 130$ ;~x~Setup for the write Tst SlctQ ;Select range active? Beq 90$ ;~x~Nope, error in command Mov SlctC,R2 ;Look at range count Mov SlctC+2,R3 ;High order count Bne 50$ ;~x~OK, its a valid count Tst R2 ;Check low order count word Beq 90$ ;~x~No real select range 50$: Clr SlctQ ;~x~Cancel select range Tst R3 ;Which way the range?? Bpl 60$ ;~x~Forward range Neg R3 ;Backward range, make pos count Neg R2 ;Low order Sbc R3 ;Adjust high order count Br 80$ ;~x~Carry on with write ........... 60$: Push ;~x~Use the count now Mov R2,R1 ;To move to beginning of range 70$: Call MvBkw ;~x~Move backward to beginning of range Bcs 100$ ;~x~Error in move Sob R1,70$ ;~x~DP count Dec (SP) ;To compute with minimum Bpl 70$ ;~x~instructions Pop <> ;Dump high order count 80$: Call 110$ ;~x~Write one character to output file Bcs 100$ ;~x~Something wrong Sob R2,80$ ;~x~DP count Dec R3 ;Which may be very large Bpl 80$ ;~x~31 bits in fact Return ;~x~Return, the job done ...... 90$: ;~x~ ;+ ;HELPER HELPER ;~x~ ; ;Select was no enabled, or there were no characters in the range. ;- 100$: ;~x~ ;+ ;HELPER HELPER ;~x~ ; ;A move function failed that was not stopped by CTRL/C. ;- ; ; Write one character to auxiliary output file ; 110$: Call MvFwd ;~x~Next char Bcs 120$ ;~x~Error MovB @BCP,R0 ;Get char we should write Call $PutCh ;~x~Output it Bcc 120$ ;~x~No error Pop <>,SAVE=*C* ;*C* caller's caller ; Sec ;Help message loaded by I/O routine 120$: Return ;~x~ ...... ; ; Setup for write ; 130$: Call C2EndQ ;~x~Proper end of command line? Mov #Ax$Out,R4 ;Setup file block Mov KNumbr,R3 ;Get rep count Blt 150$ ;~x~No good Bgt 140$ ;~x~Ok Mov #1,R3 ;Assume 1 140$: Return ;~x~ ...... 150$: Pop <> ;~x~Callers caller ;+ ;HELPER HELPER ;~x~ ;Count to write was minus ;- .DSABL LSB .SbTtl PAGCHK - Check for page operation by lines ;++ ;PAGCHK ; ;FUNCTIONAL DESCRIPTION: ; ; Check for page operation by lines ; ;INPUT: ; R2 = offset to def block for page or para ; R3 = rep count for operation ; ;OUTPUT: ; Z Clr for string page ; Z Set for lines ; R3 = correct rep count ; R2,R1 used ;-- .Enabl LSB PagChk: Mov #Df$Pag,R2 ;~x~Look at page Tst -(R2) ;Lines? Bne 20$ ;~x~String Clr R1 Mov 2(R2),R2 ;Get line count 10$: Add R3,R1 ;~x~Add to multiply Sob R2,10$ ;~x~Til done Mov R1,R3 ;Copy line count to R3 Sez ;Return Z set 20$: Return ;~x~ ...... .Dsabl LSB .SbTtl C.SETW - Set word wrap mode ;++ ;C.SETW ; ;FUNCTIONAL DESCRIPTION: ; ; Set wrap mode ; ;INPUT: ; R1 -> remainder of command string ; ;OUTPUT: ; WRAPC = column at which to wrap ; WRAPQ = nonzero for wrap enabled ;-- .Enable LSB C.SetW:: ;~x~ NoEChk ;~x~No end check here Call KNumQ ;~x~Get a number Call C1EndQ ;~x~End command properly? Cmp R2,#256. ;Too long a wrapped line?? Bhi 20$ ;~x~Yes, signal error Tst R2 ;Must be Bne 10$ ;~x~a number given Mov H.SzM2,R2 ;Use the screen width if not 10$: Mov R2,WrapC ;~x~Save the wrap column Mov SP,WrapQ ;Set the wrap mode Clc ;No error Return ;~x~ ...... 20$: ;~x~ ;+ ;HELPER HELPER ;~x~ ; ;Right column given was greater than 256. ;- .Dsabl LSB .SbTtl C.ClrW - Clear word wrap mode ;++ ;C.ClrW ; ;FUNCTIONAL DESCRIPTION: ; ; Clear word wrap mode ; ;INPUT: NONE ; ;OUTPUT: ; WRAPQ = 0 for wrap disabled ;-- .Enable LSB C.ClrW:: ;~x~ EndChk ;~x~Validate command line termination Clr WrapQ ;Clear wrap mode Return ;~x~ ...... .Dsabl LSB .SbTtl C.SRBG - Set target position to end ; ; C.SRBG -- set beginning of target ; SRPLC = zero ; .SbTtl C.SREN - Set target position to beginning ; ; C.SREN -- Set end of target ; SRPLC not = zero ; .Enable LSB C.SrBg:: ;~x~ Clr R3 ;Set beginning by clearing flag C.SrEn:: ;~x~R3<>0 EndChk ;~x~Validate command line termination Mov R3,SrplC ;Set/clear flag Return ;~x~ ...... .Dsabl LSB .SbTtl C.SREX - Set exact search ; ; C.SREX -- set exact search ; ExctQ not zero .SbTtl C.SRNE - Set non exact search ; ; C.SRNE -- set non exact search ; ExctQ zero ; .Enable LSB C.SrNE:: ;~x~ Clr R3 ;clear flag C.SrEx:: ;~x~R3<>0 EndChk ;~x~check for no more args Mov R3,ExctQ ;set flag Return ;~x~ ...... .Dsabl LSB .SbTtl C.SRBO - Set search bounded ; ; C.SRBO -- set search bounded ; .SbTtl C.SRUN - Set search unbounded ; ; C.SRUN -- set search unbounded ; C.SrUn:: ;~x~ Clr R3 ;Set for unbounded search C.SrBo:: ;~x~R3<>0 EndChk ;~x~Validate command line termination Mov R3,SBound ;Set/clear for unbounded search Return ;~x~ ...... .If NE VT10$0 .SbTtl C.LITE - Set screen reverse ; ; C.LITE - set screen background reverse ; .Enabl LSB C.Lite:: ;~x~ EndChk ;~x~Validate command line termination Mov #QutLit,QutPtr ;Set for lite screen Mov #SetLit,R0 ;Set reverse Br 10$ ;~x~join common code ........... .SbTtl C.DARK - Set screen normal ; ; C.DARK - set screen background normal ; C.Dark:: ;~x~ EndChk ;~x~Validate command line termination StDark:: ;~x~ Mov #QutDrk,QutPtR ;Set for dark screen Mov #SetDrk,R0 ;Set normal mode 10$: ;~x~ Push TtInp ExeOff ;~x~Make sure we print $Print R0 ;~x~Send escape sequence Pop TtInp ;Restore mode Return ;~x~ ...... .Dsabl LSB ; ; Escape sequences for VT100 features ; PSect .TXT. SetLit:: ;~d~ .Byte ,,,, ;~d~for reverse screen .Byte ;~d~ SetDrk:: ;~d~ .Byte ,,,, ;~d~for normal screen .Byte ;~d~ .List BEX PSect KEDCMD .SbTtl C.SETQ - Set quiet mode .SbTtl C.ClrQ - Clear quiet mode ; ; C.SETQ, C.ClrQ - set and clear quiet mode for help messages ; .Enable LSB C.SetQ:: ;~x~ EndChk ;~x~Validate command line termination Tst QutPtr ;Do we know screen video for quiet? Bne 10$ ;~x~Br if so Call StDark ;~x~Else set screen dark 10$: Mov SP,QuietQ ;~x~Non zero for quiet mode set Return ;~x~ ...... C.ClrQ:: ;~x~ EndChk ;~x~Validate command line termination Clr QuietQ ;Zero for clear Return ;~x~ ...... .Dsabl LSB .EndC; NE,VT10$0 ;VT100 Terminal .End